¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

How to get historical data on previous E-mini S&P 500 contracts


 

For example I use this code to get one year historical data for E-Mini S&P 500. ?It works.


How to get the historical data from the previous contract, e.g. expiry 201509?

I tried the same approach as below. ?It works for 201512, but it did not work for 201509.?


The error mesage:

error: 0,200,No security definition has been found for the request


Thanks.


Code Snipet.

Contract contractOld = new Contract ();

? ? ? ? ? ? ? ? contractOld.m_symbol = "ES";

? ? ? ? ? ? ? ? contractOld.m_expiry = "201512";

? ? ? ? ? ? ? ??contractOld.m_exchange = "GLOBEX";

contractOld.m_secType = "FUT";

contractOld.m_currency = "USD";

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? client.reqHistoricalData(0, contractOld,?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"20141202 00:00:00", ?// End Date/Time

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"1 D", ? ? ? ? ? ? ? ?// Duration

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"1 min", ? ? ? ? ? ? ?// Bar size

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"TRADES", ? ? ? ? ? ? // What to show

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0, ? ? ? ? ? ? ? ? ? ?// useRTH

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1, ? ? ? ? ? ? ? ? ? ?// dateFormat

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?chartOptions);



 

There¡¯s a flag you can set called something like ¡®includeExpired¡¯ (can¡¯t remember the exact name offhand, but I¡¯m sure you can find it). Set it to true and all will be well.







From: TWSAPI@... [mailto:TWSAPI@...]
Sent: 20 November 2015 14:05
To: TWSAPI@...
Subject: [TWS API] How to get historical data on previous E-mini S&P 500 contracts





For example I use this code to get one year historical data for E-Mini S&P 500. It works.



How to get the historical data from the previous contract, e.g. expiry 201509?

I tried the same approach as below. It works for 201512, but it did not work for 201509.



The error mesage:

error: 0,200,No security definition has been found for the request



Thanks.



Code Snipet.

Contract contractOld = new Contract ();

contractOld.m_symbol = "ES";

contractOld.m_expiry = "201512";

contractOld.m_exchange = "GLOBEX";

contractOld.m_secType = "FUT";

contractOld.m_currency = "USD";





client.reqHistoricalData(0, contractOld,

"20141202 00:00:00", // End Date/Time

"1 D", // Duration

"1 min", // Bar size

"TRADES", // What to show

0, // useRTH

1, // dateFormat

chartOptions);







[Non-text portions of this message have been removed]