Is there an easy way to dump historical bar data from TWS?

Discussion in 'Data Sets and Feeds' started by The Big D, Jul 21, 2010.

  1. I'd like to dump TWS' historical 5min bar data for a bunch of futures contracts to .csv or .xls files or some similar format. Is there an easy way to do this within TWS - perhaps opening a chart and then exporting it or something? Or using some free third party tool?

    I'm sure it can be done via the API but I'm hoping to avoid that.
  2. Not sure, but I think you can export data with Ninjatrader...and since it's free unless you place live orders, that falls in your price range.

    Alternatively, you wouldn't have to completely roll your own with the API as you can just tweak the VB.NET demo from TWS. That demo already allows you to submit requests for historic data (with the downloaded data printed out on the screen). All you'd need to do is stick a line or two of code to to open a file and then append data to that file each time a new tick is received (tickPrice event).

    Also of note, you can do this with the Express versions of Microsoft Visual Studio, so that's also free.
  3. All excellent suggestions. Thanks.
  4. ... or you might look into the Excel API demos which also include code to fetch historical data and need only minimal tweeks.

    Then you have the data in Excel and it's only to do "File Save" to store the .cvs file.
  5. Also a great suggestion. Thanks. Since most of the suggestions boil down to "tackle one of the APIs" I'm just biting the bullet and doing it in the java API. Hasn't been too bad.
  6. Raul641


    My free/open source Ruby interface to TWS, IB-Ruby, includes a utility in the examples/ subdirectory that does exactly this. It's at .
  7. samovar


    Thought I should reply since I've wasted about an hour trying to get historical stock option data via TWS using NinjaTrader 7. NinjaTrader used to, but no longer supports stock options, as of 2010-August.