Skip to content
Discussion options

You must be logged in to vote

IB's continuous future contracts may be what you are looking for.

Using the API, following IB docs, you can use secType="CONTFUT" to get the lead month contract, as in:

cfut = Jib.Contract(symbol="CL", secType="CONTFUT", exchange="NYMEX")
Jib.reqContractDetails(ib, idx, cfut)

# Obtain the conId from the returned contract and then
Jib.reqMktData(ib, 1, Jib.Contract(conId=xxx, exchange="NYMEX"), "", false)

Continuous contracts can be used directly in reqContractDetails() and reqHistoricalData() but not in reqMktData(), for which a two step approach as above is required.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant