Note

【量化悖论】指标越多越好吗?

· Views 1,546

选择太多,有时候反而无从选择。

 

许多做量化的兄弟开始入行时,总是兴奋地一个个地尝试各种指标,在各种花样的过拟合中徜徉。(当然,我也不能免俗。)

 

单独一个指标有时候确实能起到比较好的参考作用。但有些时候指标之间是会有矛盾的,例如震荡指标和趋势指标如果叠加使用,有时候会产生比较矛盾的情况。

 

纵然有量化界神仙能同时驾驭各类指标,但作为量化新人,建议还是从简单学起,先精,后多。

 

下面分享一个简单的双均线模型,证明一下有时候容易过拟合,但在一些情况下简单的指标也有其独特的作用:

1、策略灵感

上一期我们提及沥青和原油的关系之后,我寻思着沥青近期可能走势会偏空一些,尝试搭建一个基础的双均线模型来做空,看看收益如何。

初始资金:10W

均线:15和26

级别:分钟

 

2、收益情况:及其朴素

【量化悖论】指标越多越好吗?
朴素的胜率、朴素的收益

3、资金曲线:马马虎虎

【量化悖论】指标越多越好吗?

4、源代码:抛砖引玉

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from datetime import date

from tqsdk import TqApi, TqBacktest,TargetPosTask,TqSim


api = TqApi(TqSim(init_balance=100000),web_gui=True,backtest=TqBacktest(start_dt=date(2020, 3, 6), end_dt=date(2020, 4, 30)))
# 获得 bu2006 分钟K线的引用
klines = api.get_kline_serial("SHFE.bu2006", 60)
target_pos_bu = TargetPosTask(api, "SHFE.bu2006")


while True:
api.wait_update()
if api.is_changing(klines):
ma_15 = sum(klines.close.iloc[-15:]) / 15
ma_26 = sum(klines.close.iloc[-26:]) / 26

# 判断开仓条件
if ma_26>ma_15:
print("市价开仓")
target_pos_bu.set_target_volume(-10)
# 判断平仓条件
if ma_26 print("市价平仓")
target_pos_bu.set_target_volume(0)
# 关闭api,释放相应资源
api.close()

 

——————————————————————————————————————

参考官方文档简单搞出了本系列的首次回测,抛砖引玉。

 

Disclaimer: The content above represents only the views of the author or guest. It does not represent any views or positions of FOLLOWME and does not mean that FOLLOWME agrees with its statement or description, nor does it constitute any investment advice. For all actions taken by visitors based on information provided by the FOLLOWME community, the community does not assume any form of liability unless otherwise expressly promised in writing.

FOLLOWME Trading Community Website: https://www.followme.com

If you like, reward to support.
avatar

Hot

No comment on record. Start new comment.