download historical data of expired futures with IB

Posted By: BrainSailor

download historical data of expired futures with IB - 01/12/23 13:09

Hi,
I am currently downloading futures data with IB. This is working very well with existing (live) futures.

Is there any way of downloading a trade history for expired futures ? IB is offering historical futures data for the last two years (also from expired ones).

The function "assetHistory()" is not returning any historical data for expired futures.
Example of an Asset List:

Name,Price,Spread,RollLong,RollShort,PIP,PIPCost,MarginCost,Market,Multiplier,Commission,Symbol-2023,Centage,Desc
CL_23F,0,0,0,0,0.01,10,-30,0,1000,0,CLF3-FUT-202301-CL-NYMEX,0,Crude Oil
CL_23G,0,0,0,0,0.01,10,-30,0,1000,0,CLG3-FUT-202302-CL-NYMEX,0,Crude Oil
CL_23H,0,0,0,0,0.01,10,-30,0,1000,0,CLH3-FUT-202303-CL-NYMEX,0,Crude Oil

The download is working well for the CLG3 and CLH3 contract but is not returning any data for the CLF3.

Is there any brokerCommand for downloading historical data for expired contracts, or am I missing something?

The script I am using is very basic:

int Mode = 1;
brokerCommand(SET_PRICETYPE,2);

StartDate = EndDate = 2023;

assetList("AssetsIB_Futures");
for(listed_assets)
assetHistory(0,Mode);

Any help is highly appreciated!
BS
Posted By: BrainSailor

Re: download historical data of expired futures with IB - 01/16/23 13:38

Just a short follow up if somebody has the same question:

Read the manual again and you'll find the answer wink

FUTX and the expiiry including the expiration day did the trick!
© 2024 lite-C Forums