Hello everybody,
New to both Python and Quantopian. I'm curious if there's an easy way to create a new variable and refer to the value of this newly created variable at different points in time. Specifically, I'm interested in comparing the difference between the 10 day and 30 day moving averages of a stock, and take action based on if the difference is increasing or decreasing. I'd imagine the process would go something like this:
Determine both moving averages for a stock.
Create a new variable (we'll call it spread) which is one moving average minus the other.
Utilize the value of spread today, and the value of spread on the previous few (2?) days.
Take some action based on if spread(today) > spread(yesterday) > spread(the day before).
I've tried using the history function but with someone with a limited Python background the fact that the moving average value is not an applicable field to fetch is difficult. Any help would be greatly appreciated!
-Nick