揭秘”智能定投“

揭秘”智能定投“

更多精彩内容, 欢迎关注公众号:数量技术宅,也可添加技术宅 个人微信号:sljsz01,与我交流。

什么是智能定投

大家如果打开某某宝的基金理财界面,选择某一个基金标的的定投,往往会在选择定投方式时出现两个选项,一是普通定投、二是智能定投。而且往往智能定投的收益率会高于普通定投,那么,究竟什么是智能定投,它是怎么个智能法,使得收益率高于普通定投?我们将通过这篇文章来揭开智能定投的面纱。

[En]

If you open the fund management interface of so-and-so treasure and choose the fixed investment of a certain fund, there will often be two options when choosing the fixed investment mode, one is ordinary fixed investment, the other is intelligent fixed investment. And the rate of return of intelligent fixed investment is often higher than that of ordinary fixed investment, so what exactly is intelligent fixed investment and how is it intelligent to make the rate of return higher than that of ordinary fixed investment? We will use this article to unveil the veil of smart casting.

在介绍智能定投前,我们先简要回顾普通定投,普通定投,用一句话解释,即以固定金额、固定间隔时间,定期、定额投资于基金或其他想要投资标的。普通定投有如下几个优点:一是定期投资,积少成多,二是不需要进行择时,避免了低买高卖,三是平均投资,分散风险,四是复利效果,长期可观。

[En]

Before introducing the intelligent fixed investment, let’s briefly review the ordinary fixed investment and explain it in one sentence, that is, with a fixed amount, fixed interval, regular and fixed investment in the fund or other desired investment targets. Ordinary fixed investment has the following advantages: first, regular investment, add up, second, there is no need to choose time, avoid buying low and selling high, third, average investment, spread risk, fourth, compound interest effect, long-term considerable.

而智能定投,其实是普通定投的一种改进方式,其核心逻辑是在定投标的的价格低位、价值低估区域尽可能多投资,而在定投标的价格高位、价值高估区域少投资或不投资,从而使得其平均成本低于普通定投、收益率高于普通定投。

[En]

In fact, intelligent fixed bidding is an improved way of ordinary fixed bidding. its core logic is to invest as much as possible in the areas where the price is low and the value is undervalued, while little or no investment is made in the areas where the price is high and the value is overvalued. As a result, the average cost is lower and the rate of return is higher than the ordinary bid.

于是,智能定投的关键点聚焦在了如何判断价格的高低位,对于这个问题,某宝也给出了它自己的判断方式,其设置了一个参考指数的多日均线,当价格低于均线,且距离位置越远,定投金额越大,即低位多买。

[En]

Therefore, the key point of the intelligent fixed investment focuses on how to judge the high and low of the price. For this problem, some treasure also gives its own way of judgment, which sets a multi-day moving average of the reference index, when the price is lower than the moving average, and the farther away from the position, the larger the fixed investment amount, that is, buy more at the low level.

反过来,当价格高于均线,且距离位置越远,定投金额越小,即高位少买。这样的低位多买、高位少买逻辑,使得智能定投的收益率,比普通定投高了约3%以上的年化收益率。

[En]

Conversely, when the price is higher than the moving average, and the farther away from the position, the smaller the fixed investment, that is, the higher the price, the less you buy. This logic of buying more at a low level and buying less at a high level makes the return of smart fixed investment about 3% higher than that of ordinary fixed investment.

揭秘”智能定投“

Python实现智能定投策略

我们参考某宝的智能定投逻辑,并加以改进,同样实现的是低位多买、高位少买的大逻辑。并根据投资标的的历史波动,将标的划分为4个区域,分别是:价格低位区域、价格中等偏低区域、价格中等偏高区域、价格高位区域,并依次减小这4个区域的定投金额,即价格低位区域定投金额最大,价格高位区域定投金额最小。

[En]

We refer to the intelligent investment logic of a certain treasure and improve it, and also realize the big logic of buying more at the low level and buying less at the high level. According to the historical fluctuation of the investment target, the target is divided into four regions, namely: low price region, medium-low price region, medium-high price region and high price region, and decrease the fixed investment amount of these four regions in turn, that is, the fixed investment amount is the largest in the low price region and the smallest in the high price region.

数据准备

为实现这样的定投策略,我们首先需要准备好定投标的的历史数据,以BTC为例,我们准备好了BTC从2017年到最新的日K数据。

这里需要说明的是,我们的 定投程序支持所有金融标的的历史回溯测试,只需要将数据格式准备的与上述BTC数据样例的字段一样,即可运行程序得到相应的测试结果。

逻辑实现

读入数据后,我们逐日依次判断,当前日期的最新价格,位于价格低位区域、价格中等偏低区域、价格中等偏高区域、价格高位区域的哪个位置,并且根据价格所在的区域位置,设定投资金额的大小。

[En]

After reading the data, we judge day by day where the latest price of the current date is located in the low price area, the moderately low price area, the moderately high price area, and the high price area, and set the amount of investment according to the location of the price.

首先通过两个参数adj_1、adj_2,调整定投金额的比例,参数可以按需修改。

adj_1 = 0.4
adj_2 = 0.8

然后,通过确定价格定投区域的哪个位置,确定定投金额的大小。如果价格位于价格低位区域,则定投金额为正常金额的(1+adj_2)倍,如果价格位于价格中等偏低区域,则定投金额为正常金额的(1+adj_1)倍,其他依次类推。

condition1 = XXX
df.loc[condition1, 'invest_val'] = base_invest_fun * (1 - adj_1)

condition2 = XXX
df.loc[condition2, 'invest_val'] = base_invest_fun * (1 - adj_2)

condition3 = XXX
df.loc[condition3, 'invest_val'] = base_invest_fun * (1 + adj_1)

condition4 = XXX
df.loc[condition4, 'invest_val'] = base_invest_fun * (1 + adj_2)

结果可视化

通过每期定投金额,我们可以计算出总投资金额、以及总投资市值、盈利情况、盈利比例等结果,并将其中关键的结果,采用可视化的形式呈现出来,回测结果呈现于下一小节。

[En]

Through the fixed investment amount of each period, we can calculate the total investment amount, as well as the total investment market value, profit situation, profit ratio and other results, and present the key results in a visual form, and the back test results are presented in the next section.

fig, ax1 = plt.subplots()
ax1.plot(df['date'], df['net_value'], 'r-', label='Market Value')
ax1.plot(df['date'], df['total_invest_val'], 'y-', label='My Total Cost')
ax1.set_xlabel("year")
ax1.set_title("BTC 定投")
plt.legend(loc='best')
plt.show()

完整代码

整个智能定投Python实现的完整代码,包括文章中用到的配套历史数据,我们将独家发布在知识星球。

典型标的智能定投效果

在完成了智能定投的逻辑构建,以及相应Python代码的实现后,我们挑选了一些典型标的,包括BTC、沪深300指数、标准普尔500指数、黄金,来进行测试。

这些标的可以说是典型的定投代表,因为很多投资者会选择上述4个标的的其中之一,进行某个市场的定投。一起来看这些标的的测试结果。

BTC

沪深300指数

揭秘”智能定投“

标准普尔500指数

揭秘”智能定投“

黄金

揭秘”智能定投“

上述结果My Total Cost标签表示定投成本,Market Value标签表示最新持有的市场价值,两条线的差值就是盈利部分。从定投结果的稳定性来看,标准普尔500指数无疑是最好的,说明智能定投策略最适合长期温和上涨、偶尔暴跌的标的。

但是不论是BTC、股票指数还是黄金,只要该标的是长期上涨的,定投足够长的时间,都能产生不错的盈利。而智能定投因其低位多买、高位少买的逻辑,使得其相比较普通定投,能够产生更多的盈利。

揭秘”智能定投“

往期干货分享推荐阅读

数字货币中短线策略(数据+回测+实盘)

数字货币稳定币对网格做市策略

数字货币资金费策略

分享一个年化15%以上的无风险套利机会

网格交易系统开发

通过深度学习股价截面数据分析和预测股票价格

Omega System Trading and Development Club内部分享策略Easylanguage源码

一个真实数据集的完整机器学习解决方案(下)

一个真实数据集的完整机器学习解决方案(上)

如何使用交易开拓者(TB)开发数字货币策略

股指期货高频数据机器学习预测

如何使用TradingView(TV)回测数字货币交易策略

如何投资股票型基金?什么时间买?买什么?

【数量技术宅|量化投资策略系列分享】基于指数移动平均的股指期货交易策略

AMA指标原作者Perry Kaufman 100+套交易策略源码分享

【 数量技术宅 | 期权系列分享】期权策略的”独孤九剑”

【数量技术宅|金融数据系列分享】套利策略的价差序列计算,恐怕没有你想的那么简单

【数量技术宅|量化投资策略系列分享】成熟交易者期货持仓跟随策略

如何获取免费的数字货币历史数据

【数量技术宅|量化投资策略系列分享】多周期共振交易策略

【数量技术宅|金融数据分析系列分享】为什么中证500(IC)是最适合长期做多的指数

商品现货数据不好拿?商品季节性难跟踪?一键解决没烦恼的Python爬虫分享

【数量技术宅|金融数据分析系列分享】如何正确抄底商品期货、大宗商品

【数量技术宅|量化投资策略系列分享】股指期货IF分钟波动率统计策略

【数量技术宅 | Python爬虫系列分享】实时监控股市重大公告的Python爬虫

Original: https://www.cnblogs.com/sljsz/p/16723978.html
Author: 数量技术宅
Title: 揭秘”智能定投“

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/116054/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总