ccxt 4.4.19__py2.py3-none-any.whl → 4.4.21__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/binance.py CHANGED
@@ -11137,15 +11137,6 @@ class binance(Exchange, ImplicitAPI):
11137
11137
  #
11138
11138
  return self.parse_borrow_rate_history(response, code, since, limit)
11139
11139
 
11140
- def parse_borrow_rate_history(self, response, code, since, limit):
11141
- result = []
11142
- for i in range(0, len(response)):
11143
- item = response[i]
11144
- borrowRate = self.parse_borrow_rate(item)
11145
- result.append(borrowRate)
11146
- sorted = self.sort_by(result, 'timestamp')
11147
- return self.filter_by_currency_since_limit(sorted, code, since, limit)
11148
-
11149
11140
  def parse_borrow_rate(self, info, currency: Currency = None):
11150
11141
  #
11151
11142
  # {
ccxt/bingx.py CHANGED
@@ -4980,7 +4980,7 @@ class bingx(Exchange, ImplicitAPI):
4980
4980
  def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4981
4981
  """
4982
4982
  make a withdrawal
4983
- :see: https://bingx-api.github.io/docs/#/common/account-api.html#Withdraw
4983
+ :see: https://bingx-api.github.io/docs/#/en-us/spot/wallet-api.html#Withdraw
4984
4984
  :param str code: unified currency code
4985
4985
  :param float amount: the amount to withdraw
4986
4986
  :param str address: the address to withdraw to
@@ -4989,6 +4989,8 @@ class bingx(Exchange, ImplicitAPI):
4989
4989
  :param int [params.walletType]: 1 fund account, 2 standard account, 3 perpetual account
4990
4990
  :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
4991
4991
  """
4992
+ tag, params = self.handle_withdraw_tag_and_params(tag, params)
4993
+ self.check_address(address)
4992
4994
  self.load_markets()
4993
4995
  currency = self.currency(code)
4994
4996
  walletType = self.safe_integer(params, 'walletType')
@@ -5005,6 +5007,8 @@ class bingx(Exchange, ImplicitAPI):
5005
5007
  network = self.safe_string_upper(params, 'network')
5006
5008
  if network is not None:
5007
5009
  request['network'] = self.network_code_to_id(network)
5010
+ if tag is not None:
5011
+ request['addressTag'] = tag
5008
5012
  params = self.omit(params, ['walletType', 'network'])
5009
5013
  response = self.walletsV1PrivatePostCapitalWithdrawApply(self.extend(request, params))
5010
5014
  data = self.safe_value(response, 'data')
ccxt/bybit.py CHANGED
@@ -384,6 +384,7 @@ class bybit(Exchange, ImplicitAPI):
384
384
  # spot leverage token
385
385
  'v5/spot-lever-token/order-record': 1, # 50/s => cost = 50 / 50 = 1
386
386
  # spot margin trade
387
+ 'v5/spot-margin-trade/interest-rate-history': 5,
387
388
  'v5/spot-margin-trade/state': 5,
388
389
  'v5/spot-cross-margin-trade/loan-info': 1, # 50/s => cost = 50 / 50 = 1
389
390
  'v5/spot-cross-margin-trade/account': 1, # 50/s => cost = 50 / 50 = 1
@@ -6702,7 +6703,8 @@ class bybit(Exchange, ImplicitAPI):
6702
6703
  paginate = self.safe_bool(params, 'paginate')
6703
6704
  if paginate:
6704
6705
  params = self.omit(params, 'paginate')
6705
- return self.fetch_paginated_call_deterministic('fetchOpenInterestHistory', symbol, since, limit, timeframe, params, 500)
6706
+ params['timeframe'] = timeframe
6707
+ return self.fetch_paginated_call_cursor('fetchOpenInterestHistory', symbol, since, limit, params, 'nextPageCursor', 'cursor', None, 200)
6706
6708
  market = self.market(symbol)
6707
6709
  if market['spot'] or market['option']:
6708
6710
  raise BadRequest(self.id + ' fetchOpenInterestHistory() symbol does not support market ' + symbol)
@@ -6774,12 +6776,22 @@ class bybit(Exchange, ImplicitAPI):
6774
6776
  # "timestamp": 1666734490778
6775
6777
  # }
6776
6778
  #
6779
+ # fetchBorrowRateHistory
6780
+ # {
6781
+ # "timestamp": 1721469600000,
6782
+ # "currency": "USDC",
6783
+ # "hourlyBorrowRate": "0.000014621596",
6784
+ # "vipLevel": "No VIP"
6785
+ # }
6786
+ #
6777
6787
  timestamp = self.safe_integer(info, 'timestamp')
6778
- currencyId = self.safe_string(info, 'coin')
6788
+ currencyId = self.safe_string_2(info, 'coin', 'currency')
6789
+ hourlyBorrowRate = self.safe_number(info, 'hourlyBorrowRate')
6790
+ period = 3600000 if (hourlyBorrowRate is not None) else 86400000 # 1h or 1d
6779
6791
  return {
6780
6792
  'currency': self.safe_currency_code(currencyId, currency),
6781
- 'rate': self.safe_number(info, 'interestRate'),
6782
- 'period': 86400000, # Daily
6793
+ 'rate': self.safe_number(info, 'interestRate', hourlyBorrowRate),
6794
+ 'period': period, # Daily
6783
6795
  'timestamp': timestamp,
6784
6796
  'datetime': self.iso8601(timestamp),
6785
6797
  'info': info,
@@ -6829,6 +6841,53 @@ class bybit(Exchange, ImplicitAPI):
6829
6841
  interest = self.parse_borrow_interests(rows, None)
6830
6842
  return self.filter_by_currency_since_limit(interest, code, since, limit)
6831
6843
 
6844
+ def fetch_borrow_rate_history(self, code: str, since: Int = None, limit: Int = None, params={}):
6845
+ """
6846
+ retrieves a history of a currencies borrow interest rate at specific time slots
6847
+ :see: https://bybit-exchange.github.io/docs/v5/spot-margin-uta/historical-interest
6848
+ :param str code: unified currency code
6849
+ :param int [since]: timestamp for the earliest borrow rate
6850
+ :param int [limit]: the maximum number of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>` to retrieve
6851
+ :param dict [params]: extra parameters specific to the exchange API endpoint
6852
+ :param int [params.until]: the latest time in ms to fetch entries for
6853
+ :returns dict[]: an array of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
6854
+ """
6855
+ self.load_markets()
6856
+ currency = self.currency(code)
6857
+ request: dict = {
6858
+ 'currency': currency['id'],
6859
+ }
6860
+ if since is None:
6861
+ since = self.milliseconds() - 86400000 * 30 # last 30 days
6862
+ request['startTime'] = since
6863
+ endTime = self.safe_integer_2(params, 'until', 'endTime')
6864
+ params = self.omit(params, ['until'])
6865
+ if endTime is None:
6866
+ endTime = since + 86400000 * 30 # since + 30 days
6867
+ request['endTime'] = endTime
6868
+ response = self.privateGetV5SpotMarginTradeInterestRateHistory(self.extend(request, params))
6869
+ #
6870
+ # {
6871
+ # "retCode": 0,
6872
+ # "retMsg": "OK",
6873
+ # "result": {
6874
+ # "list": [
6875
+ # {
6876
+ # "timestamp": 1721469600000,
6877
+ # "currency": "USDC",
6878
+ # "hourlyBorrowRate": "0.000014621596",
6879
+ # "vipLevel": "No VIP"
6880
+ # }
6881
+ # ]
6882
+ # },
6883
+ # "retExtInfo": "{}",
6884
+ # "time": 1721899048991
6885
+ # }
6886
+ #
6887
+ data = self.safe_dict(response, 'result')
6888
+ rows = self.safe_list(data, 'list', [])
6889
+ return self.parse_borrow_rate_history(rows, code, since, limit)
6890
+
6832
6891
  def parse_borrow_interest(self, info: dict, market: Market = None):
6833
6892
  #
6834
6893
  # {
ccxt/gate.py CHANGED
@@ -4420,6 +4420,7 @@ class gate(Exchange, ImplicitAPI):
4420
4420
  """
4421
4421
  fetch all unfilled currently open orders
4422
4422
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-open-orders
4423
+ :see: https://www.gate.io/docs/developers/apiv4/en/#retrieve-running-auto-order-list
4423
4424
  :param str symbol: unified market symbol
4424
4425
  :param int [since]: the earliest time in ms to fetch open orders for
4425
4426
  :param int [limit]: the maximum number of open orders structures to retrieve
ccxt/htx.py CHANGED
@@ -1627,6 +1627,10 @@ class htx(Exchange, ImplicitAPI):
1627
1627
  def fetch_markets(self, params={}) -> List[Market]:
1628
1628
  """
1629
1629
  retrieves data on all markets for huobi
1630
+ :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
1631
+ :see: https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
1632
+ :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
1633
+ :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
1630
1634
  :param dict [params]: extra parameters specific to the exchange API endpoint
1631
1635
  :returns dict[]: an array of objects representing market data
1632
1636
  """
@@ -1650,7 +1654,19 @@ class htx(Exchange, ImplicitAPI):
1650
1654
  allMarkets = self.array_concat(allMarkets, promises[i])
1651
1655
  return allMarkets
1652
1656
 
1653
- def fetch_markets_by_type_and_sub_type(self, type, subType, params={}):
1657
+ def fetch_markets_by_type_and_sub_type(self, type: Str, subType: Str, params={}):
1658
+ """
1659
+ * @ignore
1660
+ retrieves data on all markets of a certain type and/or subtype
1661
+ :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
1662
+ :see: https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
1663
+ :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
1664
+ :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
1665
+ :param str [type]: 'spot', 'swap' or 'future'
1666
+ :param str [subType]: 'linear' or 'inverse'
1667
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1668
+ :returns dict[]: an array of objects representing market data
1669
+ """
1654
1670
  isSpot = (type == 'spot')
1655
1671
  request: dict = {}
1656
1672
  response = None
@@ -3014,7 +3030,15 @@ class htx(Exchange, ImplicitAPI):
3014
3030
  'code': None,
3015
3031
  }
3016
3032
 
3017
- def fetch_account_id_by_type(self, type, marginMode=None, symbol=None, params={}):
3033
+ def fetch_account_id_by_type(self, type: str, marginMode: Str = None, symbol: Str = None, params={}):
3034
+ """
3035
+ fetch all the accounts by a type and marginModeassociated with a profile
3036
+ :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
3037
+ :param str type: 'spot', 'swap' or 'future
3038
+ :param str [marginMode]: 'cross' or 'isolated'
3039
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3040
+ :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
3041
+ """
3018
3042
  accounts = self.load_accounts()
3019
3043
  accountId = self.safe_value_2(params, 'accountId', 'account-id')
3020
3044
  if accountId is not None:
ccxt/hyperliquid.py CHANGED
@@ -638,17 +638,17 @@ class hyperliquid(Exchange, ImplicitAPI):
638
638
  code = self.safe_currency_code(self.safe_string(balance, 'coin'))
639
639
  account = self.account()
640
640
  total = self.safe_string(balance, 'total')
641
- free = self.safe_string(balance, 'hold')
641
+ used = self.safe_string(balance, 'hold')
642
642
  account['total'] = total
643
- account['used'] = free
643
+ account['used'] = used
644
644
  spotBalances[code] = account
645
645
  return self.safe_balance(spotBalances)
646
646
  data = self.safe_dict(response, 'marginSummary', {})
647
647
  result: dict = {
648
648
  'info': response,
649
649
  'USDC': {
650
- 'total': self.safe_float(data, 'accountValue'),
651
- 'used': self.safe_float(data, 'totalMarginUsed'),
650
+ 'total': self.safe_number(data, 'accountValue'),
651
+ 'free': self.safe_number(response, 'withdrawable'),
652
652
  },
653
653
  }
654
654
  timestamp = self.safe_integer(response, 'time')
@@ -2112,10 +2112,11 @@ class hyperliquid(Exchange, ImplicitAPI):
2112
2112
  leverage = self.safe_dict(entry, 'leverage', {})
2113
2113
  marginMode = self.safe_string(leverage, 'type')
2114
2114
  isIsolated = (marginMode == 'isolated')
2115
- size = self.safe_number(entry, 'szi')
2115
+ size = self.safe_string(entry, 'szi')
2116
2116
  side = None
2117
2117
  if size is not None:
2118
- side = 'long' if (size > 0) else 'short'
2118
+ side = 'long' if Precise.string_gt(size, '0') else 'short'
2119
+ size = Precise.string_abs(size)
2119
2120
  unrealizedPnl = self.safe_number(entry, 'unrealizedPnl')
2120
2121
  initialMargin = self.safe_number(entry, 'marginUsed')
2121
2122
  percentage = unrealizedPnl / initialMargin * 100
ccxt/kucoin.py CHANGED
@@ -183,6 +183,7 @@ class kucoin(Exchange, ImplicitAPI):
183
183
  'mark-price/{symbol}/current': 3, # 2PW
184
184
  'mark-price/all-symbols': 3,
185
185
  'margin/config': 25, # 25SW
186
+ 'announcements': 20, # 20W
186
187
  },
187
188
  'post': {
188
189
  # ws
@@ -472,6 +473,7 @@ class kucoin(Exchange, ImplicitAPI):
472
473
  'precisionMode': TICK_SIZE,
473
474
  'exceptions': {
474
475
  'exact': {
476
+ 'The order does not exist.': OrderNotFound,
475
477
  'order not exist': OrderNotFound,
476
478
  'order not exist.': OrderNotFound, # duplicated error temporarily
477
479
  'order_not_exist': OrderNotFound, # {"code":"order_not_exist","msg":"order_not_exist"} ¯\_(ツ)_/¯
@@ -672,6 +674,7 @@ class kucoin(Exchange, ImplicitAPI):
672
674
  'currencies/{currency}': 'v3',
673
675
  'symbols': 'v2',
674
676
  'mark-price/all-symbols': 'v3',
677
+ 'announcements': 'v3',
675
678
  },
676
679
  },
677
680
  'private': {
@@ -1529,38 +1532,28 @@ class kucoin(Exchange, ImplicitAPI):
1529
1532
  # "chain": "ERC20"
1530
1533
  # }
1531
1534
  #
1535
+ minWithdrawFee = self.safe_number(fee, 'withdrawMinFee')
1532
1536
  result: dict = {
1533
1537
  'info': fee,
1534
1538
  'withdraw': {
1539
+ 'fee': minWithdrawFee,
1540
+ 'percentage': False,
1541
+ },
1542
+ 'deposit': {
1535
1543
  'fee': None,
1536
1544
  'percentage': None,
1537
1545
  },
1546
+ 'networks': {},
1547
+ }
1548
+ networkId = self.safe_string(fee, 'chain')
1549
+ networkCode = self.network_id_to_code(networkId, self.safe_string(currency, 'code'))
1550
+ result['networks'][networkCode] = {
1551
+ 'withdraw': minWithdrawFee,
1538
1552
  'deposit': {
1539
1553
  'fee': None,
1540
1554
  'percentage': None,
1541
1555
  },
1542
- 'networks': {},
1543
1556
  }
1544
- isWithdrawEnabled = self.safe_bool(fee, 'isWithdrawEnabled', True)
1545
- minFee = None
1546
- if isWithdrawEnabled:
1547
- result['withdraw']['percentage'] = False
1548
- chains = self.safe_list(fee, 'chains', [])
1549
- for i in range(0, len(chains)):
1550
- chain = chains[i]
1551
- networkId = self.safe_string(chain, 'chainId')
1552
- networkCode = self.network_id_to_code(networkId, self.safe_string(currency, 'code'))
1553
- withdrawFee = self.safe_string(chain, 'withdrawalMinFee')
1554
- if minFee is None or (Precise.string_lt(withdrawFee, minFee)):
1555
- minFee = withdrawFee
1556
- result['networks'][networkCode] = {
1557
- 'withdraw': self.parse_number(withdrawFee),
1558
- 'deposit': {
1559
- 'fee': None,
1560
- 'percentage': None,
1561
- },
1562
- }
1563
- result['withdraw']['fee'] = self.parse_number(minFee)
1564
1557
  return result
1565
1558
 
1566
1559
  def is_futures_method(self, methodName, params):
@@ -2920,7 +2913,7 @@ class kucoin(Exchange, ImplicitAPI):
2920
2913
  },
2921
2914
  'status': status,
2922
2915
  'lastTradeTimestamp': None,
2923
- 'average': None,
2916
+ 'average': self.safe_string(order, 'avgDealPrice'),
2924
2917
  'trades': None,
2925
2918
  }, market)
2926
2919
 
@@ -4153,15 +4146,6 @@ class kucoin(Exchange, ImplicitAPI):
4153
4146
  return config['v1']
4154
4147
  return self.safe_value(config, 'cost', 1)
4155
4148
 
4156
- def parse_borrow_rate_history(self, response, code, since, limit):
4157
- result = []
4158
- for i in range(0, len(response)):
4159
- item = response[i]
4160
- borrowRate = self.parse_borrow_rate(item)
4161
- result.append(borrowRate)
4162
- sorted = self.sort_by(result, 'timestamp')
4163
- return self.filter_by_currency_since_limit(sorted, code, since, limit)
4164
-
4165
4149
  def parse_borrow_rate(self, info, currency: Currency = None):
4166
4150
  #
4167
4151
  # {
ccxt/kucoinfutures.py CHANGED
@@ -2103,8 +2103,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
2103
2103
  amount = self.safe_string(order, 'size')
2104
2104
  filled = self.safe_string(order, 'filledSize')
2105
2105
  cost = self.safe_string(order, 'filledValue')
2106
- average = None
2107
- if Precise.string_gt(filled, '0'):
2106
+ average = self.safe_string(order, 'avgDealPrice')
2107
+ if (average is None) and Precise.string_gt(filled, '0'):
2108
2108
  contractSize = self.safe_string(market, 'contractSize')
2109
2109
  if market['linear']:
2110
2110
  average = Precise.string_div(cost, Precise.string_mul(contractSize, filled))
ccxt/lbank.py CHANGED
@@ -975,15 +975,15 @@ class lbank(Exchange, ImplicitAPI):
975
975
  limit = min(limit, 2000)
976
976
  if since is None:
977
977
  duration = self.parse_timeframe(timeframe)
978
- since = self.milliseconds() - duration * 1000 * limit
978
+ since = self.milliseconds() - (duration * 1000 * limit)
979
979
  request: dict = {
980
980
  'symbol': market['id'],
981
981
  'type': self.safe_string(self.timeframes, timeframe, timeframe),
982
982
  'time': self.parse_to_int(since / 1000),
983
- 'size': limit, # max 2000
983
+ 'size': min(limit + 1, 2000), # max 2000
984
984
  }
985
985
  response = self.spotPublicGetKline(self.extend(request, params))
986
- ohlcvs = self.safe_value(response, 'data', [])
986
+ ohlcvs = self.safe_list(response, 'data', [])
987
987
  #
988
988
  #
989
989
  # [
ccxt/okx.py CHANGED
@@ -17,6 +17,7 @@ from ccxt.base.errors import AccountSuspended
17
17
  from ccxt.base.errors import ArgumentsRequired
18
18
  from ccxt.base.errors import BadRequest
19
19
  from ccxt.base.errors import BadSymbol
20
+ from ccxt.base.errors import OperationRejected
20
21
  from ccxt.base.errors import ManualInteractionNeeded
21
22
  from ccxt.base.errors import InsufficientFunds
22
23
  from ccxt.base.errors import InvalidAddress
@@ -378,6 +379,9 @@ class okx(Exchange, ImplicitAPI):
378
379
  'account/fixed-loan/borrowing-limit': 4,
379
380
  'account/fixed-loan/borrowing-quote': 5,
380
381
  'account/fixed-loan/borrowing-orders-list': 5,
382
+ 'account/spot-manual-borrow-repay': 10,
383
+ 'account/set-auto-repay': 4,
384
+ 'account/spot-borrow-repay-history': 4,
381
385
  # subaccount
382
386
  'users/subaccount/list': 10,
383
387
  'account/subaccount/balances': 10 / 3,
@@ -909,6 +913,11 @@ class okx(Exchange, ImplicitAPI):
909
913
  '59301': ExchangeError, # Margin adjustment failed for exceeding the max limit
910
914
  '59313': ExchangeError, # Unable to repay. You haven't borrowed any {ccy} {ccyPair} in Quick margin mode.
911
915
  '59401': ExchangeError, # Holdings already reached the limit
916
+ '59410': OperationRejected, # You can only borrow self crypto if it supports borrowing and borrowing is enabled.
917
+ '59411': InsufficientFunds, # Manual borrowing failed. Your account's free margin is insufficient
918
+ '59412': OperationRejected, # Manual borrowing failed. The amount exceeds your borrowing limit.
919
+ '59413': OperationRejected, # You didn't borrow self crypto. No repayment needed.
920
+ '59414': BadRequest, # Manual borrowing failed. The minimum borrowing limit is {param0}.needed.
912
921
  '59500': ExchangeError, # Only the APIKey of the main account has permission
913
922
  '59501': ExchangeError, # Only 50 APIKeys can be created per account
914
923
  '59502': ExchangeError, # Note name cannot be duplicate with the currently created APIKey note name
@@ -6230,15 +6239,6 @@ class okx(Exchange, ImplicitAPI):
6230
6239
  borrowRateHistories[code] = self.filter_by_currency_since_limit(borrowRateHistories[code], code, since, limit)
6231
6240
  return borrowRateHistories
6232
6241
 
6233
- def parse_borrow_rate_history(self, response, code, since, limit):
6234
- result = []
6235
- for i in range(0, len(response)):
6236
- item = response[i]
6237
- borrowRate = self.parse_borrow_rate(item)
6238
- result.append(borrowRate)
6239
- sorted = self.sort_by(result, 'timestamp')
6240
- return self.filter_by_currency_since_limit(sorted, code, since, limit)
6241
-
6242
6242
  def fetch_borrow_rate_histories(self, codes=None, since: Int = None, limit: Int = None, params={}):
6243
6243
  """
6244
6244
  retrieves a history of a multiple currencies borrow interest rate at specific time slots, returns all currencies if no symbols passed, default is None
ccxt/phemex.py CHANGED
@@ -82,6 +82,7 @@ class phemex(Exchange, ImplicitAPI):
82
82
  'fetchMarkOHLCV': False,
83
83
  'fetchMyTrades': True,
84
84
  'fetchOHLCV': True,
85
+ 'fetchOpenInterest': True,
85
86
  'fetchOpenOrders': True,
86
87
  'fetchOrder': True,
87
88
  'fetchOrderBook': True,
@@ -4494,6 +4495,77 @@ class phemex(Exchange, ImplicitAPI):
4494
4495
  data = self.safe_dict(response, 'data', {})
4495
4496
  return self.parse_transaction(data, currency)
4496
4497
 
4498
+ def fetch_open_interest(self, symbol: str, params={}):
4499
+ """
4500
+ retrieves the open interest of a trading pair
4501
+ :see: https://phemex-docs.github.io/#query-24-hours-ticker
4502
+ :param str symbol: unified CCXT market symbol
4503
+ :param dict [params]: exchange specific parameters
4504
+ :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
4505
+ """
4506
+ self.load_markets()
4507
+ market = self.market(symbol)
4508
+ if not market['contract']:
4509
+ raise BadRequest(self.id + ' fetchOpenInterest is only supported for contract markets.')
4510
+ request: dict = {
4511
+ 'symbol': market['id'],
4512
+ }
4513
+ response = self.v2GetMdV2Ticker24hr(self.extend(request, params))
4514
+ #
4515
+ # {
4516
+ # error: null,
4517
+ # id: '0',
4518
+ # result: {
4519
+ # closeRp: '67550.1',
4520
+ # fundingRateRr: '0.0001',
4521
+ # highRp: '68400',
4522
+ # indexPriceRp: '67567.15389794',
4523
+ # lowRp: '66096.4',
4524
+ # markPriceRp: '67550.1',
4525
+ # openInterestRv: '1848.1144186',
4526
+ # openRp: '66330',
4527
+ # predFundingRateRr: '0.0001',
4528
+ # symbol: 'BTCUSDT',
4529
+ # timestamp: '1729114315443343001',
4530
+ # turnoverRv: '228863389.3237532',
4531
+ # volumeRq: '3388.5600312'
4532
+ # }
4533
+ # }
4534
+ #
4535
+ result = self.safe_dict(response, 'result')
4536
+ return self.parse_open_interest(result, market)
4537
+
4538
+ def parse_open_interest(self, interest, market: Market = None):
4539
+ #
4540
+ # {
4541
+ # closeRp: '67550.1',
4542
+ # fundingRateRr: '0.0001',
4543
+ # highRp: '68400',
4544
+ # indexPriceRp: '67567.15389794',
4545
+ # lowRp: '66096.4',
4546
+ # markPriceRp: '67550.1',
4547
+ # openInterestRv: '1848.1144186',
4548
+ # openRp: '66330',
4549
+ # predFundingRateRr: '0.0001',
4550
+ # symbol: 'BTCUSDT',
4551
+ # timestamp: '1729114315443343001',
4552
+ # turnoverRv: '228863389.3237532',
4553
+ # volumeRq: '3388.5600312'
4554
+ # }
4555
+ #
4556
+ timestamp = self.safe_integer(interest, 'timestamp') / 1000000
4557
+ id = self.safe_string(interest, 'symbol')
4558
+ return self.safe_open_interest({
4559
+ 'info': interest,
4560
+ 'symbol': self.safe_symbol(id, market),
4561
+ 'baseVolume': self.safe_string(interest, 'volumeRq'),
4562
+ 'quoteVolume': None, # deprecated
4563
+ 'openInterestAmount': self.safe_string(interest, 'openInterestRv'),
4564
+ 'openInterestValue': None,
4565
+ 'timestamp': timestamp,
4566
+ 'datetime': self.iso8601(timestamp),
4567
+ }, market)
4568
+
4497
4569
  def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
4498
4570
  if response is None:
4499
4571
  return None # fallback to default error handler
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.19'
7
+ __version__ = '4.4.21'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
@@ -37,6 +37,7 @@ from ccxt.pro.blofin import blofin # noqa
37
37
  from ccxt.pro.bybit import bybit # noqa: F401
38
38
  from ccxt.pro.cex import cex # noqa: F401
39
39
  from ccxt.pro.coinbase import coinbase # noqa: F401
40
+ from ccxt.pro.coinbaseadvanced import coinbaseadvanced # noqa: F401
40
41
  from ccxt.pro.coinbaseexchange import coinbaseexchange # noqa: F401
41
42
  from ccxt.pro.coinbaseinternational import coinbaseinternational # noqa: F401
42
43
  from ccxt.pro.coincheck import coincheck # noqa: F401
@@ -110,6 +111,7 @@ exchanges = [
110
111
  'bybit',
111
112
  'cex',
112
113
  'coinbase',
114
+ 'coinbaseadvanced',
113
115
  'coinbaseexchange',
114
116
  'coinbaseinternational',
115
117
  'coincheck',
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+
6
+ from ccxt.pro.coinbase import coinbase
7
+
8
+
9
+ class coinbaseadvanced(coinbase):
10
+
11
+ def describe(self):
12
+ return self.deep_extend(super(coinbaseadvanced, self).describe(), {
13
+ 'id': 'coinbaseadvanced',
14
+ 'name': 'Coinbase Advanced',
15
+ 'alias': True,
16
+ })
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ccxt
3
- Version: 4.4.19
3
+ Version: 4.4.21
4
4
  Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
5
5
  Home-page: https://ccxt.com
6
6
  Author: Igor Kroitor
@@ -271,13 +271,13 @@ console.log(version, Object.keys(exchanges));
271
271
 
272
272
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
273
273
 
274
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.19/dist/ccxt.browser.min.js
275
- * unpkg: https://unpkg.com/ccxt@4.4.19/dist/ccxt.browser.min.js
274
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.21/dist/ccxt.browser.min.js
275
+ * unpkg: https://unpkg.com/ccxt@4.4.21/dist/ccxt.browser.min.js
276
276
 
277
277
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
278
278
 
279
279
  ```HTML
280
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.4.19/dist/ccxt.browser.min.js"></script>
280
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.4.21/dist/ccxt.browser.min.js"></script>
281
281
  ```
282
282
 
283
283
  Creates a global `ccxt` object: