I am new to quantopian, is it possible to analyse returns of stocks (average, standard deviation etc... ) generated from my pipeline in the research environment without creating an new algorithm? Thanks.
I am new to quantopian, is it possible to analyse returns of stocks (average, standard deviation etc... ) generated from my pipeline in the research environment without creating an new algorithm? Thanks.
Is it possible you are looking for this?
Thanks Luca. Thats what I was looking for.
Although in my case I want to analysis the return for a specific time period, from close to next day's open. It seem like alphalens can only analyse forward returns for 1,5 and 10 days.
In the case for returns from close to open, I will have to build an algo, run a backtest, and then import the backtest back into the research environment to do further analysis?
Thanks.
@Brian, Alphalens work with any time frequency and your use case is covered too. Have a look at the examples in https://github.com/quantopian/alphalens/tree/master/alphalens/examples and specifically the intraday_factor NB. Though I have to say that the Alphalens version installed on Quantopian is quite old so I am not 100% sure you won't bump into any issue.
Thank you Luca! Your example gives me more clarity indeed.
I would like to go through my understanding with you conceptually if you dont mind.
1) Creating a pipeline with a numerical factor that I want to test.
2) Running the pipeline for the desired period.
3) Using "al.utils.get_clean_factor_and_forward_returns()" to run forward analysis with factor results from pipeline and "pricing".
In your example,"pricing" = (Open(t), Close(t), Open(t+1), Close(t+1), ...,), as such period = 1 means return from Open(t) to Close(t).
period = 2 means return from Open(t) to Open(t+1).
My next question is, do you know how I could import Opening prices in quantopian? Such that I could create a "pricing" matrix similar to yours?
Apologies for the lack of understanding...
That's right! :) I am still concern about the old version of Alphalens installed on Q though, but I hope it works.
Luca, I am following your example but encountered a problem.
I used '+= pd.Timedelta('16h')' '+= pd.Timedelta('9h30m')' to amend the index for 'pricing'. Tried running alphalens but didnt work. I am guessing I need to amend the index of the pipeline output as well so that they can recognize each other?
I am not familiar with amending the index of a dataframe with multiindex levels, i.e. i this format '2013-01-02 16:00:00+00:00' instead of '2013-01-02 00:00:00+00:00', anyone can give me a hint?
I used '+= pd.Timedelta('16h')' '+= pd.Timedelta('9h30m')' to amend
the index for 'pricing'. Tried running alphalens but didnt work. I am
guessing I need to amend the index of the pipeline output as well so
that they can recognize each other?
Yes, exactly. The pricing data must contain at least an entry for each timestamp/asset combination in the factor, this entry should reflect the buy price for the assets. So make sure the timestamps present in the factor DataFrame returned by Pipiline have a corresponding entry in price DataFrame, which will be the entry prices for the assets. The pricing data is also needed for the assets sell price, the asset price after 'period' timestamps will be considered the sell price for that asset when computing 'period' forward returns.
If you share your NB (or a snippet of it) here I can help you fixing that.
I am not familiar with amending the index of a dataframe with
multiindex levels, i.e. i this format '2013-01-02 16:00:00+00:00'
instead of '2013-01-02 00:00:00+00:00', anyone can give me a hint?
You probably have to unstack your dataframe, change the index and then stack it. Look for DataFrame stacking/unstacking
thanks. thats great. I got it to work finally.
In my analysis I want to first have a screen (say spot > 10 day moving average), and after rank by some factor. However I am getting errors. I am guessing the error occurs as there are days where no stocks qualify from the screen?
I want to analysis factors where on some days the qualified stocks can be zero. Do you know if there are an examples in the community that I can look at? i.e. I dont need to take risks all the time, there is an element of marking timing involved.
Thanks again,
Brian