question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kucoin fetch_closed_orders() KeyError

See original GitHub issue

Code snippet:

k = login_kucoin(keys)
k.fetch_closed_orders("VEN/ETH")

Gives the error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-15-f798c239134b> in <module>()
----> 1 k.fetch_closed_orders("VEN/ETH")

/usr/local/lib/python3.6/site-packages/ccxt/kucoin.py in fetch_closed_orders(self, symbol, since, limit, params)
    341             request['limit'] = limit
    342         response = self.privateGetOrderDealt(self.extend(request, params))
--> 343         return self.parse_orders(response['data']['datas'], market, since, limit)
    344 
    345     def create_order(self, symbol, type, side, amount, price=None, params={}):

/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py in parse_orders(self, orders, market, since, limit)
    947     def parse_orders(self, orders, market=None, since=None, limit=None):
    948         array = self.to_array(orders)
--> 949         array = [self.parse_order(order, market) for order in array]
    950         return self.filter_by_since_limit(array, since, limit)
    951 

/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py in <listcomp>(.0)
    947     def parse_orders(self, orders, market=None, since=None, limit=None):
    948         array = self.to_array(orders)
--> 949         array = [self.parse_order(order, market) for order in array]
    950         return self.filter_by_since_limit(array, since, limit)
    951 

/usr/local/lib/python3.6/site-packages/ccxt/kucoin.py in parse_order(self, order, market)
    294             symbol = order['coinType'] + '/' + order['coinTypePair']
    295         timestamp = order['createdAt']
--> 296         price = order['price']
    297         filled = order['dealAmount']
    298         remaining = order['pendingAmount']

KeyError: 'price'
  • OS: OSX
  • Programming Language version: python 3.5
  • CCXT version: last one
  • Exchange: Kucoin
  • Method: fetch_closed_orders

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ohldcommented, Jan 13, 2018

[{'info': {'coinType': 'DRGN', 'createdAt': 1515673814000, 'amount': 74.3766, 'dealValue': 0.26106187, 'fee': 0.0743766, 'dealDirection': 'SELL', 'coinTypePair': 'ETH', 'oid': '5a5758d659797d08f61f11de', 'dealPrice': 0.00351, 'orderOid': '5a5752a559797d09b5adadc7', 'feeRate': 0.001, 'direction': 'BUY'}, 'id': '5a5758d659797d08f61f11de', 'timestamp': 1515673814000, 'datetime': '2018-01-11T12:30:14.000Z', 'symbol': 'DRGN/ETH', 'type': 'limit', 'side': 'buy', 'price': 0.00351, 'amount': 74.3766, 'cost': 0.0, 'filled': 0, 'remaining': None, 'status': None, 'fee': {'cost': 0.0743766, 'rate': 0.001, 'currency': 'DRGN'}}]

Now status field is None buy should be closed.

1reaction
ohldcommented, Jan 13, 2018
GET https://api.kucoin.com/v1/order/dealt?symbol=VEN-ETH 
Request: {'KC-API-KEY': '5a57b0532933c10ceec8488a', 'KC-API-NONCE': '1515877275524', 'KC-API-SIGNATURE': '65a15557993f75cddf53229c166f3f6d534f4bd09692f2ec0d942507af9d378c', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', 'Accept-Encoding': 'gzip, deflate'} None
GET https://api.kucoin.com/v1/order/dealt?symbol=VEN-ETH 
Response: {'Date': 'Sat, 13 Jan 2018 21:01:16 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': 'https://www.kucoin.com', 'Access-Control-Allow-Credentials': 'true', 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Accept-Language', 'Access-Control-Allow-Methods': 'POST, GET, PUT, OPTIONS, DELETE, PATCH', 'Access-Control-Max-Age': '86400'} {"success":true,"code":"OK","msg":"Operation succeeded.","timestamp":1515877276248,"data":{"total":1,"firstPage":true,"lastPage":false,"datas":[{"coinType":"VEN","createdAt":1515674421000,"amount":49.7948,"dealValue":0.26316552,"fee":0.0497948,"dealDirection":"BUY","coinTypePair":"ETH","oid":"5a575b352237f92bbe068c11","dealPrice":0.005285,"orderOid":"5a575b34c35a981fe308a04b","feeRate":0.001,"direction":"BUY"}],"currPageNo":1,"limit":12,"pageNos":1}}
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-8-5bd2f23316c8> in <module>()
      1 k.verbose = True
----> 2 k.fetch_closed_orders("VEN/ETH")

/usr/local/lib/python3.6/site-packages/ccxt/kucoin.py in fetch_closed_orders(self, symbol, since, limit, params)
    351             request['limit'] = limit
    352         response = self.privateGetOrderDealt(self.extend(request, params))
--> 353         return self.parse_orders(response['data']['datas'], market, since, limit)
    354 
    355     def create_order(self, symbol, type, side, amount, price=None, params={}):

/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py in parse_orders(self, orders, market, since, limit)
    947     def parse_orders(self, orders, market=None, since=None, limit=None):
    948         array = self.to_array(orders)
--> 949         array = [self.parse_order(order, market) for order in array]
    950         return self.filter_by_since_limit(array, since, limit)
    951 

/usr/local/lib/python3.6/site-packages/ccxt/base/exchange.py in <listcomp>(.0)
    947     def parse_orders(self, orders, market=None, since=None, limit=None):
    948         array = self.to_array(orders)
--> 949         array = [self.parse_order(order, market) for order in array]
    950         return self.filter_by_since_limit(array, since, limit)
    951 

/usr/local/lib/python3.6/site-packages/ccxt/kucoin.py in parse_order(self, order, market)
    297         if price is None:
    298             price = self.safe_value(order, 'dealPrice')
--> 299         filled = order['dealAmount']
    300         remaining = order['pendingAmount']
    301         amount = self.sum(filled, remaining)

KeyError: 'dealAmount'```
Read more comments on GitHub >

github_iconTop Results From Across the Web

KuCoin API error for historical data in python - Stack Overflow
I need to download 1min kline data from 2019 from Kucoin API. ... data = data.astype(float) data = data.sort_index() return data def ...
Read more >
ccxt-dev/ccxt - Gitter
I was wondering if there is no unified method for withdrawals and deposits because all exchanges api do not support that or these...
Read more >
python cryptocurrency | ccxt.ftx().fetch_my_trades() keyerror "symbol ...
I use the CCXT module to communicate with anycodings_keyerror multiple cryptocurrency exchanges. However anycodings_keyerror when trying to request my ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found