ccxt 4.2.90__py2.py3-none-any.whl → 4.2.92__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.
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.90'
7
+ __version__ = '4.2.92'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2303,7 +2303,7 @@ class Exchange(object):
2303
2303
  def parse_to_int(self, number):
2304
2304
  # Solve Common intmisuse ex: int((since / str(1000)))
2305
2305
  # using a number which is not valid in ts
2306
- stringifiedNumber = str(number)
2306
+ stringifiedNumber = self.number_to_string(number)
2307
2307
  convertedNumber = float(stringifiedNumber)
2308
2308
  return int(convertedNumber)
2309
2309
 
@@ -4426,12 +4426,6 @@ class Exchange(object):
4426
4426
  def common_currency_code(self, code: str):
4427
4427
  if not self.substituteCommonCurrencyCodes:
4428
4428
  return code
4429
- # if the provided code already exists value in commonCurrencies dict, then we should not again transform it
4430
- # more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
4431
- commonCurrencies = list(self.commonCurrencies.values())
4432
- exists = self.in_array(code, commonCurrencies)
4433
- if exists:
4434
- return code
4435
4429
  return self.safe_string(self.commonCurrencies, code, code)
4436
4430
 
4437
4431
  def currency(self, code: str):
@@ -4985,7 +4979,6 @@ class Exchange(object):
4985
4979
  :returns dict: objects with withdraw and deposit fees, indexed by currency codes
4986
4980
  """
4987
4981
  depositWithdrawFees = {}
4988
- codes = self.marketCodes(codes)
4989
4982
  isArray = isinstance(response, list)
4990
4983
  responseKeys = response
4991
4984
  if not isArray:
@@ -5459,7 +5452,7 @@ class Exchange(object):
5459
5452
  return reconstructedDate
5460
5453
 
5461
5454
  def convert_market_id_expire_date(self, date: str):
5462
- # parse 19JAN24 to 240119
5455
+ # parse 03JAN24 to 240103
5463
5456
  monthMappping = {
5464
5457
  'JAN': '01',
5465
5458
  'FEB': '02',
@@ -5474,6 +5467,9 @@ class Exchange(object):
5474
5467
  'NOV': '11',
5475
5468
  'DEC': '12',
5476
5469
  }
5470
+ # if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
5471
+ if len(date) == 6:
5472
+ date = '0' + date
5477
5473
  year = date[0:2]
5478
5474
  monthName = date[2:5]
5479
5475
  month = self.safe_string(monthMappping, monthName)
ccxt/bybit.py CHANGED
@@ -384,6 +384,7 @@ class bybit(Exchange, ImplicitAPI):
384
384
  'v5/broker/earning-record': 5,
385
385
  'v5/broker/earnings-info': 5,
386
386
  'v5/broker/account-info': 5,
387
+ 'v5/broker/asset/query-sub-member-deposit-record': 10,
387
388
  },
388
389
  'post': {
389
390
  # Legacy option USDC
ccxt/coinbase.py CHANGED
@@ -337,6 +337,7 @@ class coinbase(Exchange, ImplicitAPI):
337
337
  'CGLD': 'CELO',
338
338
  },
339
339
  'options': {
340
+ 'brokerId': 'ccxt',
340
341
  'stablePairs': ['BUSD-USD', 'CBETH-ETH', 'DAI-USD', 'GUSD-USD', 'GYEN-USD', 'PAX-USD', 'PAX-USDT', 'USDC-EUR', 'USDC-GBP', 'USDT-EUR', 'USDT-GBP', 'USDT-USD', 'USDT-USDC', 'WBTC-BTC'],
341
342
  'fetchCurrencies': {
342
343
  'expires': 5000,
@@ -2251,8 +2252,9 @@ class coinbase(Exchange, ImplicitAPI):
2251
2252
  """
2252
2253
  self.load_markets()
2253
2254
  market = self.market(symbol)
2255
+ id = self.safe_string(self.options, 'brokerId', 'ccxt')
2254
2256
  request = {
2255
- 'client_order_id': self.uuid(),
2257
+ 'client_order_id': id + '-' + self.uuid(),
2256
2258
  'product_id': market['id'],
2257
2259
  'side': side.upper(),
2258
2260
  }
ccxt/deribit.py CHANGED
@@ -692,117 +692,127 @@ class deribit(Exchange, ImplicitAPI):
692
692
  """
693
693
  retrieves data on all markets for deribit
694
694
  :see: https://docs.deribit.com/#public-get_currencies
695
+ :see: https://docs.deribit.com/#public-get_instruments
695
696
  :param dict [params]: extra parameters specific to the exchange API endpoint
696
697
  :returns dict[]: an array of objects representing market data
697
698
  """
698
- currenciesResponse = self.publicGetGetCurrencies(params)
699
- #
700
- # {
701
- # "jsonrpc": "2.0",
702
- # "result": [
703
- # {
704
- # "withdrawal_priorities": [
705
- # {value: 0.15, name: "very_low"},
706
- # {value: 1.5, name: "very_high"},
707
- # ],
708
- # "withdrawal_fee": 0.0005,
709
- # "min_withdrawal_fee": 0.0005,
710
- # "min_confirmations": 1,
711
- # "fee_precision": 4,
712
- # "currency_long": "Bitcoin",
713
- # "currency": "BTC",
714
- # "coin_type": "BITCOIN"
715
- # }
716
- # ],
717
- # "usIn": 1583761588590479,
718
- # "usOut": 1583761588590544,
719
- # "usDiff": 65,
720
- # "testnet": False
721
- # }
722
- #
723
- parsedMarkets = {}
724
- currenciesResult = self.safe_value(currenciesResponse, 'result', [])
699
+ instrumentsResponses = []
725
700
  result = []
726
- for i in range(0, len(currenciesResult)):
727
- currencyId = self.safe_string(currenciesResult[i], 'currency')
728
- request = {
729
- 'currency': currencyId,
730
- }
731
- instrumentsResponse = self.publicGetGetInstruments(self.extend(request, params))
701
+ parsedMarkets = {}
702
+ fetchAllMarkets = None
703
+ fetchAllMarkets, params = self.handle_option_and_params(params, 'fetchMarkets', 'fetchAllMarkets', True)
704
+ if fetchAllMarkets:
705
+ instrumentsResponse = self.publicGetGetInstruments(params)
706
+ instrumentsResponses.append(instrumentsResponse)
707
+ else:
708
+ currenciesResponse = self.publicGetGetCurrencies(params)
732
709
  #
733
710
  # {
734
- # "jsonrpc":"2.0",
735
- # "result":[
736
- # {
737
- # "tick_size":0.0005,
738
- # "taker_commission":0.0003,
739
- # "strike":52000.0,
740
- # "settlement_period":"month",
741
- # "settlement_currency":"BTC",
742
- # "quote_currency":"BTC",
743
- # "option_type":"put", # put, call
744
- # "min_trade_amount":0.1,
745
- # "maker_commission":0.0003,
746
- # "kind":"option",
747
- # "is_active":true,
748
- # "instrument_name":"BTC-24JUN22-52000-P",
749
- # "expiration_timestamp":1656057600000,
750
- # "creation_timestamp":1648199543000,
751
- # "counter_currency":"USD",
752
- # "contract_size":1.0,
753
- # "block_trade_commission":0.0003,
754
- # "base_currency":"BTC"
755
- # },
711
+ # "jsonrpc": "2.0",
712
+ # "result": [
756
713
  # {
757
- # "tick_size":0.5,
758
- # "taker_commission":0.0005,
759
- # "settlement_period":"month", # month, week
760
- # "settlement_currency":"BTC",
761
- # "quote_currency":"USD",
762
- # "min_trade_amount":10.0,
763
- # "max_liquidation_commission":0.0075,
764
- # "max_leverage":50,
765
- # "maker_commission":0.0,
766
- # "kind":"future",
767
- # "is_active":true,
768
- # "instrument_name":"BTC-27MAY22",
769
- # "future_type":"reversed",
770
- # "expiration_timestamp":1653638400000,
771
- # "creation_timestamp":1648195209000,
772
- # "counter_currency":"USD",
773
- # "contract_size":10.0,
774
- # "block_trade_commission":0.0001,
775
- # "base_currency":"BTC"
776
- # },
777
- # {
778
- # "tick_size":0.5,
779
- # "taker_commission":0.0005,
780
- # "settlement_period":"perpetual",
781
- # "settlement_currency":"BTC",
782
- # "quote_currency":"USD",
783
- # "min_trade_amount":10.0,
784
- # "max_liquidation_commission":0.0075,
785
- # "max_leverage":50,
786
- # "maker_commission":0.0,
787
- # "kind":"future",
788
- # "is_active":true,
789
- # "instrument_name":"BTC-PERPETUAL",
790
- # "future_type":"reversed",
791
- # "expiration_timestamp":32503708800000,
792
- # "creation_timestamp":1534242287000,
793
- # "counter_currency":"USD",
794
- # "contract_size":10.0,
795
- # "block_trade_commission":0.0001,
796
- # "base_currency":"BTC"
797
- # },
714
+ # "withdrawal_priorities": [
715
+ # {value: 0.15, name: "very_low"},
716
+ # {value: 1.5, name: "very_high"},
717
+ # ],
718
+ # "withdrawal_fee": 0.0005,
719
+ # "min_withdrawal_fee": 0.0005,
720
+ # "min_confirmations": 1,
721
+ # "fee_precision": 4,
722
+ # "currency_long": "Bitcoin",
723
+ # "currency": "BTC",
724
+ # "coin_type": "BITCOIN"
725
+ # }
798
726
  # ],
799
- # "usIn":1648691472831791,
800
- # "usOut":1648691472831896,
801
- # "usDiff":105,
802
- # "testnet":false
727
+ # "usIn": 1583761588590479,
728
+ # "usOut": 1583761588590544,
729
+ # "usDiff": 65,
730
+ # "testnet": False
803
731
  # }
804
732
  #
805
- instrumentsResult = self.safe_value(instrumentsResponse, 'result', [])
733
+ currenciesResult = self.safe_value(currenciesResponse, 'result', [])
734
+ for i in range(0, len(currenciesResult)):
735
+ currencyId = self.safe_string(currenciesResult[i], 'currency')
736
+ request = {
737
+ 'currency': currencyId,
738
+ }
739
+ instrumentsResponse = self.publicGetGetInstruments(self.extend(request, params))
740
+ #
741
+ # {
742
+ # "jsonrpc":"2.0",
743
+ # "result":[
744
+ # {
745
+ # "tick_size":0.0005,
746
+ # "taker_commission":0.0003,
747
+ # "strike":52000.0,
748
+ # "settlement_period":"month",
749
+ # "settlement_currency":"BTC",
750
+ # "quote_currency":"BTC",
751
+ # "option_type":"put", # put, call
752
+ # "min_trade_amount":0.1,
753
+ # "maker_commission":0.0003,
754
+ # "kind":"option",
755
+ # "is_active":true,
756
+ # "instrument_name":"BTC-24JUN22-52000-P",
757
+ # "expiration_timestamp":1656057600000,
758
+ # "creation_timestamp":1648199543000,
759
+ # "counter_currency":"USD",
760
+ # "contract_size":1.0,
761
+ # "block_trade_commission":0.0003,
762
+ # "base_currency":"BTC"
763
+ # },
764
+ # {
765
+ # "tick_size":0.5,
766
+ # "taker_commission":0.0005,
767
+ # "settlement_period":"month", # month, week
768
+ # "settlement_currency":"BTC",
769
+ # "quote_currency":"USD",
770
+ # "min_trade_amount":10.0,
771
+ # "max_liquidation_commission":0.0075,
772
+ # "max_leverage":50,
773
+ # "maker_commission":0.0,
774
+ # "kind":"future",
775
+ # "is_active":true,
776
+ # "instrument_name":"BTC-27MAY22",
777
+ # "future_type":"reversed",
778
+ # "expiration_timestamp":1653638400000,
779
+ # "creation_timestamp":1648195209000,
780
+ # "counter_currency":"USD",
781
+ # "contract_size":10.0,
782
+ # "block_trade_commission":0.0001,
783
+ # "base_currency":"BTC"
784
+ # },
785
+ # {
786
+ # "tick_size":0.5,
787
+ # "taker_commission":0.0005,
788
+ # "settlement_period":"perpetual",
789
+ # "settlement_currency":"BTC",
790
+ # "quote_currency":"USD",
791
+ # "min_trade_amount":10.0,
792
+ # "max_liquidation_commission":0.0075,
793
+ # "max_leverage":50,
794
+ # "maker_commission":0.0,
795
+ # "kind":"future",
796
+ # "is_active":true,
797
+ # "instrument_name":"BTC-PERPETUAL",
798
+ # "future_type":"reversed",
799
+ # "expiration_timestamp":32503708800000,
800
+ # "creation_timestamp":1534242287000,
801
+ # "counter_currency":"USD",
802
+ # "contract_size":10.0,
803
+ # "block_trade_commission":0.0001,
804
+ # "base_currency":"BTC"
805
+ # },
806
+ # ],
807
+ # "usIn":1648691472831791,
808
+ # "usOut":1648691472831896,
809
+ # "usDiff":105,
810
+ # "testnet":false
811
+ # }
812
+ #
813
+ instrumentsResponses.append(instrumentsResponse)
814
+ for i in range(0, len(instrumentsResponses)):
815
+ instrumentsResult = self.safe_value(instrumentsResponses[i], 'result', [])
806
816
  for k in range(0, len(instrumentsResult)):
807
817
  market = instrumentsResult[k]
808
818
  kind = self.safe_string(market, 'kind')
ccxt/gemini.py CHANGED
@@ -444,6 +444,7 @@ class gemini(Exchange, ImplicitAPI):
444
444
  # '</tr>'
445
445
  # ]
446
446
  marketId = cells[0].replace('<td>', '')
447
+ marketId = marketId.replace('*', '')
447
448
  # base = self.safe_currency_code(baseId)
448
449
  minAmountString = cells[1].replace('<td>', '')
449
450
  minAmountParts = minAmountString.split(' ')
ccxt/kraken.py CHANGED
@@ -609,9 +609,7 @@ class kraken(Exchange, ImplicitAPI):
609
609
  if currencyId is not None:
610
610
  if len(currencyId) > 3:
611
611
  if (currencyId.find('X') == 0) or (currencyId.find('Z') == 0):
612
- if currencyId.find('.') > 0:
613
- return super(kraken, self).safe_currency(currencyId, currency)
614
- else:
612
+ if not (currencyId.find('.') > 0):
615
613
  currencyId = currencyId[1:]
616
614
  return super(kraken, self).safe_currency(currencyId, currency)
617
615
 
@@ -653,8 +651,13 @@ class kraken(Exchange, ImplicitAPI):
653
651
  # {
654
652
  # "error": [],
655
653
  # "result": {
656
- # "ADA": {"aclass": "currency", "altname": "ADA", "decimals": 8, "display_decimals": 6},
657
- # "BCH": {"aclass": "currency", "altname": "BCH", "decimals": 10, "display_decimals": 5},
654
+ # "BCH": {
655
+ # "aclass": "currency",
656
+ # "altname": "BCH",
657
+ # "decimals": 10,
658
+ # "display_decimals": 5
659
+ # "status": "enabled",
660
+ # },
658
661
  # ...
659
662
  # },
660
663
  # }
@@ -669,15 +672,15 @@ class kraken(Exchange, ImplicitAPI):
669
672
  # see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
670
673
  # to add support for multiple withdrawal/deposit methods and
671
674
  # differentiated fees for each particular method
672
- code = self.safe_currency_code(self.safe_string(currency, 'altname'))
675
+ code = self.safe_currency_code(id)
673
676
  precision = self.parse_number(self.parse_precision(self.safe_string(currency, 'decimals')))
674
677
  # assumes all currencies are active except those listed above
675
- active = not self.in_array(code, self.options['inactiveCurrencies'])
678
+ active = self.safe_string(currency, 'status') == 'enabled'
676
679
  result[code] = {
677
680
  'id': id,
678
681
  'code': code,
679
682
  'info': currency,
680
- 'name': code,
683
+ 'name': self.safe_string(currency, 'altname'),
681
684
  'active': active,
682
685
  'deposit': None,
683
686
  'withdraw': None,
@@ -2526,15 +2529,15 @@ class kraken(Exchange, ImplicitAPI):
2526
2529
  """
2527
2530
  fetch all open positions
2528
2531
  :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
2529
- :param str[]|None symbols: not used by kraken fetchPositions()
2532
+ :param str[] [symbols]: not used by kraken fetchPositions()
2530
2533
  :param dict [params]: extra parameters specific to the exchange API endpoint
2531
2534
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
2532
2535
  """
2533
2536
  self.load_markets()
2534
2537
  request = {
2535
2538
  # 'txid': 'comma delimited list of transaction ids to restrict output to',
2536
- # 'docalcs': False, # whether or not to include profit/loss calculations
2537
- # 'consolidation': 'market', # what to consolidate the positions data around, market will consolidate positions based on market pair
2539
+ 'docalcs': 'true', # whether or not to include profit/loss calculations
2540
+ 'consolidation': 'market', # what to consolidate the positions data around, market will consolidate positions based on market pair
2538
2541
  }
2539
2542
  response = self.privatePostOpenPositions(self.extend(request, params))
2540
2543
  #
@@ -2582,9 +2585,58 @@ class kraken(Exchange, ImplicitAPI):
2582
2585
  # ]
2583
2586
  # }
2584
2587
  #
2585
- result = self.safe_value(response, 'result')
2586
- # todo unify parsePosition/parsePositions
2587
- return result
2588
+ symbols = self.market_symbols(symbols)
2589
+ result = self.safe_list(response, 'result')
2590
+ results = self.parse_positions(result, symbols)
2591
+ return self.filter_by_array_positions(results, 'symbol', symbols, False)
2592
+
2593
+ def parse_position(self, position, market: Market = None):
2594
+ #
2595
+ # {
2596
+ # "pair": "ETHUSDT",
2597
+ # "positions": "1",
2598
+ # "type": "buy",
2599
+ # "leverage": "2.00000",
2600
+ # "cost": "28.49800",
2601
+ # "fee": "0.07979",
2602
+ # "vol": "0.02000000",
2603
+ # "vol_closed": "0.00000000",
2604
+ # "margin": "14.24900"
2605
+ # }
2606
+ #
2607
+ marketId = self.safe_string(position, 'pair')
2608
+ rawSide = self.safe_string(position, 'type')
2609
+ side = 'long' if (rawSide == 'buy') else 'short'
2610
+ return self.safe_position({
2611
+ 'info': position,
2612
+ 'id': None,
2613
+ 'symbol': self.safe_symbol(marketId, market),
2614
+ 'notional': None,
2615
+ 'marginMode': None,
2616
+ 'liquidationPrice': None,
2617
+ 'entryPrice': None,
2618
+ 'unrealizedPnl': self.safe_number(position, 'net'),
2619
+ 'realizedPnl': None,
2620
+ 'percentage': None,
2621
+ 'contracts': self.safe_number(position, 'vol'),
2622
+ 'contractSize': None,
2623
+ 'markPrice': None,
2624
+ 'lastPrice': None,
2625
+ 'side': side,
2626
+ 'hedged': None,
2627
+ 'timestamp': None,
2628
+ 'datetime': None,
2629
+ 'lastUpdateTimestamp': None,
2630
+ 'maintenanceMargin': None,
2631
+ 'maintenanceMarginPercentage': None,
2632
+ 'collateral': None,
2633
+ 'initialMargin': self.safe_number(position, 'margin'),
2634
+ 'initialMarginPercentage': None,
2635
+ 'leverage': self.safe_number(position, 'leverage'),
2636
+ 'marginRatio': None,
2637
+ 'stopLossPrice': None,
2638
+ 'takeProfitPrice': None,
2639
+ })
2588
2640
 
2589
2641
  def parse_account_type(self, account):
2590
2642
  accountByType = {
ccxt/okx.py CHANGED
@@ -1235,7 +1235,7 @@ class okx(Exchange, ImplicitAPI):
1235
1235
  # ]
1236
1236
  # }
1237
1237
  #
1238
- data = self.safe_value(response, 'data', [])
1238
+ data = self.safe_list(response, 'data', [])
1239
1239
  dataLength = len(data)
1240
1240
  update = {
1241
1241
  'updated': None,
@@ -1276,8 +1276,8 @@ class okx(Exchange, ImplicitAPI):
1276
1276
  # "msg": ""
1277
1277
  # }
1278
1278
  #
1279
- data = self.safe_value(response, 'data', [])
1280
- first = self.safe_value(data, 0, {})
1279
+ data = self.safe_list(response, 'data', [])
1280
+ first = self.safe_dict(data, 0, {})
1281
1281
  return self.safe_integer(first, 'ts')
1282
1282
 
1283
1283
  def fetch_accounts(self, params={}) -> List[Account]:
@@ -1307,7 +1307,7 @@ class okx(Exchange, ImplicitAPI):
1307
1307
  # "msg": ""
1308
1308
  # }
1309
1309
  #
1310
- data = self.safe_value(response, 'data', [])
1310
+ data = self.safe_list(response, 'data', [])
1311
1311
  result = []
1312
1312
  for i in range(0, len(data)):
1313
1313
  account = data[i]
@@ -1329,7 +1329,7 @@ class okx(Exchange, ImplicitAPI):
1329
1329
  :param dict [params]: extra parameters specific to the exchange API endpoint
1330
1330
  :returns dict[]: an array of objects representing market data
1331
1331
  """
1332
- types = self.safe_value(self.options, 'fetchMarkets')
1332
+ types = self.safe_list(self.options, 'fetchMarkets', [])
1333
1333
  promises = []
1334
1334
  result = []
1335
1335
  for i in range(0, len(types)):
@@ -1426,7 +1426,7 @@ class okx(Exchange, ImplicitAPI):
1426
1426
  symbol = symbol + '-' + ymd + '-' + strikePrice + '-' + optionType
1427
1427
  optionType = 'put' if (optionType == 'P') else 'call'
1428
1428
  tickSize = self.safe_string(market, 'tickSz')
1429
- fees = self.safe_value_2(self.fees, type, 'trading', {})
1429
+ fees = self.safe_dict_2(self.fees, type, 'trading', {})
1430
1430
  maxLeverage = self.safe_string(market, 'lever', '1')
1431
1431
  maxLeverage = Precise.string_max(maxLeverage, '1')
1432
1432
  maxSpotCost = self.safe_number(market, 'maxMktSz')
@@ -1485,7 +1485,7 @@ class okx(Exchange, ImplicitAPI):
1485
1485
  'instType': self.convert_to_instrument_type(type),
1486
1486
  }
1487
1487
  if type == 'option':
1488
- optionsUnderlying = self.safe_value(self.options, 'defaultUnderlying', ['BTC-USD', 'ETH-USD'])
1488
+ optionsUnderlying = self.safe_list(self.options, 'defaultUnderlying', ['BTC-USD', 'ETH-USD'])
1489
1489
  promises = []
1490
1490
  for i in range(0, len(optionsUnderlying)):
1491
1491
  underlying = optionsUnderlying[i]
@@ -1494,8 +1494,8 @@ class okx(Exchange, ImplicitAPI):
1494
1494
  promisesResult = promises
1495
1495
  markets = []
1496
1496
  for i in range(0, len(promisesResult)):
1497
- res = self.safe_value(promisesResult, i, {})
1498
- options = self.safe_value(res, 'data', [])
1497
+ res = self.safe_dict(promisesResult, i, {})
1498
+ options = self.safe_list(res, 'data', [])
1499
1499
  markets = self.array_concat(markets, options)
1500
1500
  return self.parse_markets(markets)
1501
1501
  response = self.publicGetPublicInstruments(self.extend(request, params))
@@ -1532,7 +1532,7 @@ class okx(Exchange, ImplicitAPI):
1532
1532
  # "msg": ""
1533
1533
  # }
1534
1534
  #
1535
- dataResponse = self.safe_value(response, 'data', [])
1535
+ dataResponse = self.safe_list(response, 'data', [])
1536
1536
  return self.parse_markets(dataResponse)
1537
1537
 
1538
1538
  def safe_network(self, networkId):
@@ -1606,7 +1606,7 @@ class okx(Exchange, ImplicitAPI):
1606
1606
  # "msg": ""
1607
1607
  # }
1608
1608
  #
1609
- data = self.safe_value(response, 'data', [])
1609
+ data = self.safe_list(response, 'data', [])
1610
1610
  result = {}
1611
1611
  dataByCurrencyId = self.group_by(data, 'ccy')
1612
1612
  currencyIds = list(dataByCurrencyId.keys())
@@ -1622,11 +1622,11 @@ class okx(Exchange, ImplicitAPI):
1622
1622
  maxPrecision = None
1623
1623
  for j in range(0, len(chains)):
1624
1624
  chain = chains[j]
1625
- canDeposit = self.safe_value(chain, 'canDep')
1625
+ canDeposit = self.safe_bool(chain, 'canDep')
1626
1626
  depositEnabled = canDeposit if (canDeposit) else depositEnabled
1627
- canWithdraw = self.safe_value(chain, 'canWd')
1627
+ canWithdraw = self.safe_bool(chain, 'canWd')
1628
1628
  withdrawEnabled = canWithdraw if (canWithdraw) else withdrawEnabled
1629
- canInternal = self.safe_value(chain, 'canInternal')
1629
+ canInternal = self.safe_bool(chain, 'canInternal')
1630
1630
  active = True if (canDeposit and canWithdraw and canInternal) else False
1631
1631
  currencyActive = active if (active) else currencyActive
1632
1632
  networkId = self.safe_string(chain, 'chain')
@@ -1655,7 +1655,7 @@ class okx(Exchange, ImplicitAPI):
1655
1655
  },
1656
1656
  'info': chain,
1657
1657
  }
1658
- firstChain = self.safe_value(chains, 0)
1658
+ firstChain = self.safe_dict(chains, 0, {})
1659
1659
  result[code] = {
1660
1660
  'info': None,
1661
1661
  'code': code,
@@ -1724,8 +1724,8 @@ class okx(Exchange, ImplicitAPI):
1724
1724
  # ]
1725
1725
  # }
1726
1726
  #
1727
- data = self.safe_value(response, 'data', [])
1728
- first = self.safe_value(data, 0, {})
1727
+ data = self.safe_list(response, 'data', [])
1728
+ first = self.safe_dict(data, 0, {})
1729
1729
  timestamp = self.safe_integer(first, 'ts')
1730
1730
  return self.parse_order_book(first, symbol, timestamp)
1731
1731
 
@@ -1824,7 +1824,7 @@ class okx(Exchange, ImplicitAPI):
1824
1824
  # ]
1825
1825
  # }
1826
1826
  #
1827
- data = self.safe_value(response, 'data', [])
1827
+ data = self.safe_list(response, 'data', [])
1828
1828
  first = self.safe_dict(data, 0, {})
1829
1829
  return self.parse_ticker(first, market)
1830
1830
 
@@ -1845,7 +1845,7 @@ class okx(Exchange, ImplicitAPI):
1845
1845
  'instType': self.convert_to_instrument_type(marketType),
1846
1846
  }
1847
1847
  if marketType == 'option':
1848
- defaultUnderlying = self.safe_value(self.options, 'defaultUnderlying', 'BTC-USD')
1848
+ defaultUnderlying = self.safe_string(self.options, 'defaultUnderlying', 'BTC-USD')
1849
1849
  currencyId = self.safe_string_2(params, 'uly', 'marketId', defaultUnderlying)
1850
1850
  if currencyId is None:
1851
1851
  raise ArgumentsRequired(self.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets')
@@ -2094,7 +2094,7 @@ class okx(Exchange, ImplicitAPI):
2094
2094
  return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 200)
2095
2095
  price = self.safe_string(params, 'price')
2096
2096
  params = self.omit(params, 'price')
2097
- options = self.safe_value(self.options, 'fetchOHLCV', {})
2097
+ options = self.safe_dict(self.options, 'fetchOHLCV', {})
2098
2098
  timezone = self.safe_string(options, 'timezone', 'UTC')
2099
2099
  if limit is None:
2100
2100
  limit = 100 # default 100, max 100
@@ -2207,7 +2207,7 @@ class okx(Exchange, ImplicitAPI):
2207
2207
  # }
2208
2208
  #
2209
2209
  rates = []
2210
- data = self.safe_value(response, 'data', [])
2210
+ data = self.safe_list(response, 'data', [])
2211
2211
  for i in range(0, len(data)):
2212
2212
  rate = data[i]
2213
2213
  timestamp = self.safe_integer(rate, 'fundingTime')
@@ -2229,10 +2229,10 @@ class okx(Exchange, ImplicitAPI):
2229
2229
 
2230
2230
  def parse_trading_balance(self, response):
2231
2231
  result = {'info': response}
2232
- data = self.safe_value(response, 'data', [])
2233
- first = self.safe_value(data, 0, {})
2232
+ data = self.safe_list(response, 'data', [])
2233
+ first = self.safe_dict(data, 0, {})
2234
2234
  timestamp = self.safe_integer(first, 'uTime')
2235
- details = self.safe_value(first, 'details', [])
2235
+ details = self.safe_list(first, 'details', [])
2236
2236
  for i in range(0, len(details)):
2237
2237
  balance = details[i]
2238
2238
  currencyId = self.safe_string(balance, 'ccy')
@@ -2254,7 +2254,7 @@ class okx(Exchange, ImplicitAPI):
2254
2254
 
2255
2255
  def parse_funding_balance(self, response):
2256
2256
  result = {'info': response}
2257
- data = self.safe_value(response, 'data', [])
2257
+ data = self.safe_list(response, 'data', [])
2258
2258
  for i in range(0, len(data)):
2259
2259
  balance = data[i]
2260
2260
  currencyId = self.safe_string(balance, 'ccy')
@@ -2332,8 +2332,8 @@ class okx(Exchange, ImplicitAPI):
2332
2332
  # "msg": ""
2333
2333
  # }
2334
2334
  #
2335
- data = self.safe_value(response, 'data', [])
2336
- first = self.safe_value(data, 0, {})
2335
+ data = self.safe_list(response, 'data', [])
2336
+ first = self.safe_dict(data, 0, {})
2337
2337
  return self.parse_trading_fee(first, market)
2338
2338
 
2339
2339
  def fetch_balance(self, params={}) -> Balances:
@@ -2747,8 +2747,8 @@ class okx(Exchange, ImplicitAPI):
2747
2747
  response = self.privatePostTradeOrderAlgo(request)
2748
2748
  else:
2749
2749
  response = self.privatePostTradeBatchOrders(request)
2750
- data = self.safe_value(response, 'data', [])
2751
- first = self.safe_value(data, 0)
2750
+ data = self.safe_list(response, 'data', [])
2751
+ first = self.safe_dict(data, 0, {})
2752
2752
  order = self.parse_order(first, market)
2753
2753
  order['type'] = type
2754
2754
  order['side'] = side
@@ -4127,7 +4127,7 @@ class okx(Exchange, ImplicitAPI):
4127
4127
  # ]
4128
4128
  # }
4129
4129
  #
4130
- data = self.safe_value(response, 'data', [])
4130
+ data = self.safe_list(response, 'data', [])
4131
4131
  return self.parse_ledger(data, currency, since, limit)
4132
4132
 
4133
4133
  def parse_ledger_entry_type(self, type):