账户是simnow
def on_bar(self, bar: BarData):
"""
Callback of new bar data update.
"""
self.cancel_all()
am = self.am
am.update_bar(bar)
if not am.inited:
return
。。。
if self.pos == 0:
if 。。。:
self.buy(bar.close_price, tradesize)
self.write_log(f"buy at price: {bar.close_price} with size {tradesize}")
elif 。。。:
self.short(bar.close_price, tradesize)
self.write_log(f"short at price: {bar.close_price} with size {tradesize}")
elif self.pos > 0:
if 。。。:
self.sell(bar.close_price, abs(self.pos), stop=True)
self.write_log(f"sell at price: {bar.close_price} with size {tradesize}")
elif self.pos < 0:
if 。。。:
self.cover(bar.close_price, abs(self.pos), stop=True)
self.write_log(f"cover at price: {bar.close_price} with size {tradesize}")
self.put_event()