How does IB's API work with historical data?

Discussion in 'App Development' started by MJM, Mar 28, 2015.

  1. MJM

    MJM

    My strategy involves using the most recent 14-week historical end of week/end of day data for a list of equities and I do a series of column sorts in excel based on some other data points to get my top picks every week. Is there a way I could do this using IB's API instead of excel? I don't want to use excel anymore is because I'm having trouble finding real time data for the most recent data point.
     
    spacewiz likes this.
  2. MJM likes this.
  3. MJM

    MJM

  4. vicirek

    vicirek

    IB API offers method call requesting historical bar data and returned data can be used in your strategy. IB Api is accessible through C++ or .Net (C#, VB, C++/CLI), and Java. There are also other ways of doing it through R, Python and other 3rd party ports. Until Api Version 970 it could be used with Excel but I am not sure if they support it with the newest version. In addition instead of building your own programs one can use 3rd party commercial applications offering historical data using IB Api. Getting historical data right is not straightforward because of the transactional nature of the request but for 14 weeks back it should not be much of the problem because it would come in one request if you get the method parameters right in terms of starting/ending time for the request and bar duration (it is an art not science).
     
    eusdaiki and MJM like this.
  5. MJM

    MJM

    Ok perfect, I plan on using Java. So I'm hoping I can request the data and put it in an array and do my sorts that way. Thanks for the help!
     
  6. rwk

    rwk

    MJM and eusdaiki like this.
  7. Butterfly

    Butterfly

    ok as usual in this type of questions, a lot of confusion and overlapping concepts

    First you need to define your data source for the 14 weeks historical, and that is not necessarily done with IB or their APIs. A number of quote vendors offer those data better than IB. That also means you might need to build a Datawarehouse to store and analyzed those data feeds in future research.

    Next, you need to find a way to "glue" your trading logic with your data feed. Again, IB and their APIs is a different issue. The programming language doesn't really matter as long as you can eventually "export" or connect to another process or system that will proceed the trades.

    If it's done in Java or C#, then you can "import" or "link" the IB API to do the trades directly within your trading logic, but again this is not necessary. You could create a separate service process in Java with IB APIs for the trades only, with the core logic of your strategy done in Perl, PHP, even Bash if you feel like it, before the result of that strategy is sent to the service for trade processing.

    Basically, the IB APIs are there for "Order Management" process, not necessarily the "strategy logic" or the Quote data feed. The IB APIs do offer a data feed service, but like I said, the IB Quote service has certain limitations and other vendors do a better job than IB for quote feeds.

    Hope that helps.
     
    Last edited: Mar 29, 2015
    eusdaiki, MJM and billyjoerob like this.
  8. MJM

    MJM

    That helps, but could you elaborate on the limitations in their data feed service. The data I would be requesting is pretty basic. Just the closing price from the last day of the week for 14 weeks. The most recent week would have to be a real time data quote.
     
  9. Butterfly

    Butterfly

    you could get the daily close from Yahoo using their webservices, no need for IB APIs

    not sure I understand what you mean for the most recent week ? by definition historical data is not real time and it's not live. Do you need to include the intra-day ticks for the most recent week in your data model ?

    It seems that you will need to define more precisely your quote data scenario, and then from that scenario, articulate a data model that you can run in your script or programming language. Nothing difficult, but you will need to put more thought in your design and planning.
     
    MJM likes this.
  10. Why don't you give it a try and let us all know? :)
     
    #10     Mar 30, 2015