Open hammerjoe opened 2 years ago
I think your problem is in the following line:
kucoin_client = kucoin_client(kucoin_api_key, kucoin_api_secret, kucoin_api_passphrase)
try one of them: 1. from kucoin.client import Client kucoin_client = Client(kucoin_api_key, kucoin_api_secret, kucoin_api_passphrase)
2.
client = kucoin_client(kucoin_api_key, kucoin_api_secret, kucoin_api_passphrase)
I was able to solve it. The call requires a start date and a end date. The docs make it seem its not mandatory.
def date_to_seconds(date_str): """Convert UTC date to seconds
If using offset strings add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
See dateparse docs for formats http://dateparser.readthedocs.io/en/latest/
:param date_str: date in readable format, i.e. "January 01, 2018", "11 hours ago UTC", "now UTC"
:type date_str: str
"""
# get epoch value in UTC
epoch = datetime.utcfromtimestamp(0).replace(tzinfo=pytz.utc)
# parse our date string
d = dateparser.parse(date_str)
# if the date is not timezone aware apply UTC timezone
if d.tzinfo is None or d.tzinfo.utcoffset(d) is None:
d = d.replace(tzinfo=pytz.utc)
# return the difference in time
return int((d - epoch).total_seconds())
and in the main code:
start_str = '260 hours ago UTC'
end_str = None
start_ts = date_to_seconds(start_str)
if end_str is None:
end_str = 'now UTC'
end_ts = date_to_seconds(end_str)
try:
kline2 = kucoin_client.get_kline_data(symbol, interval, start_ts, end_ts)
frame = pd.DataFrame(kline2)
I am trying to get a 1hour Kline for a token and I cant get it to work.
from kucoin.client import Client as kucoin_client kucoin_api_key = '6cccc1f' kucoin_api_secret = '96912bcccc47b' kucoin_api_passphrase = 'Voccccccc!'
kucoin_client = kucoin_client(kucoin_api_key, kucoin_api_secret, kucoin_api_passphrase) symbol = 'ETH-BTC' interval = '1hour' x = {'symbol': symbol} y = {'kline_type': interval} try: getkline = kucoin_client.get_kline_data(x, y) getkline = kucoin_client.get_kline_data(symbol, interval) except Exception as e: error_call = e
getkline gets the result: '<coroutine object Client.get_kline_data at 0x00000111C02ADE40>' which obviosuly not what I want. What am I doing wrong?