Backtesting futures using python

Discussion in 'Commodity Futures' started by Trade Prophet, Jun 7, 2021.

  1. Want to backtest commodity futures with python, which backtesting python framework do you recommend?
    Where can I get high-quality historical quotes?
    Thanks a bunch.
  2. There are *many* generic backtesters in python. I really ought to keep a list as this question gets asked so often. But there a list at the bottom of this page. In fact once you have backadjusted futures prices, you can use any backtester really, as long as you aren't bothered about being very precise about rolling - and you aren't worried about automated execution.

    Specifically for futures however I'm aware of

    - backtrader (also handles other asset classes)
    - zipline (also does equities)
    - pysystemtrade
    - quantconnect (commercial cloud product so may not suit)

    I use barchart to get my historical data but there is a limitation of 100 downloads a day - so for a quarterly roll you're looking at less than one instrument per day. There are plenty of other sources available however.


    Disclosure: I am the author of pysystemtrade
    Trade Prophet and traider like this.
  3. traider


    upvote pysystemtrade for momentum trading
    Gambit and Trade Prophet like this.
  4. 2rosy


    no back tester will help general trading/research incompetence. I would be surprised if any result from any back tester worked profitably in the real world
    Gambit likes this.
  5. Tell that to my bank manager

    Trade Prophet likes this.
  6. traider


    Rentech disagrees
    SimpleMeLike likes this.
  7. 2rosy


    Are saying rentech's staff are incompetent in regards to trading and research?

    What I was getting at is that these backtesters will not help if the end user has no idea what they are trying to accomplish. Case in point, zipline was part of quantopian which had an army of "researchers" "quants"... maybe millions of backtests and nothing profitable in the real world
    SimpleMeLike likes this.
  8. Yeah but you said

    "no back tester will help general trading/research incompetence."

    Which I absolutely agree with. But then you added:

    "I would be surprised if any result from any back tester worked profitably in the real world"

    Which is clearly invalid.

  9. This is indeed true.

    Anyone can click back test over and over and click Optimize over and over and walk forward over and over. That is easy