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
ccxt/bitteam.py CHANGED
@@ -669,7 +669,7 @@ class bitteam(Exchange, ImplicitAPI):
669
669
  # }
670
670
  #
671
671
  result = self.safe_value(response, 'result', {})
672
- data = self.safe_value(result, 'data', [])
672
+ data = self.safe_list(result, 'data', [])
673
673
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
674
674
 
675
675
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -844,7 +844,7 @@ class bitteam(Exchange, ImplicitAPI):
844
844
  # }
845
845
  #
846
846
  result = self.safe_value(response, 'result', {})
847
- orders = self.safe_value(result, 'orders', [])
847
+ orders = self.safe_list(result, 'orders', [])
848
848
  return self.parse_orders(orders, market, since, limit)
849
849
 
850
850
  def fetch_order(self, id: str, symbol: Str = None, params={}) -> Order:
@@ -901,7 +901,7 @@ class bitteam(Exchange, ImplicitAPI):
901
901
  # }
902
902
  # }
903
903
  #
904
- result = self.safe_value(response, 'result')
904
+ result = self.safe_dict(response, 'result')
905
905
  return self.parse_order(result, market)
906
906
 
907
907
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -1001,7 +1001,7 @@ class bitteam(Exchange, ImplicitAPI):
1001
1001
  # }
1002
1002
  # }
1003
1003
  #
1004
- order = self.safe_value(response, 'result', {})
1004
+ order = self.safe_dict(response, 'result', {})
1005
1005
  return self.parse_order(order, market)
1006
1006
 
1007
1007
  def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -1026,7 +1026,7 @@ class bitteam(Exchange, ImplicitAPI):
1026
1026
  # }
1027
1027
  # }
1028
1028
  #
1029
- result = self.safe_value(response, 'result', {})
1029
+ result = self.safe_dict(response, 'result', {})
1030
1030
  return self.parse_order(result)
1031
1031
 
1032
1032
  def cancel_all_orders(self, symbol: Str = None, params={}):
@@ -1475,7 +1475,7 @@ class bitteam(Exchange, ImplicitAPI):
1475
1475
  # }
1476
1476
  #
1477
1477
  result = self.safe_value(response, 'result', {})
1478
- pair = self.safe_value(result, 'pair', {})
1478
+ pair = self.safe_dict(result, 'pair', {})
1479
1479
  return self.parse_ticker(pair, market)
1480
1480
 
1481
1481
  def parse_ticker(self, ticker, market: Market = None) -> Ticker:
@@ -1796,7 +1796,7 @@ class bitteam(Exchange, ImplicitAPI):
1796
1796
  # }
1797
1797
  #
1798
1798
  result = self.safe_value(response, 'result', {})
1799
- trades = self.safe_value(result, 'trades', [])
1799
+ trades = self.safe_list(result, 'trades', [])
1800
1800
  return self.parse_trades(trades, market, since, limit)
1801
1801
 
1802
1802
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -2087,7 +2087,7 @@ class bitteam(Exchange, ImplicitAPI):
2087
2087
  # }
2088
2088
  #
2089
2089
  result = self.safe_value(response, 'result', {})
2090
- transactions = self.safe_value(result, 'transactions', [])
2090
+ transactions = self.safe_list(result, 'transactions', [])
2091
2091
  return self.parse_transactions(transactions, currency, since, limit)
2092
2092
 
2093
2093
  def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
ccxt/bl3p.py CHANGED
@@ -172,7 +172,7 @@ class bl3p(Exchange, ImplicitAPI):
172
172
  'market': market['id'],
173
173
  }
174
174
  response = self.publicGetMarketOrderbook(self.extend(request, params))
175
- orderbook = self.safe_value(response, 'data')
175
+ orderbook = self.safe_dict(response, 'data')
176
176
  return self.parse_order_book(orderbook, market['symbol'], None, 'bids', 'asks', 'price_int', 'amount_int')
177
177
 
178
178
  def parse_ticker(self, ticker, market: Market = None) -> Ticker:
ccxt/btcturk.py CHANGED
@@ -410,7 +410,7 @@ class btcturk(Exchange, ImplicitAPI):
410
410
  """
411
411
  self.load_markets()
412
412
  response = self.publicGetTicker(params)
413
- tickers = self.safe_value(response, 'data')
413
+ tickers = self.safe_list(response, 'data')
414
414
  return self.parse_tickers(tickers, symbols)
415
415
 
416
416
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
@@ -522,7 +522,7 @@ class btcturk(Exchange, ImplicitAPI):
522
522
  # ]
523
523
  # }
524
524
  #
525
- data = self.safe_value(response, 'data')
525
+ data = self.safe_list(response, 'data')
526
526
  return self.parse_trades(data, market, since, limit)
527
527
 
528
528
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -665,7 +665,7 @@ class btcturk(Exchange, ImplicitAPI):
665
665
  elif not ('newClientOrderId' in params):
666
666
  request['newClientOrderId'] = self.uuid()
667
667
  response = self.privatePostOrder(self.extend(request, params))
668
- data = self.safe_value(response, 'data')
668
+ data = self.safe_dict(response, 'data')
669
669
  return self.parse_order(data, market)
670
670
 
671
671
  def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -701,7 +701,7 @@ class btcturk(Exchange, ImplicitAPI):
701
701
  response = self.privateGetOpenOrders(self.extend(request, params))
702
702
  data = self.safe_value(response, 'data')
703
703
  bids = self.safe_value(data, 'bids', [])
704
- asks = self.safe_value(data, 'asks', [])
704
+ asks = self.safe_list(data, 'asks', [])
705
705
  return self.parse_orders(self.array_concat(bids, asks), market, since, limit)
706
706
 
707
707
  def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -745,7 +745,7 @@ class btcturk(Exchange, ImplicitAPI):
745
745
  # }
746
746
  # ]
747
747
  # }
748
- data = self.safe_value(response, 'data')
748
+ data = self.safe_list(response, 'data')
749
749
  return self.parse_orders(data, market, since, limit)
750
750
 
751
751
  def parse_order_status(self, status):
@@ -859,7 +859,7 @@ class btcturk(Exchange, ImplicitAPI):
859
859
  # "code": "0"
860
860
  # }
861
861
  #
862
- data = self.safe_value(response, 'data')
862
+ data = self.safe_list(response, 'data')
863
863
  return self.parse_trades(data, market, since, limit)
864
864
 
865
865
  def nonce(self):
ccxt/bybit.py CHANGED
@@ -36,7 +36,7 @@ class bybit(Exchange, ImplicitAPI):
36
36
  'version': 'v5',
37
37
  'userAgent': None,
38
38
  'rateLimit': 20,
39
- 'hostname': 'bybit.com', # bybit.com, bytick.com
39
+ 'hostname': 'bybit.com', # bybit.com, bytick.com, bybit.nl, bybit.com.hk
40
40
  'pro': True,
41
41
  'certified': True,
42
42
  'has': {
@@ -482,7 +482,7 @@ class bybit(Exchange, ImplicitAPI):
482
482
  'v5/account/mmp-modify': 5,
483
483
  'v5/account/mmp-reset': 5,
484
484
  # asset
485
- 'v5/asset/transfer/inter-transfer': 150, # 1/3/s => cost = 50 / 1/3 = 150
485
+ 'v5/asset/transfer/inter-transfer': 50, # 1/s => cost = 50 / 1 = 50
486
486
  'v5/asset/transfer/save-transfer-sub-member': 150, # 1/3/s => cost = 50 / 1/3 = 150
487
487
  'v5/asset/transfer/universal-transfer': 10, # 5/s => cost = 50 / 5 = 10
488
488
  'v5/asset/deposit/deposit-to-account': 5,
@@ -1132,70 +1132,6 @@ class bybit(Exchange, ImplicitAPI):
1132
1132
  def upgrade_unified_trade_account(self, params={}):
1133
1133
  return self.privatePostV5AccountUpgradeToUta(params)
1134
1134
 
1135
- def convert_expire_date(self, date):
1136
- # parse YYMMDD to timestamp
1137
- year = date[0:2]
1138
- month = date[2:4]
1139
- day = date[4:6]
1140
- reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z'
1141
- return reconstructedDate
1142
-
1143
- def convert_expire_date_to_market_id_date(self, date):
1144
- # parse 231229 to 29DEC23
1145
- year = date[0:2]
1146
- monthRaw = date[2:4]
1147
- month = None
1148
- day = date[4:6]
1149
- if monthRaw == '01':
1150
- month = 'JAN'
1151
- elif monthRaw == '02':
1152
- month = 'FEB'
1153
- elif monthRaw == '03':
1154
- month = 'MAR'
1155
- elif monthRaw == '04':
1156
- month = 'APR'
1157
- elif monthRaw == '05':
1158
- month = 'MAY'
1159
- elif monthRaw == '06':
1160
- month = 'JUN'
1161
- elif monthRaw == '07':
1162
- month = 'JUL'
1163
- elif monthRaw == '08':
1164
- month = 'AUG'
1165
- elif monthRaw == '09':
1166
- month = 'SEP'
1167
- elif monthRaw == '10':
1168
- month = 'OCT'
1169
- elif monthRaw == '11':
1170
- month = 'NOV'
1171
- elif monthRaw == '12':
1172
- month = 'DEC'
1173
- reconstructedDate = day + month + year
1174
- return reconstructedDate
1175
-
1176
- def convert_market_id_expire_date(self, date):
1177
- # parse 22JAN23 to 230122
1178
- monthMappping = {
1179
- 'JAN': '01',
1180
- 'FEB': '02',
1181
- 'MAR': '03',
1182
- 'APR': '04',
1183
- 'MAY': '05',
1184
- 'JUN': '06',
1185
- 'JUL': '07',
1186
- 'AUG': '08',
1187
- 'SEP': '09',
1188
- 'OCT': '10',
1189
- 'NOV': '11',
1190
- 'DEC': '12',
1191
- }
1192
- year = date[0:2]
1193
- monthName = date[2:5]
1194
- month = self.safe_string(monthMappping, monthName)
1195
- day = date[5:7]
1196
- reconstructedDate = day + month + year
1197
- return reconstructedDate
1198
-
1199
1135
  def create_expired_option_market(self, symbol: str):
1200
1136
  # support expired option contracts
1201
1137
  quote = 'USD'
@@ -2040,7 +1976,7 @@ class bybit(Exchange, ImplicitAPI):
2040
1976
  #
2041
1977
  result = self.safe_value(response, 'result', [])
2042
1978
  tickers = self.safe_value(result, 'list', [])
2043
- rawTicker = self.safe_value(tickers, 0)
1979
+ rawTicker = self.safe_dict(tickers, 0)
2044
1980
  return self.parse_ticker(rawTicker, market)
2045
1981
 
2046
1982
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -2049,6 +1985,7 @@ class bybit(Exchange, ImplicitAPI):
2049
1985
  :see: https://bybit-exchange.github.io/docs/v5/market/tickers
2050
1986
  :param str[] symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2051
1987
  :param dict [params]: extra parameters specific to the exchange API endpoint
1988
+ :param str [params.subType]: *contract only* 'linear', 'inverse'
2052
1989
  :returns dict: an array of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
2053
1990
  """
2054
1991
  self.load_markets()
@@ -2081,11 +2018,16 @@ class bybit(Exchange, ImplicitAPI):
2081
2018
  }
2082
2019
  type = None
2083
2020
  type, params = self.handle_market_type_and_params('fetchTickers', market, params)
2084
- if type == 'spot':
2021
+ # Calls like `.fetch_tickers(None, {subType:'inverse'})` should be supported for self exchange, so
2022
+ # as "options.defaultSubType" is also set in exchange options, we should consider `params.subType`
2023
+ # with higher priority and only default to spot, if `subType` is not set in params
2024
+ passedSubType = self.safe_string(params, 'subType')
2025
+ subType = None
2026
+ subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
2027
+ # only if passedSubType is None, then use spot
2028
+ if type == 'spot' and passedSubType is None:
2085
2029
  request['category'] = 'spot'
2086
- elif type == 'swap' or type == 'future':
2087
- subType = None
2088
- subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
2030
+ elif type == 'swap' or type == 'future' or subType is not None:
2089
2031
  request['category'] = subType
2090
2032
  elif type == 'option':
2091
2033
  request['category'] = 'option'
@@ -2129,7 +2071,7 @@ class bybit(Exchange, ImplicitAPI):
2129
2071
  # }
2130
2072
  #
2131
2073
  result = self.safe_value(response, 'result', {})
2132
- tickerList = self.safe_value(result, 'list', [])
2074
+ tickerList = self.safe_list(result, 'list', [])
2133
2075
  return self.parse_tickers(tickerList, parsedSymbols)
2134
2076
 
2135
2077
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -2252,7 +2194,7 @@ class bybit(Exchange, ImplicitAPI):
2252
2194
  # }
2253
2195
  #
2254
2196
  result = self.safe_value(response, 'result', {})
2255
- ohlcvs = self.safe_value(result, 'list', [])
2197
+ ohlcvs = self.safe_list(result, 'list', [])
2256
2198
  return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
2257
2199
 
2258
2200
  def parse_funding_rate(self, ticker, market: Market = None):
@@ -2686,7 +2628,7 @@ class bybit(Exchange, ImplicitAPI):
2686
2628
  # }
2687
2629
  #
2688
2630
  result = self.safe_value(response, 'result', {})
2689
- trades = self.safe_value(result, 'list', [])
2631
+ trades = self.safe_list(result, 'list', [])
2690
2632
  return self.parse_trades(trades, market, since, limit)
2691
2633
 
2692
2634
  def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
@@ -2715,10 +2657,10 @@ class bybit(Exchange, ImplicitAPI):
2715
2657
  # limit: [1, 25]. Default: 1
2716
2658
  request['category'] = 'option'
2717
2659
  elif market['linear']:
2718
- # limit: [1, 200]. Default: 25
2660
+ # limit: [1, 500]. Default: 25
2719
2661
  request['category'] = 'linear'
2720
2662
  elif market['inverse']:
2721
- # limit: [1, 200]. Default: 25
2663
+ # limit: [1, 500]. Default: 25
2722
2664
  request['category'] = 'inverse'
2723
2665
  request['limit'] = limit if (limit is not None) else defaultLimit
2724
2666
  response = self.publicGetV5MarketOrderbook(self.extend(request, params))
@@ -3381,7 +3323,7 @@ class bybit(Exchange, ImplicitAPI):
3381
3323
  # "time": 1672211918471
3382
3324
  # }
3383
3325
  #
3384
- order = self.safe_value(response, 'result', {})
3326
+ order = self.safe_dict(response, 'result', {})
3385
3327
  return self.parse_order(order, market)
3386
3328
 
3387
3329
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}, isUTA=True):
@@ -3762,7 +3704,7 @@ class bybit(Exchange, ImplicitAPI):
3762
3704
  # "tpTriggerBy":"UNKNOWN"
3763
3705
  # }
3764
3706
  #
3765
- order = self.safe_value(response, 'result', {})
3707
+ order = self.safe_dict(response, 'result', {})
3766
3708
  return self.parse_order(order, market)
3767
3709
 
3768
3710
  def edit_usdc_order(self, id, symbol, type, side, amount=None, price=None, params={}):
@@ -3810,7 +3752,7 @@ class bybit(Exchange, ImplicitAPI):
3810
3752
  # "retExtMap": {}
3811
3753
  # }
3812
3754
  #
3813
- result = self.safe_value(response, 'result', {})
3755
+ result = self.safe_dict(response, 'result', {})
3814
3756
  return self.parse_order(result, market)
3815
3757
 
3816
3758
  def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
@@ -3959,7 +3901,7 @@ class bybit(Exchange, ImplicitAPI):
3959
3901
  # "retExtMap": {}
3960
3902
  # }
3961
3903
  #
3962
- result = self.safe_value(response, 'result', {})
3904
+ result = self.safe_dict(response, 'result', {})
3963
3905
  return self.parse_order(result, market)
3964
3906
 
3965
3907
  def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -4017,7 +3959,7 @@ class bybit(Exchange, ImplicitAPI):
4017
3959
  # "time": 1672217377164
4018
3960
  # }
4019
3961
  #
4020
- result = self.safe_value(response, 'result', {})
3962
+ result = self.safe_dict(response, 'result', {})
4021
3963
  return self.parse_order(result, market)
4022
3964
 
4023
3965
  def cancel_orders(self, ids, symbol: Str = None, params={}):
@@ -4288,7 +4230,7 @@ class bybit(Exchange, ImplicitAPI):
4288
4230
  # }
4289
4231
  #
4290
4232
  result = self.safe_value(response, 'result', {})
4291
- data = self.safe_value(result, 'dataList', [])
4233
+ data = self.safe_list(result, 'dataList', [])
4292
4234
  return self.parse_orders(data, market, since, limit)
4293
4235
 
4294
4236
  def fetch_order_classic(self, id: str, symbol: Str = None, params={}):
@@ -4858,7 +4800,7 @@ class bybit(Exchange, ImplicitAPI):
4858
4800
  # }
4859
4801
  #
4860
4802
  result = self.safe_value(response, 'result', {})
4861
- dataList = self.safe_value(result, 'dataList', [])
4803
+ dataList = self.safe_list(result, 'dataList', [])
4862
4804
  return self.parse_trades(dataList, market, since, limit)
4863
4805
 
4864
4806
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -5049,7 +4991,7 @@ class bybit(Exchange, ImplicitAPI):
5049
4991
  chains = self.safe_value(result, 'chains', [])
5050
4992
  chainsIndexedById = self.index_by(chains, 'chain')
5051
4993
  selectedNetworkId = self.select_network_id_from_raw_networks(code, networkCode, chainsIndexedById)
5052
- addressObject = self.safe_value(chainsIndexedById, selectedNetworkId, {})
4994
+ addressObject = self.safe_dict(chainsIndexedById, selectedNetworkId, {})
5053
4995
  return self.parse_deposit_address(addressObject, currency)
5054
4996
 
5055
4997
  def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
@@ -5579,7 +5521,7 @@ class bybit(Exchange, ImplicitAPI):
5579
5521
  # "time": "1666892894902"
5580
5522
  # }
5581
5523
  #
5582
- result = self.safe_value(response, 'result', {})
5524
+ result = self.safe_dict(response, 'result', {})
5583
5525
  return self.parse_transaction(result, currency)
5584
5526
 
5585
5527
  def fetch_position(self, symbol: str, params={}):
@@ -5958,6 +5900,11 @@ class bybit(Exchange, ImplicitAPI):
5958
5900
  timestamp = self.parse8601(self.safe_string(position, 'updated_at'))
5959
5901
  if timestamp is None:
5960
5902
  timestamp = self.safe_integer_n(position, ['updatedTime', 'updatedAt'])
5903
+ tradeMode = self.safe_integer(position, 'tradeMode', 0)
5904
+ marginMode = None
5905
+ if (not self.options['enableUnifiedAccount']) or (self.options['enableUnifiedAccount'] and market['inverse']):
5906
+ # tradeMode would work for classic and UTA(inverse)
5907
+ marginMode = 'isolated' if (tradeMode == 1) else 'cross'
5961
5908
  collateralString = self.safe_string(position, 'positionBalance')
5962
5909
  entryPrice = self.omit_zero(self.safe_string_2(position, 'entryPrice', 'avgPrice'))
5963
5910
  liquidationPrice = self.omit_zero(self.safe_string(position, 'liqPrice'))
@@ -6014,7 +5961,7 @@ class bybit(Exchange, ImplicitAPI):
6014
5961
  'markPrice': self.safe_number(position, 'markPrice'),
6015
5962
  'lastPrice': None,
6016
5963
  'collateral': self.parse_number(collateralString),
6017
- 'marginMode': None,
5964
+ 'marginMode': marginMode,
6018
5965
  'side': side,
6019
5966
  'percentage': None,
6020
5967
  'stopLossPrice': self.safe_number_2(position, 'stop_loss', 'stopLoss'),
@@ -6985,7 +6932,7 @@ class bybit(Exchange, ImplicitAPI):
6985
6932
  # }
6986
6933
  #
6987
6934
  data = self.safe_value(response, 'result', {})
6988
- rows = self.safe_value(data, 'rows', [])
6935
+ rows = self.safe_list(data, 'rows', [])
6989
6936
  return self.parse_deposit_withdraw_fees(rows, codes, 'coin')
6990
6937
 
6991
6938
  def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
ccxt/coincheck.py CHANGED
@@ -469,7 +469,7 @@ class coincheck(Exchange, ImplicitAPI):
469
469
  # ]
470
470
  # }
471
471
  #
472
- transactions = self.safe_value(response, 'data', [])
472
+ transactions = self.safe_list(response, 'data', [])
473
473
  return self.parse_trades(transactions, market, since, limit)
474
474
 
475
475
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
@@ -500,7 +500,7 @@ class coincheck(Exchange, ImplicitAPI):
500
500
  # "created_at": "2021-12-08T14:10:33.000Z"
501
501
  # }
502
502
  #
503
- data = self.safe_value(response, 'data', [])
503
+ data = self.safe_list(response, 'data', [])
504
504
  return self.parse_trades(data, market, since, limit)
505
505
 
506
506
  def fetch_trading_fees(self, params={}):
@@ -636,7 +636,7 @@ class coincheck(Exchange, ImplicitAPI):
636
636
  # }
637
637
  # ]
638
638
  # }
639
- data = self.safe_value(response, 'deposits', [])
639
+ data = self.safe_list(response, 'deposits', [])
640
640
  return self.parse_transactions(data, currency, since, limit, {'type': 'deposit'})
641
641
 
642
642
  def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
@@ -678,7 +678,7 @@ class coincheck(Exchange, ImplicitAPI):
678
678
  # }
679
679
  # ]
680
680
  # }
681
- data = self.safe_value(response, 'data', [])
681
+ data = self.safe_list(response, 'data', [])
682
682
  return self.parse_transactions(data, currency, since, limit, {'type': 'withdrawal'})
683
683
 
684
684
  def parse_transaction_status(self, status):
ccxt/coinex.py CHANGED
@@ -1331,7 +1331,7 @@ class coinex(Exchange, ImplicitAPI):
1331
1331
  # "message": "OK"
1332
1332
  # }
1333
1333
  #
1334
- data = self.safe_value(response, 'data', [])
1334
+ data = self.safe_list(response, 'data', [])
1335
1335
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
1336
1336
 
1337
1337
  def fetch_margin_balance(self, params={}):
@@ -2168,7 +2168,7 @@ class coinex(Exchange, ImplicitAPI):
2168
2168
  #
2169
2169
  # {"code":0,"data":{"status":"success"},"message":"OK"}
2170
2170
  #
2171
- data = self.safe_value(response, 'data', {})
2171
+ data = self.safe_dict(response, 'data', {})
2172
2172
  return self.parse_order(data, market)
2173
2173
 
2174
2174
  def create_orders(self, orders: List[OrderRequest], params={}) -> List[Order]:
@@ -2446,7 +2446,7 @@ class coinex(Exchange, ImplicitAPI):
2446
2446
  # "message": "Success"
2447
2447
  # }
2448
2448
  #
2449
- data = self.safe_value(response, 'data', {})
2449
+ data = self.safe_dict(response, 'data', {})
2450
2450
  return self.parse_order(data, market)
2451
2451
 
2452
2452
  def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -2617,7 +2617,7 @@ class coinex(Exchange, ImplicitAPI):
2617
2617
  #
2618
2618
  # {"code":0,"data":{},"message":"Success"}
2619
2619
  #
2620
- data = self.safe_value(response, 'data')
2620
+ data = self.safe_dict(response, 'data')
2621
2621
  return self.parse_order(data, market)
2622
2622
 
2623
2623
  def cancel_all_orders(self, symbol: Str = None, params={}):
@@ -2798,7 +2798,7 @@ class coinex(Exchange, ImplicitAPI):
2798
2798
  # "message":"OK"
2799
2799
  # }
2800
2800
  #
2801
- data = self.safe_value(response, 'data')
2801
+ data = self.safe_dict(response, 'data')
2802
2802
  return self.parse_order(data, market)
2803
2803
 
2804
2804
  def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -3006,7 +3006,7 @@ class coinex(Exchange, ImplicitAPI):
3006
3006
  #
3007
3007
  tradeRequest = 'records' if (marketType == 'swap') else 'data'
3008
3008
  data = self.safe_value(response, 'data')
3009
- orders = self.safe_value(data, tradeRequest, [])
3009
+ orders = self.safe_list(data, tradeRequest, [])
3010
3010
  return self.parse_orders(orders, market, since, limit)
3011
3011
 
3012
3012
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
@@ -3065,7 +3065,7 @@ class coinex(Exchange, ImplicitAPI):
3065
3065
  # },
3066
3066
  # "message": "Success"
3067
3067
  # }
3068
- data = self.safe_value(response, 'data', {})
3068
+ data = self.safe_dict(response, 'data', {})
3069
3069
  return self.parse_deposit_address(data, currency)
3070
3070
 
3071
3071
  def fetch_deposit_address(self, code: str, params={}):
@@ -3275,7 +3275,7 @@ class coinex(Exchange, ImplicitAPI):
3275
3275
  #
3276
3276
  tradeRequest = 'records' if swap else 'data'
3277
3277
  data = self.safe_value(response, 'data')
3278
- trades = self.safe_value(data, tradeRequest, [])
3278
+ trades = self.safe_list(data, tradeRequest, [])
3279
3279
  return self.parse_trades(trades, market, since, limit)
3280
3280
 
3281
3281
  def fetch_positions(self, symbols: Strings = None, params={}):
@@ -3456,7 +3456,7 @@ class coinex(Exchange, ImplicitAPI):
3456
3456
  # "message": "OK"
3457
3457
  # }
3458
3458
  #
3459
- data = self.safe_value(response, 'data', [])
3459
+ data = self.safe_list(response, 'data', [])
3460
3460
  return self.parse_position(data[0], market)
3461
3461
 
3462
3462
  def parse_position(self, position, market: Market = None):
@@ -3514,8 +3514,7 @@ class coinex(Exchange, ImplicitAPI):
3514
3514
  # }
3515
3515
  #
3516
3516
  marketId = self.safe_string(position, 'market')
3517
- defaultType = self.safe_string(self.options, 'defaultType')
3518
- market = self.safe_market(marketId, market, None, defaultType)
3517
+ market = self.safe_market(marketId, market, None, 'swap')
3519
3518
  symbol = market['symbol']
3520
3519
  positionId = self.safe_integer(position, 'position_id')
3521
3520
  marginModeInteger = self.safe_integer(position, 'type')
@@ -4107,7 +4106,7 @@ class coinex(Exchange, ImplicitAPI):
4107
4106
  # "message": "Ok"
4108
4107
  # }
4109
4108
  #
4110
- transaction = self.safe_value(response, 'data', {})
4109
+ transaction = self.safe_dict(response, 'data', {})
4111
4110
  return self.parse_transaction(transaction, currency)
4112
4111
 
4113
4112
  def parse_transaction_status(self, status):
@@ -4493,7 +4492,7 @@ class coinex(Exchange, ImplicitAPI):
4493
4492
  # }
4494
4493
  #
4495
4494
  data = self.safe_value(response, 'data', {})
4496
- transfers = self.safe_value(data, 'records', [])
4495
+ transfers = self.safe_list(data, 'records', [])
4497
4496
  return self.parse_transfers(transfers, currency, since, limit)
4498
4497
 
4499
4498
  def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
ccxt/coinlist.py CHANGED
@@ -708,7 +708,7 @@ class coinlist(Exchange, ImplicitAPI):
708
708
  # ]
709
709
  # }
710
710
  #
711
- candles = self.safe_value(response, 'candles', [])
711
+ candles = self.safe_list(response, 'candles', [])
712
712
  return self.parse_ohlcvs(candles, market, timeframe, since, limit)
713
713
 
714
714
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -781,7 +781,7 @@ class coinlist(Exchange, ImplicitAPI):
781
781
  # ]
782
782
  # }
783
783
  #
784
- auctions = self.safe_value(response, 'auctions', [])
784
+ auctions = self.safe_list(response, 'auctions', [])
785
785
  return self.parse_trades(auctions, market, since, limit)
786
786
 
787
787
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -1163,7 +1163,7 @@ class coinlist(Exchange, ImplicitAPI):
1163
1163
  # ]
1164
1164
  # }
1165
1165
  #
1166
- fills = self.safe_value(response, 'fills', [])
1166
+ fills = self.safe_list(response, 'fills', [])
1167
1167
  return self.parse_trades(fills, market, since, limit)
1168
1168
 
1169
1169
  def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
@@ -1240,7 +1240,7 @@ class coinlist(Exchange, ImplicitAPI):
1240
1240
  # ]
1241
1241
  # }
1242
1242
  #
1243
- orders = self.safe_value(response, 'orders', [])
1243
+ orders = self.safe_list(response, 'orders', [])
1244
1244
  return self.parse_orders(orders, market, since, limit)
1245
1245
 
1246
1246
  def fetch_order(self, id: str, symbol: Str = None, params={}):
@@ -1458,7 +1458,7 @@ class coinlist(Exchange, ImplicitAPI):
1458
1458
  # "timestamp": "2023-10-26T11:30:55.376Z"
1459
1459
  # }
1460
1460
  #
1461
- order = self.safe_value(response, 'order', {})
1461
+ order = self.safe_dict(response, 'order', {})
1462
1462
  return self.parse_order(order, market)
1463
1463
 
1464
1464
  def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
@@ -1729,7 +1729,7 @@ class coinlist(Exchange, ImplicitAPI):
1729
1729
  # ]
1730
1730
  # }
1731
1731
  #
1732
- transfers = self.safe_value(response, 'transfers', [])
1732
+ transfers = self.safe_list(response, 'transfers', [])
1733
1733
  return self.parse_transfers(transfers, currency, since, limit)
1734
1734
 
1735
1735
  def parse_transfer(self, transfer, currency: Currency = None):
@@ -1889,7 +1889,7 @@ class coinlist(Exchange, ImplicitAPI):
1889
1889
  # "transfer_id": "d4a2d8dd-7def-4545-a062-761683b9aa05"
1890
1890
  # }
1891
1891
  #
1892
- data = self.safe_value(response, 'data', {})
1892
+ data = self.safe_dict(response, 'data', {})
1893
1893
  return self.parse_transaction(data, currency)
1894
1894
 
1895
1895
  def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
ccxt/coinmate.py CHANGED
@@ -395,7 +395,7 @@ class coinmate(Exchange, ImplicitAPI):
395
395
  # }
396
396
  # }
397
397
  #
398
- data = self.safe_value(response, 'data')
398
+ data = self.safe_dict(response, 'data')
399
399
  return self.parse_ticker(data, market)
400
400
 
401
401
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -660,7 +660,7 @@ class coinmate(Exchange, ImplicitAPI):
660
660
  if since is not None:
661
661
  request['timestampFrom'] = since
662
662
  response = self.privatePostTradeHistory(self.extend(request, params))
663
- data = self.safe_value(response, 'data', [])
663
+ data = self.safe_list(response, 'data', [])
664
664
  return self.parse_trades(data, None, since, limit)
665
665
 
666
666
  def parse_trade(self, trade, market: Market = None) -> Trade:
@@ -758,7 +758,7 @@ class coinmate(Exchange, ImplicitAPI):
758
758
  # ]
759
759
  # }
760
760
  #
761
- data = self.safe_value(response, 'data', [])
761
+ data = self.safe_list(response, 'data', [])
762
762
  return self.parse_trades(data, market, since, limit)
763
763
 
764
764
  def fetch_trading_fee(self, symbol: str, params={}):
@@ -985,7 +985,7 @@ class coinmate(Exchange, ImplicitAPI):
985
985
  if symbol:
986
986
  market = self.market(symbol)
987
987
  response = self.privatePostOrderById(self.extend(request, params))
988
- data = self.safe_value(response, 'data')
988
+ data = self.safe_dict(response, 'data')
989
989
  return self.parse_order(data, market)
990
990
 
991
991
  def cancel_order(self, id: str, symbol: Str = None, params={}):