尝试把CincoStrategy 用 tick 回测
on_tick 没有回调
反而 on_bar 有回调,但传过来的是DbTickData的对象
回测异常:
AttributeError: 'DbTickData' object has no attribute 'close_price'
回测程序如果下:
def run_backtesting(strategy_class, setting, vt_symbol, interval, start, end, rate, slippage, size, pricetick, capital):
engine = BacktestingEngine()
engine.set_parameters(
vt_symbol=vt_symbol,
interval=interval,
start=start,
end=end,
rate=rate,
slippage=slippage,
size=size,
pricetick=pricetick,
mode=BacktestingMode.TICK,
capital=capital
)
engine.add_strategy(strategy_class, setting)
engine.load_data()
engine.run_backtesting()
df = engine.calculate_result()
engine.calculate_statistics()
engine.show_chart()
return df
if name == "main":
df = run_backtesting(
strategy_class=CincoStrategy,
setting={},
vt_symbol="IF1912.CFFEX",
interval=Interval.TICK,
start=datetime(2019, 11, 25),
end=datetime(2019, 11, 26),
rate=0.3 / 10000,
slippage=0.2,
size=300,
pricetick=0.2,
capital=1_000_000,
)