ccxt 4.2.64__py2.py3-none-any.whl → 4.2.65__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 (41) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/blofin.py +1 -0
  3. ccxt/abstract/kucoin.py +9 -0
  4. ccxt/abstract/kucoinfutures.py +9 -0
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/base/exchange.py +2 -2
  7. ccxt/async_support/binance.py +26 -4
  8. ccxt/async_support/bingx.py +11 -4
  9. ccxt/async_support/bitmex.py +2 -1
  10. ccxt/async_support/blofin.py +34 -1
  11. ccxt/async_support/btcmarkets.py +9 -0
  12. ccxt/async_support/coinbase.py +9 -2
  13. ccxt/async_support/delta.py +92 -2
  14. ccxt/async_support/gate.py +1 -1
  15. ccxt/async_support/kucoin.py +84 -61
  16. ccxt/async_support/okx.py +1 -1
  17. ccxt/async_support/woo.py +1 -1
  18. ccxt/base/exchange.py +14 -3
  19. ccxt/binance.py +26 -4
  20. ccxt/bingx.py +11 -4
  21. ccxt/bitmex.py +2 -1
  22. ccxt/blofin.py +34 -1
  23. ccxt/btcmarkets.py +9 -0
  24. ccxt/coinbase.py +9 -2
  25. ccxt/delta.py +92 -2
  26. ccxt/gate.py +1 -1
  27. ccxt/kucoin.py +84 -61
  28. ccxt/okx.py +1 -1
  29. ccxt/pro/__init__.py +1 -1
  30. ccxt/pro/currencycom.py +1 -1
  31. ccxt/static_dependencies/ethereum/utils/__init__.py +0 -6
  32. ccxt/static_dependencies/ethereum/utils/curried/__init__.py +0 -4
  33. ccxt/test/base/test_shared_methods.py +1 -1
  34. ccxt/woo.py +1 -1
  35. {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/METADATA +4 -4
  36. {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/RECORD +38 -41
  37. ccxt/static_dependencies/ethereum/utils/__json/eth_networks.json +0 -1
  38. ccxt/static_dependencies/ethereum/utils/network.py +0 -88
  39. ccxt-4.2.64.data/data/ccxt/eth_networks.json +0 -1
  40. {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/WHEEL +0 -0
  41. {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/top_level.txt +0 -0
ccxt/binance.py CHANGED
@@ -2374,7 +2374,7 @@ class binance(Exchange, ImplicitAPI):
2374
2374
  else:
2375
2375
  return subType == 'linear'
2376
2376
 
2377
- def set_sandbox_mode(self, enable):
2377
+ def set_sandbox_mode(self, enable: bool):
2378
2378
  super(binance, self).set_sandbox_mode(enable)
2379
2379
  self.options['sandboxMode'] = enable
2380
2380
 
@@ -2521,6 +2521,7 @@ class binance(Exchange, ImplicitAPI):
2521
2521
  :see: https://binance-docs.github.io/apidocs/futures/en/#check-server-time # swap
2522
2522
  :see: https://binance-docs.github.io/apidocs/delivery/en/#check-server-time # future
2523
2523
  :param dict [params]: extra parameters specific to the exchange API endpoint
2524
+ :param str [params.subType]: "linear" or "inverse"
2524
2525
  :returns int: the current integer timestamp in milliseconds from the exchange server
2525
2526
  """
2526
2527
  defaultType = self.safe_string_2(self.options, 'fetchTime', 'defaultType', 'spot')
@@ -3251,6 +3252,7 @@ class binance(Exchange, ImplicitAPI):
3251
3252
  :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
3252
3253
  :param str[]|None [params.symbols]: unified market symbols, only used in isolated margin mode
3253
3254
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch the balance for a portfolio margin account
3255
+ :param str [params.subType]: "linear" or "inverse"
3254
3256
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
3255
3257
  """
3256
3258
  self.load_markets()
@@ -3791,6 +3793,7 @@ class binance(Exchange, ImplicitAPI):
3791
3793
  :see: https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker # future
3792
3794
  :param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
3793
3795
  :param dict [params]: extra parameters specific to the exchange API endpoint
3796
+ :param str [params.subType]: "linear" or "inverse"
3794
3797
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
3795
3798
  """
3796
3799
  self.load_markets()
@@ -3824,6 +3827,7 @@ class binance(Exchange, ImplicitAPI):
3824
3827
  :see: https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker # future
3825
3828
  :param str[]|None symbols: unified symbols of the markets to fetch the last prices
3826
3829
  :param dict [params]: extra parameters specific to the exchange API endpoint
3830
+ :param str [params.subType]: "linear" or "inverse"
3827
3831
  :returns dict: a dictionary of lastprices structures
3828
3832
  """
3829
3833
  self.load_markets()
@@ -3923,6 +3927,7 @@ class binance(Exchange, ImplicitAPI):
3923
3927
  :see: https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics # option
3924
3928
  :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
3925
3929
  :param dict [params]: extra parameters specific to the exchange API endpoint
3930
+ :param str [params.subType]: "linear" or "inverse"
3926
3931
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
3927
3932
  """
3928
3933
  self.load_markets()
@@ -6102,6 +6107,7 @@ class binance(Exchange, ImplicitAPI):
6102
6107
  :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
6103
6108
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch open orders in the portfolio margin account
6104
6109
  :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account conditional orders
6110
+ :param str [params.subType]: "linear" or "inverse"
6105
6111
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
6106
6112
  """
6107
6113
  self.load_markets()
@@ -8018,6 +8024,7 @@ class binance(Exchange, ImplicitAPI):
8018
8024
  :param str symbol: unified market symbol
8019
8025
  :param dict [params]: extra parameters specific to the exchange API endpoint
8020
8026
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch trading fees in a portfolio margin account
8027
+ :param str [params.subType]: "linear" or "inverse"
8021
8028
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
8022
8029
  """
8023
8030
  self.load_markets()
@@ -8076,6 +8083,7 @@ class binance(Exchange, ImplicitAPI):
8076
8083
  :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
8077
8084
  :see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
8078
8085
  :param dict [params]: extra parameters specific to the exchange API endpoint
8086
+ :param str [params.subType]: "linear" or "inverse"
8079
8087
  :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
8080
8088
  """
8081
8089
  self.load_markets()
@@ -8311,6 +8319,7 @@ class binance(Exchange, ImplicitAPI):
8311
8319
  :param dict [params]: extra parameters specific to the exchange API endpoint
8312
8320
  :param int [params.until]: timestamp in ms of the latest funding rate
8313
8321
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
8322
+ :param str [params.subType]: "linear" or "inverse"
8314
8323
  :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
8315
8324
  """
8316
8325
  self.load_markets()
@@ -8373,6 +8382,7 @@ class binance(Exchange, ImplicitAPI):
8373
8382
  :see: https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
8374
8383
  :param str[]|None symbols: list of unified market symbols
8375
8384
  :param dict [params]: extra parameters specific to the exchange API endpoint
8385
+ :param str [params.subType]: "linear" or "inverse"
8376
8386
  :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
8377
8387
  """
8378
8388
  self.load_markets()
@@ -8943,6 +8953,7 @@ class binance(Exchange, ImplicitAPI):
8943
8953
  :param str[]|None symbols: list of unified market symbols
8944
8954
  :param dict [params]: extra parameters specific to the exchange API endpoint
8945
8955
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch the leverage tiers for a portfolio margin account
8956
+ :param str [params.subType]: "linear" or "inverse"
8946
8957
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
8947
8958
  """
8948
8959
  self.load_markets()
@@ -9229,6 +9240,7 @@ class binance(Exchange, ImplicitAPI):
9229
9240
  :param str[]|None symbols: list of unified market symbols
9230
9241
  :param dict [params]: extra parameters specific to the exchange API endpoint
9231
9242
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch positions in a portfolio margin account
9243
+ :param str [params.subType]: "linear" or "inverse"
9232
9244
  :returns dict: data on account positions
9233
9245
  """
9234
9246
  if symbols is not None:
@@ -9271,6 +9283,7 @@ class binance(Exchange, ImplicitAPI):
9271
9283
  :param str[]|None symbols: list of unified market symbols
9272
9284
  :param dict [params]: extra parameters specific to the exchange API endpoint
9273
9285
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch positions for a portfolio margin account
9286
+ :param str [params.subType]: "linear" or "inverse"
9274
9287
  :returns dict: data on the positions risk
9275
9288
  """
9276
9289
  if symbols is not None:
@@ -9417,6 +9430,7 @@ class binance(Exchange, ImplicitAPI):
9417
9430
  :param dict [params]: extra parameters specific to the exchange API endpoint
9418
9431
  :param int [params.until]: timestamp in ms of the latest funding history entry
9419
9432
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch the funding history for a portfolio margin account
9433
+ :param str [params.subType]: "linear" or "inverse"
9420
9434
  :returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
9421
9435
  """
9422
9436
  self.load_markets()
@@ -9563,6 +9577,7 @@ class binance(Exchange, ImplicitAPI):
9563
9577
  :param str symbol: not used by binance setPositionMode()
9564
9578
  :param dict [params]: extra parameters specific to the exchange API endpoint
9565
9579
  :param boolean [params.portfolioMargin]: set to True if you would like to set the position mode for a portfolio margin account
9580
+ :param str [params.subType]: "linear" or "inverse"
9566
9581
  :returns dict: response from the exchange
9567
9582
  """
9568
9583
  defaultType = self.safe_string(self.options, 'defaultType', 'future')
@@ -9586,11 +9601,13 @@ class binance(Exchange, ImplicitAPI):
9586
9601
  response = self.papiPostCmPositionSideDual(self.extend(request, params))
9587
9602
  else:
9588
9603
  response = self.dapiPrivatePostPositionSideDual(self.extend(request, params))
9589
- else:
9604
+ elif self.is_linear(type, subType):
9590
9605
  if isPortfolioMargin:
9591
9606
  response = self.papiPostUmPositionSideDual(self.extend(request, params))
9592
9607
  else:
9593
9608
  response = self.fapiPrivatePostPositionSideDual(self.extend(request, params))
9609
+ else:
9610
+ raise BadRequest(self.id + ' setPositionMode() supports linear and inverse contracts only')
9594
9611
  #
9595
9612
  # {
9596
9613
  # "code": 200,
@@ -9608,6 +9625,7 @@ class binance(Exchange, ImplicitAPI):
9608
9625
  :see: https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
9609
9626
  :param str[] [symbols]: a list of unified market symbols
9610
9627
  :param dict [params]: extra parameters specific to the exchange API endpoint
9628
+ :param str [params.subType]: "linear" or "inverse"
9611
9629
  :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
9612
9630
  """
9613
9631
  self.load_markets()
@@ -9855,6 +9873,7 @@ class binance(Exchange, ImplicitAPI):
9855
9873
  :param int [params.until]: timestamp in ms of the latest ledger entry
9856
9874
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
9857
9875
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch the ledger for a portfolio margin account
9876
+ :param str [params.subType]: "linear" or "inverse"
9858
9877
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
9859
9878
  """
9860
9879
  self.load_markets()
@@ -10854,6 +10873,8 @@ class binance(Exchange, ImplicitAPI):
10854
10873
  :param int [params.until]: timestamp in ms of the latest liquidation
10855
10874
  :param boolean [params.paginate]: *spot only* default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
10856
10875
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch liquidations in a portfolio margin account
10876
+ :param str [params.type]: "spot"
10877
+ :param str [params.subType]: "linear" or "inverse"
10857
10878
  :returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
10858
10879
  """
10859
10880
  self.load_markets()
@@ -11154,8 +11175,8 @@ class binance(Exchange, ImplicitAPI):
11154
11175
  """
11155
11176
  fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
11156
11177
  :param str symbol: unified symbol of the market to fetch the order book for
11157
- :param dict params: extra parameters specific to the exchange API endpoint
11158
- :param str params['subType']: "linear" or "inverse"
11178
+ :param dict [params]: extra parameters specific to the exchange API endpoint
11179
+ :param str [params.subType]: "linear" or "inverse"
11159
11180
  :returns dict: an object detailing whether the market is in hedged or one-way mode
11160
11181
  """
11161
11182
  market = None
@@ -11187,6 +11208,7 @@ class binance(Exchange, ImplicitAPI):
11187
11208
  :see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
11188
11209
  :param str symbol: unified symbol of the market the order was made in
11189
11210
  :param dict [params]: extra parameters specific to the exchange API endpoint
11211
+ :param str [params.subType]: "linear" or "inverse"
11190
11212
  :returns dict: a list of `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
11191
11213
  """
11192
11214
  self.load_markets()
ccxt/bingx.py CHANGED
@@ -1769,6 +1769,7 @@ class bingx(Exchange, ImplicitAPI):
1769
1769
  takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1770
1770
  trailingAmount = self.safe_string(params, 'trailingAmount')
1771
1771
  trailingPercent = self.safe_string_2(params, 'trailingPercent', 'priceRate')
1772
+ trailingType = self.safe_string(params, 'trailingType', 'TRAILING_STOP_MARKET')
1772
1773
  isTriggerOrder = triggerPrice is not None
1773
1774
  isStopLossPriceOrder = stopLossPrice is not None
1774
1775
  isTakeProfitPriceOrder = takeProfitPrice is not None
@@ -1804,7 +1805,7 @@ class bingx(Exchange, ImplicitAPI):
1804
1805
  elif (type == 'LIMIT') or (type == 'TAKE_PROFIT'):
1805
1806
  request['type'] = 'TAKE_PROFIT'
1806
1807
  elif isTrailing:
1807
- request['type'] = 'TRAILING_STOP_MARKET'
1808
+ request['type'] = trailingType
1808
1809
  if isTrailingAmountOrder:
1809
1810
  request['price'] = self.parse_to_numeric(trailingAmount)
1810
1811
  elif isTrailingPercentOrder:
@@ -1849,7 +1850,7 @@ class bingx(Exchange, ImplicitAPI):
1849
1850
  positionSide = 'LONG' if (side == 'buy') else 'SHORT'
1850
1851
  request['positionSide'] = positionSide
1851
1852
  request['quantity'] = self.parse_to_numeric(self.amount_to_precision(symbol, amount))
1852
- params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId'])
1853
+ params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId'])
1853
1854
  return self.extend(request, params)
1854
1855
 
1855
1856
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: float = None, params={}):
@@ -1877,14 +1878,20 @@ class bingx(Exchange, ImplicitAPI):
1877
1878
  :param float [params.takeProfit.triggerPrice]: take profit trigger price
1878
1879
  :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
1879
1880
  :param float [params.stopLoss.triggerPrice]: stop loss trigger price
1881
+ :param boolean [params.test]: *swap only* whether to use the test endpoint or not, default is False
1880
1882
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1881
1883
  """
1882
1884
  self.load_markets()
1883
1885
  market = self.market(symbol)
1886
+ test = self.safe_bool(params, 'test', False)
1887
+ params = self.omit(params, 'test')
1884
1888
  request = self.create_order_request(symbol, type, side, amount, price, params)
1885
1889
  response = None
1886
1890
  if market['swap']:
1887
- response = self.swapV2PrivatePostTradeOrder(request)
1891
+ if test:
1892
+ response = self.swapV2PrivatePostTradeOrderTest(request)
1893
+ else:
1894
+ response = self.swapV2PrivatePostTradeOrder(request)
1888
1895
  else:
1889
1896
  response = self.spotV1PrivatePostTradeOrder(request)
1890
1897
  #
@@ -3791,7 +3798,7 @@ class bingx(Exchange, ImplicitAPI):
3791
3798
  :param str [params.newClientOrderId]: custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
3792
3799
  :param str [params.positionSide]: *contract only* position direction, required for single position, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
3793
3800
  :param str [params.reduceOnly]: *contract only* True or False, default=false for single position mode. self parameter is not accepted for both long and short positions mode
3794
- :param float [params.priceRate]: *contract only* for type TRAILING_STOP_Market, Max = 1
3801
+ :param float [params.priceRate]: *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
3795
3802
  :param str [params.workingType]: *contract only* StopPrice trigger price types, MARK_PRICE(default), CONTRACT_PRICE, or INDEX_PRICE
3796
3803
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3797
3804
  """
ccxt/bitmex.py CHANGED
@@ -2388,7 +2388,8 @@ class bitmex(Exchange, ImplicitAPI):
2388
2388
  params = self.omit(params, ['until', 'till'])
2389
2389
  if until is not None:
2390
2390
  request['endTime'] = self.iso8601(until)
2391
- request['reverse'] = True
2391
+ if (since is None) and (until is None):
2392
+ request['reverse'] = True
2392
2393
  response = self.publicGetFunding(self.extend(request, params))
2393
2394
  #
2394
2395
  # [
ccxt/blofin.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.blofin import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, MarginMode, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import ArgumentsRequired
@@ -91,6 +91,8 @@ class blofin(Exchange, ImplicitAPI):
91
91
  'fetchLeverage': True,
92
92
  'fetchLeverages': True,
93
93
  'fetchLeverageTiers': False,
94
+ 'fetchMarginMode': True,
95
+ 'fetchMarginModes': False,
94
96
  'fetchMarketLeverageTiers': False,
95
97
  'fetchMarkets': True,
96
98
  'fetchMarkOHLCV': False,
@@ -194,6 +196,7 @@ class blofin(Exchange, ImplicitAPI):
194
196
  'account/balance': 1,
195
197
  'account/positions': 1,
196
198
  'account/leverage-info': 1,
199
+ 'account/margin-mode': 1,
197
200
  'account/batch-leverage-info': 1,
198
201
  'trade/orders-tpsl-pending': 1,
199
202
  'trade/orders-history': 1,
@@ -1954,6 +1957,36 @@ class blofin(Exchange, ImplicitAPI):
1954
1957
  data = self.safe_list(response, 'data', [])
1955
1958
  return self.parse_orders(data, market, since, limit)
1956
1959
 
1960
+ def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
1961
+ """
1962
+ fetches the margin mode of a trading pair
1963
+ :see: https://docs.blofin.com/index.html#get-margin-mode
1964
+ :param str symbol: unified symbol of the market to fetch the margin mode for
1965
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1966
+ :returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
1967
+ """
1968
+ self.load_markets()
1969
+ market = self.market(symbol)
1970
+ response = self.privateGetAccountMarginMode(params)
1971
+ #
1972
+ # {
1973
+ # "code": "0",
1974
+ # "msg": "success",
1975
+ # "data": {
1976
+ # "marginMode": "cross"
1977
+ # }
1978
+ # }
1979
+ #
1980
+ data = self.safe_dict(response, 'data', {})
1981
+ return self.parse_margin_mode(data, market)
1982
+
1983
+ def parse_margin_mode(self, marginMode, market=None) -> MarginMode:
1984
+ return {
1985
+ 'info': marginMode,
1986
+ 'symbol': market['symbol'],
1987
+ 'marginMode': self.safe_string(marginMode, 'marginMode'),
1988
+ }
1989
+
1957
1990
  def handle_errors(self, httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody):
1958
1991
  if response is None:
1959
1992
  return None # fallback to default error handler
ccxt/btcmarkets.py CHANGED
@@ -870,6 +870,15 @@ class btcmarkets(Exchange, ImplicitAPI):
870
870
  return self.privateDeleteOrdersId(self.extend(request, params))
871
871
 
872
872
  def calculate_fee(self, symbol, type, side, amount, price, takerOrMaker='taker', params={}):
873
+ """
874
+ calculates the presumptive fee that would be charged for an order
875
+ :param str symbol: unified market symbol
876
+ :param str type: not used by btcmarkets.calculate_fee :param string side: not used by btcmarkets.calculate_fee :param float amount: how much you want to trade, in units of the base currency on most exchanges, or number of contracts
877
+ :param float price: the price for the order to be filled at, in units of the quote currency
878
+ :param str takerOrMaker: 'taker' or 'maker'
879
+ :param dict params:
880
+ :returns dict: contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
881
+ """
873
882
  market = self.markets[symbol]
874
883
  currency = None
875
884
  cost = None
ccxt/coinbase.py CHANGED
@@ -3521,7 +3521,8 @@ class coinbase(Exchange, ImplicitAPI):
3521
3521
  def sign(self, path, api=[], method='GET', params={}, headers=None, body=None):
3522
3522
  version = api[0]
3523
3523
  signed = api[1] == 'private'
3524
- pathPart = 'api/v3' if (version == 'v3') else 'v2'
3524
+ isV3 = version == 'v3'
3525
+ pathPart = 'api/v3' if (isV3) else 'v2'
3525
3526
  fullPath = '/' + pathPart + '/' + self.implode_params(path, params)
3526
3527
  query = self.omit(params, self.extract_params(path))
3527
3528
  savedPath = fullPath
@@ -3555,8 +3556,14 @@ class coinbase(Exchange, ImplicitAPI):
3555
3556
  if query:
3556
3557
  body = self.json(query)
3557
3558
  payload = body
3558
- # 'GET' doesn't need payload in the signature. inside url is enough
3559
+ else:
3560
+ if not isV3:
3561
+ if query:
3562
+ payload += '?' + self.urlencode(query)
3563
+ # v3: 'GET' doesn't need payload in the signature. inside url is enough
3559
3564
  # https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
3565
+ # v2: 'GET' require payload in the signature
3566
+ # https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-key-authentication
3560
3567
  auth = timestampString + method + savedPath + payload
3561
3568
  signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256)
3562
3569
  headers = {
ccxt/delta.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.delta import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Market, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
9
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, MarginMode, Market, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import ArgumentsRequired
@@ -61,7 +61,8 @@ class delta(Exchange, ImplicitAPI):
61
61
  'fetchLedger': True,
62
62
  'fetchLeverage': True,
63
63
  'fetchLeverageTiers': False, # An infinite number of tiers, see examples/js/delta-maintenance-margin-rate-max-leverage.js
64
- 'fetchMarginMode': False,
64
+ 'fetchMarginMode': True,
65
+ 'fetchMarginModes': False,
65
66
  'fetchMarketLeverageTiers': False,
66
67
  'fetchMarkets': True,
67
68
  'fetchMarkOHLCV': True,
@@ -3088,6 +3089,95 @@ class delta(Exchange, ImplicitAPI):
3088
3089
  position = self.parse_position(self.safe_value(response, 'result', {}))
3089
3090
  return [position]
3090
3091
 
3092
+ def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
3093
+ """
3094
+ fetches the margin mode of a trading pair
3095
+ :see: https://docs.delta.exchange/#get-user
3096
+ :param str symbol: unified symbol of the market to fetch the margin mode for
3097
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3098
+ :returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
3099
+ """
3100
+ self.load_markets()
3101
+ market = None
3102
+ if symbol is not None:
3103
+ market = self.market(symbol)
3104
+ response = self.privateGetProfile(params)
3105
+ #
3106
+ # {
3107
+ # "result": {
3108
+ # "is_password_set": True,
3109
+ # "kyc_expiry_date": null,
3110
+ # "phishing_code": "12345",
3111
+ # "preferences": {
3112
+ # "favorites": []
3113
+ # },
3114
+ # "is_kyc_provisioned": False,
3115
+ # "country": "Canada",
3116
+ # "margin_mode": "isolated",
3117
+ # "mfa_updated_at": "2023-07-19T01:04:43Z",
3118
+ # "last_name": "",
3119
+ # "oauth_apple_active": False,
3120
+ # "pf_index_symbol": null,
3121
+ # "proof_of_identity_status": "approved",
3122
+ # "dob": null,
3123
+ # "email": "abc_123@gmail.com",
3124
+ # "force_change_password": False,
3125
+ # "nick_name": "still-breeze-123",
3126
+ # "oauth_google_active": False,
3127
+ # "phone_verification_status": "verified",
3128
+ # "id": 12345678,
3129
+ # "last_seen": null,
3130
+ # "is_withdrawal_enabled": True,
3131
+ # "force_change_mfa": False,
3132
+ # "enable_bots": False,
3133
+ # "kyc_verified_on": null,
3134
+ # "created_at": "2023-07-19T01:02:32Z",
3135
+ # "withdrawal_blocked_till": null,
3136
+ # "proof_of_address_status": "approved",
3137
+ # "is_password_change_blocked": False,
3138
+ # "is_mfa_enabled": True,
3139
+ # "is_kyc_done": True,
3140
+ # "oauth": null,
3141
+ # "account_name": "Main",
3142
+ # "sub_account_permissions": null,
3143
+ # "phone_number": null,
3144
+ # "tracking_info": {
3145
+ # "ga_cid": "1234.4321",
3146
+ # "is_kyc_gtm_tracked": True,
3147
+ # "sub_account_config": {
3148
+ # "cross": 2,
3149
+ # "isolated": 2,
3150
+ # "portfolio": 2
3151
+ # }
3152
+ # },
3153
+ # "first_name": "",
3154
+ # "phone_verified_on": null,
3155
+ # "seen_intro": False,
3156
+ # "password_updated_at": null,
3157
+ # "is_login_enabled": True,
3158
+ # "registration_date": "2023-07-19T01:02:32Z",
3159
+ # "permissions": {},
3160
+ # "max_sub_accounts_limit": 2,
3161
+ # "country_calling_code": null,
3162
+ # "is_sub_account": False,
3163
+ # "is_kyc_refresh_required": False
3164
+ # },
3165
+ # "success": True
3166
+ # }
3167
+ #
3168
+ result = self.safe_dict(response, 'result', {})
3169
+ return self.parse_margin_mode(result, market)
3170
+
3171
+ def parse_margin_mode(self, marginMode, market=None) -> MarginMode:
3172
+ symbol = None
3173
+ if market is not None:
3174
+ symbol = market['symbol']
3175
+ return {
3176
+ 'info': marginMode,
3177
+ 'symbol': symbol,
3178
+ 'marginMode': self.safe_string(marginMode, 'margin_mode'),
3179
+ }
3180
+
3091
3181
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
3092
3182
  requestPath = '/' + self.version + '/' + self.implode_params(path, params)
3093
3183
  url = self.urls['api'][api] + requestPath
ccxt/gate.py CHANGED
@@ -879,7 +879,7 @@ class gate(Exchange, ImplicitAPI):
879
879
  },
880
880
  })
881
881
 
882
- def set_sandbox_mode(self, enable):
882
+ def set_sandbox_mode(self, enable: bool):
883
883
  super(gate, self).set_sandbox_mode(enable)
884
884
  self.options['sandboxMode'] = enable
885
885