Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Looking at historical indicator crossover

I've been able to implement quite a few different solutions using Quantopian. I'm struggling to see what the best way would be to look at the history of an indicator crossing. For example RSI dips below a certain value twice in a month, or a Bollinger band is crossed a couple of times in a period. How do I do that kind of history? Any ideas to direct me? Thanks!!!

2 responses

Paul, I guess what you are looking for is an event study. An event study shows the average returns (and errors) of the stocks in the days following a particular event.

In your RSI example, the event study would show what happens on average to the price of the stocks that experienced a "RSI dips below a certain value twice in a month" in the days following that particular event. That information allows you to decide if the event is tradeable. if the event study shows that the price steadily increase (or decrease) for some days (before turning into a random walk again) you can decide to buy/sell the stocks on the date of the event, as you know that on average the following days the price of those stocks will increase/decrease.

The good news is that you already have the event study code in Quantopian. What the event study needs as input are the dates of the event you like to analyse. For that you can use 'get_pricing' function to get historical stock prices and then you have to search in those price for your event. You have to generate a list of date/stock pairs, one pair each time the event happened. Finally you pass this date/stock pairs list to the event study that does all the hard work and enjoy the results :) (the date/stock pairs list is actually a Dataframe, see the event study for details).

Thanks. I took a good look at that today. I don't think I had seed the term "event study". I assume that is a quant term.