ccxt 4.2.69__py2.py3-none-any.whl → 4.2.71__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (105) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/coinbase.py +2 -0
  3. ccxt/ascendex.py +1 -1
  4. ccxt/async_support/__init__.py +1 -1
  5. ccxt/async_support/ascendex.py +1 -1
  6. ccxt/async_support/base/exchange.py +1 -1
  7. ccxt/async_support/bigone.py +1 -1
  8. ccxt/async_support/binance.py +1 -1
  9. ccxt/async_support/bingx.py +1 -1
  10. ccxt/async_support/bitfinex.py +1 -1
  11. ccxt/async_support/bitfinex2.py +1 -1
  12. ccxt/async_support/bitget.py +13 -7
  13. ccxt/async_support/bitmart.py +1 -1
  14. ccxt/async_support/bitmex.py +1 -1
  15. ccxt/async_support/bitrue.py +1 -1
  16. ccxt/async_support/bitstamp.py +1 -1
  17. ccxt/async_support/bl3p.py +1 -1
  18. ccxt/async_support/blofin.py +1 -1
  19. ccxt/async_support/btcalpha.py +1 -1
  20. ccxt/async_support/bybit.py +1 -1
  21. ccxt/async_support/coinbase.py +104 -89
  22. ccxt/async_support/coinex.py +1 -1
  23. ccxt/async_support/coinlist.py +1 -1
  24. ccxt/async_support/coinmetro.py +1 -1
  25. ccxt/async_support/deribit.py +1 -1
  26. ccxt/async_support/digifinex.py +3 -2
  27. ccxt/async_support/gate.py +163 -2
  28. ccxt/async_support/hitbtc.py +1 -1
  29. ccxt/async_support/htx.py +1 -1
  30. ccxt/async_support/hyperliquid.py +2 -2
  31. ccxt/async_support/kraken.py +2 -1
  32. ccxt/async_support/krakenfutures.py +1 -1
  33. ccxt/async_support/kucoin.py +1 -1
  34. ccxt/async_support/kucoinfutures.py +1 -1
  35. ccxt/async_support/latoken.py +1 -1
  36. ccxt/async_support/lykke.py +1 -1
  37. ccxt/async_support/mexc.py +10 -1
  38. ccxt/async_support/ndax.py +1 -1
  39. ccxt/async_support/novadax.py +1 -1
  40. ccxt/async_support/okcoin.py +1 -1
  41. ccxt/async_support/okx.py +1 -1
  42. ccxt/async_support/paymium.py +1 -1
  43. ccxt/async_support/phemex.py +1 -1
  44. ccxt/async_support/poloniex.py +1 -1
  45. ccxt/async_support/wazirx.py +1 -1
  46. ccxt/async_support/whitebit.py +1 -1
  47. ccxt/async_support/woo.py +1 -1
  48. ccxt/async_support/zonda.py +1 -1
  49. ccxt/base/exchange.py +1 -1
  50. ccxt/bigone.py +1 -1
  51. ccxt/binance.py +1 -1
  52. ccxt/bingx.py +1 -1
  53. ccxt/bitfinex.py +1 -1
  54. ccxt/bitfinex2.py +1 -1
  55. ccxt/bitget.py +13 -7
  56. ccxt/bitmart.py +1 -1
  57. ccxt/bitmex.py +1 -1
  58. ccxt/bitrue.py +1 -1
  59. ccxt/bitstamp.py +1 -1
  60. ccxt/bl3p.py +1 -1
  61. ccxt/blofin.py +1 -1
  62. ccxt/btcalpha.py +1 -1
  63. ccxt/bybit.py +1 -1
  64. ccxt/coinbase.py +104 -89
  65. ccxt/coinex.py +1 -1
  66. ccxt/coinlist.py +1 -1
  67. ccxt/coinmetro.py +1 -1
  68. ccxt/deribit.py +1 -1
  69. ccxt/digifinex.py +3 -2
  70. ccxt/gate.py +163 -2
  71. ccxt/hitbtc.py +1 -1
  72. ccxt/htx.py +1 -1
  73. ccxt/hyperliquid.py +2 -2
  74. ccxt/kraken.py +2 -1
  75. ccxt/krakenfutures.py +1 -1
  76. ccxt/kucoin.py +1 -1
  77. ccxt/kucoinfutures.py +1 -1
  78. ccxt/latoken.py +1 -1
  79. ccxt/lykke.py +1 -1
  80. ccxt/mexc.py +10 -1
  81. ccxt/ndax.py +1 -1
  82. ccxt/novadax.py +1 -1
  83. ccxt/okcoin.py +1 -1
  84. ccxt/okx.py +1 -1
  85. ccxt/paymium.py +1 -1
  86. ccxt/phemex.py +1 -1
  87. ccxt/poloniex.py +1 -1
  88. ccxt/pro/__init__.py +3 -1
  89. ccxt/pro/hyperliquid.py +524 -0
  90. ccxt/pro/luno.py +1 -1
  91. ccxt/test/base/test_balance.py +3 -0
  92. ccxt/test/base/test_market.py +1 -1
  93. ccxt/test/base/test_order_book.py +1 -0
  94. ccxt/test/base/test_shared_methods.py +12 -2
  95. ccxt/test/base/test_trade.py +1 -1
  96. ccxt/test/test_async.py +78 -39
  97. ccxt/test/test_sync.py +78 -39
  98. ccxt/wazirx.py +1 -1
  99. ccxt/whitebit.py +1 -1
  100. ccxt/woo.py +1 -1
  101. ccxt/zonda.py +1 -1
  102. {ccxt-4.2.69.dist-info → ccxt-4.2.71.dist-info}/METADATA +5 -5
  103. {ccxt-4.2.69.dist-info → ccxt-4.2.71.dist-info}/RECORD +105 -104
  104. {ccxt-4.2.69.dist-info → ccxt-4.2.71.dist-info}/WHEEL +0 -0
  105. {ccxt-4.2.69.dist-info → ccxt-4.2.71.dist-info}/top_level.txt +0 -0
ccxt/bybit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Market, Order, OrderBook, OrderRequest, 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
ccxt/coinbase.py CHANGED
@@ -236,6 +236,8 @@ class coinbase(Exchange, ImplicitAPI):
236
236
  'brokerage/intx/portfolio/{portfolio_uuid}': 1,
237
237
  'brokerage/intx/positions/{portfolio_uuid}': 1,
238
238
  'brokerage/intx/positions/{portfolio_uuid}/{symbol}': 1,
239
+ 'brokerage/payment_methods': 1,
240
+ 'brokerage/payment_methods/{payment_method_id}': 1,
239
241
  },
240
242
  'post': {
241
243
  'brokerage/orders': 1,
@@ -386,7 +388,7 @@ class coinbase(Exchange, ImplicitAPI):
386
388
  # }
387
389
  # }
388
390
  #
389
- response = self.safe_value(response, 'data', {})
391
+ response = self.safe_dict(response, 'data', {})
390
392
  else:
391
393
  response = self.v3PublicGetBrokerageTime(params)
392
394
  #
@@ -472,7 +474,7 @@ class coinbase(Exchange, ImplicitAPI):
472
474
  accounts = self.safe_list(response, 'data', [])
473
475
  length = len(accounts)
474
476
  lastIndex = length - 1
475
- last = self.safe_value(accounts, lastIndex)
477
+ last = self.safe_dict(accounts, lastIndex)
476
478
  if (cursor is not None) and (cursor != ''):
477
479
  last['next_starting_after'] = cursor
478
480
  accounts[lastIndex] = last
@@ -521,7 +523,7 @@ class coinbase(Exchange, ImplicitAPI):
521
523
  accounts = self.safe_list(response, 'accounts', [])
522
524
  length = len(accounts)
523
525
  lastIndex = length - 1
524
- last = self.safe_value(accounts, lastIndex)
526
+ last = self.safe_dict(accounts, lastIndex)
525
527
  cursor = self.safe_string(response, 'cursor')
526
528
  if (cursor is not None) and (cursor != ''):
527
529
  last['cursor'] = cursor
@@ -584,9 +586,9 @@ class coinbase(Exchange, ImplicitAPI):
584
586
  # }
585
587
  # }
586
588
  #
587
- active = self.safe_value(account, 'active')
589
+ active = self.safe_bool(account, 'active')
588
590
  currencyIdV3 = self.safe_string(account, 'currency')
589
- currency = self.safe_value(account, 'currency', {})
591
+ currency = self.safe_dict(account, 'currency', {})
590
592
  currencyId = self.safe_string(currency, 'code', currencyIdV3)
591
593
  typeV3 = self.safe_string(account, 'name')
592
594
  typeV2 = self.safe_string(account, 'type')
@@ -657,7 +659,7 @@ class coinbase(Exchange, ImplicitAPI):
657
659
  # }
658
660
  # }
659
661
  #
660
- data = self.safe_value(response, 'data', {})
662
+ data = self.safe_dict(response, 'data', {})
661
663
  tag = self.safe_string(data, 'destination_tag')
662
664
  address = self.safe_string(data, 'address')
663
665
  return {
@@ -863,21 +865,21 @@ class coinbase(Exchange, ImplicitAPI):
863
865
  amountAndCurrencyObject = None
864
866
  feeObject = None
865
867
  if transactionType == 'send':
866
- network = self.safe_value(transaction, 'network', {})
867
- amountAndCurrencyObject = self.safe_value(network, 'transaction_amount', {})
868
- feeObject = self.safe_value(network, 'transaction_fee', {})
868
+ network = self.safe_dict(transaction, 'network', {})
869
+ amountAndCurrencyObject = self.safe_dict(network, 'transaction_amount', {})
870
+ feeObject = self.safe_dict(network, 'transaction_fee', {})
869
871
  else:
870
- amountAndCurrencyObject = self.safe_value(transaction, 'subtotal', {})
871
- feeObject = self.safe_value(transaction, 'fee', {})
872
+ amountAndCurrencyObject = self.safe_dict(transaction, 'subtotal', {})
873
+ feeObject = self.safe_dict(transaction, 'fee', {})
872
874
  status = self.parse_transaction_status(self.safe_string(transaction, 'status'))
873
875
  if status is None:
874
- committed = self.safe_value(transaction, 'committed')
876
+ committed = self.safe_bool(transaction, 'committed')
875
877
  status = 'ok' if committed else 'pending'
876
878
  id = self.safe_string(transaction, 'id')
877
879
  currencyId = self.safe_string(amountAndCurrencyObject, 'currency')
878
880
  feeCurrencyId = self.safe_string(feeObject, 'currency')
879
- datetime = self.safe_value(transaction, 'created_at')
880
- toObject = self.safe_value(transaction, 'to', {})
881
+ datetime = self.safe_string(transaction, 'created_at')
882
+ toObject = self.safe_dict(transaction, 'to', {})
881
883
  toAddress = self.safe_string(toObject, 'address')
882
884
  return {
883
885
  'info': transaction,
@@ -896,7 +898,7 @@ class coinbase(Exchange, ImplicitAPI):
896
898
  'amount': self.safe_number(amountAndCurrencyObject, 'amount'),
897
899
  'currency': self.safe_currency_code(currencyId, currency),
898
900
  'status': status,
899
- 'updated': self.parse8601(self.safe_value(transaction, 'updated_at')),
901
+ 'updated': self.parse8601(self.safe_string(transaction, 'updated_at')),
900
902
  'fee': {
901
903
  'cost': self.safe_number(feeObject, 'amount'),
902
904
  'currency': self.safe_currency_code(feeCurrencyId),
@@ -966,10 +968,10 @@ class coinbase(Exchange, ImplicitAPI):
966
968
  # }
967
969
  #
968
970
  symbol = None
969
- totalObject = self.safe_value(trade, 'total', {})
970
- amountObject = self.safe_value(trade, 'amount', {})
971
- subtotalObject = self.safe_value(trade, 'subtotal', {})
972
- feeObject = self.safe_value(trade, 'fee', {})
971
+ totalObject = self.safe_dict(trade, 'total', {})
972
+ amountObject = self.safe_dict(trade, 'amount', {})
973
+ subtotalObject = self.safe_dict(trade, 'subtotal', {})
974
+ feeObject = self.safe_dict(trade, 'fee', {})
973
975
  marketId = self.safe_string(trade, 'product_id')
974
976
  market = self.safe_market(marketId, market, '-')
975
977
  if market is not None:
@@ -981,7 +983,7 @@ class coinbase(Exchange, ImplicitAPI):
981
983
  base = self.safe_currency_code(baseId)
982
984
  quote = self.safe_currency_code(quoteId)
983
985
  symbol = base + '/' + quote
984
- sizeInQuote = self.safe_value(trade, 'size_in_quote')
986
+ sizeInQuote = self.safe_bool(trade, 'size_in_quote')
985
987
  v3Price = self.safe_string(trade, 'price')
986
988
  v3Cost = None
987
989
  v3Amount = self.safe_string(trade, 'size')
@@ -1042,11 +1044,11 @@ class coinbase(Exchange, ImplicitAPI):
1042
1044
 
1043
1045
  def fetch_markets_v2(self, params={}):
1044
1046
  response = self.fetch_currencies_from_cache(params)
1045
- currencies = self.safe_value(response, 'currencies', {})
1046
- exchangeRates = self.safe_value(response, 'exchangeRates', {})
1047
- data = self.safe_value(currencies, 'data', [])
1047
+ currencies = self.safe_dict(response, 'currencies', {})
1048
+ exchangeRates = self.safe_dict(response, 'exchangeRates', {})
1049
+ data = self.safe_list(currencies, 'data', [])
1048
1050
  dataById = self.index_by(data, 'id')
1049
- rates = self.safe_value(self.safe_value(exchangeRates, 'data', {}), 'rates', {})
1051
+ rates = self.safe_dict(self.safe_dict(exchangeRates, 'data', {}), 'rates', {})
1050
1052
  baseIds = list(rates.keys())
1051
1053
  result = []
1052
1054
  for i in range(0, len(baseIds)):
@@ -1165,8 +1167,8 @@ class coinbase(Exchange, ImplicitAPI):
1165
1167
  # "coinbase_pro_fees": 0
1166
1168
  # }
1167
1169
  #
1168
- feeTier = self.safe_value(fees, 'fee_tier', {})
1169
- data = self.safe_value(response, 'products', [])
1170
+ feeTier = self.safe_dict(fees, 'fee_tier', {})
1171
+ data = self.safe_list(response, 'products', [])
1170
1172
  result = []
1171
1173
  for i in range(0, len(data)):
1172
1174
  market = data[i]
@@ -1176,8 +1178,8 @@ class coinbase(Exchange, ImplicitAPI):
1176
1178
  base = self.safe_currency_code(baseId)
1177
1179
  quote = self.safe_currency_code(quoteId)
1178
1180
  marketType = self.safe_string_lower(market, 'product_type')
1179
- tradingDisabled = self.safe_value(market, 'trading_disabled')
1180
- stablePairs = self.safe_value(self.options, 'stablePairs', [])
1181
+ tradingDisabled = self.safe_bool(market, 'trading_disabled')
1182
+ stablePairs = self.safe_list(self.options, 'stablePairs', [])
1181
1183
  result.append({
1182
1184
  'id': id,
1183
1185
  'symbol': base + '/' + quote,
@@ -1232,7 +1234,7 @@ class coinbase(Exchange, ImplicitAPI):
1232
1234
  return result
1233
1235
 
1234
1236
  def fetch_currencies_from_cache(self, params={}):
1235
- options = self.safe_value(self.options, 'fetchCurrencies', {})
1237
+ options = self.safe_dict(self.options, 'fetchCurrencies', {})
1236
1238
  timestamp = self.safe_integer(options, 'timestamp')
1237
1239
  expires = self.safe_integer(options, 'expires', 1000)
1238
1240
  now = self.milliseconds()
@@ -1285,7 +1287,7 @@ class coinbase(Exchange, ImplicitAPI):
1285
1287
  :returns dict: an associative dictionary of currencies
1286
1288
  """
1287
1289
  response = self.fetch_currencies_from_cache(params)
1288
- currencies = self.safe_value(response, 'currencies', {})
1290
+ currencies = self.safe_dict(response, 'currencies', {})
1289
1291
  #
1290
1292
  # fiat
1291
1293
  #
@@ -1397,8 +1399,8 @@ class coinbase(Exchange, ImplicitAPI):
1397
1399
  # }
1398
1400
  # }
1399
1401
  #
1400
- data = self.safe_value(response, 'data', {})
1401
- rates = self.safe_value(data, 'rates', {})
1402
+ data = self.safe_dict(response, 'data', {})
1403
+ rates = self.safe_dict(data, 'rates', {})
1402
1404
  quoteId = self.safe_string(data, 'currency')
1403
1405
  result = {}
1404
1406
  baseIds = list(rates.keys())
@@ -1455,7 +1457,7 @@ class coinbase(Exchange, ImplicitAPI):
1455
1457
  # "num_products": 549
1456
1458
  # }
1457
1459
  #
1458
- data = self.safe_value(response, 'products', [])
1460
+ data = self.safe_list(response, 'products', [])
1459
1461
  result = {}
1460
1462
  for i in range(0, len(data)):
1461
1463
  entry = data[i]
@@ -1499,9 +1501,9 @@ class coinbase(Exchange, ImplicitAPI):
1499
1501
  #
1500
1502
  # {"data":{"base":"BTC","currency":"USD","amount":"48691.23"}}
1501
1503
  #
1502
- spotData = self.safe_value(spot, 'data', {})
1503
- askData = self.safe_value(ask, 'data', {})
1504
- bidData = self.safe_value(bid, 'data', {})
1504
+ spotData = self.safe_dict(spot, 'data', {})
1505
+ askData = self.safe_dict(ask, 'data', {})
1506
+ bidData = self.safe_dict(bid, 'data', {})
1505
1507
  bidAskLast = {
1506
1508
  'bid': self.safe_number(bidData, 'amount'),
1507
1509
  'ask': self.safe_number(askData, 'amount'),
@@ -1535,7 +1537,7 @@ class coinbase(Exchange, ImplicitAPI):
1535
1537
  # "best_ask": "28208.62"
1536
1538
  # }
1537
1539
  #
1538
- data = self.safe_value(response, 'trades', [])
1540
+ data = self.safe_list(response, 'trades', [])
1539
1541
  ticker = self.parse_ticker(data[0], market)
1540
1542
  ticker['bid'] = self.safe_number(response, 'best_bid')
1541
1543
  ticker['ask'] = self.safe_number(response, 'best_ask')
@@ -1627,8 +1629,8 @@ class coinbase(Exchange, ImplicitAPI):
1627
1629
  bidVolume = None
1628
1630
  askVolume = None
1629
1631
  if ('bids' in ticker):
1630
- bids = self.safe_value(ticker, 'bids', [])
1631
- asks = self.safe_value(ticker, 'asks', [])
1632
+ bids = self.safe_list(ticker, 'bids', [])
1633
+ asks = self.safe_list(ticker, 'asks', [])
1632
1634
  bid = self.safe_number(bids[0], 'price')
1633
1635
  bidVolume = self.safe_number(bids[0], 'size')
1634
1636
  ask = self.safe_number(asks[0], 'price')
@@ -1660,21 +1662,21 @@ class coinbase(Exchange, ImplicitAPI):
1660
1662
  }, market)
1661
1663
 
1662
1664
  def parse_custom_balance(self, response, params={}):
1663
- balances = self.safe_value_2(response, 'data', 'accounts', [])
1664
- accounts = self.safe_value(params, 'type', self.options['accounts'])
1665
- v3Accounts = self.safe_value(params, 'type', self.options['v3Accounts'])
1665
+ balances = self.safe_list_2(response, 'data', 'accounts', [])
1666
+ accounts = self.safe_list(params, 'type', self.options['accounts'])
1667
+ v3Accounts = self.safe_list(params, 'type', self.options['v3Accounts'])
1666
1668
  result = {'info': response}
1667
1669
  for b in range(0, len(balances)):
1668
1670
  balance = balances[b]
1669
1671
  type = self.safe_string(balance, 'type')
1670
1672
  if self.in_array(type, accounts):
1671
- value = self.safe_value(balance, 'balance')
1673
+ value = self.safe_dict(balance, 'balance')
1672
1674
  if value is not None:
1673
1675
  currencyId = self.safe_string(value, 'currency')
1674
1676
  code = self.safe_currency_code(currencyId)
1675
1677
  total = self.safe_string(value, 'amount')
1676
1678
  free = total
1677
- account = self.safe_value(result, code)
1679
+ account = self.safe_dict(result, code)
1678
1680
  if account is None:
1679
1681
  account = self.account()
1680
1682
  account['free'] = free
@@ -1684,15 +1686,15 @@ class coinbase(Exchange, ImplicitAPI):
1684
1686
  account['total'] = Precise.string_add(account['total'], total)
1685
1687
  result[code] = account
1686
1688
  elif self.in_array(type, v3Accounts):
1687
- available = self.safe_value(balance, 'available_balance')
1688
- hold = self.safe_value(balance, 'hold')
1689
+ available = self.safe_dict(balance, 'available_balance')
1690
+ hold = self.safe_dict(balance, 'hold')
1689
1691
  if available is not None and hold is not None:
1690
1692
  currencyId = self.safe_string(available, 'currency')
1691
1693
  code = self.safe_currency_code(currencyId)
1692
1694
  used = self.safe_string(hold, 'value')
1693
1695
  free = self.safe_string(available, 'value')
1694
1696
  total = Precise.string_add(used, free)
1695
- account = self.safe_value(result, code)
1697
+ account = self.safe_dict(result, code)
1696
1698
  if account is None:
1697
1699
  account = self.account()
1698
1700
  account['free'] = free
@@ -2088,7 +2090,7 @@ class coinbase(Exchange, ImplicitAPI):
2088
2090
  # }
2089
2091
  # }
2090
2092
  #
2091
- amountInfo = self.safe_value(item, 'amount', {})
2093
+ amountInfo = self.safe_dict(item, 'amount', {})
2092
2094
  amount = self.safe_string(amountInfo, 'amount')
2093
2095
  direction = None
2094
2096
  if Precise.string_lt(amount, '0'):
@@ -2108,9 +2110,9 @@ class coinbase(Exchange, ImplicitAPI):
2108
2110
  # txid = None
2109
2111
  #
2110
2112
  fee = None
2111
- networkInfo = self.safe_value(item, 'network', {})
2113
+ networkInfo = self.safe_dict(item, 'network', {})
2112
2114
  # txid = network['hash'] # txid does not belong to the unified ledger structure
2113
- feeInfo = self.safe_value(networkInfo, 'transaction_fee')
2115
+ feeInfo = self.safe_dict(networkInfo, 'transaction_fee')
2114
2116
  if feeInfo is not None:
2115
2117
  feeCurrencyId = self.safe_string(feeInfo, 'currency')
2116
2118
  feeCurrencyCode = self.safe_currency_code(feeCurrencyId, currency)
@@ -2119,7 +2121,7 @@ class coinbase(Exchange, ImplicitAPI):
2119
2121
  'cost': feeAmount,
2120
2122
  'currency': feeCurrencyCode,
2121
2123
  }
2122
- timestamp = self.parse8601(self.safe_value(item, 'created_at'))
2124
+ timestamp = self.parse8601(self.safe_string(item, 'created_at'))
2123
2125
  id = self.safe_string(item, 'id')
2124
2126
  type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
2125
2127
  status = self.parse_ledger_entry_status(self.safe_string(item, 'status'))
@@ -2236,7 +2238,7 @@ class coinbase(Exchange, ImplicitAPI):
2236
2238
  isStopLoss = stopLossPrice is not None
2237
2239
  isTakeProfit = takeProfitPrice is not None
2238
2240
  timeInForce = self.safe_string(params, 'timeInForce')
2239
- postOnly = True if (timeInForce == 'PO') else self.safe_value_2(params, 'postOnly', 'post_only', False)
2241
+ postOnly = True if (timeInForce == 'PO') else self.safe_bool_2(params, 'postOnly', 'post_only', False)
2240
2242
  endTime = self.safe_string(params, 'end_time')
2241
2243
  stopDirection = self.safe_string(params, 'stop_direction')
2242
2244
  if type == 'limit':
@@ -2294,6 +2296,13 @@ class coinbase(Exchange, ImplicitAPI):
2294
2296
  'post_only': postOnly,
2295
2297
  },
2296
2298
  }
2299
+ elif timeInForce == 'IOC':
2300
+ request['order_configuration'] = {
2301
+ 'sor_limit_ioc': {
2302
+ 'base_size': self.amount_to_precision(symbol, amount),
2303
+ 'limit_price': self.price_to_precision(symbol, price),
2304
+ },
2305
+ }
2297
2306
  else:
2298
2307
  request['order_configuration'] = {
2299
2308
  'limit_limit_gtc': {
@@ -2335,7 +2344,7 @@ class coinbase(Exchange, ImplicitAPI):
2335
2344
  },
2336
2345
  }
2337
2346
  params = self.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time'])
2338
- preview = self.safe_value_2(params, 'preview', 'test', False)
2347
+ preview = self.safe_bool_2(params, 'preview', 'test', False)
2339
2348
  response = None
2340
2349
  if preview:
2341
2350
  params = self.omit(params, ['preview', 'test'])
@@ -2380,16 +2389,16 @@ class coinbase(Exchange, ImplicitAPI):
2380
2389
  # }
2381
2390
  # }
2382
2391
  #
2383
- success = self.safe_value(response, 'success')
2392
+ success = self.safe_bool(response, 'success')
2384
2393
  if success is not True:
2385
- errorResponse = self.safe_value(response, 'error_response')
2394
+ errorResponse = self.safe_dict(response, 'error_response')
2386
2395
  errorTitle = self.safe_string(errorResponse, 'error')
2387
2396
  errorMessage = self.safe_string(errorResponse, 'message')
2388
2397
  if errorResponse is not None:
2389
2398
  self.throw_exactly_matched_exception(self.exceptions['exact'], errorTitle, errorMessage)
2390
2399
  self.throw_broadly_matched_exception(self.exceptions['broad'], errorTitle, errorMessage)
2391
2400
  raise ExchangeError(errorMessage)
2392
- data = self.safe_value(response, 'success_response', {})
2401
+ data = self.safe_dict(response, 'success_response', {})
2393
2402
  return self.parse_order(data, market)
2394
2403
 
2395
2404
  def parse_order(self, order, market: Market = None) -> Order:
@@ -2459,28 +2468,35 @@ class coinbase(Exchange, ImplicitAPI):
2459
2468
  symbol = self.safe_symbol(marketId, market, '-')
2460
2469
  if symbol is not None:
2461
2470
  market = self.market(symbol)
2462
- orderConfiguration = self.safe_value(order, 'order_configuration', {})
2463
- limitGTC = self.safe_value(orderConfiguration, 'limit_limit_gtc')
2464
- limitGTD = self.safe_value(orderConfiguration, 'limit_limit_gtd')
2465
- stopLimitGTC = self.safe_value(orderConfiguration, 'stop_limit_stop_limit_gtc')
2466
- stopLimitGTD = self.safe_value(orderConfiguration, 'stop_limit_stop_limit_gtd')
2467
- marketIOC = self.safe_value(orderConfiguration, 'market_market_ioc')
2468
- isLimit = ((limitGTC is not None) or (limitGTD is not None))
2471
+ orderConfiguration = self.safe_dict(order, 'order_configuration', {})
2472
+ limitGTC = self.safe_dict(orderConfiguration, 'limit_limit_gtc')
2473
+ limitGTD = self.safe_dict(orderConfiguration, 'limit_limit_gtd')
2474
+ limitIOC = self.safe_dict(orderConfiguration, 'sor_limit_ioc')
2475
+ stopLimitGTC = self.safe_dict(orderConfiguration, 'stop_limit_stop_limit_gtc')
2476
+ stopLimitGTD = self.safe_dict(orderConfiguration, 'stop_limit_stop_limit_gtd')
2477
+ marketIOC = self.safe_dict(orderConfiguration, 'market_market_ioc')
2478
+ isLimit = ((limitGTC is not None) or (limitGTD is not None) or (limitIOC is not None))
2469
2479
  isStop = ((stopLimitGTC is not None) or (stopLimitGTD is not None))
2470
2480
  price = None
2471
2481
  amount = None
2472
2482
  postOnly = None
2473
2483
  triggerPrice = None
2474
2484
  if isLimit:
2475
- target = limitGTC if (limitGTC is not None) else limitGTD
2485
+ target = None
2486
+ if limitGTC is not None:
2487
+ target = limitGTC
2488
+ elif limitGTD is not None:
2489
+ target = limitGTD
2490
+ else:
2491
+ target = limitIOC
2476
2492
  price = self.safe_string(target, 'limit_price')
2477
2493
  amount = self.safe_string(target, 'base_size')
2478
- postOnly = self.safe_value(target, 'post_only')
2494
+ postOnly = self.safe_bool(target, 'post_only')
2479
2495
  elif isStop:
2480
2496
  stopTarget = stopLimitGTC if (stopLimitGTC is not None) else stopLimitGTD
2481
2497
  price = self.safe_string(stopTarget, 'limit_price')
2482
2498
  amount = self.safe_string(stopTarget, 'base_size')
2483
- postOnly = self.safe_value(stopTarget, 'post_only')
2499
+ postOnly = self.safe_bool(stopTarget, 'post_only')
2484
2500
  triggerPrice = self.safe_string(stopTarget, 'stop_price')
2485
2501
  else:
2486
2502
  amount = self.safe_string(marketIOC, 'base_size')
@@ -2560,7 +2576,7 @@ class coinbase(Exchange, ImplicitAPI):
2560
2576
  """
2561
2577
  self.load_markets()
2562
2578
  orders = self.cancel_orders([id], symbol, params)
2563
- return self.safe_value(orders, 0, {})
2579
+ return self.safe_dict(orders, 0, {})
2564
2580
 
2565
2581
  def cancel_orders(self, ids, symbol: Str = None, params={}):
2566
2582
  """
@@ -2590,9 +2606,9 @@ class coinbase(Exchange, ImplicitAPI):
2590
2606
  # ]
2591
2607
  # }
2592
2608
  #
2593
- orders = self.safe_value(response, 'results', [])
2609
+ orders = self.safe_list(response, 'results', [])
2594
2610
  for i in range(0, len(orders)):
2595
- success = self.safe_value(orders[i], 'success')
2611
+ success = self.safe_bool(orders[i], 'success')
2596
2612
  if success is not True:
2597
2613
  raise BadRequest(self.id + ' cancelOrders() has failed, check your arguments and parameters')
2598
2614
  return self.parse_orders(orders, market)
@@ -2620,7 +2636,7 @@ class coinbase(Exchange, ImplicitAPI):
2620
2636
  request['size'] = self.amount_to_precision(symbol, amount)
2621
2637
  if price is not None:
2622
2638
  request['price'] = self.price_to_precision(symbol, price)
2623
- preview = self.safe_value_2(params, 'preview', 'test', False)
2639
+ preview = self.safe_bool_2(params, 'preview', 'test', False)
2624
2640
  response = None
2625
2641
  if preview:
2626
2642
  params = self.omit(params, ['preview', 'test'])
@@ -2694,7 +2710,7 @@ class coinbase(Exchange, ImplicitAPI):
2694
2710
  # }
2695
2711
  # }
2696
2712
  #
2697
- order = self.safe_value(response, 'order', {})
2713
+ order = self.safe_dict(response, 'order', {})
2698
2714
  return self.parse_order(order, market)
2699
2715
 
2700
2716
  def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = 100, params={}) -> List[Order]:
@@ -2724,7 +2740,7 @@ class coinbase(Exchange, ImplicitAPI):
2724
2740
  request['limit'] = limit
2725
2741
  if since is not None:
2726
2742
  request['start_date'] = self.iso8601(since)
2727
- until = self.safe_value_n(params, ['until', 'till'])
2743
+ until = self.safe_integer_n(params, ['until', 'till'])
2728
2744
  if until is not None:
2729
2745
  params = self.omit(params, ['until', 'till'])
2730
2746
  request['end_date'] = self.iso8601(until)
@@ -2771,8 +2787,8 @@ class coinbase(Exchange, ImplicitAPI):
2771
2787
  # "cursor": ""
2772
2788
  # }
2773
2789
  #
2774
- orders = self.safe_value(response, 'orders', [])
2775
- first = self.safe_value(orders, 0)
2790
+ orders = self.safe_list(response, 'orders', [])
2791
+ first = self.safe_dict(orders, 0)
2776
2792
  cursor = self.safe_string(response, 'cursor')
2777
2793
  if (cursor is not None) and (cursor != ''):
2778
2794
  first['cursor'] = cursor
@@ -2794,7 +2810,7 @@ class coinbase(Exchange, ImplicitAPI):
2794
2810
  request['limit'] = limit
2795
2811
  if since is not None:
2796
2812
  request['start_date'] = self.iso8601(since)
2797
- until = self.safe_value_n(params, ['until', 'till'])
2813
+ until = self.safe_integer_n(params, ['until', 'till'])
2798
2814
  if until is not None:
2799
2815
  params = self.omit(params, ['until', 'till'])
2800
2816
  request['end_date'] = self.iso8601(until)
@@ -2841,8 +2857,8 @@ class coinbase(Exchange, ImplicitAPI):
2841
2857
  # "cursor": ""
2842
2858
  # }
2843
2859
  #
2844
- orders = self.safe_value(response, 'orders', [])
2845
- first = self.safe_value(orders, 0)
2860
+ orders = self.safe_list(response, 'orders', [])
2861
+ first = self.safe_dict(orders, 0)
2846
2862
  cursor = self.safe_string(response, 'cursor')
2847
2863
  if (cursor is not None) and (cursor != ''):
2848
2864
  first['cursor'] = cursor
@@ -2924,7 +2940,7 @@ class coinbase(Exchange, ImplicitAPI):
2924
2940
  'product_id': market['id'],
2925
2941
  'granularity': self.safe_string(self.timeframes, timeframe, timeframe),
2926
2942
  }
2927
- until = self.safe_value_n(params, ['until', 'till', 'end'])
2943
+ until = self.safe_integer_n(params, ['until', 'till', 'end'])
2928
2944
  params = self.omit(params, ['until', 'till'])
2929
2945
  duration = self.parse_timeframe(timeframe)
2930
2946
  requestedDuration = limit * duration
@@ -2955,7 +2971,7 @@ class coinbase(Exchange, ImplicitAPI):
2955
2971
  # ]
2956
2972
  # }
2957
2973
  #
2958
- candles = self.safe_value(response, 'candles', [])
2974
+ candles = self.safe_list(response, 'candles', [])
2959
2975
  return self.parse_ohlcvs(candles, market, timeframe, since, limit)
2960
2976
 
2961
2977
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
@@ -3022,7 +3038,7 @@ class coinbase(Exchange, ImplicitAPI):
3022
3038
  # ]
3023
3039
  # }
3024
3040
  #
3025
- trades = self.safe_value(response, 'trades', [])
3041
+ trades = self.safe_list(response, 'trades', [])
3026
3042
  return self.parse_trades(trades, market, since, limit)
3027
3043
 
3028
3044
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -3052,7 +3068,7 @@ class coinbase(Exchange, ImplicitAPI):
3052
3068
  request['limit'] = limit
3053
3069
  if since is not None:
3054
3070
  request['start_sequence_timestamp'] = self.iso8601(since)
3055
- until = self.safe_value_n(params, ['until', 'till'])
3071
+ until = self.safe_integer_n(params, ['until', 'till'])
3056
3072
  if until is not None:
3057
3073
  params = self.omit(params, ['until', 'till'])
3058
3074
  request['end_sequence_timestamp'] = self.iso8601(until)
@@ -3080,8 +3096,8 @@ class coinbase(Exchange, ImplicitAPI):
3080
3096
  # "cursor": ""
3081
3097
  # }
3082
3098
  #
3083
- trades = self.safe_value(response, 'fills', [])
3084
- first = self.safe_value(trades, 0)
3099
+ trades = self.safe_list(response, 'fills', [])
3100
+ first = self.safe_dict(trades, 0)
3085
3101
  cursor = self.safe_string(response, 'cursor')
3086
3102
  if (cursor is not None) and (cursor != ''):
3087
3103
  first['cursor'] = cursor
@@ -3166,7 +3182,7 @@ class coinbase(Exchange, ImplicitAPI):
3166
3182
  # ]
3167
3183
  # }
3168
3184
  #
3169
- tickers = self.safe_value(response, 'pricebooks', [])
3185
+ tickers = self.safe_list(response, 'pricebooks', [])
3170
3186
  return self.parse_tickers(tickers, symbols)
3171
3187
 
3172
3188
  def withdraw(self, code: str, amount: float, address, tag=None, params={}):
@@ -3254,7 +3270,7 @@ class coinbase(Exchange, ImplicitAPI):
3254
3270
  # }
3255
3271
  # }
3256
3272
  #
3257
- data = self.safe_value(response, 'data', {})
3273
+ data = self.safe_dict(response, 'data', {})
3258
3274
  return self.parse_transaction(data, currency)
3259
3275
 
3260
3276
  def fetch_deposit_addresses_by_network(self, code: str, params={}):
@@ -3515,7 +3531,7 @@ class coinbase(Exchange, ImplicitAPI):
3515
3531
  # }
3516
3532
  # }
3517
3533
  #
3518
- data = self.safe_value(response, 'data', {})
3534
+ data = self.safe_dict(response, 'data', {})
3519
3535
  return self.parse_transaction(data)
3520
3536
 
3521
3537
  def sign(self, path, api=[], method='GET', params={}, headers=None, body=None):
@@ -3598,7 +3614,7 @@ class coinbase(Exchange, ImplicitAPI):
3598
3614
  self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
3599
3615
  self.throw_broadly_matched_exception(self.exceptions['broad'], errorMessage, feedback)
3600
3616
  raise ExchangeError(feedback)
3601
- errors = self.safe_value(response, 'errors')
3617
+ errors = self.safe_list(response, 'errors')
3602
3618
  if errors is not None:
3603
3619
  if isinstance(errors, list):
3604
3620
  numErrors = len(errors)
@@ -3610,7 +3626,6 @@ class coinbase(Exchange, ImplicitAPI):
3610
3626
  self.throw_broadly_matched_exception(self.exceptions['broad'], errorMessage, feedback)
3611
3627
  raise ExchangeError(feedback)
3612
3628
  advancedTrade = self.options['advanced']
3613
- data = self.safe_value(response, 'data')
3614
- if (data is None) and (not advancedTrade):
3629
+ if not ('data' in response) and (not advancedTrade):
3615
3630
  raise ExchangeError(self.id + ' failed due to a malformed response ' + self.json(response))
3616
3631
  return None
ccxt/coinex.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
- from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, Market, Order, TransferEntry, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
8
+ from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, Market, Order, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import PermissionDenied
ccxt/coinlist.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinlist import ImplicitAPI
8
8
  import hashlib
9
9
  import math
10
- from ccxt.base.types import Balances, Currency, Int, Market, Order, TransferEntry, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
+ from ccxt.base.types import Balances, Currency, Int, Market, Order, OrderBook, 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
ccxt/coinmetro.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinmetro import ImplicitAPI
8
- from ccxt.base.types import Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, IndexType, Str, Strings, Ticker, Tickers, Trade
8
+ from ccxt.base.types import Balances, Currency, IndexType, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import PermissionDenied
ccxt/deribit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.deribit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Greeks, Int, Market, Order, TransferEntry, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Market, 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
ccxt/digifinex.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import Balances, Currency, Int, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
+ from ccxt.base.types import Balances, Currency, Int, Market, 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
@@ -1463,7 +1463,8 @@ class digifinex(Exchange, ImplicitAPI):
1463
1463
  elif limit is not None:
1464
1464
  endTime = self.seconds()
1465
1465
  duration = self.parse_timeframe(timeframe)
1466
- request['start_time'] = self.sum(endTime, -limit * duration)
1466
+ auxLimit = limit # in c# -limit is mutating the arg
1467
+ request['start_time'] = self.sum(endTime, -auxLimit * duration)
1467
1468
  response = self.publicSpotGetKline(self.extend(request, params))
1468
1469
  #
1469
1470
  # spot