So I've managed to backtest simple strategies, like MA, RSI and some fundamental ones (P/E ratios etc) but Im stuck at my last strategy. Here is some information:

Tools: Excel and Python (also a little familiar with R)

My strategy is based on 3 momentum factors:

  1. Weekly %net change in mean analyst reccommendations 1-5, where 1 is the best.
  2. Weekly %net change in mean analyst NTM EPS estimates, and
  3. Weekly % net change in stock price.

Every factor is equally weighted.

My stock Universe is the Nordics (Norway, Sweden, Denmark and Finland) where I filter on 3 month average volume and nr of analysts so that I end up with ~100 stocks as my final stock universe.

I have 20 years of weekly historical factor data downloaded from my data vendor. The file format is xls(excel). I guess (although not sure with all stocks) I can retrive the OHLC and volume data from Yahoo Finance with Pandas.

So the crude process is sketched out like this:

  1. Lookback period = t-1W
  2. Fetch all stocks in universe by reading CSV (Read from Yahoo with Pandas.io.data?)
  3. Read the excel file with all the factors for all the stocks (Work with xlwing, xlrdr, Pandas?)
  4. Compute Z-Score for all the factors for all stocks
  5. Aggregate the total Z-Score (AZS) for all stocks
  6. Eliminate outliers and Winsorize s.t. -3 >= AZS =< 3
  7. BUY top decile and SHORT bottom decile

From here I can either

  1. Equal Weight or,
  2. Weight with Expected Excess Return/Std.dev (SR): Where I calculate Expected Excess Return = IC * rank * vol where IC=0,05 (constant for all stocks), rank=Z-score rank and vol is the past 3 months volatility in %(stored in another excel file). std.dev is the past 3 years realized volatility (I know, the best would be to forecast std.dev with GARCH or similar)
  3. At t+1W, repeat step 1-9 and reweight if necessary.

I am a little familiar with the open source backtesters out there: bt, backtester.com, pyalgotrade and zipline. But perhaps my strategy is a bit more complicated to work out with these backtesters? Or can one use fex zipline to backtest this strategy? I don't know.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.