For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Issues with cancelling order



  • Hi!
    I repeated the order and cancel a lot.
    Then self.cancel(order) doesn’t work.
    Does anyone know why this is?

    Thanks!

    code

    
    class St(bt.Strategy):
    
        params = dict(
            interval_pips = 6,
            order_size = 1000
        )
    
        def __init__(self):
            self.above_order = [None]*2
            self.below_order = [None]*2
            self.current_tp_order = None
            self.tradeid_seq = 0
            self.cancel_orders = []
    
        def notify_order(self, order):
            print(
                "[{}|{}]:::::ORDER::::: ref:{}, tradeid:{}, OrdType:{}, Status:{}, Price:{}({}), ExecType:{}, size:{}({})".format( 
                    self.data.datetime.time().strftime('%H:%M:%S'), 
                    datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'),
                    order.ref, order.tradeid, bt.Order.OrdTypes[order.ordtype], bt.Order.Status[order.status], 
                    order.price, order.executed.price, bt.Order.ExecTypes[order.exectype], order.size, order.executed.size
                )
            )
            if order.status in [order.Completed]:
                # make above and below orders
                self.create_new_trap(order.executed.price, order.executed.size, order.tradeid)
            elif order.status in [order.Canceled]:
                if len(self.cancel_orders)!=0:
                    for o in self.cancel_orders:
                        if o.ref == order.ref:
                            self.cancel_orders.remove(o)
                            break
    
        def next(self):
    
            if self.tradeid_seq==0:
                # make 1st orders
                self.create_new_trap(self.data.close[0])
            else:
                # repeat cancel
                self.execute_cancel_orders()
                    
        def create_new_trap(self, price, size=0, tradeid=-1):
    
            if self.current_tp_order is not None:
                if (size > 0 and self.current_tp_order.isbuy()) or \
                    (size < 0 and self.current_tp_order.issell()):
                    self.cancel_orders.append(self.current_tp_order)
    
            if tradeid != -1:
                if tradeid == self.above_order[0].tradeid:
                    self.cancel_orders.append(self.below_order[0])
                    self.current_tp_order = self.above_order[1]
                elif tradeid == self.below_order[0].tradeid:
                    self.cancel_orders.append(self.above_order[0])
                    self.current_tp_order = self.below_order[1]
                else:
                    pass
    
                self.execute_cancel_orders(put_log=True)
    
            interval_price = self.p.interval_pips * 0.01
    
            above_price = price
            below_price = price
    
            above_size = self.p.order_size
            below_size = self.p.order_size
    
            if size > 0:
                above_price += interval_price
                below_size += self.p.order_size
            elif size < 0:
                below_price -= interval_price
                above_size += self.p.order_size
            else: # only 1st time
                above_price += interval_price/4
                below_price -= interval_price/4
    
            # above order
            self.tradeid_seq+=1
            self.above_order[0] = self.buy(size=above_size, price=above_price, exectype=bt.Order.Stop, 
                                            tradeid=self.tradeid_seq, transmit=False)
            self.above_order[1] = self.sell(size=self.p.order_size, price=self.above_order[0].price+interval_price, exectype=bt.Order.Limit, 
                                            parent=self.above_order[0], tradeid=self.above_order[0].tradeid, transmit=True)
    
            # below order
            self.tradeid_seq+=1
            self.below_order[0] = self.sell(size=below_size, price=below_price, exectype=bt.Order.Stop, 
                                    tradeid=self.tradeid_seq, transmit=False)
            self.below_order[1] = self.buy(size=self.p.order_size, price=self.below_order[0].price-interval_price, exectype=bt.Order.Limit, 
                                    parent=self.below_order[0], tradeid=self.below_order[0].tradeid, transmit=True)
    
    
        def execute_cancel_orders(self, put_log=False):
    
            if len(self.cancel_orders)!=0:
                for o in self.cancel_orders:
                    if o.status in [o.Submitted, o.Accepted]:
                        if put_log:
                            print(
                                "[{}|{}]-----CANCEL----- ref:{}, tradeid:{}, OrdType:{}, Status:{}, Price:{}({}), ExecType:{}, size:{}({}), alive:{}".format( 
                                    self.data.datetime.time().strftime('%H:%M:%S'), 
                                    datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'),
                                    o.ref, o.tradeid, bt.Order.OrdTypes[o.ordtype], bt.Order.Status[o.status], 
                                    o.price, o.executed.price, bt.Order.ExecTypes[o.exectype], o.size, o.executed.size, o.alive()
                                )
                            )
                        self.cancel(o)
    
    

    output

    [19:09:30|2020-08-24 19:09:30.346813]:::::ORDER::::: ref:1, tradeid:1, OrdType:Buy, Status:Submitted, Price:105.755(0.0), ExecType:Stop, size:1000(0)
    [19:09:30|2020-08-24 19:09:30.346923]:::::ORDER::::: ref:2, tradeid:1, OrdType:Sell, Status:Submitted, Price:105.815(0.0), ExecType:Limit, size:-1000(0)
    [19:09:30|2020-08-24 19:09:30.347003]:::::ORDER::::: ref:3, tradeid:2, OrdType:Sell, Status:Submitted, Price:105.725(0.0), ExecType:Stop, size:-1000(0)
    [19:09:30|2020-08-24 19:09:30.347079]:::::ORDER::::: ref:4, tradeid:2, OrdType:Buy, Status:Submitted, Price:105.66499999999999(0.0), ExecType:Limit, size:1000(0)
    [19:09:30|2020-08-24 19:09:30.347155]:::::ORDER::::: ref:1, tradeid:1, OrdType:Buy, Status:Accepted, Price:105.755(0.0), ExecType:Stop, size:1000(0)
    [19:09:30|2020-08-24 19:09:30.347231]:::::ORDER::::: ref:3, tradeid:2, OrdType:Sell, Status:Accepted, Price:105.725(0.0), ExecType:Stop, size:-1000(0)
    [19:10:15|2020-08-24 19:10:15.258356]:::::ORDER::::: ref:1, tradeid:1, OrdType:Buy, Status:Completed, Price:105.755(105.756), ExecType:Stop, size:1000(1000.0)
    [19:10:15|2020-08-24 19:10:15.258495]-----CANCEL----- ref:3, tradeid:2, OrdType:Sell, Status:Accepted, Price:105.725(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:15|2020-08-24 19:10:15.259901]:::::ORDER::::: ref:2, tradeid:1, OrdType:Sell, Status:Accepted, Price:105.815(0.0), ExecType:Limit, size:-1000(0)
    [19:10:20|2020-08-24 19:10:20.351076]:::::ORDER::::: ref:5, tradeid:3, OrdType:Buy, Status:Submitted, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:20|2020-08-24 19:10:20.351162]:::::ORDER::::: ref:6, tradeid:3, OrdType:Sell, Status:Submitted, Price:105.876(0.0), ExecType:Limit, size:-1000(0)
    [19:10:20|2020-08-24 19:10:20.351209]:::::ORDER::::: ref:7, tradeid:4, OrdType:Sell, Status:Submitted, Price:105.756(0.0), ExecType:Stop, size:-2000(0)
    [19:10:20|2020-08-24 19:10:20.351251]:::::ORDER::::: ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0)
    [19:10:20|2020-08-24 19:10:20.351292]:::::ORDER::::: ref:3, tradeid:2, OrdType:Sell, Status:Canceled, Price:105.725(0.0), ExecType:Stop, size:-1000(0)
    [19:10:20|2020-08-24 19:10:20.351333]:::::ORDER::::: ref:3, tradeid:2, OrdType:Sell, Status:Canceled, Price:105.725(0.0), ExecType:Stop, size:-1000(0)
    [19:10:20|2020-08-24 19:10:20.351389]:::::ORDER::::: ref:5, tradeid:3, OrdType:Buy, Status:Accepted, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:20|2020-08-24 19:10:20.351438]:::::ORDER::::: ref:3, tradeid:2, OrdType:Sell, Status:Canceled, Price:105.725(0.0), ExecType:Stop, size:-1000(0)
    [19:10:20|2020-08-24 19:10:20.351492]:::::ORDER::::: ref:7, tradeid:4, OrdType:Sell, Status:Accepted, Price:105.756(0.0), ExecType:Stop, size:-2000(0)
    [19:10:20|2020-08-24 19:10:20.351561]:::::ORDER::::: ref:7, tradeid:4, OrdType:Sell, Status:Completed, Price:105.756(105.752), ExecType:Stop, size:-2000(-2000.0)
    [19:10:20|2020-08-24 19:10:20.351646]-----CANCEL----- ref:2, tradeid:1, OrdType:Sell, Status:Accepted, Price:105.815(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:20|2020-08-24 19:10:20.351762]-----CANCEL----- ref:5, tradeid:3, OrdType:Buy, Status:Accepted, Price:105.816(0.0), ExecType:Stop, size:1000(0), alive:True
    [19:10:25|2020-08-24 19:10:25.330410]:::::ORDER::::: ref:9, tradeid:5, OrdType:Buy, Status:Submitted, Price:105.752(0.0), ExecType:Stop, size:2000(0)
    [19:10:25|2020-08-24 19:10:25.330569]:::::ORDER::::: ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0)
    [19:10:25|2020-08-24 19:10:25.330674]:::::ORDER::::: ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0)
    [19:10:25|2020-08-24 19:10:25.330750]:::::ORDER::::: ref:12, tradeid:6, OrdType:Buy, Status:Submitted, Price:105.63199999999999(0.0), ExecType:Limit, size:1000(0)
    [19:10:25|2020-08-24 19:10:25.330829]:::::ORDER::::: ref:2, tradeid:1, OrdType:Sell, Status:Canceled, Price:105.815(0.0), ExecType:Limit, size:-1000(0)
    [19:10:25|2020-08-24 19:10:25.331042]:::::ORDER::::: ref:9, tradeid:5, OrdType:Buy, Status:Accepted, Price:105.752(0.0), ExecType:Stop, size:2000(0)
    [19:10:25|2020-08-24 19:10:25.331179]:::::ORDER::::: ref:9, tradeid:5, OrdType:Buy, Status:Completed, Price:105.752(105.756), ExecType:Stop, size:2000(2000.0)
    [19:10:25|2020-08-24 19:10:25.331262]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:25|2020-08-24 19:10:25.331383]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:25|2020-08-24 19:10:25.332845]:::::ORDER::::: ref:5, tradeid:3, OrdType:Buy, Status:Canceled, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:25|2020-08-24 19:10:25.334040]:::::ORDER::::: ref:2, tradeid:1, OrdType:Sell, Status:Canceled, Price:105.815(0.0), ExecType:Limit, size:-1000(0)
    [19:10:25|2020-08-24 19:10:25.334167]:::::ORDER::::: ref:5, tradeid:3, OrdType:Buy, Status:Canceled, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:30|2020-08-24 19:10:30.363453]:::::ORDER::::: ref:13, tradeid:7, OrdType:Buy, Status:Submitted, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:30|2020-08-24 19:10:30.363561]:::::ORDER::::: ref:14, tradeid:7, OrdType:Sell, Status:Submitted, Price:105.876(0.0), ExecType:Limit, size:-1000(0)
    [19:10:30|2020-08-24 19:10:30.363666]:::::ORDER::::: ref:15, tradeid:8, OrdType:Sell, Status:Submitted, Price:105.756(0.0), ExecType:Stop, size:-2000(0)
    [19:10:30|2020-08-24 19:10:30.363739]:::::ORDER::::: ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0)
    [19:10:30|2020-08-24 19:10:30.363847]:::::ORDER::::: ref:13, tradeid:7, OrdType:Buy, Status:Accepted, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:30|2020-08-24 19:10:30.363962]:::::ORDER::::: ref:15, tradeid:8, OrdType:Sell, Status:Accepted, Price:105.756(0.0), ExecType:Stop, size:-2000(0)
    [19:10:30|2020-08-24 19:10:30.364278]:::::ORDER::::: ref:15, tradeid:8, OrdType:Sell, Status:Completed, Price:105.756(105.752), ExecType:Stop, size:-2000(-2000.0)
    [19:10:30|2020-08-24 19:10:30.364359]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:30|2020-08-24 19:10:30.364451]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:30|2020-08-24 19:10:30.364532]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:30|2020-08-24 19:10:30.365090]-----CANCEL----- ref:13, tradeid:7, OrdType:Buy, Status:Accepted, Price:105.816(0.0), ExecType:Stop, size:1000(0), alive:True
    [19:10:35|2020-08-24 19:10:35.146308]:::::ORDER::::: ref:17, tradeid:9, OrdType:Buy, Status:Submitted, Price:105.752(0.0), ExecType:Stop, size:2000(0)
    [19:10:35|2020-08-24 19:10:35.146496]:::::ORDER::::: ref:18, tradeid:9, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0)
    [19:10:35|2020-08-24 19:10:35.146576]:::::ORDER::::: ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0)
    [19:10:35|2020-08-24 19:10:35.146644]:::::ORDER::::: ref:20, tradeid:10, OrdType:Buy, Status:Submitted, Price:105.63199999999999(0.0), ExecType:Limit, size:1000(0)
    [19:10:35|2020-08-24 19:10:35.146716]:::::ORDER::::: ref:13, tradeid:7, OrdType:Buy, Status:Canceled, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:35|2020-08-24 19:10:35.146795]:::::ORDER::::: ref:13, tradeid:7, OrdType:Buy, Status:Canceled, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:35|2020-08-24 19:10:35.146868]:::::ORDER::::: ref:17, tradeid:9, OrdType:Buy, Status:Accepted, Price:105.752(0.0), ExecType:Stop, size:2000(0)
    [19:10:35|2020-08-24 19:10:35.146939]:::::ORDER::::: ref:17, tradeid:9, OrdType:Buy, Status:Completed, Price:105.752(105.762), ExecType:Stop, size:2000(2000.0)
    [19:10:35|2020-08-24 19:10:35.147026]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:35|2020-08-24 19:10:35.147143]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:35|2020-08-24 19:10:35.147231]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:35|2020-08-24 19:10:35.147316]-----CANCEL----- ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:35|2020-08-24 19:10:35.147397]-----CANCEL----- ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:35|2020-08-24 19:10:35.148375]:::::ORDER::::: ref:13, tradeid:7, OrdType:Buy, Status:Canceled, Price:105.816(0.0), ExecType:Stop, size:1000(0)
    [19:10:40|2020-08-24 19:10:40.158727]:::::ORDER::::: ref:21, tradeid:11, OrdType:Buy, Status:Submitted, Price:105.822(0.0), ExecType:Stop, size:1000(0)
    [19:10:40|2020-08-24 19:10:40.158838]:::::ORDER::::: ref:22, tradeid:11, OrdType:Sell, Status:Submitted, Price:105.882(0.0), ExecType:Limit, size:-1000(0)
    [19:10:40|2020-08-24 19:10:40.158921]:::::ORDER::::: ref:23, tradeid:12, OrdType:Sell, Status:Submitted, Price:105.762(0.0), ExecType:Stop, size:-2000(0)
    [19:10:40|2020-08-24 19:10:40.159005]:::::ORDER::::: ref:24, tradeid:12, OrdType:Buy, Status:Submitted, Price:105.702(0.0), ExecType:Limit, size:1000(0)
    [19:10:40|2020-08-24 19:10:40.159101]:::::ORDER::::: ref:21, tradeid:11, OrdType:Buy, Status:Accepted, Price:105.822(0.0), ExecType:Stop, size:1000(0)
    [19:10:40|2020-08-24 19:10:40.159185]:::::ORDER::::: ref:23, tradeid:12, OrdType:Sell, Status:Accepted, Price:105.762(0.0), ExecType:Stop, size:-2000(0)
    [19:10:40|2020-08-24 19:10:40.159258]:::::ORDER::::: ref:23, tradeid:12, OrdType:Sell, Status:Completed, Price:105.762(105.758), ExecType:Stop, size:-2000(-2000.0)
    [19:10:40|2020-08-24 19:10:40.159359]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:40|2020-08-24 19:10:40.159475]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:40|2020-08-24 19:10:40.159561]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:40|2020-08-24 19:10:40.159645]-----CANCEL----- ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:40|2020-08-24 19:10:40.159729]-----CANCEL----- ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:40|2020-08-24 19:10:40.159812]-----CANCEL----- ref:18, tradeid:9, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:40|2020-08-24 19:10:40.159897]-----CANCEL----- ref:21, tradeid:11, OrdType:Buy, Status:Accepted, Price:105.822(0.0), ExecType:Stop, size:1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.431596]:::::ORDER::::: ref:25, tradeid:13, OrdType:Buy, Status:Submitted, Price:105.758(0.0), ExecType:Stop, size:2000(0)
    [19:10:45|2020-08-24 19:10:45.431829]:::::ORDER::::: ref:26, tradeid:13, OrdType:Sell, Status:Submitted, Price:105.818(0.0), ExecType:Limit, size:-1000(0)
    [19:10:45|2020-08-24 19:10:45.432092]:::::ORDER::::: ref:27, tradeid:14, OrdType:Sell, Status:Submitted, Price:105.698(0.0), ExecType:Stop, size:-1000(0)
    [19:10:45|2020-08-24 19:10:45.432529]:::::ORDER::::: ref:28, tradeid:14, OrdType:Buy, Status:Submitted, Price:105.63799999999999(0.0), ExecType:Limit, size:1000(0)
    [19:10:45|2020-08-24 19:10:45.432744]:::::ORDER::::: ref:21, tradeid:11, OrdType:Buy, Status:Canceled, Price:105.822(0.0), ExecType:Stop, size:1000(0)
    [19:10:45|2020-08-24 19:10:45.432858]:::::ORDER::::: ref:21, tradeid:11, OrdType:Buy, Status:Canceled, Price:105.822(0.0), ExecType:Stop, size:1000(0)
    [19:10:45|2020-08-24 19:10:45.432934]:::::ORDER::::: ref:25, tradeid:13, OrdType:Buy, Status:Accepted, Price:105.758(0.0), ExecType:Stop, size:2000(0)
    [19:10:45|2020-08-24 19:10:45.433010]:::::ORDER::::: ref:25, tradeid:13, OrdType:Buy, Status:Completed, Price:105.758(105.764), ExecType:Stop, size:2000(2000.0)
    [19:10:45|2020-08-24 19:10:45.433099]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433192]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433286]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433370]-----CANCEL----- ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433423]-----CANCEL----- ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433469]-----CANCEL----- ref:18, tradeid:9, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433513]-----CANCEL----- ref:24, tradeid:12, OrdType:Buy, Status:Submitted, Price:105.702(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.433557]-----CANCEL----- ref:27, tradeid:14, OrdType:Sell, Status:Submitted, Price:105.698(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:45|2020-08-24 19:10:45.435032]:::::ORDER::::: ref:21, tradeid:11, OrdType:Buy, Status:Canceled, Price:105.822(0.0), ExecType:Stop, size:1000(0)
    [19:10:50|2020-08-24 19:10:50.441612]:::::ORDER::::: ref:29, tradeid:15, OrdType:Buy, Status:Submitted, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:10:50|2020-08-24 19:10:50.441700]:::::ORDER::::: ref:30, tradeid:15, OrdType:Sell, Status:Submitted, Price:105.884(0.0), ExecType:Limit, size:-1000(0)
    [19:10:50|2020-08-24 19:10:50.441771]:::::ORDER::::: ref:31, tradeid:16, OrdType:Sell, Status:Submitted, Price:105.764(0.0), ExecType:Stop, size:-2000(0)
    [19:10:50|2020-08-24 19:10:50.441835]:::::ORDER::::: ref:32, tradeid:16, OrdType:Buy, Status:Submitted, Price:105.704(0.0), ExecType:Limit, size:1000(0)
    [19:10:50|2020-08-24 19:10:50.441903]:::::ORDER::::: ref:29, tradeid:15, OrdType:Buy, Status:Accepted, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:10:50|2020-08-24 19:10:50.441970]:::::ORDER::::: ref:31, tradeid:16, OrdType:Sell, Status:Accepted, Price:105.764(0.0), ExecType:Stop, size:-2000(0)
    [19:10:50|2020-08-24 19:10:50.442031]:::::ORDER::::: ref:31, tradeid:16, OrdType:Sell, Status:Completed, Price:105.764(105.76), ExecType:Stop, size:-2000(-2000.0)
    [19:10:50|2020-08-24 19:10:50.442108]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.442214]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.442291]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.442368]-----CANCEL----- ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.442443]-----CANCEL----- ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.442974]-----CANCEL----- ref:18, tradeid:9, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.443084]-----CANCEL----- ref:24, tradeid:12, OrdType:Buy, Status:Submitted, Price:105.702(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.443171]-----CANCEL----- ref:27, tradeid:14, OrdType:Sell, Status:Submitted, Price:105.698(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.443256]-----CANCEL----- ref:26, tradeid:13, OrdType:Sell, Status:Submitted, Price:105.818(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:50|2020-08-24 19:10:50.443335]-----CANCEL----- ref:29, tradeid:15, OrdType:Buy, Status:Accepted, Price:105.824(0.0), ExecType:Stop, size:1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.207002]:::::ORDER::::: ref:33, tradeid:17, OrdType:Buy, Status:Submitted, Price:105.76(0.0), ExecType:Stop, size:2000(0)
    [19:10:55|2020-08-24 19:10:55.207126]:::::ORDER::::: ref:34, tradeid:17, OrdType:Sell, Status:Submitted, Price:105.82000000000001(0.0), ExecType:Limit, size:-1000(0)
    [19:10:55|2020-08-24 19:10:55.207211]:::::ORDER::::: ref:35, tradeid:18, OrdType:Sell, Status:Submitted, Price:105.7(0.0), ExecType:Stop, size:-1000(0)
    [19:10:55|2020-08-24 19:10:55.207286]:::::ORDER::::: ref:36, tradeid:18, OrdType:Buy, Status:Submitted, Price:105.64(0.0), ExecType:Limit, size:1000(0)
    [19:10:55|2020-08-24 19:10:55.207354]:::::ORDER::::: ref:29, tradeid:15, OrdType:Buy, Status:Canceled, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:10:55|2020-08-24 19:10:55.207407]:::::ORDER::::: ref:29, tradeid:15, OrdType:Buy, Status:Canceled, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:10:55|2020-08-24 19:10:55.207448]:::::ORDER::::: ref:33, tradeid:17, OrdType:Buy, Status:Accepted, Price:105.76(0.0), ExecType:Stop, size:2000(0)
    [19:10:55|2020-08-24 19:10:55.207486]:::::ORDER::::: ref:33, tradeid:17, OrdType:Buy, Status:Completed, Price:105.76(105.764), ExecType:Stop, size:2000(2000.0)
    [19:10:55|2020-08-24 19:10:55.207691]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.207773]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.207820]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.207863]-----CANCEL----- ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.207914]-----CANCEL----- ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.207981]-----CANCEL----- ref:18, tradeid:9, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.208040]-----CANCEL----- ref:24, tradeid:12, OrdType:Buy, Status:Submitted, Price:105.702(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.208082]-----CANCEL----- ref:27, tradeid:14, OrdType:Sell, Status:Submitted, Price:105.698(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.208285]-----CANCEL----- ref:26, tradeid:13, OrdType:Sell, Status:Submitted, Price:105.818(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.208470]-----CANCEL----- ref:32, tradeid:16, OrdType:Buy, Status:Submitted, Price:105.704(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.208694]-----CANCEL----- ref:35, tradeid:18, OrdType:Sell, Status:Submitted, Price:105.7(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:10:55|2020-08-24 19:10:55.210063]:::::ORDER::::: ref:29, tradeid:15, OrdType:Buy, Status:Canceled, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:11:00|2020-08-24 19:11:00.241086]:::::ORDER::::: ref:37, tradeid:19, OrdType:Buy, Status:Submitted, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:11:00|2020-08-24 19:11:00.241421]:::::ORDER::::: ref:38, tradeid:19, OrdType:Sell, Status:Submitted, Price:105.884(0.0), ExecType:Limit, size:-1000(0)
    [19:11:00|2020-08-24 19:11:00.241569]:::::ORDER::::: ref:39, tradeid:20, OrdType:Sell, Status:Submitted, Price:105.764(0.0), ExecType:Stop, size:-2000(0)
    [19:11:00|2020-08-24 19:11:00.241706]:::::ORDER::::: ref:40, tradeid:20, OrdType:Buy, Status:Submitted, Price:105.704(0.0), ExecType:Limit, size:1000(0)
    [19:11:00|2020-08-24 19:11:00.241801]:::::ORDER::::: ref:37, tradeid:19, OrdType:Buy, Status:Accepted, Price:105.824(0.0), ExecType:Stop, size:1000(0)
    [19:11:00|2020-08-24 19:11:00.241881]:::::ORDER::::: ref:39, tradeid:20, OrdType:Sell, Status:Accepted, Price:105.764(0.0), ExecType:Stop, size:-2000(0)
    [19:11:00|2020-08-24 19:11:00.241946]:::::ORDER::::: ref:39, tradeid:20, OrdType:Sell, Status:Completed, Price:105.764(105.758), ExecType:Stop, size:-2000(-2000.0)
    [19:11:00|2020-08-24 19:11:00.242032]-----CANCEL----- ref:8, tradeid:4, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242148]-----CANCEL----- ref:11, tradeid:6, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242231]-----CANCEL----- ref:10, tradeid:5, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242361]-----CANCEL----- ref:16, tradeid:8, OrdType:Buy, Status:Submitted, Price:105.696(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242455]-----CANCEL----- ref:19, tradeid:10, OrdType:Sell, Status:Submitted, Price:105.692(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242539]-----CANCEL----- ref:18, tradeid:9, OrdType:Sell, Status:Submitted, Price:105.812(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242622]-----CANCEL----- ref:24, tradeid:12, OrdType:Buy, Status:Submitted, Price:105.702(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242698]-----CANCEL----- ref:27, tradeid:14, OrdType:Sell, Status:Submitted, Price:105.698(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242772]-----CANCEL----- ref:26, tradeid:13, OrdType:Sell, Status:Submitted, Price:105.818(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242847]-----CANCEL----- ref:32, tradeid:16, OrdType:Buy, Status:Submitted, Price:105.704(0.0), ExecType:Limit, size:1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.242929]-----CANCEL----- ref:35, tradeid:18, OrdType:Sell, Status:Submitted, Price:105.7(0.0), ExecType:Stop, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.243013]-----CANCEL----- ref:34, tradeid:17, OrdType:Sell, Status:Submitted, Price:105.82000000000001(0.0), ExecType:Limit, size:-1000(0), alive:True
    [19:11:00|2020-08-24 19:11:00.243221]-----CANCEL----- ref:37, tradeid:19, OrdType:Buy, Status:Accepted, Price:105.824(0.0), ExecType:Stop, size:1000(0), alive:True
    


  • @T-H said in Issues with cancelling order:

    Then self.cancel(order) doesn’t work.
    Does anyone know why this is?

    You have an error in your code which causes this issue.



  • @ab_trader Thank you for checking my code!
    I know the biggest issue is myself, but could I ask you that issue?



  • Thank you everyone for thinking about this issue.
    But I decided to think of alternative ways.

    It was over my head! lol

    Thanks!


Log in to reply
 

});