Best Python Framework for IB

Discussion in 'Automated Trading' started by hurricane_sh, Oct 16, 2019.

  1. 2rosy

    2rosy

    i think back test and automated trading are two completely different things. This is new back tester I saw on a mailing list
    https://pypi.org/project/pyqstrat/
     
    #11     Oct 16, 2019
    KGTrader and hurricane_sh like this.
  2. I use my backtesting software to generate signals for my automated trading. This way I can synchronize my actual trades with the backtest and I can get a very accurate picture of performance and trade execution.

    My backtest engine is custom C# code that generates a trade signal file. The trade signal file is provided to Alera which uses the IB API to do the actual trade execution. Fairly simple system but works very well.

    Good luck with the software development. The time I've spent developing mine has been very worthwhile and rewarding.
     
    #12     Oct 16, 2019
    Orbiter and hurricane_sh like this.
  3. Sorry but can you explain why backtesters are written (highly tend to) in python/r/matlab as opposed to statically-typed compiled languages like java/C#? Is it just proto-typing speed is faster in python/r, or there is more to it?
     
    Last edited: Oct 17, 2019
    #13     Oct 17, 2019
  4. d08

    d08

    For me there's two reasons.
    One thing is that I write everything in Python and I don't want to learn a new language at this point. Having to do it all myself (like some others on ET), my time is quite limited.

    Secondly, using Python modules prototyping is very fast. You will definitely not use native Python for data handling anyway, you have a wide range of tools from numpy to pandas (+modin) to numba to many others -- however you want to handle it, if I was forced to rely on standard Python methods then I wouldn't bother with it.
    Writing in Python but eventually compiling to C makes most sense to me.
    On top of that you'll have a whole set of ML tools which I'm clueless about but planning to learn.

    Note that I'm not a professional programmer and there are many others on the board who know a lot more about the subject. If I was dealing with millisecond differences in execution I wouldn't use Python but then again I definitely wouldn't use IB either.
     
    #14     Oct 17, 2019
    globalarbtrader likes this.
  5. Hi,

    The author of *backtrader* here.

    0. Some Linkes
    1. Open source is preferred.
    • See above for the repo
    2. A long development history. I don't want to learn a system that's abandoned soon.

    • Well, it was developed to have as many features as possible and be easy to use ... over a long time of period.
    3. Widely used with a big developer base.
    • (See above for the references) Without trying to be cocky, I believe it is by far the most used Python backtester and it could well be that it is the mostly used. It has been used in companies, banks, quant firms, energy trading, universities, for cryptocurrency bots, in university courses, thesis and PHDs, listed by many as a skill in the LinkedIn profile and also in hire-for-work-sites.

    4. A community such as a forum is a big plus.
    • See above for the community link
    5. Robust, flexible, etc.
    • You probably want to read through the docs (see above for the link)
    • 100% flexible. Everything can be plugged-in. It is a kit with many off-the-shelf blocks but you can plug your own.
    • Robust, well ... that depends on your definition. If your code is clean it will be robust. But one of the design decisions was to let Exceptions propagate to the end user: the reason ... if your code produces an exception during backtesting it may well do the same during live trading ... so you'd better catch the errors it before you put some money in the market.
    6. Back-test is more important than live trading for me at the stage.
    • It is also for me, by far. The goal was to have a tool which allows rapid prototyping of ideas in the form of indicators, strategies, performance analysis, visualization ... but the platform took over and grew up to be what it is.
    ******** Some additional notes *********

    7. For example `pyqstrat` was mentioned here. You can see in the PyPi package that *backtrader* is one source of inspiration ( have not checked if it is the source of some source code too :) )

    It's not the only package which draws on *backtrader.*

    8. It is pure Python. A single `pip install backtrader` suffices (visualization requires *matplotlib*, but these days most people use Conda or WinPython or something with lots of packages precompiled and installed)

    9. One of the most important things ... it has to suit you. You may not like the API, the object orientation, the need to plug in things or ... or ... Even if I think *backtrader* is the best by far (and have seen people often in reddit which say so) it doesn't have to be your cup of tea. One size cannot fit all needs and tastes.

    10. I may of course be completely wrong about *backtrader* being used widely and much more than other platforms ...

    Best regards
     
    #15     Oct 18, 2019
  6. Hi @backtrader, thank you so much for taking the time to explain things in details, I'm sure it will be helpful to other people here too. Now I'm more determined to go with Python.

    Cheers!
     
    #16     Oct 18, 2019
  7. ajensen

    ajensen

    #17     Oct 20, 2019
    hurricane_sh and blueraincap like this.
  8. joederp

    joederp

    Sierra is C++, not #, no EasyLanguage
     
    #18     Oct 21, 2019
  9. SteveH

    SteveH

    Off-topic from strict Python resources, but just in case anyone is reading this and looking for C# alternatives with a VERY FAST, inexpensive (as far as commercial products go) backtester that is rock solid, consider using this:

    http://www.dotnetforab.com/home

    in conjunction with Amibroker.

    [disclaimer: I do not use this product. But I have held an Amibroker license for over 15 years]

    Amibroker can utilize all the cores on your CPU for backtesting and it's got a COM interface so you could even glue it into a Python front-end if you want. It's going to be as fast as you can get in the trading marketplace, free or not.

    Let's put it this way. Anyone here coming up with their own backtester is not going to be anywhere near as good as this one. You're talking about a man, Tomasz Janezko, who has perfected / optimized his code base since 1995. He is incredible. His betas feel like full releases because his internal testing and programming skills are so good.
     
    #19     Oct 23, 2019
  10. d08

    d08

    On a somewhat unrelated note, I would advise the OP not to tie trading with IB's API. I'm at the mercy of IB since the alternative is months worth of coding and testing to move to an alternative. Use FIX or anything else that allows you to move to a competitor within days.
     
    #20     Oct 23, 2019