What programs are usually used to back-test trading strategies?

Answer by Laurent Bernut:

Testing a strategy is a journey. For any journey, You need the right equipment. I test everything on WealthLab then program on other platforms. Here is why

The objective of back-testing is to simulate real trading. When You trade real money, You face the following problems:

  1. Position size: You do not trade 1 share per trade. You may have sophisticated position sizing algo. Platforms offering position sizing algos in back-testing phase are few and far between: WealthLab & amiBroker. QuantConnect and Quantopian may but I have not tried
  2. Cash constraint: You strategy may generate signals but if You do not have cash to execute either a Buy Long or a Buy to Cover, it is a moot point. WLD and amiBroker
  3. Portfolio rotation: this is similar to the above point. Test may look great/poor on one security but in real life, you trade a portfolio.
  4. Slippage & commission: always set slippage at max. My settings is -0.5% one-way, that is 1% slippage + commission for a round trip
  5. Volume: only academics and efficient market believers trade on thin markets and banking holidays
  6. Borrow and uptick: structural shorts are a dime a dozen. Profitable structural shorts are the unicorns of short-selling. If You find one, capture it safely and let’s study it

The journey:
The first part of the journey is to get the signal right. This is where most people stop. They identify a signal that they test across a population of stocks one after the other. This may seem fine in theory but in practice You will rapidly come across a concept called Buying Power. If You don’t have the cash, You can’t execute. If You can’t execute, then it’s all academic. This excludes primitve versions of Matlab, MT4 and older versions of TradeStation
Math formula for that level is: Signal Validity = Win%

Second stage is when You start testing at portfolio level
You have realised that signals must be executable to be worth anything.
At this stage, You will test signals. These are where most people stop. This is the province of most sell-side quants using R or Matlab. Tradestation does not go any further. Not sure about Ninja, never tested that one
It assumes all positions are equal weight. This is primitive
math is  Win rate = Win% – Loss %
Bloomberg BTST is a rudimentary version of that

Third stage is when You start working on the real trading edge formula
Trading Edge = Win% *Avg Win% -Loss%* Avg Loss%
This is when You start to realise that size does matter in the markets, particularly when strategy fails to deliver.
At this stage, there are only two platforms which deliver: WealthLab Developer and Amibroker. Both have a comprehensive position sizing library.
Matlab can deliver but You will need to buy an additional expensive module. Matlab is an expensive guillotine, hardly suitable for neurosurgery. I do not recommend it.
WealthLab and amibroker are both C#. They both have canned strategies You can learn from and a vibrant community.

Personally WealthLab changed my life. It permanently changed the way I perceive the markets.

A word about optimisation: the masala smoothie approach
When I started working on the strategy, I, as everyone else, ventured on the side of complexity. I resorted to optimistion to find the best indicator value.

Most people, most quants, love to optimise and re-reoptimise and re-re-optimise their optimisations.
Bad news: it gives the right mathematical answer to the wrong question. Optimisation is the monosodium glutamate MSG of strategies: it gives depth and substance to poor quality food.
Work on the logic, not on the value of some hypothetical Billion Dollar idea.
Do not throw everything in hoping it will stick. Optimisers will waterboard the data until it confesses everything

PS: 100% Free Kick -A@#resource:
Andrew Swanscott interviewed me on Better System Trader.
Interview with Laurent Bernut – Better System Trader
Off line, he suggested I should offer something to his audience. Here is a tool I use daily.

The Trading Edge Visualiser User’s Manual
The way to use it to load your backtest data and look at distribution. I use this tool many times a day during strategy development.

What programs are usually used to back-test trading strategies?

2 replies
  1. paolo marzotto says:

    Thank you, Lauren. Great article. BTW, Amibroker has nothing to do with C#…
    It utilizes a proprietary scripting language.

    Reply
    • lbernut says:

      Thank You very much Paolo,

      You are right. My knowledge of amibroker is limited.
      I am using WealthLab and we were comparing notes with a friend. He showed me the capability of the platform and briefly showed his code. My honest mistake.

      That said, I am considering purchaisng an Amibroker license soon.

      Thank You very much for your correction

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *