再也不用担心重复下单啦,😁😁😁

只提供下单细粒度控制相关的代码

def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
    self.active_orderids = []       #活跃委托ID列表
#------------------------------------------------------------------------------------
def on_tick(self, tick: TickData):
    #提供多开下单基于委托ID的细粒度控制,其他方向下单相似
    if not self.pos  and not self.active_orderids:
        orderids = self.buy(tick.last_price,self.fixed_size,True)
        if orderids:
            self.active_orderids.extend(orderids)
#------------------------------------------------------------------------------------
def on_order(self, order: OrderData):
    #没有活跃订单撤掉active_orderids的委托ID
    if not order.is_active() and order.vt_orderid in self.active_orderids:
        self.active_orderids.remove(order.vt_orderid)