When I try to calculate the ichimoku on df of assets into the exchange like phemex in this case I have got a problem because they return me values of kijun and tenkan but Nan of senko "kumo" and chikou and I don´t know what can I do whith that I´m so noob coding at the moment :_P this is my code
import pandas as pd
import pandas_ta as pta
from pandas import DataFrame
from datetime import timedelta
import numpy as np
import ccxt
from FuncionesbotIchimoku import*
import nocompartir
import onecall
# como conectar al exchange
# coger API KEY y SECRET KEY "phemex"
phe = ccxt.phemex({
'enableRatelimit': True,
'apiKey': nocompartir.xP_key,
'secret': nocompartir.secret,
})
balance= onecall.phemex.get_balance
#extraer DF del activo
timeframe = '4h'
limit = 50
symbol ='uBTCUSD'
size= 1
ohlcv = pd.DataFrame(phe.fetch_ohlcv(symbol = symbol, timeframe = timeframe, limit = limit), columns= ['time', 'open', 'high', 'low', 'close', 'volume'])
high10 = ohlcv.high.rolling(10).max()
high30 = ohlcv.high.rolling(30).max()
high60 = ohlcv.high.rolling(60).max()
low10 = ohlcv.high.rolling(10).min()
low30 = ohlcv.high.rolling(30).min()
low60 = ohlcv.high.rolling(60).min()
#cálculo ichimoku
ohlcv['tenkan_sen']= (high10 + low10)/2
ohlcv['kijun_sen']= (high30 + low30)/2
ohlcv['senkou_A']= ((ohlcv.tenkan_sen + ohlcv.kijun_sen)/2).shift(26)
ohlcv['senkou_B']= ((high60 + low60)/2).shift(26)
ohlcv['chikou']= ohlcv.close.shift(-26)
ohlcv= ohlcv.iloc [26:]
print (ohlcv)
I tried some differents ways to calculate the ichimoku with this DF but the code above is the "closet" because I can see values of tenkan and kijun but no results for the kumo and chinkou I´m expecting obtain all de values into the df of the exchanges to make some trading strategy bots
Finally I reach a solution for phemex exchange to calculate ichimoku values if someone need help can try this code:
`
symbol ='uBTCUSD'
size= 1
bars= exchange.fetch_ohlcv(symbol='uBTCUSD', timeframe='4h', limit=1000 )
df =pd.DataFrame(bars, columns=['time', 'open', 'high', 'low', 'close', 'volume'])
#cálculo ichimoku
high10 = df.high.rolling(10).max()
high30 = df.high.rolling(30).max()
high60 = df.high.rolling(60).max()
low10 = df.low.rolling(10).min()
low30 = df.low.rolling(30).min()
low60 = df.low.rolling(60).min()
df['tenkan_sen']= (high10 + low10)/2
df['kijun_sen']= (high30 + low30)/2
df['senkou_A']= ((df.tenkan_sen + df.kijun_sen)/2).shift(26)
df['senkou_B']= ((high60 + low60)/2).shift(26)
df['chikou']= df.close.shift(-26)
df= df.iloc [26:]`