Query kucoin for all past user trades returns nothing
See original GitHub issue- OS: Linux
- Programming Language version: Python v3.7.9
- CCXT version: 1.41.87
Hello. I have been trying to use ccxt to fetch all past Kucoin closed orders of some user’s api key. I read some relevant past closed issues, and noticed that you must query the endpoint in increments of 1 week as per this example in your docs.
I tried to do that with a slightly modified version as the original failed. The "endAt"
has to be no more than a week after "startAt"
so the max
had to be switched to a min
, or an error is returned. Also I start since the founding of Kucoin (09/2017 according to google).
# -*- coding: utf-8 -*-
import os
import sys
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')
import ccxt # noqa: E402
exchange = ccxt.kucoin({
"apiKey": "KEY",
"secret": "SECRET",
"password": "PASSWORD",
'enableRateLimit': True,
})
exchange.load_markets()
# exchange.verbose = True # enable verbose mode after loading the markets
symbol = None # all orders
now = exchange.milliseconds()
day = 24 * 3600 * 1000
week = 7 * day
since = 1504224000000 # founding of kucoin in ms
limit = 20
found_orders_num = 0
while since < now:
end = min(since + week, now)
params = {'endAt': end}
orders = exchange.fetch_closed_orders(symbol, since, limit, params)
print(exchange.iso8601(since), '-', exchange.iso8601(end), len(orders), 'orders')
found_orders_num += len(orders)
if len(orders) == limit:
since = orders[-1]['timestamp']
else:
since += week
print(f'Found {found_orders_num} orders')
This returns 0 closed orders. Even though essentially the since
parameters starts at the founding of Kucoin and the user does have closed trades in their account.
What am I doing wrong? Am I missing something? Shouldn’t the above return any trades the user has completed in their account since they started using the exchange?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (11 by maintainers)
@LefterisJP i’ve tested it on my side – works for me:
Hey @kroitor thank you. The key then was
'options': {'fetchMyTradesMethod':'private_get_hist_orders'}
and that this one underneath deals in seconds not milliseconds.Thank you for your time and quick responses.