Hi,
I am trying to get the code to calculate the mean of all 9 sector RSIs, and then short the etfs whose current RSI is below the average RSI. I cannot seem to get the formulation to work (line 48 area).
Thanks in advance for your help.
Alex
Hi,
I am trying to get the code to calculate the mean of all 9 sector RSIs, and then short the etfs whose current RSI is below the average RSI. I cannot seem to get the formulation to work (line 48 area).
Thanks in advance for your help.
Alex
Shouldn't you put these lines:
price_history = history(200, '1d', 'price')
rsi = price_history.apply(talib.RSI, timeperiod=14).iloc[-1]
rsi_rank = [rsi[sid(19662)]+rsi[sid(19656)]+rsi[sid(19658)]+rsi[sid(19655)]+rsi[sid(19661)]+rsi[sid(19657)]+rsi[sid(19659)]+rsi[sid(19654)]+rsi[sid(19660)]]/rsi[stock]
print rsi_rank
outside this for loop:
for stock in context.stocks:
so that it computes the lines only once?