Back to Community
Calculate monthly RSI

Does anyone know how I can go about calculating the monthly RSI(14) value in quantopian?

1 response

Try this:

# RSI Monthly

import talib  
def initialize(context):  
    schedule_function(record_rsi, date_rules.month_start())  

def record_rsi(context, data):  
    asset = symbol('SPY')  
    period, threshold = 14, 50

    monthly_prices = data.history(asset, 'price', period*21 + 1, '1d').resample('1M').last()  
    rsi = talib.RSI(monthly_prices, period)[-1]  
    print  rsi  
    record(rsi = rsi, threshold = threshold)