[R-SIG-Finance] IBrokers: placing a combo order

Robert Schien robsch at robsch.eu
Fri Jul 10 15:20:09 CEST 2015

I want to place a combo order (futures calendar spread) and
tried this:

tws <- ibgConnect()
contr1 <- twsFuture("ESTX50","DTB","201512",currency="EUR")
contr2 <- twsFuture("ESTX50","DTB","201509",currency="EUR")
cid1 <- reqContractDetails(tws,contr1)[[1]]$conId
cid2 <- reqContractDetails(tws,contr2)[[1]]$conId
leg1 <- twsComboLeg(conId=cid1,ratio="1",action="BUY",exchange="DTB")
leg2 <- twsComboLeg(conId=cid2,ratio="1",action="SELL",exchange="DTB")
bag <- twsBAG(list(leg1,leg2))
order <- twsOrder(1,"BUY",1,"MKT")

reqOpenOrders(tws) delivered the error message that the details
of leg '0' were invalid. 
I don't know what leg '0' is but I assume that it is the
first leg in the combo.

Have I overlooked a detail?

I apologize for asking in this list but on the yahoolist twsapi
are only few R programmers and I received no answer there.

Thank you in advance.

More information about the R-SIG-Finance mailing list