Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need some help with this strategy

Hi,

This statarb code is based on the example in zipline. I changed the zscore method to sscore which is in the paper Statistical Arbitrage in the U.S. Equities Market. I think I replicate the paper well, but it doesn't seem to make money...

Could anyone take a look at the code and see if I made some mistake anywhere? I am very new to zipline, and can really make some stupid mistakes that I am not aware of. Thanks very much!!!

Kel

6 responses

Hi Kel,
I looked at it and found differences with the paper:
- jpm and xlf sids have been entered
- ols_transform: alpha should be multiplied by 252
- place_orders: slightly modified to match the paper
- batch_transform: 61 days to get 60 returns

By the way, in the paper, there is no quantitative results about JPM/XLF just a plot of s-score! It will not be the first paper where you cannot reproduce the conclusions...

My opinion on why this strategy will not work using this algo:
Let's say an order is generated on Monday. The order will be executed on Tuesday's close price. The lag annihilates the strategy.

Hello Guy (and Yi Zhang),

Sounds correct if the algorithm is run on daily bars...orders submitted on day 0 will be filled on day 1 at the the day 1 closing price. If this "lag annihilates the strategy" what timing would be appropriate? Does it need to be run on minute bars, with orders submitted in minute 0 and filled in minute 1 at the minute 1 closing price, for example? Also, how should the algorithm handle periods when the market is closed? For example, should it submit an order at the end of day 0 to be filled at the open of day 1 (at the closing price of the the first minute of day 1)? Or should it be intra-day only?

Grant

@ Zhang, it seems interesting. Can you please share the link of the article here? I will code it again and will let you know the results.

I think the strategy should be ideally executed one minute after the daily s-score is computed.
I see many alternatives: get after-hours market data, specify a time at which the batch transform is computed, force the orders to be executed on the closing price on day 0 as you wrote or run it yourself in R or Python ...
Cheers, Guy