How to Modify or Cancel Existing Open Orders

Hi,

How do I Modify or Cancel already placed open orders? For example:

I place advance orders square off orders in strategy_enter_position() and based on the status in strategy_exit_position() I want to either modify or cancel the orders. How can that be done?

def strategy_enter_position(self, candle, instrument, sideband_info):
    self.logger.info('Entering Position')
    child = sideband_info['child']
    self.main_order_map[instrument] = self.broker.OrderRegular(instrument, sideband_info['action'], quantity=self.number_of_lots * instrument.lot_size, position=BrokerExistingOrderPositionConstants.ENTER)
    
    buy_order_status = str(self.main_order_map[instrument].get_order_status())
    self.logger.info(buy_order_status)
    self.logger.info(self.instrument)
    self.logger.info(instrument.lot_size)
    self.logger.info(self.number_of_lots)
    self.logger.info(self._mode)
    
    if self._mode == 1:
            
        if buy_order_status == 'COMPLETE':
            self.order_details['FirstSellOrder']=self.broker.OrderRegular(instrument=instrument, order_transaction_type='SELL', quantity=instrument.lot_size*self.number_of_lots/2, related_order=self.main_order_map[instrument], position=BrokerExistingOrderPositionConstants.EXIT, order_variety=BrokerOrderVarietyConstants.LIMIT, price = self.Action[child]['Target1'])
            self.logger.info(self.order_details['FirstSellOrder'])
            self.logger.info('FirstSellOrder')
            self.logger.info(self.order_details['FirstSellOrder'].get_order_status())
            
            self.order_details['SecondSellOrder']=self.broker.OrderRegular(instrument=instrument, order_transaction_type='SELL', quantity=instrument.lot_size*self.number_of_lots/2, related_order=self.main_order_map[instrument], position=BrokerExistingOrderPositionConstants.EXIT, order_variety=BrokerOrderVarietyConstants.LIMIT, price=self.Action[child]['Target2'])
            self.logger.info('SecondSellOrder')
            self.logger.info(self.order_details['SecondSellOrder'].get_order_status())

    return self.main_order_map[instrument]