A framework for backtesting trading strategies