X0Leon / XQuant

Simple backtester for human.
MIT License
75 stars 39 forks source link

portfolio.equity_curve长度比data中大2 #2

Closed X0Leon closed 7 years ago

X0Leon commented 8 years ago

portfolio.equity_curve比data_handler.latest_symbol_data字典元素的长度大2,多在一头一尾,发现portfolio在处理过程中在开始和结束处多加了两行,从datetime可以看出。

X0Leon commented 7 years ago

这不是问题,处理时可以根据需要更改,如果不需要df.iloc[1:-1]即可。

X0Leon commented 7 years ago

问题进一步解决:1)在开始多加一行是测试时初始化账户需要;2)在结束时多了一行是因为data.py中CSVDataHandler类,update_bars方法在put市场事件时没有判断continue_backtest,因为即使结束仍然会最后一次将bar put到event队列,即将修正:

if self.continue_backtest:
    self.events.put(MarketEvent())