策略有一个参数 strategy_cash 用于记录当前策略还有多少钱,每次停止单报单前根据 strategy_cash / bar.close_price 确定下单量。
在on_stop_order 里,
多头开仓成交时,strategy_cash 减去成交额, 多头平仓时strategy_cash 加上成交额
空头开仓成交时,strategy_cash 加上成交额,空头平仓时strategy_cash 减去成交额
on_stop_order 函数:
on_bar 下单逻辑:
回测的成交记录: