Skip to content

Backtesting Algorithmic Trading With Python

Backtesting algorithmic trading with Python#

Backtesting is the research process of applying a trading strategy idea to historical data to understand how it would have performed.

Backtests can always take more factors into account, so they are rarely finished in an absolute sense.

Types of Backtesting Systems#

  • Research based: used to find out if a strategy works. Speed of development is more important than speed of execution. Common tools include Matlab, R and Python* Event based: used in the trade-execution cycle, modelling a real-world scenario. Speed of execution is more important than speed of development. Common tools include C, C++ and Java

Initial Backtester#

Required parts:

  • Strategy: receives bars, or open, high, low and close data, on a time basis. It produces signals such as 1, 0 and -1 for long, hold and short Portfolio: receives the signals from the strategy, creates positions allocated against cash, keeps track of fees and trades, and builds an equity curve Performance: takes the portfolio object and returns useful statistics about performance, such as risk return, Sharpe ratio and drawdown

Source#