Help a newbie with automated trading API programming

Discussion in 'Automated Trading' started by ezbentley, Mar 17, 2009.

  1. Background:
    I self-taught C++ in high school and majored in computer engineering in undergrad, so I am not totally ignorant of programming. However, I have never written any code to implement an automated trading system with APIs.

    I am looking for any learning resource that can help me get started with writing an ATS, preferably in C++. If there is any simple "example code" out there, that would be ideal since I think it's the fastest and easiest way to learn.

    From browsing this forum, it seems like APIs are just an interface to connect to a platform(Laser, Sterling Pro, Anvil...). So do people just use C++ or VB to write their own program to make function calls to the API? Does that mean you can just use any general purpose IDE for your preferred language?

    There are some commercial software(NT, OQ, RE) that can do automation. If you write your own ATS in C++ or VB, are you essentially writing your own software package that does what those commercial ones do with more customization? If that's the case, it would seem like a huge project. Can anyone provide an estimate of the time required to implement an ATS from scratch for a reasonable programmer?

    I am new to this so some of my question may not make sense. Feel free to correct me and any help/advice is highly appreciated.
  2. Baywolf


    It is a huge project, which is why I suggest you have a known working strategy before you start a software project of that scope. Why don't you instead prototype a strategy and test it for viability in one of the off the shelf backtesting software packages?
  3. Hi,

    I am already using AmiBroker to backtest the strategies. I don't really need to program a backtesting software. What I really need is an "automation" software that can make automatic trades based on the strategies I designed in AmiBroker.

  4. Charlton


    There's no point in reinventing the wheel and you will need to find a broker that has an API. For example Amibroker has a facility to receive a data stream from Interactive Brokers. Also IB has an API to enable it to receive order data generated externally

    Similarly Tradestation has strategy generation and backtesting captability with the ability to generate orders directly to the Tradestation broker.

    Furthermore TS can interface with other external applications including ones you build yourself, if necessary, through its Software Development Kit, All-Data-Everywhere and Global Variables.

    So I would recommend you first search out existing broker APIs that could be integrated with Amibroker (if that remains your chosen strategy builder) and get it to generate a simple order.

  5. Baywolf


    OK... that's not what I was suggesting, but whatever. Lets say you do have a strategy that works.

    I'd start by diagramming the classes you will need to make your strategy work.

    Here are some classes I would start writing first:

    connection class (to talk to the API)
    data class (database, bar construction)
    strategy classes (handles logic, trades)
    validation classes (make sure strategy is OK to fire based on other factors like open orders, trading time, BBO spreads, buying power, etc.)
    portfolio class (handles portfolio)

    Or you can go with off-the-shelf (COTS) software, and just deal with the strategy classes.
  6. Hi Charlton,
    I am aware of the IB API with AB and TS, but they are just not my brokerage of choice. I need to automate my strategies with either Genesis, Sterling Pro, or Anvil...

    Hi Tight Face,
    Sorry I mis-read your first reply. Are you suggesting I tried those commercial packages like NinjaTrader and OpenQuant?

    In fact I have played with their demos, but they are just lacking some of the capabilities that my strategies need, especially multi-symbol processing. From my experience and the experience of other users on this forum, both software have trouble handling more than a couple hundred symbols simultaneously, whereas AmiBroker can backtest 10 years of data on 7000+ symbols under 10 minutes. My strategies will probably need only under 1000 symbols, but that is already a stretch for NT and OQ.
  7. Charlton


    Ok - it looks like Anvil would be a likely bet as they have an APi listed on their site.

  8. Hi ezbentley,

    I started to develop my Application about 10 years ago and it isn’t finished. I also spend a long time searching for the right broker offering an API. Finally I choose IB for several reasons. Since I have also developed everything in C++ and do development only in my spare time it took about 10 years until now. If I could choose again I would not do it again, but use any available package like NT or TradeStation. On the other hand I have now an Application which I can change to my needs if I like – and – I know how everything works together.
    If you have any more questions concerning the development I will try to help.

    Good Trades,
  9. Thanks for everyone for the inputs.

    Does there exist any step-by-step guide "for dummies" to program this?

    I mean for some of the most basic functions, such as receiving a quote from the API, sending an order, getting order confirmation, etc, I really don't see the point of re-inventing the wheel. These functions are so simple that the platform vendor should just provide a programming guide with code examples on how to do these things. It's quite a headache to start from scratch even for the simple functions.

    Any other suggestion?
  10. travis


    I am totally ignorant on programming, so maybe I shouldn't even participate in this thread, but since he said he's a newbie, I am just going to give some advice, even though it's probably good advice only for newbies who are not programmers like he is.

    Without knowing any programming languages and having a liberal arts background, I opened an account with IB, studied some vba, and modified their sample excel file and built (in a few years) all the 30 systems that I have now. They all run smoothly on just one excel file, at the cost of zero dollars (unlike tradestation, I think). And I can customize it all I want and very quickly, with all the advantages of excel (like live charts and so on).

    Everything begins from here:

    On the first link, what they write of my thing is as follows:

    Access Technology: Beginner
    Robustness and Performance: Limited; uses obsolete technologies; lower performance.
    Code Platform: Windows only
    Time to Production: Small learning curve; rapid development time

    So that's why I suppose you C++ people think it's crap, so feel free to ignore this post.
    #10     Mar 18, 2009