Alphalens Analysis - Session Cumulative Returns

this post is part of my investment strategies class at university. (overnight)

14
14 responses

9

Great going, Omar - that's good alpha and fine results - wonder what your turnover is like..?

Alphalense with ML

10

Thanks Karl. Here is an updated notebook with turnover. if you look at the pyfolio analysis i am trying to analyze the 1 day forward returns which means (if i understand correctly) that we will be rebalancing everyday, so in this case a higher or lower turnover does not matter so much since we will incur commission fees daily. (different overnight momentum)

8

Hi Omar,

I enjoy following your progress and updates as well. What’s the course called you’re taking at which university?

Thanks, Omar.

Yes I follow your reasoning - perhaps peg a mental note that as you get to the algorithm stage, backtest tear sheets will help visualise how best to trade the strategy - including turnover costs if traded too frequently than necessary.

I can see the 1D/5D/10D is very consistent in your Returns Analysis:

1D  5D  10D
Ann. alpha   0.107   0.109   0.107
beta   0.011   0.018   0.044
Mean Period Wise Return Bottom Quantile (bps)   -3.110   -3.332   -3.267
Mean Period Wise Spread (bps)   7.204   7.511   7.495


Thanks Karl and Joakim

The course is called Introduction to Systematic Investment Strategies and offered at the University of Freiburg in Germany.
here is a link with more details :
https://www.finance.uni-freiburg.de/studium-und-lehre-en/ws1819/itsis_ws18_19_en

Thanks Omar, appreciated!

Wow Omar does the course at University of Freiburg teach machine learning methods too?

I can see that your post on January 17 Alphalens with ML working with a set of factors is quite scaleable.

one of the tasks is related to machine learning but the course is not intended to teach you machine learning because we are economics, finance and not computer science students. The learning process depends on how much effort and time you put on the task and of course you get help from the supervisors when you face problems. I personally started learning python during this course.

@Omar, nice work! Have you tried translating your Alphalens findings into the backtesting framework with Optimize API and its constraints with default commissions and slippage? I'd be very interested if your above ML example is really scalable in the backtest environment without running into compute timeout exceptions. If I'm not mistaken, the backtesting environment does not have the benefit of chunking. Somebody correct me if I'm wrong.

Hi James, thank you. I didn't backtest these results yet but this would be the next thing to learn/do. In this notebook i increased the number of quantiles which improved the results a little bit.

I am also interested in seeing how does the model perform on Intraday Returns. The notebook i am using is from the ML lecture where they use daily returns, I tried to edit that with this custom factor intraday returns function

class Intraday(CustomFactor):
inputs = [USEquityPricing.close, USEquityPricing.open]
window_length = 5
def compute(self, today, assets, out, close, open):
out[:] = np.cumprod(open[:] / close[:], axis=0)[-1] - 1


but i got the following error:

NonWindowSafeInput: Can't compute windowed expression ML([Intraday(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...), GroupedRowTransform(...)], 31) with windowed input Intraday([EquityPricing.close, EquityPricing.open], 5).

it would be really nice if someone has an idea how to solve this problem

6

@Omar,

class Intraday(CustomFactor):