¿ªÔÆÌåÓý

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

Re: Historical Data Download : Compare Experiences


 

¿ªÔÆÌåÓý

My downloader works rather differently, in that it uses a lot of asynchrony to get the data as fast as possible.

?

I¡¯ve just run it for daily S&P500 bars from 01/01/2005 to 01/0/2015. It went through the whole list, taking 66 minutes in total.

?

It doesn¡¯t do anything differently for older data. For each symbol (read from stdin) it does a contract details request (just to make sure the symbol is valid: my S&P500 list is a bit out of date, with about 30 or so incorrect symbols so far), followed by a historical data request, and then writes the returned data out to a text file. Multiple contract details requests and historical data requests are made concurrently, up to 20 of them for the contracts. As each contract request completes, the corresponding historical data request is added to a queue and the next contract request is made. As each data request completes, the next one in the queue is fired.

?

So it appears that TWS itself doesn¡¯t prevent old data downloads running smoothly.

?

I don¡¯t know what to suggest regarding your issue, though it does look like it¡¯s likely to be a fault in your code. The fact that it hangs after 98 API requests looks very suspicious. But then why wouldn¡¯t it do the same with more recent data?...

?

Using single requests for 20 years should work fine, but if you¡¯re anything like me you¡¯ll probably want to track down the cause of the problem.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of David Armour
Sent: 21 February 2023 02:06
To: [email protected]
Subject: [TWS API] Historical Data Download : Compare Experiences

?

I, like many of you I am sure, have created a data downloader. I came across a problem recently with my code which has been running well for ages (years). The difference this time is I am trying to download quite old data. Let me explain.

1) I have no problem to download the last 10 years of daily S&P500 stock (503 stocks currently) price data. Works fine, no hang-ups except for a couple of stocks (VICI & LIN) which IB have admitted to a problem and need special handling. (Note: I always take the minimum period between 10 years or the head timestamp)

2) Recently I am trying to run some data analysis on some longer history, so I set my "END DATE" to 20141231-115959 US/EASTERN and started a similar download to #1 above asking for 10 years history. This time I get to AXP which happens to be my 98th API call and TWS returns nothing. No error in the API log, just nothing. I removed AXP and tried again but the same thing happened with the 98th stock (this time AZO). After a 2min time-out waiting for data or a response, the next API call to TWS gets no reply again (this time happens to be a reqHeadTimestamp() call). If I move AXP to the head of my list, the AXP data downloads fine so it is not a data issue with that stock.

My code is very conservative and I download data in serial so there are no concurrent calls to reqMktData() however I suspect this is a form of pacing, but is it normal to get no response? I literally have to disconnect and reconnect my app to get things moving again.

Has anyone seen a problem on older data vs newer data like this?

Perhaps rather than trying to do this in 2 steps I could just ask for 20 years daily history.

Can anyone offer me pointers to getting older data out of TWS?

Join [email protected] to automatically receive all group messages.