I have been thinking about the way Quantopian does backtesting/benchmarking to understand and see how it can be improved. I say this because, a lot of the algorithms at first glance of the backtesting graph and return comparison sounds spectacular, but on doesnt' stand closer scrutiny.
What do yall think?
So I started looking at what the problems were. I have done a fair bit of trading and algorithm development outside of Quantopian and I think I have a decent understanding of the problem.
Issues:
1. Leverage - Many algorithms have wild leverage. Though in theory it starts with a $10000 initial the algorithm seems to run wild buy/selling way more than the portfolio.
2. A small section of the backtest with good returns can mask mediocre or bad returns for the rest of the back testing period or vice versa
3. The effect of portfolio size over time, meaning though you start with only $10000 initial as the portfolio size grows/reduces in size of the later trades becomes bigger/smaller. I kinda tend to look at this as skewing in some way to the profit/loss expectation of the algorithm over time.
A good way to evaluate algorithms is to first evaluate all your trading signals separated from the impact of portfolio management.
That is evaluate all potential trade signals as a collection of bets with a probability of success/failure with an associated profit/loss potential. Look at all the buy/sell/hold signals as a collection of trades(along with stop-loss rules) independent of portfolio size with/without commissions. Ignoring the fact that consecutive buy/sell signals on consecutive days/bars for the same stock may not actually translate to trades in the real world running of the algorithm. But we look at all of them as whole.
And we evaluate each trade as a constant sized bet(with/without commissions) and understand the size of profit or loss for each trade
Then understand the statistical probability of profit or loss as well as the "Expected" size of profit or loss.
Compare that to the equivalent trades/numbers of the benchmark.
And also understand these numbers separately for up markets and down markets.
If we were to evaluate the reliability of the algorithms signals, and that would give us a good understanding of the trading signals that we will be working with. This would give a true understand of the strength of an algorithm.
The next phase would then be to apply portfolio management rules.
Now I don't expect Quantopian to implement all of this and every one evaluates algorithms differently and may be even in a proprietary way. But what I am suggesting with this thread, is a way that I as a developer can calculate and display these various custom statistics both in table and/or graphical forms as well as custom summary statistics. Like,
- Extensions to record() to show custom graphs
- May be additional API to record to a table format display
- As well an API to display custom summary statistics for the entire backtesting
my 2c,
Sarvi
PS: A good reference for everything I am talking about would be Trading Systems and Methods by Kaufman.