Hi,
I'm new to Quantopian, gotten pretty good with working with algos, but struggling a little bit in the notebook, I'm hoping to get some help! What I'd like to do is get the RSI data for a particular stock over the past X years, then iterate through the RSI data. Below is the code that shows what i'm doing it in the algos, and I believe this is correct (it prints values to log).
Algo code:
import talib
def initialize(context):
context.stock = symbol('LMT')
context.x = 0
schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open(minutes=5))
def my_rebalance(context,data):
prices = data.history(context.stock, "close", 30, "1d")
RSI2 = talib.RSI(prices, 2)
context.x+=1
print(context.x, RSI2[-1])
My issue is that in the notebook (code below), the numbers don't match up. I understand that there is a warm up period at the start of the rsi period, but in my case, the numbers aren't even close! I think there is something wrong with the way I am doing it in the notebook, what is the correct way for me to do this?
Notebook code:
import talib
sec = 'LMT'
sec_prices = get_pricing(sec, start_date='2011-01-03', end_date='2017-01-03', symbol_reference_date=None, frequency='daily', fields='close_price')
RSI2 = talib.RSI(sec_prices, 2)
for i in range(len(RSI2)-1):
print(i, RSI2[i])
Thank you.