vn.py量化社区
By Traders, For Traders.
Member
加入于:
帖子: 38
声望: 1

通过
cta_engine.add_strategy(class_name='Test_1', strategy_name='DoubleMaStrategy', vt_symbol='ni2006.SHFE', setting={'class_name':'DoubleMaStrategy', 'fast_window':10,'slow_window':20})
添加策略的时候,提示创建策略失败,找不到策略类,请问策略类是什么?只能通过编辑cta_strategy_setting.json文件来添加策略吗?谢谢

Member
avatar
加入于:
帖子: 38
声望: 5

truego wrote:

通过
cta_engine.add_strategy(class_name='Test_1', strategy_name='DoubleMaStrategy', vt_symbol='ni2006.SHFE', setting={'class_name':'DoubleMaStrategy', 'fast_window':10,'slow_window':20})
添加策略的时候,提示创建策略失败,找不到策略类,请问策略类是什么?只能通过编辑cta_strategy_setting.json文件来添加策略吗?谢谢

兄弟,你把class_name和strategy_name写反了,策略类class_name是你开发的CTA策略,策略名strategy_name是策略实例可以很多个。
cta_engine.add_strategy(class_name='DoubleMaStrategy', strategy_name='Test_1', vt_symbol='ni2006.SHFE', setting=('fast_window':10,'slow_window':20})
可以参考我写的一篇教程:https://www.vnpy.com/forum/topic/2876-wu-jie-mian-mo-shi-yun-xing-ctace-lue-shi-xian-mo-ni-shi-pan-jiao-yi

Member
加入于:
帖子: 38
声望: 1

写错参数了,已解决,谢谢

Member
加入于:
帖子: 38
声望: 1

chwei2ch wrote:

truego wrote:

通过
cta_engine.add_strategy(class_name='Test_1', strategy_name='DoubleMaStrategy', vt_symbol='ni2006.SHFE', setting={'class_name':'DoubleMaStrategy', 'fast_window':10,'slow_window':20})
添加策略的时候,提示创建策略失败,找不到策略类,请问策略类是什么?只能通过编辑cta_strategy_setting.json文件来添加策略吗?谢谢

兄弟,你把class_name和strategy_name写反了,策略类class_name是你开发的CTA策略,策略名strategy_name是策略实例可以很多个。
cta_engine.add_strategy(class_name='DoubleMaStrategy', strategy_name='Test_1', vt_symbol='ni2006.SHFE', setting=('fast_window':10,'slow_window':20})
可以参考我写的一篇教程:https://www.vnpy.com/forum/topic/2876-wu-jie-mian-mo-shi-yun-xing-ctace-lue-shi-xian-mo-ni-shi-pan-jiao-yi

谢谢

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3