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

Jupyter运行多进程参数优化时报错:
"""
Traceback (most recent call last):
File "c:\vnstudio\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 1164, in optimize
engine.run_backtesting()
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 293, in run_backtesting
func(data)
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 707, in new_bar
self.cross_stop_order()
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 874, in cross_stop_order
self.active_stop_orders.pop(stop_order.stop_orderid)
KeyError: 'STOP.42450'
"""

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)

<ipython-input-1-744c12103984> in <module>
30 import time
31 start = time.time()
---> 32 res = engine.run_optimization(setting)
33 print (u'耗时:%s' %(time.time()-start))

c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py in run_optimization(self, optimization_setting, output)
553
554 # Sort results and output
--> 555 result_values = [result.get() for result in results]
556 result_values.sort(reverse=True, key=lambda result: result[1])
557

c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py in <listcomp>(.0)
553
554 # Sort results and output
--> 555 result_values = [result.get() for result in results]
556 result_values.sort(reverse=True, key=lambda result: result[1])
557

c:\vnstudio\lib\multiprocessing\pool.py in get(self, timeout)
681 return self._value
682 else:
--> 683 raise self._value
684
685 def _set(self, i, obj):

KeyError: 'STOP.42450'

Member
avatar
加入于:
帖子: 9
声望: 1

这个错误出现在自带的KingKeltner策略回测时,考虑是不是OCO方式挂单的问题导致的

Administrator
avatar
加入于:
帖子: 1690
声望: 80

请问直接回测KK策略,是否也会触发这个报错呢

Member
avatar
加入于:
帖子: 9
声望: 1

直接回测KK,会出现这个报错
将KK策略的订单管理方式改为了粗暴的每个5minbar中cancel_all,然后测了下发现不报错

Administrator
avatar
加入于:
帖子: 1690
声望: 80

我们来检查下,感觉可能是某一方向成交后反向立即撤单,导致的委托找不到

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