0

Hi I'm trying to place combo orders with IB Native API but it keeps being rejected with a popup:

popup

The error message is "Rejected - Invalid value in field # 6079". I don't know which field is #6079.

My code looks like this (the conid's were previously stored):

contract = Contract()
contract.symbol = "DJX"
contract.secType = "BAG"
contract.currency = "USD"
contract.exchange = "SMART"

leg1 = ComboLeg()
leg1.conId = 492705004
leg1.ratio = 1
leg1.action = "BUY"
leg1.exchange = "SMART"
leg1.openClose = 0
leg1.designatedLocation = ""

leg2 = ComboLeg()
leg2.conId = 492705004
leg2.ratio = 1
leg2.action = "SELL"
leg2.exchange = "SMART"
leg2.openClose = 0
leg2.designatedLocation = ""

contract.comboLegs = []
contract.comboLegs.append(leg1)
contract.comboLegs.append(leg2)
    
order = Order()
order.account = acc
order.action = "BUY"
order.orderType = "LMT"
order.totalQuantity = 1
order.orderComboLegs = []
legPrices = [340, 39]
for price in legPrices:
    comboLeg = OrderComboLeg()
    comboLeg.price = price
    order.orderComboLegs.append(comboLeg)

order.smartComboRoutingParams = []
order.smartComboRoutingParams.append(TagValue("NonGuaranteed", "1"))

app.placeOrder(this_id, contract=contract, order=order)

Can someone help me?

Thanks

EDIT: I think this error raises when the conid is the same, I've changed for different conid and it seems to have solved the problem.

  • Are you sure this code worked after changing the conIDs? The combo contract is essentially a combined contract and it's price is a weighted sum of the component. I don't think separate leg prices need to be passed. – Mayank R Sep 11 '21 at 01:45
  • This code worked at the time. I also think it would be redundant but it is specified at the docs (https://interactivebrokers.github.io/tws-api/classIBApi_1_1OrderComboLeg.html#details). In the end, I was not pretty sure how to pass the ratio and the prices, one of them must be the main. – Pedro Tayer Sep 12 '21 at 13:54

0 Answers0