I want to use 15 minutes data to calculate my own RSI strategy. I am using binance API with python. So I need the last 15 closes data of BTCUSDT. I am getting it like this.
start = str(dt.datetime.now(dt.timezone.utc) - dt.timedelta(minutes=15*15))
end = str(dt.datetime.now())
trades = client.get_historical_klines(symbol='BTCUSDT',
interval=Client.KLINE_INTERVAL_15MINUTE,
start_str=start,
end_str=end)
Gets last 15 data And calculates the rsi value like following.
closes = [float(row[4]) for row in trades]
c = numpy.array(closes)
rsi = talib.RSI(c, timeperiod=14)
print(rsi[-1])
The print the value of last RSI is different from binance online chart. For example my calculated is 34.41 and binance web application shows latest RSI is 39.68 on chart for 15 minutes.
If I calculate of the initial RSI value, I will put new close values in my array using web socket of. But it is wrong. How can I do this?