Hi everyone,
I have loaded external data into quantopian,
if we are going to make RSI custom indicator:
we will have to use
IF_rsi = rsi_data[context.stock]instead of
IF_rsi = rsi_data[data['IF']['close']]
why is it?
if we are going to make Standard Deviation, we have to use:
`std_data = std[context.stock]` instead of
std_data = std[data['IF']['close']]
Why is it?
Also:
I wonder what data (IF's
closeprices oropenprices ?) doescontext.stock
exactly contain or use for calculating custom indicators?Can I specifically ask
context.stockto contain or use IF's 'volume' data
or 'high' prices instead ofcloseprices?
def initialize(context):
fetch_csv('https://copy.com/OWPM6TLGOZ8IlLj2',
date_column = 'Date',
date_format = '%Y/%m/%d',
pre_func = preview,
post_func = add_fields,
symbol='IF')
context.stock = symbol('IF')
def preview(df):
log.info(df.head())
return df
def handle_data(context, data):
log.info(context.stock)
prices = history(15, '1d', 'price')
std = prices.std()
rsi_data = prices.apply(talib.RSI, timeperiod=14).iloc[-1]
IF_rsi = rsi_data[context.stock] #[data['IF']['close']]
std_data = std[context.stock] #std[data['IF']['close']]
# record(std = std_data, rsi = IF_rsi)
record(fastMA = data['IF']['fastMA'], Close = close[context.stock])