code: def createComboLeg(self, contract, action, ratio=1, exchange=None):
          
          leg = ComboLeg()
  
          loops = 0
          conId = 0
          while conId == 0 and loops < 100:
              conId = self.getConId(contract)
              loops += 1
              time.sleep(0.05)
  
          leg.m_conId = conId
          leg.m_ratio = abs(ratio)
          leg.m_action = action
          leg.m_exchange = contract.m_exchange if exchange is None else exchange
          leg.m_openClose = 0
          leg.m_shortSaleSlot = 0
          leg.m_designatedLocation = ""
  
          return leg
docs: create combo leg
          https://www.interactivebrokers.com/en/software/api/apiguide/java/comboleg.htm