ccxt 4.2.83__py2.py3-none-any.whl → 4.2.85__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bybit.py +1 -1
  3. ccxt/ace.py +5 -5
  4. ccxt/ascendex.py +8 -8
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/ace.py +5 -5
  7. ccxt/async_support/ascendex.py +8 -8
  8. ccxt/async_support/base/exchange.py +3 -27
  9. ccxt/async_support/bigone.py +12 -12
  10. ccxt/async_support/binance.py +20 -32
  11. ccxt/async_support/bingx.py +12 -9
  12. ccxt/async_support/bit2c.py +1 -1
  13. ccxt/async_support/bitbank.py +8 -8
  14. ccxt/async_support/bitbns.py +5 -5
  15. ccxt/async_support/bitfinex.py +1 -1
  16. ccxt/async_support/bitfinex2.py +1 -1
  17. ccxt/async_support/bitget.py +39 -28
  18. ccxt/async_support/bithumb.py +5 -5
  19. ccxt/async_support/bitmart.py +16 -16
  20. ccxt/async_support/bitopro.py +1 -1
  21. ccxt/async_support/bitrue.py +4 -4
  22. ccxt/async_support/bitso.py +5 -5
  23. ccxt/async_support/bitstamp.py +1 -1
  24. ccxt/async_support/bitteam.py +8 -8
  25. ccxt/async_support/bl3p.py +1 -1
  26. ccxt/async_support/btcturk.py +6 -6
  27. ccxt/async_support/bybit.py +34 -87
  28. ccxt/async_support/coincheck.py +4 -4
  29. ccxt/async_support/coinex.py +12 -13
  30. ccxt/async_support/coinlist.py +7 -7
  31. ccxt/async_support/coinmate.py +4 -4
  32. ccxt/async_support/coinmetro.py +3 -3
  33. ccxt/async_support/coinone.py +5 -5
  34. ccxt/async_support/coinspot.py +2 -2
  35. ccxt/async_support/cryptocom.py +17 -17
  36. ccxt/async_support/currencycom.py +1 -1
  37. ccxt/async_support/delta.py +0 -8
  38. ccxt/async_support/deribit.py +16 -80
  39. ccxt/async_support/digifinex.py +8 -8
  40. ccxt/async_support/exmo.py +8 -8
  41. ccxt/async_support/gate.py +0 -8
  42. ccxt/async_support/hitbtc.py +5 -4
  43. ccxt/async_support/hollaex.py +7 -7
  44. ccxt/async_support/htx.py +12 -34
  45. ccxt/async_support/huobijp.py +3 -3
  46. ccxt/async_support/idex.py +2 -2
  47. ccxt/async_support/independentreserve.py +2 -2
  48. ccxt/async_support/indodax.py +2 -2
  49. ccxt/async_support/kraken.py +8 -8
  50. ccxt/async_support/krakenfutures.py +6 -6
  51. ccxt/async_support/kucoin.py +14 -2
  52. ccxt/async_support/kucoinfutures.py +8 -8
  53. ccxt/async_support/kuna.py +16 -16
  54. ccxt/async_support/latoken.py +2 -2
  55. ccxt/async_support/lbank.py +10 -10
  56. ccxt/async_support/luno.py +4 -4
  57. ccxt/async_support/mercado.py +5 -5
  58. ccxt/async_support/mexc.py +6 -6
  59. ccxt/async_support/ndax.py +1 -1
  60. ccxt/async_support/novadax.py +9 -9
  61. ccxt/async_support/oceanex.py +7 -7
  62. ccxt/async_support/okcoin.py +13 -13
  63. ccxt/async_support/okx.py +23 -31
  64. ccxt/async_support/onetrading.py +4 -4
  65. ccxt/async_support/p2b.py +7 -7
  66. ccxt/async_support/phemex.py +12 -12
  67. ccxt/async_support/poloniexfutures.py +5 -5
  68. ccxt/async_support/probit.py +11 -11
  69. ccxt/async_support/timex.py +7 -7
  70. ccxt/async_support/tokocrypto.py +9 -9
  71. ccxt/async_support/wavesexchange.py +3 -3
  72. ccxt/async_support/whitebit.py +5 -5
  73. ccxt/async_support/woo.py +1 -1
  74. ccxt/async_support/zaif.py +1 -1
  75. ccxt/async_support/zonda.py +7 -7
  76. ccxt/base/exchange.py +66 -23
  77. ccxt/bigone.py +12 -12
  78. ccxt/binance.py +20 -32
  79. ccxt/bingx.py +12 -9
  80. ccxt/bit2c.py +1 -1
  81. ccxt/bitbank.py +8 -8
  82. ccxt/bitbns.py +5 -5
  83. ccxt/bitfinex.py +1 -1
  84. ccxt/bitfinex2.py +1 -1
  85. ccxt/bitget.py +39 -28
  86. ccxt/bithumb.py +5 -5
  87. ccxt/bitmart.py +16 -16
  88. ccxt/bitopro.py +1 -1
  89. ccxt/bitrue.py +4 -4
  90. ccxt/bitso.py +5 -5
  91. ccxt/bitstamp.py +1 -1
  92. ccxt/bitteam.py +8 -8
  93. ccxt/bl3p.py +1 -1
  94. ccxt/btcturk.py +6 -6
  95. ccxt/bybit.py +34 -87
  96. ccxt/coincheck.py +4 -4
  97. ccxt/coinex.py +12 -13
  98. ccxt/coinlist.py +7 -7
  99. ccxt/coinmate.py +4 -4
  100. ccxt/coinmetro.py +3 -3
  101. ccxt/coinone.py +5 -5
  102. ccxt/coinspot.py +2 -2
  103. ccxt/cryptocom.py +17 -17
  104. ccxt/currencycom.py +1 -1
  105. ccxt/delta.py +0 -8
  106. ccxt/deribit.py +16 -80
  107. ccxt/digifinex.py +8 -8
  108. ccxt/exmo.py +8 -8
  109. ccxt/gate.py +0 -8
  110. ccxt/hitbtc.py +5 -4
  111. ccxt/hollaex.py +7 -7
  112. ccxt/htx.py +12 -34
  113. ccxt/huobijp.py +3 -3
  114. ccxt/idex.py +2 -2
  115. ccxt/independentreserve.py +2 -2
  116. ccxt/indodax.py +2 -2
  117. ccxt/kraken.py +8 -8
  118. ccxt/krakenfutures.py +6 -6
  119. ccxt/kucoin.py +14 -2
  120. ccxt/kucoinfutures.py +8 -8
  121. ccxt/kuna.py +16 -16
  122. ccxt/latoken.py +2 -2
  123. ccxt/lbank.py +10 -10
  124. ccxt/luno.py +4 -4
  125. ccxt/mercado.py +5 -5
  126. ccxt/mexc.py +6 -6
  127. ccxt/ndax.py +1 -1
  128. ccxt/novadax.py +9 -9
  129. ccxt/oceanex.py +7 -7
  130. ccxt/okcoin.py +13 -13
  131. ccxt/okx.py +23 -31
  132. ccxt/onetrading.py +4 -4
  133. ccxt/p2b.py +7 -7
  134. ccxt/phemex.py +12 -12
  135. ccxt/poloniexfutures.py +5 -5
  136. ccxt/pro/__init__.py +1 -1
  137. ccxt/pro/binance.py +150 -112
  138. ccxt/pro/kucoin.py +6 -7
  139. ccxt/pro/okx.py +12 -1
  140. ccxt/probit.py +11 -11
  141. ccxt/test/base/test_market.py +3 -0
  142. ccxt/timex.py +7 -7
  143. ccxt/tokocrypto.py +9 -9
  144. ccxt/wavesexchange.py +3 -3
  145. ccxt/whitebit.py +5 -5
  146. ccxt/woo.py +1 -1
  147. ccxt/zaif.py +1 -1
  148. ccxt/zonda.py +7 -7
  149. {ccxt-4.2.83.dist-info → ccxt-4.2.85.dist-info}/METADATA +4 -4
  150. {ccxt-4.2.83.dist-info → ccxt-4.2.85.dist-info}/RECORD +152 -152
  151. {ccxt-4.2.83.dist-info → ccxt-4.2.85.dist-info}/WHEEL +0 -0
  152. {ccxt-4.2.83.dist-info → ccxt-4.2.85.dist-info}/top_level.txt +0 -0
@@ -622,7 +622,7 @@ class hollaex(Exchange, ImplicitAPI):
622
622
  # ]
623
623
  # }
624
624
  #
625
- trades = self.safe_value(response, market['id'], [])
625
+ trades = self.safe_list(response, market['id'], [])
626
626
  return self.parse_trades(trades, market, since, limit)
627
627
 
628
628
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -1017,7 +1017,7 @@ class hollaex(Exchange, ImplicitAPI):
1017
1017
  # ]
1018
1018
  # }
1019
1019
  #
1020
- data = self.safe_value(response, 'data', [])
1020
+ data = self.safe_list(response, 'data', [])
1021
1021
  return self.parse_orders(data, market, since, limit)
1022
1022
 
1023
1023
  def parse_order_status(self, status):
@@ -1266,7 +1266,7 @@ class hollaex(Exchange, ImplicitAPI):
1266
1266
  # ]
1267
1267
  # }
1268
1268
  #
1269
- data = self.safe_value(response, 'data', [])
1269
+ data = self.safe_list(response, 'data', [])
1270
1270
  return self.parse_trades(data, market, since, limit)
1271
1271
 
1272
1272
  def parse_deposit_address(self, depositAddress, currency: Currency = None):
@@ -1411,7 +1411,7 @@ class hollaex(Exchange, ImplicitAPI):
1411
1411
  # ]
1412
1412
  # }
1413
1413
  #
1414
- data = self.safe_value(response, 'data', [])
1414
+ data = self.safe_list(response, 'data', [])
1415
1415
  return self.parse_transactions(data, currency, since, limit)
1416
1416
 
1417
1417
  async def fetch_withdrawal(self, id: str, code: Str = None, params={}):
@@ -1456,7 +1456,7 @@ class hollaex(Exchange, ImplicitAPI):
1456
1456
  # }
1457
1457
  #
1458
1458
  data = self.safe_value(response, 'data', [])
1459
- transaction = self.safe_value(data, 0, {})
1459
+ transaction = self.safe_dict(data, 0, {})
1460
1460
  return self.parse_transaction(transaction, currency)
1461
1461
 
1462
1462
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
@@ -1511,7 +1511,7 @@ class hollaex(Exchange, ImplicitAPI):
1511
1511
  # ]
1512
1512
  # }
1513
1513
  #
1514
- data = self.safe_value(response, 'data', [])
1514
+ data = self.safe_list(response, 'data', [])
1515
1515
  return self.parse_transactions(data, currency, since, limit)
1516
1516
 
1517
1517
  def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
@@ -1757,7 +1757,7 @@ class hollaex(Exchange, ImplicitAPI):
1757
1757
  # "network":"https://api.hollaex.network"
1758
1758
  # }
1759
1759
  #
1760
- coins = self.safe_value(response, 'coins')
1760
+ coins = self.safe_list(response, 'coins')
1761
1761
  return self.parse_deposit_withdraw_fees(coins, codes, 'symbol')
1762
1762
 
1763
1763
  def normalize_number_if_needed(self, number):
ccxt/async_support/htx.py CHANGED
@@ -2141,7 +2141,7 @@ class htx(Exchange, ImplicitAPI):
2141
2141
  # "ts":1639547261293
2142
2142
  # }
2143
2143
  #
2144
- # inverse swaps, linear swaps, inverse futures
2144
+ # linear swap, linear future, inverse swap, inverse future
2145
2145
  #
2146
2146
  # {
2147
2147
  # "status":"ok",
@@ -2158,37 +2158,15 @@ class htx(Exchange, ImplicitAPI):
2158
2158
  # "high":"0.10725",
2159
2159
  # "amount":"2340267.415144052378486261756692535687481566",
2160
2160
  # "count":882,
2161
- # "vol":"24706"
2161
+ # "vol":"24706",
2162
+ # "trade_turnover":"840726.5048", # only in linear futures
2163
+ # "business_type":"futures", # only in linear futures
2164
+ # "contract_code":"BTC-USDT-CW", # only in linear futures, instead of 'symbol'
2162
2165
  # }
2163
2166
  # ],
2164
2167
  # "ts":1637504679376
2165
2168
  # }
2166
2169
  #
2167
- # linear futures
2168
- #
2169
- # {
2170
- # "status":"ok",
2171
- # "ticks":[
2172
- # {
2173
- # "id":1640745627,
2174
- # "ts":1640745627957,
2175
- # "ask":[48079.1,20],
2176
- # "bid":[47713.8,125],
2177
- # "business_type":"futures",
2178
- # "contract_code":"BTC-USDT-CW",
2179
- # "open":"49011.8",
2180
- # "close":"47934",
2181
- # "low":"47292.3",
2182
- # "high":"49011.8",
2183
- # "amount":"17.398",
2184
- # "count":1515,
2185
- # "vol":"17398",
2186
- # "trade_turnover":"840726.5048"
2187
- # }
2188
- # ],
2189
- # "ts":1640745627988
2190
- # }
2191
- #
2192
2170
  tickers = self.safe_value_2(response, 'data', 'ticks', [])
2193
2171
  timestamp = self.safe_integer(response, 'ts')
2194
2172
  result = {}
@@ -2315,7 +2293,7 @@ class htx(Exchange, ImplicitAPI):
2315
2293
  else:
2316
2294
  raise NotSupported(self.id + ' fetchLastPrices() does not support ' + type + ' markets yet')
2317
2295
  tick = self.safe_value(response, 'tick', {})
2318
- data = self.safe_value(tick, 'data', [])
2296
+ data = self.safe_list(tick, 'data', [])
2319
2297
  return self.parse_last_prices(data, symbols)
2320
2298
 
2321
2299
  def parse_last_price(self, entry, market: Market = None):
@@ -3735,7 +3713,7 @@ class htx(Exchange, ImplicitAPI):
3735
3713
  # ]
3736
3714
  # }
3737
3715
  #
3738
- data = self.safe_value(response, 'data', [])
3716
+ data = self.safe_list(response, 'data', [])
3739
3717
  return self.parse_orders(data, market, since, limit)
3740
3718
 
3741
3719
  async def fetch_spot_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -6735,7 +6713,7 @@ class htx(Exchange, ImplicitAPI):
6735
6713
  else:
6736
6714
  request['symbol'] = market['id']
6737
6715
  response = await self.contractPrivatePostApiV3ContractFinancialRecordExact(self.extend(request, query))
6738
- data = self.safe_value(response, 'data', [])
6716
+ data = self.safe_list(response, 'data', [])
6739
6717
  return self.parse_incomes(data, market, since, limit)
6740
6718
 
6741
6719
  async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
@@ -7464,7 +7442,7 @@ class htx(Exchange, ImplicitAPI):
7464
7442
  # ]
7465
7443
  # }
7466
7444
  #
7467
- data = self.safe_value(response, 'data')
7445
+ data = self.safe_list(response, 'data')
7468
7446
  return self.parse_leverage_tiers(data, symbols, 'contract_code')
7469
7447
 
7470
7448
  async def fetch_market_leverage_tiers(self, symbol: str, params={}):
@@ -7653,7 +7631,7 @@ class htx(Exchange, ImplicitAPI):
7653
7631
  # }
7654
7632
  #
7655
7633
  data = self.safe_value(response, 'data')
7656
- tick = self.safe_value(data, 'tick')
7634
+ tick = self.safe_list(data, 'tick')
7657
7635
  return self.parse_open_interests(tick, market, since, limit)
7658
7636
 
7659
7637
  async def fetch_open_interest(self, symbol: str, params={}):
@@ -8132,7 +8110,7 @@ class htx(Exchange, ImplicitAPI):
8132
8110
  # ]
8133
8111
  # }
8134
8112
  #
8135
- data = self.safe_value(response, 'data')
8113
+ data = self.safe_list(response, 'data')
8136
8114
  return self.parse_deposit_withdraw_fees(data, codes, 'currency')
8137
8115
 
8138
8116
  def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
@@ -8345,7 +8323,7 @@ class htx(Exchange, ImplicitAPI):
8345
8323
  # "ts": 1604312615051
8346
8324
  # }
8347
8325
  #
8348
- data = self.safe_value(response, 'data', [])
8326
+ data = self.safe_list(response, 'data', [])
8349
8327
  return self.parse_liquidations(data, market, since, limit)
8350
8328
 
8351
8329
  def parse_liquidation(self, liquidation, market: Market = None):
@@ -941,7 +941,7 @@ class huobijp(Exchange, ImplicitAPI):
941
941
  # ]
942
942
  # }
943
943
  #
944
- data = self.safe_value(response, 'data', [])
944
+ data = self.safe_list(response, 'data', [])
945
945
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
946
946
 
947
947
  async def fetch_accounts(self, params={}) -> List[Account]:
@@ -1125,7 +1125,7 @@ class huobijp(Exchange, ImplicitAPI):
1125
1125
  'id': id,
1126
1126
  }
1127
1127
  response = await self.privateGetOrderOrdersId(self.extend(request, params))
1128
- order = self.safe_value(response, 'data')
1128
+ order = self.safe_dict(response, 'data')
1129
1129
  return self.parse_order(order)
1130
1130
 
1131
1131
  async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -1210,7 +1210,7 @@ class huobijp(Exchange, ImplicitAPI):
1210
1210
  # ]
1211
1211
  # }
1212
1212
  #
1213
- data = self.safe_value(response, 'data', [])
1213
+ data = self.safe_list(response, 'data', [])
1214
1214
  return self.parse_orders(data, market, since, limit)
1215
1215
 
1216
1216
  def parse_order_status(self, status):
@@ -363,7 +363,7 @@ class idex(Exchange, ImplicitAPI):
363
363
  # }
364
364
  # ]
365
365
  response = await self.publicGetTickers(self.extend(request, params))
366
- ticker = self.safe_value(response, 0)
366
+ ticker = self.safe_dict(response, 0)
367
367
  return self.parse_ticker(ticker, market)
368
368
 
369
369
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -1407,7 +1407,7 @@ class idex(Exchange, ImplicitAPI):
1407
1407
  }
1408
1408
  # [{orderId: "688336f0-ec50-11ea-9842-b332f8a34d0e"}]
1409
1409
  response = await self.privateDeleteOrders(self.extend(request, params))
1410
- canceledOrder = self.safe_value(response, 0)
1410
+ canceledOrder = self.safe_dict(response, 0)
1411
1411
  return self.parse_order(canceledOrder, market)
1412
1412
 
1413
1413
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
@@ -480,7 +480,7 @@ class independentreserve(Exchange, ImplicitAPI):
480
480
  request['pageIndex'] = 1
481
481
  request['pageSize'] = limit
482
482
  response = await self.privatePostGetOpenOrders(self.extend(request, params))
483
- data = self.safe_value(response, 'Data', [])
483
+ data = self.safe_list(response, 'Data', [])
484
484
  return self.parse_orders(data, market, since, limit)
485
485
 
486
486
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -504,7 +504,7 @@ class independentreserve(Exchange, ImplicitAPI):
504
504
  request['pageIndex'] = 1
505
505
  request['pageSize'] = limit
506
506
  response = await self.privatePostGetClosedOrders(self.extend(request, params))
507
- data = self.safe_value(response, 'Data', [])
507
+ data = self.safe_list(response, 'Data', [])
508
508
  return self.parse_orders(data, market, since, limit)
509
509
 
510
510
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = 50, params={}):
@@ -473,7 +473,7 @@ class indodax(Exchange, ImplicitAPI):
473
473
  # }
474
474
  # }
475
475
  #
476
- ticker = self.safe_value(response, 'ticker', {})
476
+ ticker = self.safe_dict(response, 'ticker', {})
477
477
  return self.parse_ticker(ticker, market)
478
478
 
479
479
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -502,7 +502,7 @@ class indodax(Exchange, ImplicitAPI):
502
502
  # }
503
503
  #
504
504
  response = await self.publicGetApiTickerAll(params)
505
- tickers = self.safe_value(response, 'tickers')
505
+ tickers = self.safe_list(response, 'tickers')
506
506
  return self.parse_tickers(tickers, symbols)
507
507
 
508
508
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -979,7 +979,7 @@ class kraken(Exchange, ImplicitAPI):
979
979
  # }
980
980
  # }
981
981
  result = self.safe_value(response, 'result', {})
982
- ohlcvs = self.safe_value(result, market['id'], [])
982
+ ohlcvs = self.safe_list(result, market['id'], [])
983
983
  return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
984
984
 
985
985
  def parse_ledger_entry_type(self, type):
@@ -1341,7 +1341,7 @@ class kraken(Exchange, ImplicitAPI):
1341
1341
  # }
1342
1342
  # }
1343
1343
  #
1344
- result = self.safe_value(response, 'result')
1344
+ result = self.safe_dict(response, 'result')
1345
1345
  return self.parse_order(result)
1346
1346
 
1347
1347
  def find_market_by_altname_or_id(self, id):
@@ -1724,7 +1724,7 @@ class kraken(Exchange, ImplicitAPI):
1724
1724
  # }
1725
1725
  # }
1726
1726
  #
1727
- data = self.safe_value(response, 'result', {})
1727
+ data = self.safe_dict(response, 'result', {})
1728
1728
  return self.parse_order(data, market)
1729
1729
 
1730
1730
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
@@ -2022,8 +2022,8 @@ class kraken(Exchange, ImplicitAPI):
2022
2022
  market = None
2023
2023
  if symbol is not None:
2024
2024
  market = self.market(symbol)
2025
- result = self.safe_value(response, 'result', {})
2026
- orders = self.safe_value(result, 'open', [])
2025
+ result = self.safe_dict(response, 'result', {})
2026
+ orders = self.safe_dict(result, 'open', {})
2027
2027
  return self.parse_orders(orders, market, since, limit)
2028
2028
 
2029
2029
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -2090,8 +2090,8 @@ class kraken(Exchange, ImplicitAPI):
2090
2090
  market = None
2091
2091
  if symbol is not None:
2092
2092
  market = self.market(symbol)
2093
- result = self.safe_value(response, 'result', {})
2094
- orders = self.safe_value(result, 'closed', [])
2093
+ result = self.safe_dict(response, 'result', {})
2094
+ orders = self.safe_dict(result, 'closed', {})
2095
2095
  return self.parse_orders(orders, market, since, limit)
2096
2096
 
2097
2097
  def parse_transaction_status(self, status):
@@ -2518,7 +2518,7 @@ class kraken(Exchange, ImplicitAPI):
2518
2518
  # }
2519
2519
  # }
2520
2520
  #
2521
- result = self.safe_value(response, 'result', {})
2521
+ result = self.safe_dict(response, 'result', {})
2522
2522
  return self.parse_transaction(result, currency)
2523
2523
  raise ExchangeError(self.id + " withdraw() requires a 'key' parameter(withdrawal key name, up on your account)")
2524
2524
 
@@ -535,7 +535,7 @@ class krakenfutures(Exchange, ImplicitAPI):
535
535
  # "serverTime": "2022-02-18T14:16:29.440Z"
536
536
  # }
537
537
  #
538
- tickers = self.safe_value(response, 'tickers')
538
+ tickers = self.safe_list(response, 'tickers')
539
539
  return self.parse_tickers(tickers, symbols)
540
540
 
541
541
  def parse_ticker(self, ticker, market: Market = None) -> Ticker:
@@ -662,7 +662,7 @@ class krakenfutures(Exchange, ImplicitAPI):
662
662
  # "more_candles": True
663
663
  # }
664
664
  #
665
- candles = self.safe_value(response, 'candles')
665
+ candles = self.safe_list(response, 'candles')
666
666
  return self.parse_ohlcvs(candles, market, timeframe, since, limit)
667
667
 
668
668
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -1087,7 +1087,7 @@ class krakenfutures(Exchange, ImplicitAPI):
1087
1087
  # ]
1088
1088
  # }
1089
1089
  #
1090
- data = self.safe_value(response, 'batchStatus', [])
1090
+ data = self.safe_list(response, 'batchStatus', [])
1091
1091
  return self.parse_orders(data)
1092
1092
 
1093
1093
  async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
@@ -1191,7 +1191,7 @@ class krakenfutures(Exchange, ImplicitAPI):
1191
1191
  # }
1192
1192
  # ]
1193
1193
  # }
1194
- batchStatus = self.safe_value(response, 'batchStatus', [])
1194
+ batchStatus = self.safe_list(response, 'batchStatus', [])
1195
1195
  return self.parse_orders(batchStatus)
1196
1196
 
1197
1197
  async def cancel_all_orders(self, symbol: Str = None, params={}):
@@ -1223,7 +1223,7 @@ class krakenfutures(Exchange, ImplicitAPI):
1223
1223
  if symbol is not None:
1224
1224
  market = self.market(symbol)
1225
1225
  response = await self.privateGetOpenorders(params)
1226
- orders = self.safe_value(response, 'openOrders', [])
1226
+ orders = self.safe_list(response, 'openOrders', [])
1227
1227
  return self.parse_orders(orders, market, since, limit)
1228
1228
 
1229
1229
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -2217,7 +2217,7 @@ class krakenfutures(Exchange, ImplicitAPI):
2217
2217
  # "serverTime": "2018-07-19T11:32:39.433Z"
2218
2218
  # }
2219
2219
  #
2220
- data = self.safe_value(response, 'instruments')
2220
+ data = self.safe_list(response, 'instruments')
2221
2221
  return self.parse_leverage_tiers(data, symbols, 'symbol')
2222
2222
 
2223
2223
  def parse_market_leverage_tiers(self, info, market: Market = None):
@@ -26,6 +26,7 @@ from ccxt.base.errors import RateLimitExceeded
26
26
  from ccxt.base.errors import ExchangeNotAvailable
27
27
  from ccxt.base.errors import InvalidNonce
28
28
  from ccxt.base.errors import AuthenticationError
29
+ from ccxt.base.decimal_to_precision import TRUNCATE
29
30
  from ccxt.base.decimal_to_precision import TICK_SIZE
30
31
  from ccxt.base.precise import Precise
31
32
 
@@ -442,6 +443,7 @@ class kucoin(Exchange, ImplicitAPI):
442
443
  'Order size below the minimum requirement.': InvalidOrder, # {"code":"400100","msg":"Order size below the minimum requirement."}
443
444
  'The withdrawal amount is below the minimum requirement.': ExchangeError, # {"code":"400100","msg":"The withdrawal amount is below the minimum requirement."}
444
445
  'Unsuccessful! Exceeded the max. funds out-transfer limit': InsufficientFunds, # {"code":"200000","msg":"Unsuccessful! Exceeded the max. funds out-transfer limit"}
446
+ 'The amount increment is invalid.': BadRequest,
445
447
  '400': BadRequest,
446
448
  '401': AuthenticationError,
447
449
  '403': NotSupported,
@@ -2092,6 +2094,13 @@ class kucoin(Exchange, ImplicitAPI):
2092
2094
  data = self.safe_list(data, 'data', [])
2093
2095
  return self.parse_orders(data)
2094
2096
 
2097
+ def market_order_amount_to_precision(self, symbol: str, amount):
2098
+ market = self.market(symbol)
2099
+ result = self.decimal_to_precision(amount, TRUNCATE, market['info']['quoteIncrement'], self.precisionMode, self.paddingMode)
2100
+ if result == '0':
2101
+ raise InvalidOrder(self.id + ' amount of ' + market['symbol'] + ' must be greater than minimum amount precision of ' + self.number_to_string(market['precision']['amount']))
2102
+ return result
2103
+
2095
2104
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2096
2105
  market = self.market(symbol)
2097
2106
  # required param, cannot be used twice
@@ -2112,7 +2121,7 @@ class kucoin(Exchange, ImplicitAPI):
2112
2121
  if quoteAmount is not None:
2113
2122
  params = self.omit(params, ['cost', 'funds'])
2114
2123
  # kucoin uses base precision even for quote values
2115
- costString = self.amount_to_precision(symbol, quoteAmount)
2124
+ costString = self.market_order_amount_to_precision(symbol, quoteAmount)
2116
2125
  request['funds'] = costString
2117
2126
  else:
2118
2127
  amountString = self.amount_to_precision(symbol, amount)
@@ -2375,8 +2384,11 @@ class kucoin(Exchange, ImplicitAPI):
2375
2384
  # ]
2376
2385
  # }
2377
2386
  # }
2387
+ listData = self.safe_list(response, 'data')
2388
+ if listData is not None:
2389
+ return self.parse_orders(listData, market, since, limit)
2378
2390
  responseData = self.safe_dict(response, 'data', {})
2379
- orders = self.safe_value(responseData, 'items', responseData)
2391
+ orders = self.safe_list(responseData, 'items', [])
2380
2392
  return self.parse_orders(orders, market, since, limit)
2381
2393
 
2382
2394
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -591,7 +591,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
591
591
  # ]
592
592
  # }
593
593
  #
594
- data = self.safe_value(response, 'data', [])
594
+ data = self.safe_list(response, 'data', [])
595
595
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
596
596
 
597
597
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -1042,7 +1042,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1042
1042
  # }
1043
1043
  # }
1044
1044
  #
1045
- data = self.safe_value(response, 'data', {})
1045
+ data = self.safe_dict(response, 'data', {})
1046
1046
  return self.parse_position(data, market)
1047
1047
 
1048
1048
  async def fetch_positions(self, symbols: Strings = None, params={}):
@@ -1101,7 +1101,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1101
1101
  # ]
1102
1102
  # }
1103
1103
  #
1104
- data = self.safe_value(response, 'data')
1104
+ data = self.safe_list(response, 'data')
1105
1105
  return self.parse_positions(data, symbols)
1106
1106
 
1107
1107
  def parse_position(self, position, market: Market = None):
@@ -1243,7 +1243,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1243
1243
  # },
1244
1244
  # }
1245
1245
  #
1246
- data = self.safe_value(response, 'data', {})
1246
+ data = self.safe_dict(response, 'data', {})
1247
1247
  return self.parse_order(data, market)
1248
1248
 
1249
1249
  async def create_orders(self, orders: List[OrderRequest], params={}):
@@ -1289,7 +1289,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1289
1289
  # ]
1290
1290
  # }
1291
1291
  #
1292
- data = self.safe_value(response, 'data', [])
1292
+ data = self.safe_list(response, 'data', [])
1293
1293
  return self.parse_orders(data)
1294
1294
 
1295
1295
  def create_contract_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
@@ -1658,7 +1658,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1658
1658
  # }
1659
1659
  #
1660
1660
  responseData = self.safe_value(response, 'data', {})
1661
- orders = self.safe_value(responseData, 'items', [])
1661
+ orders = self.safe_list(responseData, 'items', [])
1662
1662
  return self.parse_orders(orders, market, since, limit)
1663
1663
 
1664
1664
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -1747,7 +1747,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1747
1747
  # }
1748
1748
  #
1749
1749
  market = self.market(symbol) if (symbol is not None) else None
1750
- responseData = self.safe_value(response, 'data')
1750
+ responseData = self.safe_dict(response, 'data')
1751
1751
  return self.parse_order(responseData, market)
1752
1752
 
1753
1753
  def parse_order(self, order, market: Market = None) -> Order:
@@ -2146,7 +2146,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
2146
2146
  # ]
2147
2147
  # }
2148
2148
  #
2149
- trades = self.safe_value(response, 'data', [])
2149
+ trades = self.safe_list(response, 'data', [])
2150
2150
  return self.parse_trades(trades, market, since, limit)
2151
2151
 
2152
2152
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -650,7 +650,7 @@ class kuna(Exchange, ImplicitAPI):
650
650
  # }
651
651
  # }
652
652
  #
653
- data = self.safe_value(response, 'data', {})
653
+ data = self.safe_dict(response, 'data', {})
654
654
  return self.parse_order_book(data, market['symbol'], None, 'bids', 'asks', 0, 1)
655
655
 
656
656
  def parse_ticker(self, ticker, market: Market = None) -> Ticker:
@@ -728,7 +728,7 @@ class kuna(Exchange, ImplicitAPI):
728
728
  # ]
729
729
  # }
730
730
  #
731
- data = self.safe_value(response, 'data', [])
731
+ data = self.safe_list(response, 'data', [])
732
732
  return self.parse_tickers(data, symbols, params)
733
733
 
734
734
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
@@ -766,7 +766,7 @@ class kuna(Exchange, ImplicitAPI):
766
766
  # }
767
767
  #
768
768
  data = self.safe_value(response, 'data', [])
769
- ticker = self.safe_value(data, 0)
769
+ ticker = self.safe_dict(data, 0)
770
770
  return self.parse_ticker(ticker, market)
771
771
 
772
772
  async def fetch_l3_order_book(self, symbol: str, limit: Int = None, params={}):
@@ -968,7 +968,7 @@ class kuna(Exchange, ImplicitAPI):
968
968
  # }
969
969
  # }
970
970
  #
971
- data = self.safe_value(response, 'data', {})
971
+ data = self.safe_dict(response, 'data', {})
972
972
  return self.parse_order(data, market)
973
973
 
974
974
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -1023,7 +1023,7 @@ class kuna(Exchange, ImplicitAPI):
1023
1023
  # ]
1024
1024
  # }
1025
1025
  #
1026
- data = self.safe_value(response, 'data', [])
1026
+ data = self.safe_list(response, 'data', [])
1027
1027
  return self.parse_orders(data)
1028
1028
 
1029
1029
  def parse_order_status(self, status):
@@ -1165,7 +1165,7 @@ class kuna(Exchange, ImplicitAPI):
1165
1165
  # }
1166
1166
  # }
1167
1167
  #
1168
- data = self.safe_value(response, 'data', {})
1168
+ data = self.safe_dict(response, 'data', {})
1169
1169
  return self.parse_order(data)
1170
1170
 
1171
1171
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -1219,7 +1219,7 @@ class kuna(Exchange, ImplicitAPI):
1219
1219
  # ]
1220
1220
  # }
1221
1221
  #
1222
- data = self.safe_value(response, 'data', [])
1222
+ data = self.safe_list(response, 'data', [])
1223
1223
  return self.parse_orders(data, market, since, limit)
1224
1224
 
1225
1225
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -1294,7 +1294,7 @@ class kuna(Exchange, ImplicitAPI):
1294
1294
  # ]
1295
1295
  # }
1296
1296
  #
1297
- data = self.safe_value(response, 'data', [])
1297
+ data = self.safe_list(response, 'data', [])
1298
1298
  return self.parse_orders(data, market, since, limit)
1299
1299
 
1300
1300
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -1337,7 +1337,7 @@ class kuna(Exchange, ImplicitAPI):
1337
1337
  # ]
1338
1338
  # }
1339
1339
  #
1340
- data = self.safe_value(response, 'data')
1340
+ data = self.safe_list(response, 'data')
1341
1341
  return self.parse_trades(data, market, since, limit)
1342
1342
 
1343
1343
  async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
@@ -1384,7 +1384,7 @@ class kuna(Exchange, ImplicitAPI):
1384
1384
  # }
1385
1385
  # }
1386
1386
  #
1387
- data = self.safe_value(response, 'data', {})
1387
+ data = self.safe_dict(response, 'data', {})
1388
1388
  return self.parse_transaction(data, currency)
1389
1389
 
1390
1390
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
@@ -1445,7 +1445,7 @@ class kuna(Exchange, ImplicitAPI):
1445
1445
  # ]
1446
1446
  # }
1447
1447
  #
1448
- data = self.safe_value(response, 'data', [])
1448
+ data = self.safe_list(response, 'data', [])
1449
1449
  return self.parse_transactions(data, currency)
1450
1450
 
1451
1451
  async def fetch_withdrawal(self, id: str, code: Str = None, params={}):
@@ -1483,7 +1483,7 @@ class kuna(Exchange, ImplicitAPI):
1483
1483
  # }
1484
1484
  # }
1485
1485
  #
1486
- data = self.safe_value(response, 'data', {})
1486
+ data = self.safe_dict(response, 'data', {})
1487
1487
  return self.parse_transaction(data)
1488
1488
 
1489
1489
  async def create_deposit_address(self, code: str, params={}):
@@ -1509,7 +1509,7 @@ class kuna(Exchange, ImplicitAPI):
1509
1509
  # }
1510
1510
  # }
1511
1511
  #
1512
- data = self.safe_value(response, 'data', {})
1512
+ data = self.safe_dict(response, 'data', {})
1513
1513
  return self.parse_deposit_address(data, currency)
1514
1514
 
1515
1515
  async def fetch_deposit_address(self, code: str, params={}):
@@ -1535,7 +1535,7 @@ class kuna(Exchange, ImplicitAPI):
1535
1535
  # }
1536
1536
  # }
1537
1537
  #
1538
- data = self.safe_value(response, 'data', {})
1538
+ data = self.safe_dict(response, 'data', {})
1539
1539
  return self.parse_deposit_address(data, currency)
1540
1540
 
1541
1541
  def parse_deposit_address(self, depositAddress, currency: Currency = None):
@@ -1626,7 +1626,7 @@ class kuna(Exchange, ImplicitAPI):
1626
1626
  # ]
1627
1627
  # }
1628
1628
  #
1629
- data = self.safe_value(response, 'data', [])
1629
+ data = self.safe_list(response, 'data', [])
1630
1630
  return self.parse_transactions(data, currency)
1631
1631
 
1632
1632
  async def fetch_deposit(self, id: str, code: Str = None, params={}):
@@ -1667,7 +1667,7 @@ class kuna(Exchange, ImplicitAPI):
1667
1667
  # }
1668
1668
  # }
1669
1669
  #
1670
- data = self.safe_value(response, 'data', {})
1670
+ data = self.safe_dict(response, 'data', {})
1671
1671
  return self.parse_transaction(data, currency)
1672
1672
 
1673
1673
  def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
@@ -1382,7 +1382,7 @@ class latoken(Exchange, ImplicitAPI):
1382
1382
  currency = None
1383
1383
  if code is not None:
1384
1384
  currency = self.currency(code)
1385
- content = self.safe_value(response, 'content', [])
1385
+ content = self.safe_list(response, 'content', [])
1386
1386
  return self.parse_transactions(content, currency, since, limit)
1387
1387
 
1388
1388
  def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
@@ -1506,7 +1506,7 @@ class latoken(Exchange, ImplicitAPI):
1506
1506
  # "hasContent": True
1507
1507
  # }
1508
1508
  #
1509
- transfers = self.safe_value(response, 'content', [])
1509
+ transfers = self.safe_list(response, 'content', [])
1510
1510
  return self.parse_transfers(transfers, currency, since, limit)
1511
1511
 
1512
1512
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry: