'how I can take all klines for symbols in kucoin with python
I want take all symbols for future in kucoin and then I want to get klines for all symbol I write some code but I cant get all symbol and also I cant get klines
get symbols:
import requests
import pandas as pd
url = " https://api-futures.kucoin.com/api/v1/contracts/active"
payload={}
files={}
headers = {}
margin = requests.request("GET", url, headers=headers, data=payload, files=files)
margin=margin.json()
margin=margin['data']
margin=pd.DataFrame(margin)
pd.set_option('display.max_row', margin.shape[0]+1)
it cant give some symbol in future for exmple btcusdt.
get klines:
import pandas as pd
import requests
url = "https://api-futures.kucoin.com/api/v1/kline/query?symbol=.KXBT&granularity=480&from=1535302400000"
payload={}
files={}
headers ={}
df = requests.request("GET", url, headers=headers, data=payload, files=files)
df=df.json()
df=df['data']
df=pd.DataFrame(df)
df[0] = pd.to_datetime(df[0], unit='ms')
df['date'] = df[0].dt.strftime("%d/%m/%Y")
df['time-utc'] = df[0].dt.strftime("%H:%M:%S")
df
I never see such symbol (KXBT) also when I want place another symbols like BTCUSDT and another symbols I cant take any data I read doc but I cant take any thing
Solution 1:[1]
from kucoin_futures.client import Market
client = Market(url='https://api-futures.kucoin.com')
all_future_tick = client.get_contracts_list()
for word in all_future_tick:
part_1 = word['baseCurrency']
mid = '-'
part_2 = word['quoteCurrency']
compined = part_1 + mid + part_2
print(compined)
this will give you the name of the coins
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mr Dream |
