ccxt 4.2.76__py2.py3-none-any.whl → 4.2.78__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 (57) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/kucoin.py +1 -0
  3. ccxt/abstract/kucoinfutures.py +1 -0
  4. ccxt/async_support/__init__.py +1 -1
  5. ccxt/async_support/base/exchange.py +1 -1
  6. ccxt/async_support/binance.py +503 -444
  7. ccxt/async_support/bingx.py +1 -1
  8. ccxt/async_support/bitflyer.py +2 -2
  9. ccxt/async_support/bithumb.py +2 -2
  10. ccxt/async_support/blofin.py +11 -2
  11. ccxt/async_support/bybit.py +88 -52
  12. ccxt/async_support/coinbase.py +21 -10
  13. ccxt/async_support/delta.py +65 -51
  14. ccxt/async_support/deribit.py +2 -2
  15. ccxt/async_support/gate.py +3 -2
  16. ccxt/async_support/htx.py +34 -27
  17. ccxt/async_support/hyperliquid.py +7 -5
  18. ccxt/async_support/kraken.py +8 -8
  19. ccxt/async_support/kucoin.py +192 -5
  20. ccxt/async_support/okcoin.py +27 -1
  21. ccxt/async_support/okx.py +20 -2
  22. ccxt/async_support/woo.py +62 -3
  23. ccxt/base/exchange.py +9 -4
  24. ccxt/binance.py +503 -444
  25. ccxt/bingx.py +1 -1
  26. ccxt/bitflyer.py +2 -2
  27. ccxt/bithumb.py +2 -2
  28. ccxt/blofin.py +11 -2
  29. ccxt/bybit.py +88 -52
  30. ccxt/coinbase.py +21 -10
  31. ccxt/delta.py +65 -51
  32. ccxt/deribit.py +2 -2
  33. ccxt/gate.py +3 -2
  34. ccxt/htx.py +34 -27
  35. ccxt/hyperliquid.py +7 -5
  36. ccxt/kraken.py +8 -8
  37. ccxt/kucoin.py +192 -5
  38. ccxt/okcoin.py +27 -1
  39. ccxt/okx.py +20 -2
  40. ccxt/pro/__init__.py +1 -1
  41. ccxt/pro/ascendex.py +1 -1
  42. ccxt/pro/bitvavo.py +1 -1
  43. ccxt/pro/coinex.py +20 -14
  44. ccxt/pro/deribit.py +1 -1
  45. ccxt/pro/exmo.py +1 -1
  46. ccxt/pro/krakenfutures.py +1 -1
  47. ccxt/pro/phemex.py +1 -1
  48. ccxt/pro/poloniex.py +1 -1
  49. ccxt/pro/probit.py +1 -1
  50. ccxt/pro/woo.py +50 -6
  51. ccxt/test/test_async.py +9 -16
  52. ccxt/test/test_sync.py +9 -16
  53. ccxt/woo.py +62 -3
  54. {ccxt-4.2.76.dist-info → ccxt-4.2.78.dist-info}/METADATA +4 -4
  55. {ccxt-4.2.76.dist-info → ccxt-4.2.78.dist-info}/RECORD +57 -57
  56. {ccxt-4.2.76.dist-info → ccxt-4.2.78.dist-info}/WHEEL +0 -0
  57. {ccxt-4.2.76.dist-info → ccxt-4.2.78.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.delta import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, MarginMode, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
9
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, MarginMode, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import ArgumentsRequired
@@ -325,7 +325,7 @@ class delta(Exchange, ImplicitAPI):
325
325
  'info': None,
326
326
  }
327
327
 
328
- def safe_market(self, marketId=None, market=None, delimiter=None, marketType=None):
328
+ def safe_market(self, marketId: Str = None, market: Market = None, delimiter: Str = None, marketType: Str = None) -> MarketInterface:
329
329
  isOption = (marketId is not None) and ((marketId.endswith('-C')) or (marketId.endswith('-P')) or (marketId.startswith('C-')) or (marketId.startswith('P-')))
330
330
  if isOption and not (marketId in self.markets_by_id):
331
331
  # handle expired option contracts
@@ -340,7 +340,7 @@ class delta(Exchange, ImplicitAPI):
340
340
  """
341
341
  response = await self.publicGetSettings(params)
342
342
  # full response sample under `fetchStatus`
343
- result = self.safe_value(response, 'result', {})
343
+ result = self.safe_dict(response, 'result', {})
344
344
  return self.safe_integer_product(result, 'server_time', 0.001)
345
345
 
346
346
  async def fetch_status(self, params={}):
@@ -403,7 +403,7 @@ class delta(Exchange, ImplicitAPI):
403
403
  # "success": True
404
404
  # }
405
405
  #
406
- result = self.safe_value(response, 'result', {})
406
+ result = self.safe_dict(response, 'result', {})
407
407
  underMaintenance = self.safe_string(result, 'under_maintenance')
408
408
  status = 'maintenance' if (underMaintenance == 'true') else 'ok'
409
409
  updated = self.safe_integer_product(result, 'server_time', 0.001, self.milliseconds())
@@ -453,7 +453,7 @@ class delta(Exchange, ImplicitAPI):
453
453
  # "success":true
454
454
  # }
455
455
  #
456
- currencies = self.safe_value(response, 'result', [])
456
+ currencies = self.safe_list(response, 'result', [])
457
457
  result = {}
458
458
  for i in range(0, len(currencies)):
459
459
  currency = currencies[i]
@@ -489,14 +489,28 @@ class delta(Exchange, ImplicitAPI):
489
489
 
490
490
  async def load_markets(self, reload=False, params={}):
491
491
  markets = await super(delta, self).load_markets(reload, params)
492
- currenciesByNumericId = self.safe_value(self.options, 'currenciesByNumericId')
492
+ currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId')
493
493
  if (currenciesByNumericId is None) or reload:
494
- self.options['currenciesByNumericId'] = self.index_by(self.currencies, 'numericId')
495
- marketsByNumericId = self.safe_value(self.options, 'marketsByNumericId')
494
+ self.options['currenciesByNumericId'] = self.index_by_stringified_numeric_id(self.currencies)
495
+ marketsByNumericId = self.safe_dict(self.options, 'marketsByNumericId')
496
496
  if (marketsByNumericId is None) or reload:
497
- self.options['marketsByNumericId'] = self.index_by(self.markets, 'numericId')
497
+ self.options['marketsByNumericId'] = self.index_by_stringified_numeric_id(self.markets)
498
498
  return markets
499
499
 
500
+ def index_by_stringified_numeric_id(self, input):
501
+ result = {}
502
+ if input is None:
503
+ return None
504
+ keys = list(input.keys())
505
+ for i in range(0, len(keys)):
506
+ key = keys[i]
507
+ item = input[key]
508
+ numericIdString = self.safe_string(item, 'numericId')
509
+ if numericIdString is None:
510
+ continue
511
+ result[numericIdString] = item
512
+ return result
513
+
500
514
  async def fetch_markets(self, params={}):
501
515
  """
502
516
  retrieves data on all markets for delta
@@ -683,7 +697,7 @@ class delta(Exchange, ImplicitAPI):
683
697
  # "success":true
684
698
  # }
685
699
  #
686
- markets = self.safe_value(response, 'result', [])
700
+ markets = self.safe_list(response, 'result', [])
687
701
  result = []
688
702
  for i in range(0, len(markets)):
689
703
  market = markets[i]
@@ -691,10 +705,10 @@ class delta(Exchange, ImplicitAPI):
691
705
  if type == 'options_combos':
692
706
  continue
693
707
  # settlingAsset = self.safe_value(market, 'settling_asset', {})
694
- quotingAsset = self.safe_value(market, 'quoting_asset', {})
695
- underlyingAsset = self.safe_value(market, 'underlying_asset', {})
696
- settlingAsset = self.safe_value(market, 'settling_asset')
697
- productSpecs = self.safe_value(market, 'product_specs', {})
708
+ quotingAsset = self.safe_dict(market, 'quoting_asset', {})
709
+ underlyingAsset = self.safe_dict(market, 'underlying_asset', {})
710
+ settlingAsset = self.safe_dict(market, 'settling_asset')
711
+ productSpecs = self.safe_dict(market, 'product_specs', {})
698
712
  baseId = self.safe_string(underlyingAsset, 'symbol')
699
713
  quoteId = self.safe_string(quotingAsset, 'symbol')
700
714
  settleId = self.safe_string(settlingAsset, 'symbol')
@@ -917,7 +931,7 @@ class delta(Exchange, ImplicitAPI):
917
931
  marketId = self.safe_string(ticker, 'symbol')
918
932
  symbol = self.safe_symbol(marketId, market)
919
933
  last = self.safe_string(ticker, 'close')
920
- quotes = self.safe_value(ticker, 'quotes', {})
934
+ quotes = self.safe_dict(ticker, 'quotes', {})
921
935
  return self.safe_ticker({
922
936
  'symbol': symbol,
923
937
  'timestamp': timestamp,
@@ -1079,7 +1093,7 @@ class delta(Exchange, ImplicitAPI):
1079
1093
  # "success": True
1080
1094
  # }
1081
1095
  #
1082
- result = self.safe_value(response, 'result', {})
1096
+ result = self.safe_dict(response, 'result', {})
1083
1097
  return self.parse_ticker(result, market)
1084
1098
 
1085
1099
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -1223,7 +1237,7 @@ class delta(Exchange, ImplicitAPI):
1223
1237
  # "success":true
1224
1238
  # }
1225
1239
  #
1226
- tickers = self.safe_value(response, 'result', [])
1240
+ tickers = self.safe_list(response, 'result', [])
1227
1241
  result = {}
1228
1242
  for i in range(0, len(tickers)):
1229
1243
  ticker = self.parse_ticker(tickers[i])
@@ -1266,7 +1280,7 @@ class delta(Exchange, ImplicitAPI):
1266
1280
  # "success":true
1267
1281
  # }
1268
1282
  #
1269
- result = self.safe_value(response, 'result', {})
1283
+ result = self.safe_dict(response, 'result', {})
1270
1284
  return self.parse_order_book(result, market['symbol'], None, 'buy', 'sell', 'price', 'size')
1271
1285
 
1272
1286
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -1323,7 +1337,7 @@ class delta(Exchange, ImplicitAPI):
1323
1337
  timestamp = self.safe_integer_product(trade, 'timestamp', 0.001, timestamp)
1324
1338
  priceString = self.safe_string(trade, 'price')
1325
1339
  amountString = self.safe_string(trade, 'size')
1326
- product = self.safe_value(trade, 'product', {})
1340
+ product = self.safe_dict(trade, 'product', {})
1327
1341
  marketId = self.safe_string(product, 'symbol')
1328
1342
  symbol = self.safe_symbol(marketId, market)
1329
1343
  sellerRole = self.safe_string(trade, 'seller_role')
@@ -1334,14 +1348,14 @@ class delta(Exchange, ImplicitAPI):
1334
1348
  elif sellerRole == 'maker':
1335
1349
  side = 'buy'
1336
1350
  takerOrMaker = self.safe_string(trade, 'role')
1337
- metaData = self.safe_value(trade, 'meta_data', {})
1351
+ metaData = self.safe_dict(trade, 'meta_data', {})
1338
1352
  type = self.safe_string(metaData, 'order_type')
1339
1353
  if type is not None:
1340
1354
  type = type.replace('_order', '')
1341
1355
  feeCostString = self.safe_string(trade, 'commission')
1342
1356
  fee = None
1343
1357
  if feeCostString is not None:
1344
- settlingAsset = self.safe_value(product, 'settling_asset', {})
1358
+ settlingAsset = self.safe_dict(product, 'settling_asset', {})
1345
1359
  feeCurrencyId = self.safe_string(settlingAsset, 'symbol')
1346
1360
  feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
1347
1361
  fee = {
@@ -1395,7 +1409,7 @@ class delta(Exchange, ImplicitAPI):
1395
1409
  # "success":true
1396
1410
  # }
1397
1411
  #
1398
- result = self.safe_value(response, 'result', [])
1412
+ result = self.safe_list(response, 'result', [])
1399
1413
  return self.parse_trades(result, market, since, limit)
1400
1414
 
1401
1415
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -1463,17 +1477,17 @@ class delta(Exchange, ImplicitAPI):
1463
1477
  # ]
1464
1478
  # }
1465
1479
  #
1466
- result = self.safe_value(response, 'result', [])
1480
+ result = self.safe_list(response, 'result', [])
1467
1481
  return self.parse_ohlcvs(result, market, timeframe, since, limit)
1468
1482
 
1469
1483
  def parse_balance(self, response) -> Balances:
1470
- balances = self.safe_value(response, 'result', [])
1484
+ balances = self.safe_list(response, 'result', [])
1471
1485
  result = {'info': response}
1472
- currenciesByNumericId = self.safe_value(self.options, 'currenciesByNumericId', {})
1486
+ currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId', {})
1473
1487
  for i in range(0, len(balances)):
1474
1488
  balance = balances[i]
1475
1489
  currencyId = self.safe_string(balance, 'asset_id')
1476
- currency = self.safe_value(currenciesByNumericId, currencyId)
1490
+ currency = self.safe_dict(currenciesByNumericId, currencyId)
1477
1491
  code = currencyId if (currency is None) else currency['code']
1478
1492
  account = self.account()
1479
1493
  account['total'] = self.safe_string(balance, 'balance')
@@ -1537,7 +1551,7 @@ class delta(Exchange, ImplicitAPI):
1537
1551
  # "success":true
1538
1552
  # }
1539
1553
  #
1540
- result = self.safe_value(response, 'result', {})
1554
+ result = self.safe_dict(response, 'result', {})
1541
1555
  return self.parse_position(result, market)
1542
1556
 
1543
1557
  async def fetch_positions(self, symbols: Strings = None, params={}):
@@ -1571,7 +1585,7 @@ class delta(Exchange, ImplicitAPI):
1571
1585
  # ]
1572
1586
  # }
1573
1587
  #
1574
- result = self.safe_value(response, 'result', [])
1588
+ result = self.safe_list(response, 'result', [])
1575
1589
  return self.parse_positions(result, symbols)
1576
1590
 
1577
1591
  def parse_position(self, position, market: Market = None):
@@ -1690,7 +1704,7 @@ class delta(Exchange, ImplicitAPI):
1690
1704
  clientOrderId = self.safe_string(order, 'client_order_id')
1691
1705
  timestamp = self.parse8601(self.safe_string(order, 'created_at'))
1692
1706
  marketId = self.safe_string(order, 'product_id')
1693
- marketsByNumericId = self.safe_value(self.options, 'marketsByNumericId', {})
1707
+ marketsByNumericId = self.safe_dict(self.options, 'marketsByNumericId', {})
1694
1708
  market = self.safe_value(marketsByNumericId, marketId, market)
1695
1709
  symbol = marketId if (market is None) else market['symbol']
1696
1710
  status = self.parse_order_status(self.safe_string(order, 'state'))
@@ -1706,7 +1720,7 @@ class delta(Exchange, ImplicitAPI):
1706
1720
  if feeCostString is not None:
1707
1721
  feeCurrencyCode = None
1708
1722
  if market is not None:
1709
- settlingAsset = self.safe_value(market['info'], 'settling_asset', {})
1723
+ settlingAsset = self.safe_dict(market['info'], 'settling_asset', {})
1710
1724
  feeCurrencyId = self.safe_string(settlingAsset, 'symbol')
1711
1725
  feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
1712
1726
  fee = {
@@ -1767,7 +1781,7 @@ class delta(Exchange, ImplicitAPI):
1767
1781
  params = self.omit(params, ['clientOrderId', 'client_order_id'])
1768
1782
  if clientOrderId is not None:
1769
1783
  request['client_order_id'] = clientOrderId
1770
- reduceOnly = self.safe_value(params, 'reduceOnly')
1784
+ reduceOnly = self.safe_bool(params, 'reduceOnly')
1771
1785
  if reduceOnly:
1772
1786
  request['reduce_only'] = reduceOnly
1773
1787
  params = self.omit(params, 'reduceOnly')
@@ -1808,7 +1822,7 @@ class delta(Exchange, ImplicitAPI):
1808
1822
  # "success":true
1809
1823
  # }
1810
1824
  #
1811
- result = self.safe_value(response, 'result', {})
1825
+ result = self.safe_dict(response, 'result', {})
1812
1826
  return self.parse_order(result, market)
1813
1827
 
1814
1828
  async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
@@ -1854,7 +1868,7 @@ class delta(Exchange, ImplicitAPI):
1854
1868
  # }
1855
1869
  # }
1856
1870
  #
1857
- result = self.safe_value(response, 'result')
1871
+ result = self.safe_dict(response, 'result')
1858
1872
  return self.parse_order(result, market)
1859
1873
 
1860
1874
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -1911,7 +1925,7 @@ class delta(Exchange, ImplicitAPI):
1911
1925
  # "success":true
1912
1926
  # }
1913
1927
  #
1914
- result = self.safe_value(response, 'result')
1928
+ result = self.safe_dict(response, 'result')
1915
1929
  return self.parse_order(result, market)
1916
1930
 
1917
1931
  async def cancel_all_orders(self, symbol: Str = None, params={}):
@@ -2012,7 +2026,7 @@ class delta(Exchange, ImplicitAPI):
2012
2026
  # }
2013
2027
  # }
2014
2028
  #
2015
- result = self.safe_value(response, 'result', [])
2029
+ result = self.safe_list(response, 'result', [])
2016
2030
  return self.parse_orders(result, market, since, limit)
2017
2031
 
2018
2032
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -2089,7 +2103,7 @@ class delta(Exchange, ImplicitAPI):
2089
2103
  # "success":true
2090
2104
  # }
2091
2105
  #
2092
- result = self.safe_value(response, 'result', [])
2106
+ result = self.safe_list(response, 'result', [])
2093
2107
  return self.parse_trades(result, market, since, limit)
2094
2108
 
2095
2109
  async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -2138,7 +2152,7 @@ class delta(Exchange, ImplicitAPI):
2138
2152
  # "success":true
2139
2153
  # }
2140
2154
  #
2141
- result = self.safe_value(response, 'result', [])
2155
+ result = self.safe_list(response, 'result', [])
2142
2156
  return self.parse_ledger(result, currency, since, limit)
2143
2157
 
2144
2158
  def parse_ledger_entry_type(self, type):
@@ -2175,7 +2189,7 @@ class delta(Exchange, ImplicitAPI):
2175
2189
  id = self.safe_string(item, 'uuid')
2176
2190
  direction = None
2177
2191
  account = None
2178
- metaData = self.safe_value(item, 'meta_data', {})
2192
+ metaData = self.safe_dict(item, 'meta_data', {})
2179
2193
  referenceId = self.safe_string(metaData, 'transaction_id')
2180
2194
  referenceAccount = None
2181
2195
  type = self.safe_string(item, 'transaction_type')
@@ -2184,8 +2198,8 @@ class delta(Exchange, ImplicitAPI):
2184
2198
  elif (type == 'withdrawal') or (type == 'commission') or (type == 'conversion') or (type == 'perpetual_futures_funding'):
2185
2199
  direction = 'out'
2186
2200
  type = self.parse_ledger_entry_type(type)
2187
- currencyId = self.safe_integer(item, 'asset_id')
2188
- currenciesByNumericId = self.safe_value(self.options, 'currenciesByNumericId')
2201
+ currencyId = self.safe_string(item, 'asset_id')
2202
+ currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId')
2189
2203
  currency = self.safe_value(currenciesByNumericId, currencyId, currency)
2190
2204
  code = None if (currency is None) else currency['code']
2191
2205
  amount = self.safe_string(item, 'amount')
@@ -2246,7 +2260,7 @@ class delta(Exchange, ImplicitAPI):
2246
2260
  # }
2247
2261
  # }
2248
2262
  #
2249
- result = self.safe_value(response, 'result', {})
2263
+ result = self.safe_dict(response, 'result', {})
2250
2264
  return self.parse_deposit_address(result, currency)
2251
2265
 
2252
2266
  def parse_deposit_address(self, depositAddress, currency: Currency = None):
@@ -2337,7 +2351,7 @@ class delta(Exchange, ImplicitAPI):
2337
2351
  # "success": True
2338
2352
  # }
2339
2353
  #
2340
- result = self.safe_value(response, 'result', {})
2354
+ result = self.safe_dict(response, 'result', {})
2341
2355
  return self.parse_funding_rate(result, market)
2342
2356
 
2343
2357
  async def fetch_funding_rates(self, symbols: Strings = None, params={}):
@@ -2401,7 +2415,7 @@ class delta(Exchange, ImplicitAPI):
2401
2415
  # "success":true
2402
2416
  # }
2403
2417
  #
2404
- rates = self.safe_value(response, 'result', [])
2418
+ rates = self.safe_list(response, 'result', [])
2405
2419
  result = self.parse_funding_rates(rates)
2406
2420
  return self.filter_by_array(result, 'symbol', symbols)
2407
2421
 
@@ -2528,7 +2542,7 @@ class delta(Exchange, ImplicitAPI):
2528
2542
  # "success": True
2529
2543
  # }
2530
2544
  #
2531
- result = self.safe_value(response, 'result', {})
2545
+ result = self.safe_dict(response, 'result', {})
2532
2546
  return self.parse_margin_modification(result, market)
2533
2547
 
2534
2548
  def parse_margin_modification(self, data, market: Market = None):
@@ -2632,7 +2646,7 @@ class delta(Exchange, ImplicitAPI):
2632
2646
  # "success": True
2633
2647
  # }
2634
2648
  #
2635
- result = self.safe_value(response, 'result', {})
2649
+ result = self.safe_dict(response, 'result', {})
2636
2650
  return self.parse_open_interest(result, market)
2637
2651
 
2638
2652
  def parse_open_interest(self, interest, market: Market = None):
@@ -2847,7 +2861,7 @@ class delta(Exchange, ImplicitAPI):
2847
2861
  # "success": True
2848
2862
  # }
2849
2863
  #
2850
- result = self.safe_value(response, 'result', [])
2864
+ result = self.safe_list(response, 'result', [])
2851
2865
  settlements = self.parse_settlements(result, market)
2852
2866
  sorted = self.sort_by(settlements, 'timestamp')
2853
2867
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
@@ -2988,7 +3002,7 @@ class delta(Exchange, ImplicitAPI):
2988
3002
  # "success": True
2989
3003
  # }
2990
3004
  #
2991
- result = self.safe_value(response, 'result', {})
3005
+ result = self.safe_dict(response, 'result', {})
2992
3006
  return self.parse_greeks(result, market)
2993
3007
 
2994
3008
  def parse_greeks(self, greeks, market: Market = None):
@@ -3044,8 +3058,8 @@ class delta(Exchange, ImplicitAPI):
3044
3058
  timestamp = self.safe_integer_product(greeks, 'timestamp', 0.001)
3045
3059
  marketId = self.safe_string(greeks, 'symbol')
3046
3060
  symbol = self.safe_symbol(marketId, market)
3047
- stats = self.safe_value(greeks, 'greeks', {})
3048
- quotes = self.safe_value(greeks, 'quotes', {})
3061
+ stats = self.safe_dict(greeks, 'greeks', {})
3062
+ quotes = self.safe_dict(greeks, 'quotes', {})
3049
3063
  return {
3050
3064
  'symbol': symbol,
3051
3065
  'timestamp': timestamp,
@@ -3086,7 +3100,7 @@ class delta(Exchange, ImplicitAPI):
3086
3100
  #
3087
3101
  # {"result":{},"success":true}
3088
3102
  #
3089
- position = self.parse_position(self.safe_value(response, 'result', {}))
3103
+ position = self.parse_position(self.safe_dict(response, 'result', {}))
3090
3104
  return [position]
3091
3105
 
3092
3106
  async def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
@@ -3212,7 +3226,7 @@ class delta(Exchange, ImplicitAPI):
3212
3226
  #
3213
3227
  # {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
3214
3228
  #
3215
- error = self.safe_value(response, 'error', {})
3229
+ error = self.safe_dict(response, 'error', {})
3216
3230
  errorCode = self.safe_string(error, 'code')
3217
3231
  if errorCode is not None:
3218
3232
  feedback = self.id + ' ' + body
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.deribit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, Greeks, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currency, Greeks, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -553,7 +553,7 @@ class deribit(Exchange, ImplicitAPI):
553
553
  'info': None,
554
554
  }
555
555
 
556
- def safe_market(self, marketId=None, market=None, delimiter=None, marketType=None):
556
+ def safe_market(self, marketId: Str = None, market: Market = None, delimiter: Str = None, marketType: Str = None) -> MarketInterface:
557
557
  isOption = (marketId is not None) and ((marketId.endswith('-C')) or (marketId.endswith('-P')))
558
558
  if isOption and not (marketId in self.markets_by_id):
559
559
  # handle expired option contracts
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, Market, MarketInterface, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import PermissionDenied
@@ -68,6 +68,7 @@ class gate(Exchange, ImplicitAPI):
68
68
  'rebate': 'https://api.gateio.ws/api/v4',
69
69
  'earn': 'https://api.gateio.ws/api/v4',
70
70
  'account': 'https://api.gateio.ws/api/v4',
71
+ 'loan': 'https://api.gateio.ws/api/v4',
71
72
  },
72
73
  },
73
74
  'test': {
@@ -956,7 +957,7 @@ class gate(Exchange, ImplicitAPI):
956
957
  'info': None,
957
958
  }
958
959
 
959
- def safe_market(self, marketId=None, market=None, delimiter=None, marketType=None):
960
+ def safe_market(self, marketId: Str = None, market: Market = None, delimiter: Str = None, marketType: Str = None) -> MarketInterface:
960
961
  isOption = (marketId is not None) and ((marketId.find('-C') > -1) or (marketId.find('-P') > -1))
961
962
  if isOption and not (marketId in self.markets_by_id):
962
963
  # handle expired option contracts
ccxt/async_support/htx.py CHANGED
@@ -2849,63 +2849,68 @@ class htx(Exchange, ImplicitAPI):
2849
2849
  # 'from': int((since / str(1000))), spot only
2850
2850
  # 'to': self.seconds(), spot only
2851
2851
  }
2852
- price = self.safe_string(params, 'price')
2853
- params = self.omit(params, 'price')
2852
+ priceType = self.safe_string_n(params, ['priceType', 'price'])
2853
+ params = self.omit(params, ['priceType', 'price'])
2854
+ until = None
2855
+ until, params = self.handle_param_integer(params, 'until')
2856
+ untilSeconds = self.parse_to_int(until / 1000) if (until is not None) else None
2854
2857
  if market['contract']:
2855
2858
  if limit is not None:
2856
- request['size'] = limit # when using limit from and to are ignored
2859
+ request['size'] = limit # when using limit: from & to are ignored
2857
2860
  # https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
2858
2861
  else:
2859
2862
  limit = 2000 # only used for from/to calculation
2860
- if price is None:
2863
+ if priceType is None:
2861
2864
  duration = self.parse_timeframe(timeframe)
2865
+ calcualtedEnd = None
2862
2866
  if since is None:
2863
2867
  now = self.seconds()
2864
2868
  request['from'] = now - duration * (limit - 1)
2865
- request['to'] = now
2869
+ calcualtedEnd = now
2866
2870
  else:
2867
2871
  start = self.parse_to_int(since / 1000)
2868
2872
  request['from'] = start
2869
- request['to'] = self.sum(start, duration * (limit - 1))
2873
+ calcualtedEnd = self.sum(start, duration * (limit - 1))
2874
+ request['to'] = untilSeconds if (untilSeconds is not None) else calcualtedEnd
2870
2875
  response = None
2871
2876
  if market['future']:
2872
2877
  if market['inverse']:
2873
2878
  request['symbol'] = market['id']
2874
- if price == 'mark':
2879
+ if priceType == 'mark':
2875
2880
  response = await self.contractPublicGetIndexMarketHistoryMarkPriceKline(self.extend(request, params))
2876
- elif price == 'index':
2881
+ elif priceType == 'index':
2877
2882
  response = await self.contractPublicGetIndexMarketHistoryIndex(self.extend(request, params))
2878
- elif price == 'premiumIndex':
2879
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2883
+ elif priceType == 'premiumIndex':
2884
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2880
2885
  else:
2881
2886
  response = await self.contractPublicGetMarketHistoryKline(self.extend(request, params))
2882
2887
  elif market['linear']:
2883
2888
  request['contract_code'] = market['id']
2884
- if price == 'mark':
2889
+ if priceType == 'mark':
2885
2890
  response = await self.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(self.extend(request, params))
2886
- elif price == 'index':
2887
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2888
- elif price == 'premiumIndex':
2891
+ elif priceType == 'index':
2892
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2893
+ elif priceType == 'premiumIndex':
2889
2894
  response = await self.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(self.extend(request, params))
2890
2895
  else:
2891
2896
  response = await self.contractPublicGetLinearSwapExMarketHistoryKline(self.extend(request, params))
2892
2897
  elif market['swap']:
2893
2898
  request['contract_code'] = market['id']
2894
2899
  if market['inverse']:
2895
- if price == 'mark':
2900
+ if priceType == 'mark':
2896
2901
  response = await self.contractPublicGetIndexMarketHistorySwapMarkPriceKline(self.extend(request, params))
2897
- elif price == 'index':
2898
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2899
- elif price == 'premiumIndex':
2902
+ elif priceType == 'index':
2903
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2904
+ elif priceType == 'premiumIndex':
2900
2905
  response = await self.contractPublicGetIndexMarketHistorySwapPremiumIndexKline(self.extend(request, params))
2901
2906
  else:
2902
2907
  response = await self.contractPublicGetSwapExMarketHistoryKline(self.extend(request, params))
2903
2908
  elif market['linear']:
2904
- if price == 'mark':
2909
+ if priceType == 'mark':
2905
2910
  response = await self.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(self.extend(request, params))
2906
- elif price == 'index':
2907
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2908
- elif price == 'premiumIndex':
2911
+ elif priceType == 'index':
2912
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2913
+ elif priceType == 'premiumIndex':
2909
2914
  response = await self.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(self.extend(request, params))
2910
2915
  else:
2911
2916
  response = await self.contractPublicGetLinearSwapExMarketHistoryKline(self.extend(request, params))
@@ -2914,15 +2919,17 @@ class htx(Exchange, ImplicitAPI):
2914
2919
  useHistorical = None
2915
2920
  useHistorical, params = self.handle_option_and_params(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', True)
2916
2921
  if not useHistorical:
2917
- # `limit` only available for the self endpoint
2918
2922
  if limit is not None:
2919
- request['size'] = limit # max 2000
2923
+ request['size'] = min(2000, limit) # max 2000
2920
2924
  response = await self.spotPublicGetMarketHistoryKline(self.extend(request, params))
2921
2925
  else:
2922
- # `since` only available for the self endpoint
2926
+ # "from & to" only available for the self endpoint
2923
2927
  if since is not None:
2924
- # default 150 bars
2925
2928
  request['from'] = self.parse_to_int(since / 1000)
2929
+ if untilSeconds is not None:
2930
+ request['to'] = untilSeconds
2931
+ if limit is not None:
2932
+ request['size'] = min(1000, limit) # max 1000, otherwise default returns 150
2926
2933
  response = await self.spotPublicGetMarketHistoryCandles(self.extend(request, params))
2927
2934
  #
2928
2935
  # {
@@ -2936,7 +2943,7 @@ class htx(Exchange, ImplicitAPI):
2936
2943
  # ]
2937
2944
  # }
2938
2945
  #
2939
- data = self.safe_value(response, 'data', [])
2946
+ data = self.safe_list(response, 'data', [])
2940
2947
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
2941
2948
 
2942
2949
  async def fetch_accounts(self, params={}) -> List[Account]:
@@ -550,7 +550,7 @@ class hyperliquid(Exchange, ImplicitAPI):
550
550
  # }
551
551
  #
552
552
  return [
553
- self.safe_integer(ohlcv, 'T'),
553
+ self.safe_integer(ohlcv, 't'),
554
554
  self.safe_number(ohlcv, 'o'),
555
555
  self.safe_number(ohlcv, 'h'),
556
556
  self.safe_number(ohlcv, 'l'),
@@ -747,8 +747,9 @@ class hyperliquid(Exchange, ImplicitAPI):
747
747
  :param bool [params.postOnly]: True or False whether the order is post-only
748
748
  :param bool [params.reduceOnly]: True or False whether the order is reduce-only
749
749
  :param float [params.triggerPrice]: The price at which a trigger order is triggered at
750
- :param str [params.clientOrderId]: client order id, optional 128 bit hex string
750
+ :param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
751
751
  :param str [params.slippage]: the slippage for market order
752
+ :param str [params.vaultAddress]: the vault address for order
752
753
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
753
754
  """
754
755
  await self.load_markets()
@@ -791,7 +792,7 @@ class hyperliquid(Exchange, ImplicitAPI):
791
792
  clientOrderId = self.safe_string_2(orderParams, 'clientOrderId', 'client_id')
792
793
  if clientOrderId is None:
793
794
  raise ArgumentsRequired(self.id + ' createOrders() all orders must have clientOrderId if at least one has a clientOrderId')
794
- params = self.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice'])
795
+ params = self.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce'])
795
796
  nonce = self.milliseconds()
796
797
  orderReq = []
797
798
  for i in range(0, len(orders)):
@@ -905,7 +906,7 @@ class hyperliquid(Exchange, ImplicitAPI):
905
906
  :param str id: order id
906
907
  :param str symbol: unified symbol of the market the order was made in
907
908
  :param dict [params]: extra parameters specific to the exchange API endpoint
908
- :param str [params.clientOrderId]: client order id(default None)
909
+ :param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
909
910
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
910
911
  """
911
912
  return await self.cancel_orders([id], symbol, params)
@@ -918,7 +919,7 @@ class hyperliquid(Exchange, ImplicitAPI):
918
919
  :param str[] ids: order ids
919
920
  :param str [symbol]: unified market symbol
920
921
  :param dict [params]: extra parameters specific to the exchange API endpoint
921
- :param string|str[] [params.clientOrderId]: client order ids(default None)
922
+ :param string|str[] [params.clientOrderId]: client order ids,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
922
923
  :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
923
924
  """
924
925
  self.check_required_credentials()
@@ -993,6 +994,7 @@ class hyperliquid(Exchange, ImplicitAPI):
993
994
  :param bool [params.reduceOnly]: True or False whether the order is reduce-only
994
995
  :param float [params.triggerPrice]: The price at which a trigger order is triggered at
995
996
  :param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
997
+ :param str [params.vaultAddress]: the vault address for order
996
998
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
997
999
  """
998
1000
  self.check_required_credentials()