7.3 Cheat On Open
2020-04-26 本文已影响0人
wanggs66
针对一些all-in策略,会利用当天的close price计算出来的交易量,在第二天以开盘成交。但是开盘价和前收盘价之间存在一个缺口,可能会导致现金不够买入之前计算成交数量的情况,这个时候broker会拒绝执行订单。
针对这种情况,可以通过正数index[1]来获取第二天的开盘价,但是这并不是在各种情况下都可行的一种方式。
所以考虑引入cheat on open 这种方式来解决上面的问题。
cerebro = bt.Cerebro(cheat_on_open=True)
This:
- Activates an extra cycle in the system which calls the methods in the strategy next_open, nextstart_open and prenext_open. 会在执行next之后执行一个next open操作。
The following holds true when inside a xxx_open method:
The indicators have not been recalculated and hold the values that were last seen during the previous cycle in the equivalent xxx regular methods next_open等方法中不会重新计算indicator
The broker has not yet evaluated the pending orders for the new cycle and new orders can be introduced which will be evaluated if possible. 还没有评估新一轮的pending orders, 如果可以则可以执行。