Building your own program to live trade with IB?

Discussion in 'Programming' started by GloriaBrown, Nov 23, 2018.

  1. Where did you get most of the coding information to connect with IB and other related stuff? Thx.
     
  2. ensemble

    ensemble

    The TWS API is simple, but it is missing a lot of pieces for a fully automated system. You need to write your own trade and position management, and real-time PnL/risk. You also need to consider the effect of pending/partial orders on your trading strategy.
     
  3. guru

    guru

    It’s actually not that simple as it doesn’t support rest api/requests where you could simply retrieve what you want whenever you’d want.
    Instead, you have to subscribe/unsubscribe to streamed data and handle variety of received data snippets and errors.
    I’m not saying that’s a bad approach, but not as simple as for example receiving historical data or account information via a single API request through various other services, or generally any modern website or API. Something that currently most programmers can do in minutes with modern rest APIs, requires days with IB.
    But IB API comes with good examples and plenty of documention that helps you get started quite fast:
    https://interactivebrokers.github.io/
     
    Last edited: Nov 23, 2018
  4. How did you get the basic info to start to write codes? Here is a good place to ask questions?
     
  5. What programming language do you use with ib api and why?
     
  6. guru

    guru

    The above link contains all the basics and examples and that’s where I got started.

    Myself, I use C# because it’s very fast (to execute and to code), convenient, popular, with lots of features, and commercially supported (while being free, including free Visual Studio that is a great coding IDE).
    Though many people use Java and Python. You can find many examples with source code in those languages by Googling.
     
  7. Thx I use C sharp and feel creating interface for Java is much harder, I would use C sharp then.

    Any pain for updating codes for Visual Studio version? Every few years people are forced to update codes if they want to use the latest visual studio.
     
  8. If I want to get historical data, do I need to pay monthly subscription fee for that market? How about if I want to test real time performance with demo account?
     
  9. Craig66

    Craig66

    The IB API is a a series of clear text TCP messages, so you can use any language you want.
    I started with C++, but then moved to C#, they provide an example client in C#.
    The hard part is covering all the little inconsistencies they have built in, for example, there are two different ways to track the state of orders, also, things change in subtle ways between releases. What I did was to build basic systems which place paper orders and watch the messages you get back to get a feel for the flow of events. Another good resource is the TWS API group (do a search), the discussion tends to revolve around more advanced aspects of the API, so you're unlikely to get any starter help. But it's a good place to search for questions already asked.
     
  10. guru

    guru

    I didn't have any issues with maintaining the same code for years, don't remember needing any major changes.

    IB openly states that they are not a data provider and don't have resources to provide data, so they have limits on how much historical data you can obtain and how often:
    https://interactivebrokers.github.io/tws-api/historical_limitations.html

    No problems with testing real time performance with demo account, though your orders may not fill the same way since IB cannot know if an order may be filled, or how much qty may be filled, and at what exact price - unless it actually fills. but you can probably get 95%+ accuracy.
     
    #10     Nov 23, 2018