alphalens icon indicating copy to clipboard operation
alphalens copied to clipboard

Completely remove prices argument from alphalens.tears.* functions

Open luca-s opened this issue 8 years ago • 0 comments

While the main Alphalens functions work with forward returns, there are still the event study related functions that work with prices (create_event_study_tear_sheet and create_event_returns_tear_sheet).

It would be nice to have a alphalens.utils.something function similar to get_clean_factor_and_forward_returns that helps building the event study functions input from the prices.

The formatted data returned by get_clean_factor_and_forward_returns looks like this: image

This format would fit the event study functions and the only change required would be to add a forward return column for each period specified in the event study range. E.g. if avgretplot=(5, 15) we need to add forward return columns: -5, -4, -3, -2, ... , 12, 13, 14, 15

screenshot from 2017-08-04 11-44-55

Unfortunately the memory usage for such data format would be too much. E.g. universe of 1500 securities, for 15 years (equivalent to Quantopian Q1500US universe along the full date range avaliable on the platform) using avgretplot=(5, 15)

1500 (securities) * 252 (trading days in a year) * 15 (number of years) * 20 (avgretplot=(5, 15) * 8 (float64) =~ 870 MB of Memory

When using prices we have the following instead: 1500 (securities) * 252 (trading days in a year) * 15 (number of years) * 8 (float64) =~ 45 MB of Memory

While I like the extended format, I believe it uses too much memory, so I suggest we use another data format for event study related functions.

luca-s avatar Jul 26 '17 08:07 luca-s