Hi All,
I'm trying to learn how to create custom factors, so one of the things I thought I would do would be to code a DV2 custom factor. However that is proving more difficult than I thought. The problem is that I need to create a rolling window ranking of the values over a certain lookback period.
For example, assume I'm just trying to write a custom factor that tells me where the close price is for stock XXX today, as compared to a 500 day lookback window. I've coded stuff like this in python in the past, using the method rolling from pandas, but when working with custom factors the data is in numpy array format. Without converting to pandas dataframe, is there a way to get a ranking over a certain lookback period in terms of colums (times), not rows (different stocks).
I've tried looking at stack overflow for non Quantopian examples, and have tried using rank = close.argsort(axis=0).argsort(axis=0) + 1, but this doesn't seem to be working.
Apologies if I haven't explained this properly, I'm new to the community, but any feedback would be appreciated. If there's a way I can better explain this, or my post etiquette is flawed, please just advise the changes I should be making.
Cheers.