Matlab with TWS interative brokers

Discussion in 'Automated Trading' started by kseminario, Jan 3, 2007.

  1. I am anti-Matlab... support OpenSource software!.
    Ok now that I got that out of the way :D.... doesn't Matlab interface easily with C source code? If I remember correctly it does. Here's the TWS C API, naturally it's open source. Enjoy.

    -kt
     
    #11     Jan 4, 2007
  2. txuk

    txuk

    Then you might like SciLab, an open source app that runs matlab code. http://www.scilab.org/
     
    #12     Jan 4, 2007
  3. I dont know how fast you want your trading algorithm to be? I trade off of 1 min bar calculations. The MATLAB timer fires every 1 second. I didnt miss a tick. The calculations are vectorised. The calculation loop didnt take more than 1/2 a second. I forgot the exact number of seconds that it took me. I will post it later.

    Ofcourse, it depends on the algorithm. But I bet if you are using advanced stuff such as Neural networks, Genetic Algorithms, Wavelets, then MATLAB is faster than Other software.

    Ofcourse, one can always convert the matlab code into C/C++.
     
    #13     Jan 4, 2007
  4. dchang0

    dchang0

    There was a product called "Trading with MATLAB" by Gloriosia.com. Not sure if they're still in business, but the primary purpose of their software was to allow MATLAB (.m scripts) to drive automatic trading systems on IB's TWS API.
     
    #14     Jan 4, 2007
  5. Kohanz

    Kohanz

    Possibly other 3rd party software, but not faster than an ATS written in C or C++ and <gasp> perhaps even Java.
     
    #15     Jan 4, 2007
  6. Exactly right, other choices (for those that aren't aware) might also be R statistical package, or Octave.

    Python also has a package popular amongst the scientific community, as there choice for a Matlab alternative, called Scipy.

    Personally, I prefer to roll my own C/C++.
     
    #16     Jan 4, 2007
  7. I have to agree with mbatrader. I have used matlab for years as an engineer. In one case, I used it to collect measurement data from an instrument hooked up to a disk drive setup. Matlab is fast enough to send orders using tick by tick data.

    RoughTrader
     
    #17     Jan 4, 2007
  8. Kohanz

    Kohanz

    Having used Matlab a lot for engineering purposes as well, my hesistance to use it for an ATS would be based not on speed concerns but due to it basically being a scripting/function-language that is not OO. For operations that are mostly serial in nature I can see it being "good enough", but I would feel much more comfortable with C++ for something more complex, especially when trying to devise an ATS with multiple strategies and trading multiple instruments. Perhaps I need to delve more into the abilities of the Matlab scripting language, but I would venture to say that building such a system in Matlab would be more complex to program than with C++. Of course I'm open to opposing viewpoints.
     
    #18     Jan 4, 2007
  9. Another concern I have just thought of is the memory management of matlab, which historically has not been that good. If not designed carefully, a matlab script run repeatedly as market data comes in might quickly consume the computer's memory unless vectors and arrays are constantly refreshed and held to a fixed size. Just something to mull over....

    RoughTrader
     
    #19     Jan 4, 2007
  10. Kohanz:

    I beg to differ that programming in MATLAB will be more complex than programming in c++. Since you have already used MATLAB, I dont need to tell you that how many lines of code it takes to do data manipulation in matlab vs c++. In MATLAB, you can create classes and Objects. you can make it OO if you want to.

    Ofcourse, If you are a BIG trader with lots of instruments and all, then yes, you will need to go the c++ route BECAUSE of MEMORY. Matlab is bad in memory management. Its good in algorithms. But for retail trader with engineering background who is trading with Limited Number of Instruments, MATLAB is enough.

    Basically, what I am trying to do is avoid another layer of complexity. I.e develop the trading idea in MATLAB and instead of again porting the matlab code to c++, trade directly from it.
     
    #20     Jan 4, 2007