The attached backtest illustrates an implementation of the RAA strategy from AlphaArchitects (described in this post). The strategy requires an implementation of both a Value and Momentum strategy. To ease the implementation I created a framework for incorporating multiple strategies ( I adapted some of the ideas from these posts, modular framework for trading algorithms, and abstracting an algorithm from one stock to many)
I thought it may be useful to the community so I’ve posted it here.
A couple of notes on the implementation,
- all strategies are required to implement a robust asset allocation function
- as a simplification the framework assumes all existing assets in a strategy are sold before new assets are ranked and then bought
- the implementation ensures that strategies that do fundamental queries are executed on distinct days so that a maximum number of securities relevant to the particular strategy are examined (i.e. the 500 securities in 'data' are selected by the specific strategy and there is no overlap with other strategies)
- Since stocks in the Q universe are generally restricted to those that trade on a US exchange, no distinct allocation is made to domestic and international equities, rather fundamental queries are allowed to invest in ADRs, and in securities not necessarily domiciled in the US
- a Gold etf (GSG) is used to approximate an allocation to commodities. This is done to allow for a longer backtest.
- the Value strategy implemented is the Magic formula
- the momentum strategy is Time Series Momentum with a 12 month lookback
- the strategy simply goes to cash when out of the market instead of investing in treasuries. An improvement to the framework would be to add a Portfolio Manager class to manage all trades from all strategies and put any cash in an appropriate alternative
Regards,
Mark