请问下,大神原谅我这个新手。谢谢之前的大神解答我好几个小白问题
1、如果我之前short开一手空单。现在self.buy(bar.close_price , abs(self.pos) , stop = True) 。
那么我是平掉之前的空单,并开一手多单?还是既有一手空单,又有一手多单,锁仓了?
2、我在self.buy(bar.close_price , abs(self.pos) , stop = True)以及sell、short、cover 后面都 print(bar.datetime , bar.close_price),
然后我又在on_order函数后又 print(order.datetime , order.price), 发现时间order.datetime 比 bar.datetime 晚了五分钟(我是在on_5min_bar上执行的),但bar.close_price 和 order.price 是一样的。对比k线数据 on_5min_bar里面bar.datetime 和bar.close_price 对应的才是正确的。这是为什么呢?
例如:buy后面的打印的是 2022-04-12 13:35:00 1234 ,on_order打印的是 2022-04-12 13:40:00 1234
请问,我看代码上on_5min_bar是等这根5分钟k线路走完才调用,不是每个tick都调用一次(我之前用TB,盘中每个tick都会影响当前的5minK线)。那这样我直接用close_price回测,是不是就没有未来函数的问题?我的理解正不正确?
if not (bar.datetime.minute + 1) % self.window:
self.on_window_bar(self.window_bar)
self.window_bar = None
self.buy(long_entry, self.fixed_size, stop=True)
如果stop=True,是不是是触发条件后按照涨跌停价发单?如果是这样,这个long_entry是不是就没有意义,反正都是以涨停价购买?