I'm working on an application to automate some trades via Interactive Brokers' Python API.
So far I have no trouble getting a simple example trade accepted:
contract = Contract()
contract.symbol = "GOOG"
contract.secType = "OPT"
contract.exchange = "BOX"
contract.currency = "USD"
contract.lastTradeDateOrContractMonth = "20191018"
contract.strike = 1230
contract.right = "C"
contract.multiplier = "100"
app.simplePlaceOid = 51
order = Order()
order.action = "BUY"
order.orderType = "LMT"
order.totalQuantity = 1
order.lmtPrice = 24.60
app.placeOrder(app.simplePlaceOid, contract, order)
But I need to support option spread orders with multiple legs.
I realized I was missing the conId member when setting up legs of the trade, and this was giving me an unhelpful 504 You are not connected error.
So I tried to run examples of the routine to get the contract IDs, even the example from the documentation:
self.reqMatchingSymbols(211, "IB")
... and I get a similar you are not connected error.
Any ideas on this?