VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 16
声望: 0

写了个小策略,回测20180601至今的1分钟数据,跑了两趟,都遭遇了cursor not found error,跑不下去。这是什么情况?

Traceback (most recent call last):

File "<ipython-input-73-226684c405f4>", line 1, in <module>
runfile('C:/vnpy-1.9.2/examples/CtaBacktesting/runBacktesting.py', wdir='C:/vnpy-1.9.2/examples/CtaBacktesting')

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 95, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

File "C:/vnpy-1.9.2/examples/CtaBacktesting/runBacktesting.py", line 45, in <module>
engine.runBacktesting()

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\vnpy\trader\app\ctaStrategy\ctaBacktesting.py", line 278, in runBacktesting
for d in self.dbCursor:

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\pymongo\cursor.py", line 1189, in next
if len(self.__data) or self._refresh():

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\pymongo\cursor.py", line 1126, in _refresh
self.__send_message(g)

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\pymongo\cursor.py", line 982, in __send_message
helpers._check_command_response(first)

File "C:\ProgramData\Anaconda3\envs\py2\lib\site-packages\pymongo\helpers.py", line 152, in _check_command_response
raise CursorNotFound(errmsg, code, response)

CursorNotFound: Cursor not found, cursor id: 369143098222

Administrator
avatar
加入于:
帖子: 4501
声望: 321

这个原因应该是MongoDB数据库的问题,要么是数据库坏了,要么是你的数据不足,检查下吧

Member
avatar
加入于:
帖子: 16
声望: 0

我解决了,原来是mongoDB超时报错,(暂时没有去弄清楚连接mongoDB多长时间报错,网上说10分钟,但我感觉不止)。对策是将mongoDB的数据一次性都导入到一个list,从再list里面取数据进行回测。这样处理,一个多小时的回测就顺利跑完了。

2019-04-26 11:47:16.820000 第一笔交易: 2015-02-27 21:37:00
2019-04-26 11:47:16.821000 最后一笔交易: 2019-03-29 09:01:00
2019-04-26 11:47:16.821000 总交易次数: 90.0
2019-04-26 11:47:16.821000 总盈亏: 1,315,979.81
2019-04-26 11:47:16.821000 最大回撤: -161,938.23
2019-04-26 11:47:16.821000 平均每笔盈利: 14,622.0
2019-04-26 11:47:16.821000 平均每笔滑点: 1,412.89
2019-04-26 11:47:16.821000 平均每笔佣金: 379.89
2019-04-26 11:47:16.821000 胜率 50.0%
2019-04-26 11:47:16.821000 盈利交易平均值 49,286.24
2019-04-26 11:47:16.822000 亏损交易平均值 -20,042.25
2019-04-26 11:47:16.822000 盈亏比: 2.46

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

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】