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

求教大神:
CTA回测中,d、h周期运行正常可见回测结果,但m周期却提示如下错误,在“数据管理”模块中检查了“分钟线”数据未见NaN,如何解决求指点。

19:36:30 BTC-USDT.OKEX-1m历史数据下载完成
19:36:38 ----------------------------------------
19:36:38 开始加载历史数据
19:36:38 加载进度:########## [100%]
19:36:38 历史数据加载完成,数据量:1440
19:36:44 触发异常,回测终止
19:36:44 Traceback (most recent call last):
File "c:\vnstudio\lib\site-packages\talib__init__.py", line 20, in wrapper
for arg in chain(args, kwargs.values())
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 286, in run_backtesting
self.callback(data)
File "C:\Users\wangw\strategies\wTrader002.py", line 227, in on_bar
m30StochRSI = self.StochRSI(am.close_array, 12, 12, 3, 3, True)
File "C:\Users\wangw\strategies\wTrader002.py", line 104, in StochRSI
SRSID = talib.MA(np.array(SRSIK), dp)
File "c:\vnstudio\lib\site-packages\talib__init__.py", line 24, in wrapper
return func(*args, **kwargs)
File "_func.pxi", line 7902, in talib._ta_lib.MA
Exception: inputs are all NaN

19:36:44 开始计算逐日盯市盈亏
19:36:44 成交记录为空,无法计算
19:36:44 开始计算策略统计指标
19:36:44 策略统计指标计算完成

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

历史数据太少了,还不够算指标的

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

def load_bar(
self,
days: int, # days 是天数!
interval: Interval = Interval.MINUTE,
callback: Callable = None,
use_database: bool = False
):
self.load_bar(48),不是48根K线,而是48天,仅下载2天的K线,所以加载的历史数据不足导致报错。

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