Oh no, not another python backtester...

Discussion in 'App Development' started by globalarbtrader, Dec 18, 2015.

  1. There are already many python packages where you can back test trading strategies. Some of them also include a framework for automatic execution and complete position management.

    I can't give an exhaustive list but I'll pick out:

    - Quantopian's zipline
    - BT
    - pythalesians
    - pyalgotrade
    There is a longer list here.

    Does the world really need another one? Well, probably not, but today I've released one anyway (this explains at least partly why it's been a month since my last post, since I've spent the last month writing it).

    You can find pysystemtrade on github, here. This is version 0.0.1. It provides a basic backtesting enviroment that implements the 'staunch systems trader' example in my book. And it's GPL 3 open source.

    However it's my intention that this will become a fully featured back tester that will include all the optimisation and calibration techniques that I've discussed here on the blog, and in my book. It will also, eventually, include a complete end to end system that can be used for fully automated futures trading with interactive brokers.

    More on my blog, in the usual place.

    GAT
     
  2. this is a stupid question, but do these use python or do I need to know python to use them?
     
  3. They use python, and you wouldn't get very far using them unless you knew python
     
  4. Which is the most mature with the largest user base ?
    Why is Python becoming a new standard in algo trading ?
     
  5. Assume this is directed at a certain user I'm ignoring, rather than me...

    GAT
     
  6. nemo4242

    nemo4242

    Looks interesting. I was able to clone it from GitHub and to recreate the graph and data for the demo system from your book. I think that equity curve was really missing in your book, when I read it.
    One question, though:

    Your price data for the instruments in the system start at different dates:

    EDOLLAR: 1983-09-26
    US10: 1982-05-04
    EUROSTX: 2013-03-19
    V2X: 2013-03-26
    MXP: 1995-04-26
    CORN: 1981-09-25

    How is that handled in your backtester? Are the instrument weights adjusted, so that they add up to one at each day?
    Most of the testing time, only EDOLLAR, US10 and CORN are available, after 1995 MXP.
    EUROSTX and V2X are basically not used at all, since their history starts so late.

    Sorry, I could not find it in your code, yet.

    I printed the stats() for the system:

    Code:
    [[('min', '-0.764'), 
     ('max', '0.1589'), 
     ('median', '0'), 
     ('mean', '0.000671'), 
     ('std', '0.02224'), 
     ('skew', '-5.727'), 
     ('ann_daily_mean', '0.1718'), 
     ('ann_daily_std', '0.3559'), 
     ('sharpe', '0.4827'), 
     ('sortino', '0.4677'), 
     ('avg_drawdown', '-0.339'), 
     ('time_in_drawdown', '0.9864'), 
     ('calmar', '0.1109'), 
     ('avg_return_to_drawdown', '0.5067'), 
     ('avg_loss', '-0.01581'), 
     ('avg_gain', '0.01534'), 
     ('gaintolossratio', '0.9702'), 
     ('profitfactor', '1.113'), 
     ('hitrate', '0.5343')], 
    ('You can also plot:', ['rolling_ann_std', 'drawdown', 'curve']), 
    ('You can also print:', ['weekly', 'monthly', 'annual'])]
    
    Why is the skew so negative? Shouldn't it be positive from the trend-following part?
    What are min/max/median/mean? Return in %?
     
  7. The instrument weights are adjusted to add up to 1.0

    However the instrument div. multiplier should also be adjusted - it should be lower in the past. Future releases will calculate the idm on an out of sample basis (and also optimise the instr. weights).

    I didn't choose these instruments because they had long history (or god forbid, better back test performance), but because they had smaller risk, so better for the account size in the book.

    Skew would probably be positive on a monthly basis - the positive skew will only appear when measured at a frequency analagous to the holding period. Anything with a holding period of more than a few days will inherit the daily skew of the underlying assets rather than the trading strategy.

    Again a future release will calculate skew on different time periods.

    min/max/median/mean refer to daily returns.

    GAT

     
  8. Butterfly

    Butterfly

    why do we keep seeing all those frameworks when any good Python programmers could make one of its own with more flexibility and more accountability.

    seems like a lot of bored developers are putting good effort into something that few needs really
     
  9. Perhaps. But having already 'made one of my own', and since plenty of people asked me to release it into the wild, it seemed like no extra work to do so

    GAT
     
    AvantGarde and d08 like this.
  10. #10     Jan 18, 2016