I have defined a function which can get the history price for the coin:
def get_price(pair):
df=binance.fetch_ohlcv(pair,limit=258,timeframe="1d")
df=pd.DataFrame(df).rename(columns={0:"date",1:"open",2:"high",3:"low",4:"close",5:"volume"})
df["date"]=pd.to_datetime(df["date"],unit="ms")+pd.Timedelta(hours=8)
df.set_index("date",inplace=True)
return df
Then i want to use zip function to create two lists which can correspond to each other,so i can easily apply the function to get history data for each of the coin in the name list:
name=["btc","eth"]
symbol=["BTC/USDT","ETH/USDT"]
for name,pair in zip(name,symbol):
name=get_price(pair)
eth
But when i type "eth",to get the dataframe of "ETH/USDT", it gave me the error of "NameError: name 'eth' is not defined". The reason for me to do this is if i have a list of more than 10 pairs of coins, i dont want to use get_price function for each of them one by one in order to get the history data for all of them. can anyone help me to fix this errors? Thanks