Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
30mins RSI using ta-lib

Hi all

I use the code below to try to get the RSI based on 30min, but I dont think it works, do I expect to see those nan value?

log is attached, please correct me.

Many thanks for all the helps.

Code:
prices_1m = data.history(context.secs, 'price', 14*30, '1m')
print('prices_1m')
print(prices_1m)
prices = prices_1m.resample('30T', closed='left').mean()
print('prices')
print(prices)
# Get the rsi of this stock.
rsi = talib.RSI(prices.dropna(), timeperiod=14)
print('rsi')
print(rsi)
rsi_current = rsi[-1] # Get most recent RSI of the stock
print('rsi_current')
print(rsi_current)

Log:
2017-01-03 14:31 PRINT prices_1m
2017-01-03 14:31 PRINT 2016-12-29 20:32:00+00:00 119.695
2016-12-29 20:33:00+00:00 119.680
2016-12-29 20:34:00+00:00 119.690
2016-12-29 20:35:00+00:00 119.660
2016-12-29 20:36:00+00:00 119.640
2016-12-29 20:37:00+00:00 119.630
2016-12-29 20:38:00+00:00 119.645
2016-12-29 20:39:00+00:00 119.645
2016-12-29 20:40:00+00:00 119.650
2016-12-29 20:41:00+00:00 119.650
2016-12-29 20:42:00+00:00 119.640
2016-12-29 20:43:00+00:00 119.635
2016-12-29 20:44:00+00:00 119.635
2016-12-29 20:45:00+00:00 119.645
2016-12-29 20:46:00+00:00 119.670
2016-12-29 20:47:00+00:00 119.645
2016-12-29 20:48:00+00:00 119.670
2016-12-29 20:49:00+00:00 119.660
2016-12-29 20:50:00+00:00 119.660
2016-12-29 20:51:00+00:00 119.705
2016-12-29 20:52:00+00:00 119.692
2016-12-29 20:53:00+00:00 119.710
2016-12-29 20:54:00+00:00 119.700
2016-12-29 20:55:00+00:00 119.685
2016-12-29 20:56:00+00:00 119.715
2016-12-29 20:57:00+00:00 119.720
2016-12-29 20:58:00+00:00 119.740
2016-12-29 20:59:00+00:00...
2017-01-03 14:31 PRINT prices
2017-01-03 14:31 PRINT 2016-12-29 20:30:00+00:00 119.671857
2016-12-29 21:00:00+00:00 119.700000
2016-12-29 21:30:00+00:00 NaN
2016-12-29 22:00:00+00:00 NaN
2016-12-29 22:30:00+00:00 NaN
2016-12-29 23:00:00+00:00 NaN
2016-12-29 23:30:00+00:00 NaN
2016-12-30 00:00:00+00:00 NaN
2016-12-30 00:30:00+00:00 NaN
2016-12-30 01:00:00+00:00 NaN
2016-12-30 01:30:00+00:00 NaN
2016-12-30 02:00:00+00:00 NaN
2016-12-30 02:30:00+00:00 NaN
2016-12-30 03:00:00+00:00 NaN
2016-12-30 03:30:00+00:00 NaN
2016-12-30 04:00:00+00:00 NaN
2016-12-30 04:30:00+00:00 NaN
2016-12-30 05:00:00+00:00 NaN
2016-12-30 05:30:00+00:00 NaN
2016-12-30 06:00:00+00:00 NaN
2016-12-30 06:30:00+00:00 NaN
2016-12-30 07:00:00+00:00 NaN
2016-12-30 07:30:00+00:00 NaN
2016-12-30 08:00:00+00:00 NaN
2016-12-30 08:30:00+00:00 NaN
2016-12-30 09:00:00+00:0...
2017-01-03 14:31 PRINT rsi
2017-01-03 14:31 PRINT [ nan nan nan nan nan
nan nan nan nan nan
nan nan nan nan 12.34064462
19.69058689 43.26549637]
2017-01-03 14:31 PRINT rsi_current
2017-01-03 14:31 PRINT 43.2654963691