Ultimate goal: Be able to submit both WhatIf:True
& WhatIf:False
on a combo order with SMART routing.
I read this here: The IBKR API requires setting a "non-guaranteed" flag on SMART-routed combo orders to acknowledge the risk of partial execution. QuantRocket sets this flag for you on SMART-routed combo orders.
For orders '6001:1', '6001:2'
I submitted as WhatIf:True
.
For order '6001:3'
I submitted commented out (below). Either way I end up with the non-guaranteed error, but my interpretation is QR would do this automatically given the sentence above. The margin fields are NaN
for all 3 orders. I'm submitting to a paper-account right now. This is a test on index options, wondering if Exchange: SMART
must be different?
order_id = place_orders(orders=[{
'Sid': 'IC3',
'Exchange': 'SMART',
'OrderType': 'LMT',
'LmtPrice': -2.50,
'TotalQuantity': 1,
'Action': 'BUY',
'Tif': 'Day',
'Account': 'xxxxx',
'OrderRef': 'xxxxxx',
# 'WhatIf': True,
}
])
download_order_statuses(f,
order_ids=['6001:1', '6001:2', '6001:3'],
fields=['InitMarginChange', 'MaintMarginChange', 'EquityWithLoanChange', 'MinCommission', 'MaxCommission']
)
statuses = pd.read_csv(f)
display(statuses[['OrderId', 'Status']])
print(statuses['Errors'].values)
OrderId Status
0 6001:1 Inactive
1 6001:2 Inactive
2 6001:3 Error
['[{"ErrorCode": 10043, "ErrorMsg": "Missing or invalid NonGuaranteed value. REL+MKT, LMT+MKT, and REL+LMT order of two legs can only be set as non-guaranteed."}]'
'[{"ErrorCode": 10043, "ErrorMsg": "Missing or invalid NonGuaranteed value. REL+MKT, LMT+MKT, and REL+LMT order of two legs can only be set as non-guaranteed."}]'
'[{"ErrorCode": 10043, "ErrorMsg": "Missing or invalid NonGuaranteed value. REL+MKT, LMT+MKT, and REL+LMT order of two legs can only be set as non-guaranteed."}]']
Side question: On the IBKR App & TWS if I submit a manual mid-price LMT
credit combo order like the above it seems to always fill on all N legs or not at all; however, this NonGuaranteed section makes me question this. For example, I've never experienced submitting a bull-put credit spread selecting 2 legs with a combo bid-ask of 1.50-1.70, submit at -1.60, and only have either the long or short leg execute, they always have in tandem.