ccxt 4.2.63__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.
- ccxt/__init__.py +1 -1
- ccxt/abstract/blofin.py +1 -0
- ccxt/abstract/krakenfutures.py +1 -0
- ccxt/abstract/kucoin.py +10 -0
- ccxt/abstract/kucoinfutures.py +10 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +2 -2
- ccxt/async_support/binance.py +32 -13
- ccxt/async_support/bingx.py +56 -49
- ccxt/async_support/bitget.py +66 -2
- ccxt/async_support/bitmex.py +2 -1
- ccxt/async_support/blofin.py +45 -12
- ccxt/async_support/btcmarkets.py +9 -0
- ccxt/async_support/bybit.py +90 -6
- ccxt/async_support/coinbase.py +9 -2
- ccxt/async_support/delta.py +92 -2
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/gemini.py +9 -5
- ccxt/async_support/hitbtc.py +1 -1
- ccxt/async_support/krakenfutures.py +1 -0
- ccxt/async_support/kucoin.py +85 -61
- ccxt/async_support/okx.py +1 -1
- ccxt/async_support/woo.py +1 -1
- ccxt/async_support/yobit.py +15 -15
- ccxt/base/exchange.py +14 -3
- ccxt/binance.py +32 -13
- ccxt/bingx.py +56 -49
- ccxt/bitget.py +66 -2
- ccxt/bitmex.py +2 -1
- ccxt/blofin.py +45 -12
- ccxt/btcmarkets.py +9 -0
- ccxt/bybit.py +90 -6
- ccxt/coinbase.py +9 -2
- ccxt/delta.py +92 -2
- ccxt/gate.py +1 -1
- ccxt/gemini.py +9 -5
- ccxt/hitbtc.py +1 -1
- ccxt/krakenfutures.py +1 -0
- ccxt/kucoin.py +85 -61
- ccxt/okx.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitget.py +4 -3
- ccxt/pro/coinex.py +4 -4
- ccxt/pro/currencycom.py +1 -1
- ccxt/pro/lbank.py +1 -1
- ccxt/static_dependencies/ethereum/utils/__init__.py +0 -6
- ccxt/static_dependencies/ethereum/utils/curried/__init__.py +0 -4
- ccxt/test/base/test_shared_methods.py +1 -1
- ccxt/test/test_async.py +13 -1
- ccxt/test/test_sync.py +13 -1
- ccxt/woo.py +1 -1
- ccxt/yobit.py +15 -15
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/METADATA +4 -4
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/RECORD +56 -59
- ccxt/static_dependencies/ethereum/utils/__json/eth_networks.json +0 -1
- ccxt/static_dependencies/ethereum/utils/network.py +0 -88
- ccxt-4.2.63.data/data/ccxt/eth_networks.json +0 -1
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/WHEEL +0 -0
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/top_level.txt +0 -0
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.2.
|
7
|
+
__version__ = '4.2.65'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -2818,6 +2818,17 @@ class Exchange(object):
|
|
2818
2818
|
return self.filter_by_symbol_since_limit(results, symbol, since, limit)
|
2819
2819
|
|
2820
2820
|
def calculate_fee(self, symbol: str, type: str, side: str, amount: float, price: float, takerOrMaker='taker', params={}):
|
2821
|
+
"""
|
2822
|
+
calculates the presumptive fee that would be charged for an order
|
2823
|
+
:param str symbol: unified market symbol
|
2824
|
+
:param str type: 'market' or 'limit'
|
2825
|
+
:param str side: 'buy' or 'sell'
|
2826
|
+
:param float amount: how much you want to trade, in units of the base currency on most exchanges, or number of contracts
|
2827
|
+
:param float price: the price for the order to be filled at, in units of the quote currency
|
2828
|
+
:param str takerOrMaker: 'taker' or 'maker'
|
2829
|
+
:param dict params:
|
2830
|
+
: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
|
2831
|
+
"""
|
2821
2832
|
if type == 'market' and takerOrMaker == 'maker':
|
2822
2833
|
raise ArgumentsRequired(self.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.')
|
2823
2834
|
market = self.markets[symbol]
|
@@ -3834,7 +3845,7 @@ class Exchange(object):
|
|
3834
3845
|
self.load_markets()
|
3835
3846
|
if not self.has['fetchBorrowRates']:
|
3836
3847
|
raise NotSupported(self.id + ' fetchIsolatedBorrowRate() is not supported yet')
|
3837
|
-
borrowRates = self.
|
3848
|
+
borrowRates = self.fetch_isolated_borrow_rates(params)
|
3838
3849
|
rate = self.safe_dict(borrowRates, symbol)
|
3839
3850
|
if rate is None:
|
3840
3851
|
raise ExchangeError(self.id + ' fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ' + symbol)
|
@@ -3849,7 +3860,7 @@ class Exchange(object):
|
|
3849
3860
|
params = self.omit(params, [optionName, defaultOptionName])
|
3850
3861
|
else:
|
3851
3862
|
# handle routed methods like "watchTrades > watchTradesForSymbols"(or "watchTicker > watchTickers")
|
3852
|
-
methodName, params = self.
|
3863
|
+
methodName, params = self.handle_param_string(params, 'callerMethodName', methodName)
|
3853
3864
|
# check if exchange has properties for self method
|
3854
3865
|
exchangeWideMethodOptions = self.safe_value(self.options, methodName)
|
3855
3866
|
if exchangeWideMethodOptions is not None:
|
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')
|
@@ -2758,14 +2759,11 @@ class binance(Exchange, ImplicitAPI):
|
|
2758
2759
|
else:
|
2759
2760
|
raise ExchangeError(self.id + ' fetchMarkets() self.options fetchMarkets "' + marketType + '" is not a supported market type')
|
2760
2761
|
promises = promisesRaw
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
markets = self.array_concat(markets, futureMarkets)
|
2767
|
-
markets = self.array_concat(markets, deliveryMarkets)
|
2768
|
-
markets = self.array_concat(markets, optionMarkets)
|
2762
|
+
markets = []
|
2763
|
+
for i in range(0, len(fetchMarkets)):
|
2764
|
+
promise = self.safe_dict(promises, i)
|
2765
|
+
promiseMarkets = self.safe_list_2(promise, 'symbols', 'optionSymbols', [])
|
2766
|
+
markets = self.array_concat(markets, promiseMarkets)
|
2769
2767
|
#
|
2770
2768
|
# spot / margin
|
2771
2769
|
#
|
@@ -3254,6 +3252,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3254
3252
|
:param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
|
3255
3253
|
:param str[]|None [params.symbols]: unified market symbols, only used in isolated margin mode
|
3256
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"
|
3257
3256
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
3258
3257
|
"""
|
3259
3258
|
self.load_markets()
|
@@ -3794,6 +3793,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3794
3793
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker # future
|
3795
3794
|
:param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
3796
3795
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3796
|
+
:param str [params.subType]: "linear" or "inverse"
|
3797
3797
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
3798
3798
|
"""
|
3799
3799
|
self.load_markets()
|
@@ -3827,6 +3827,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3827
3827
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker # future
|
3828
3828
|
:param str[]|None symbols: unified symbols of the markets to fetch the last prices
|
3829
3829
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3830
|
+
:param str [params.subType]: "linear" or "inverse"
|
3830
3831
|
:returns dict: a dictionary of lastprices structures
|
3831
3832
|
"""
|
3832
3833
|
self.load_markets()
|
@@ -3926,6 +3927,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3926
3927
|
:see: https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics # option
|
3927
3928
|
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
3928
3929
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3930
|
+
:param str [params.subType]: "linear" or "inverse"
|
3929
3931
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
3930
3932
|
"""
|
3931
3933
|
self.load_markets()
|
@@ -6105,6 +6107,7 @@ class binance(Exchange, ImplicitAPI):
|
|
6105
6107
|
:param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
|
6106
6108
|
:param boolean [params.portfolioMargin]: set to True if you would like to fetch open orders in the portfolio margin account
|
6107
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"
|
6108
6111
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
6109
6112
|
"""
|
6110
6113
|
self.load_markets()
|
@@ -8021,6 +8024,7 @@ class binance(Exchange, ImplicitAPI):
|
|
8021
8024
|
:param str symbol: unified market symbol
|
8022
8025
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8023
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"
|
8024
8028
|
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
8025
8029
|
"""
|
8026
8030
|
self.load_markets()
|
@@ -8079,6 +8083,7 @@ class binance(Exchange, ImplicitAPI):
|
|
8079
8083
|
:see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
8080
8084
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
8081
8085
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8086
|
+
:param str [params.subType]: "linear" or "inverse"
|
8082
8087
|
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
|
8083
8088
|
"""
|
8084
8089
|
self.load_markets()
|
@@ -8314,6 +8319,7 @@ class binance(Exchange, ImplicitAPI):
|
|
8314
8319
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8315
8320
|
:param int [params.until]: timestamp in ms of the latest funding rate
|
8316
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"
|
8317
8323
|
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
|
8318
8324
|
"""
|
8319
8325
|
self.load_markets()
|
@@ -8376,6 +8382,7 @@ class binance(Exchange, ImplicitAPI):
|
|
8376
8382
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
|
8377
8383
|
:param str[]|None symbols: list of unified market symbols
|
8378
8384
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8385
|
+
:param str [params.subType]: "linear" or "inverse"
|
8379
8386
|
:returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
|
8380
8387
|
"""
|
8381
8388
|
self.load_markets()
|
@@ -8946,6 +8953,7 @@ class binance(Exchange, ImplicitAPI):
|
|
8946
8953
|
:param str[]|None symbols: list of unified market symbols
|
8947
8954
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8948
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"
|
8949
8957
|
:returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
|
8950
8958
|
"""
|
8951
8959
|
self.load_markets()
|
@@ -9232,6 +9240,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9232
9240
|
:param str[]|None symbols: list of unified market symbols
|
9233
9241
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
9234
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"
|
9235
9244
|
:returns dict: data on account positions
|
9236
9245
|
"""
|
9237
9246
|
if symbols is not None:
|
@@ -9274,6 +9283,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9274
9283
|
:param str[]|None symbols: list of unified market symbols
|
9275
9284
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
9276
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"
|
9277
9287
|
:returns dict: data on the positions risk
|
9278
9288
|
"""
|
9279
9289
|
if symbols is not None:
|
@@ -9420,6 +9430,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9420
9430
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
9421
9431
|
:param int [params.until]: timestamp in ms of the latest funding history entry
|
9422
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"
|
9423
9434
|
:returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
|
9424
9435
|
"""
|
9425
9436
|
self.load_markets()
|
@@ -9566,6 +9577,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9566
9577
|
:param str symbol: not used by binance setPositionMode()
|
9567
9578
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
9568
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"
|
9569
9581
|
:returns dict: response from the exchange
|
9570
9582
|
"""
|
9571
9583
|
defaultType = self.safe_string(self.options, 'defaultType', 'future')
|
@@ -9589,11 +9601,13 @@ class binance(Exchange, ImplicitAPI):
|
|
9589
9601
|
response = self.papiPostCmPositionSideDual(self.extend(request, params))
|
9590
9602
|
else:
|
9591
9603
|
response = self.dapiPrivatePostPositionSideDual(self.extend(request, params))
|
9592
|
-
|
9604
|
+
elif self.is_linear(type, subType):
|
9593
9605
|
if isPortfolioMargin:
|
9594
9606
|
response = self.papiPostUmPositionSideDual(self.extend(request, params))
|
9595
9607
|
else:
|
9596
9608
|
response = self.fapiPrivatePostPositionSideDual(self.extend(request, params))
|
9609
|
+
else:
|
9610
|
+
raise BadRequest(self.id + ' setPositionMode() supports linear and inverse contracts only')
|
9597
9611
|
#
|
9598
9612
|
# {
|
9599
9613
|
# "code": 200,
|
@@ -9611,6 +9625,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9611
9625
|
:see: https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
9612
9626
|
:param str[] [symbols]: a list of unified market symbols
|
9613
9627
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
9628
|
+
:param str [params.subType]: "linear" or "inverse"
|
9614
9629
|
:returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
|
9615
9630
|
"""
|
9616
9631
|
self.load_markets()
|
@@ -9858,6 +9873,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9858
9873
|
:param int [params.until]: timestamp in ms of the latest ledger entry
|
9859
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)
|
9860
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"
|
9861
9877
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
9862
9878
|
"""
|
9863
9879
|
self.load_markets()
|
@@ -10857,6 +10873,8 @@ class binance(Exchange, ImplicitAPI):
|
|
10857
10873
|
:param int [params.until]: timestamp in ms of the latest liquidation
|
10858
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)
|
10859
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"
|
10860
10878
|
:returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
|
10861
10879
|
"""
|
10862
10880
|
self.load_markets()
|
@@ -11157,8 +11175,8 @@ class binance(Exchange, ImplicitAPI):
|
|
11157
11175
|
"""
|
11158
11176
|
fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
|
11159
11177
|
:param str symbol: unified symbol of the market to fetch the order book for
|
11160
|
-
:param dict params: extra parameters specific to the exchange API endpoint
|
11161
|
-
:param str params
|
11178
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11179
|
+
:param str [params.subType]: "linear" or "inverse"
|
11162
11180
|
:returns dict: an object detailing whether the market is in hedged or one-way mode
|
11163
11181
|
"""
|
11164
11182
|
market = None
|
@@ -11190,7 +11208,8 @@ class binance(Exchange, ImplicitAPI):
|
|
11190
11208
|
:see: https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
11191
11209
|
:param str symbol: unified symbol of the market the order was made in
|
11192
11210
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11193
|
-
:
|
11211
|
+
:param str [params.subType]: "linear" or "inverse"
|
11212
|
+
:returns dict: a list of `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
11194
11213
|
"""
|
11195
11214
|
self.load_markets()
|
11196
11215
|
market = None
|
ccxt/bingx.py
CHANGED
@@ -446,7 +446,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
446
446
|
# }
|
447
447
|
# }
|
448
448
|
#
|
449
|
-
data = self.
|
449
|
+
data = self.safe_dict(response, 'data')
|
450
450
|
return self.safe_integer(data, 'serverTime')
|
451
451
|
|
452
452
|
def fetch_currencies(self, params={}):
|
@@ -497,14 +497,14 @@ class bingx(Exchange, ImplicitAPI):
|
|
497
497
|
# ],
|
498
498
|
# }
|
499
499
|
#
|
500
|
-
data = self.
|
500
|
+
data = self.safe_list(response, 'data', [])
|
501
501
|
result = {}
|
502
502
|
for i in range(0, len(data)):
|
503
503
|
entry = data[i]
|
504
504
|
currencyId = self.safe_string(entry, 'coin')
|
505
505
|
code = self.safe_currency_code(currencyId)
|
506
506
|
name = self.safe_string(entry, 'name')
|
507
|
-
networkList = self.
|
507
|
+
networkList = self.safe_list(entry, 'networkList')
|
508
508
|
networks = {}
|
509
509
|
fee = None
|
510
510
|
active = None
|
@@ -514,8 +514,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
514
514
|
rawNetwork = networkList[j]
|
515
515
|
network = self.safe_string(rawNetwork, 'network')
|
516
516
|
networkCode = self.network_id_to_code(network)
|
517
|
-
isDefault = self.
|
518
|
-
withdrawEnabled = self.
|
517
|
+
isDefault = self.safe_bool(rawNetwork, 'isDefault')
|
518
|
+
withdrawEnabled = self.safe_bool(rawNetwork, 'withdrawEnable')
|
519
519
|
limits = {
|
520
520
|
'amounts': {'min': self.safe_number(rawNetwork, 'withdrawMin'), 'max': self.safe_number(rawNetwork, 'withdrawMax')},
|
521
521
|
}
|
@@ -573,8 +573,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
573
573
|
# }
|
574
574
|
# }
|
575
575
|
#
|
576
|
-
data = self.
|
577
|
-
markets = self.
|
576
|
+
data = self.safe_dict(response, 'data')
|
577
|
+
markets = self.safe_list(data, 'symbols', [])
|
578
578
|
return self.parse_markets(markets)
|
579
579
|
|
580
580
|
def fetch_swap_markets(self, params):
|
@@ -602,7 +602,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
602
602
|
# ]
|
603
603
|
# }
|
604
604
|
#
|
605
|
-
markets = self.
|
605
|
+
markets = self.safe_list(response, 'data', [])
|
606
606
|
return self.parse_markets(markets)
|
607
607
|
|
608
608
|
def parse_market(self, market) -> Market:
|
@@ -626,7 +626,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
626
626
|
symbol = base + '/' + quote
|
627
627
|
if settle is not None:
|
628
628
|
symbol += ':' + settle
|
629
|
-
fees = self.
|
629
|
+
fees = self.safe_dict(self.fees, type, {})
|
630
630
|
contractSize = self.safe_number(market, 'size')
|
631
631
|
isActive = self.safe_string(market, 'status') == '1'
|
632
632
|
isInverse = None if (spot) else False
|
@@ -697,8 +697,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
697
697
|
if not isSandbox:
|
698
698
|
requests.append(self.fetch_spot_markets(params)) # sandbox is swap only
|
699
699
|
promises = requests
|
700
|
-
spotMarkets = self.
|
701
|
-
swapMarkets = self.
|
700
|
+
spotMarkets = self.safe_list(promises, 0, [])
|
701
|
+
swapMarkets = self.safe_list(promises, 1, [])
|
702
702
|
return self.array_concat(spotMarkets, swapMarkets)
|
703
703
|
|
704
704
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
@@ -895,7 +895,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
895
895
|
# ]
|
896
896
|
# }
|
897
897
|
#
|
898
|
-
trades = self.
|
898
|
+
trades = self.safe_list(response, 'data', [])
|
899
899
|
return self.parse_trades(trades, market, since, limit)
|
900
900
|
|
901
901
|
def parse_trade(self, trade, market: Market = None) -> Trade:
|
@@ -989,9 +989,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
989
989
|
type = 'spot' if (cost is None) else 'swap'
|
990
990
|
currencyId = self.safe_string_n(trade, ['currency', 'N', 'commissionAsset'])
|
991
991
|
currencyCode = self.safe_currency_code(currencyId)
|
992
|
-
m = self.
|
992
|
+
m = self.safe_bool(trade, 'm')
|
993
993
|
marketId = self.safe_string(trade, 's')
|
994
|
-
isBuyerMaker = self.
|
994
|
+
isBuyerMaker = self.safe_bool_2(trade, 'buyerMaker', 'isBuyerMaker')
|
995
995
|
takeOrMaker = None
|
996
996
|
if (isBuyerMaker is not None) or (m is not None):
|
997
997
|
takeOrMaker = 'maker' if (isBuyerMaker or m) else 'taker'
|
@@ -1000,10 +1000,10 @@ class bingx(Exchange, ImplicitAPI):
|
|
1000
1000
|
if (isBuyerMaker is not None) or (m is not None):
|
1001
1001
|
side = 'sell' if (isBuyerMaker or m) else 'buy'
|
1002
1002
|
takeOrMaker = 'taker'
|
1003
|
-
isBuyer = self.
|
1003
|
+
isBuyer = self.safe_bool(trade, 'isBuyer')
|
1004
1004
|
if isBuyer is not None:
|
1005
1005
|
side = 'buy' if isBuyer else 'sell'
|
1006
|
-
isMaker = self.
|
1006
|
+
isMaker = self.safe_bool(trade, 'isMaker')
|
1007
1007
|
if isMaker is not None:
|
1008
1008
|
takeOrMaker = 'maker' if isMaker else 'taker'
|
1009
1009
|
return self.safe_trade({
|
@@ -1107,7 +1107,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1107
1107
|
# ]}
|
1108
1108
|
# }
|
1109
1109
|
#
|
1110
|
-
orderbook = self.
|
1110
|
+
orderbook = self.safe_dict(response, 'data', {})
|
1111
1111
|
timestamp = self.safe_integer_2(orderbook, 'T', 'ts')
|
1112
1112
|
return self.parse_order_book(orderbook, market['symbol'], timestamp, 'bids', 'asks', 0, 1)
|
1113
1113
|
|
@@ -1141,7 +1141,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1141
1141
|
# ]
|
1142
1142
|
# }
|
1143
1143
|
#
|
1144
|
-
data = self.
|
1144
|
+
data = self.safe_list(response, 'data', [])
|
1145
1145
|
return self.parse_funding_rate(data, market)
|
1146
1146
|
|
1147
1147
|
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
@@ -1155,7 +1155,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1155
1155
|
self.load_markets()
|
1156
1156
|
symbols = self.market_symbols(symbols, 'swap', True)
|
1157
1157
|
response = self.swapV2PublicGetQuotePremiumIndex(self.extend(params))
|
1158
|
-
data = self.
|
1158
|
+
data = self.safe_list(response, 'data', [])
|
1159
1159
|
filteredResponse = []
|
1160
1160
|
for i in range(0, len(data)):
|
1161
1161
|
item = data[i]
|
@@ -1243,7 +1243,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1243
1243
|
# ]
|
1244
1244
|
# }
|
1245
1245
|
#
|
1246
|
-
data = self.
|
1246
|
+
data = self.safe_list(response, 'data', [])
|
1247
1247
|
rates = []
|
1248
1248
|
for i in range(0, len(data)):
|
1249
1249
|
entry = data[i]
|
@@ -1285,7 +1285,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1285
1285
|
# }
|
1286
1286
|
# }
|
1287
1287
|
#
|
1288
|
-
data = self.
|
1288
|
+
data = self.safe_dict(response, 'data', {})
|
1289
1289
|
return self.parse_open_interest(data, market)
|
1290
1290
|
|
1291
1291
|
def parse_open_interest(self, interest, market: Market = None):
|
@@ -1596,7 +1596,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1596
1596
|
# ]
|
1597
1597
|
# }
|
1598
1598
|
#
|
1599
|
-
positions = self.
|
1599
|
+
positions = self.safe_list(response, 'data', [])
|
1600
1600
|
return self.parse_positions(positions, symbols)
|
1601
1601
|
|
1602
1602
|
def parse_position(self, position, market: Market = None):
|
@@ -1631,7 +1631,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1631
1631
|
#
|
1632
1632
|
marketId = self.safe_string(position, 'symbol', '')
|
1633
1633
|
marketId = marketId.replace('/', '-') # standard return different format
|
1634
|
-
isolated = self.
|
1634
|
+
isolated = self.safe_bool(position, 'isolated')
|
1635
1635
|
marginMode = None
|
1636
1636
|
if isolated is not None:
|
1637
1637
|
marginMode = 'isolated' if isolated else 'cross'
|
@@ -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'] =
|
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
|
-
|
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
|
#
|
@@ -1958,7 +1965,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1958
1965
|
side = self.safe_string(rawOrder, 'side')
|
1959
1966
|
amount = self.safe_number(rawOrder, 'amount')
|
1960
1967
|
price = self.safe_number(rawOrder, 'price')
|
1961
|
-
orderParams = self.
|
1968
|
+
orderParams = self.safe_dict(rawOrder, 'params', {})
|
1962
1969
|
orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
|
1963
1970
|
ordersRequests.append(orderRequest)
|
1964
1971
|
market = self.market(symbol)
|
@@ -2015,8 +2022,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
2015
2022
|
# }
|
2016
2023
|
# }
|
2017
2024
|
#
|
2018
|
-
data = self.
|
2019
|
-
result = self.
|
2025
|
+
data = self.safe_dict(response, 'data', {})
|
2026
|
+
result = self.safe_list(data, 'orders', [])
|
2020
2027
|
return self.parse_orders(result, market)
|
2021
2028
|
|
2022
2029
|
def parse_order_side(self, side):
|
@@ -2704,8 +2711,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
2704
2711
|
# }
|
2705
2712
|
# }
|
2706
2713
|
#
|
2707
|
-
data = self.
|
2708
|
-
orders = self.
|
2714
|
+
data = self.safe_dict(response, 'data', {})
|
2715
|
+
orders = self.safe_list(data, 'orders', [])
|
2709
2716
|
return self.parse_orders(orders, market, since, limit)
|
2710
2717
|
|
2711
2718
|
def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
@@ -2811,7 +2818,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2811
2818
|
"""
|
2812
2819
|
self.load_markets()
|
2813
2820
|
currency = self.currency(code)
|
2814
|
-
accountsByType = self.
|
2821
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType', {})
|
2815
2822
|
fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
|
2816
2823
|
toId = self.safe_string(accountsByType, toAccount, toAccount)
|
2817
2824
|
request: dict = {
|
@@ -2851,7 +2858,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2851
2858
|
currency = None
|
2852
2859
|
if code is not None:
|
2853
2860
|
currency = self.currency(code)
|
2854
|
-
accountsByType = self.
|
2861
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType', {})
|
2855
2862
|
fromAccount = self.safe_string(params, 'fromAccount')
|
2856
2863
|
toAccount = self.safe_string(params, 'toAccount')
|
2857
2864
|
fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
|
@@ -2881,7 +2888,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2881
2888
|
# ]
|
2882
2889
|
# }
|
2883
2890
|
#
|
2884
|
-
rows = self.
|
2891
|
+
rows = self.safe_list(response, 'rows', [])
|
2885
2892
|
return self.parse_transfers(rows, currency, since, limit)
|
2886
2893
|
|
2887
2894
|
def parse_transfer(self, transfer, currency: Currency = None):
|
@@ -2889,7 +2896,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2889
2896
|
timestamp = self.safe_integer(transfer, 'timestamp')
|
2890
2897
|
currencyCode = self.safe_currency_code(None, currency)
|
2891
2898
|
status = self.safe_string(transfer, 'status')
|
2892
|
-
accountsById = self.
|
2899
|
+
accountsById = self.safe_dict(self.options, 'accountsById', {})
|
2893
2900
|
typeId = self.safe_string(transfer, 'type')
|
2894
2901
|
typeIdSplit = typeId.split('_')
|
2895
2902
|
fromId = self.safe_string(typeIdSplit, 0)
|
@@ -2945,7 +2952,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2945
2952
|
# }
|
2946
2953
|
# }
|
2947
2954
|
#
|
2948
|
-
data = self.
|
2955
|
+
data = self.safe_list(self.safe_dict(response, 'data'), 'data')
|
2949
2956
|
parsed = self.parse_deposit_addresses(data, [currency['code']], False)
|
2950
2957
|
return self.index_by(parsed, 'network')
|
2951
2958
|
|
@@ -3359,8 +3366,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
3359
3366
|
fills = None
|
3360
3367
|
if market['spot']:
|
3361
3368
|
response = self.spotV1PrivateGetTradeMyTrades(self.extend(request, params))
|
3362
|
-
data = self.
|
3363
|
-
fills = self.
|
3369
|
+
data = self.safe_dict(response, 'data', {})
|
3370
|
+
fills = self.safe_list(data, 'fills', [])
|
3364
3371
|
#
|
3365
3372
|
# {
|
3366
3373
|
# "code": 0,
|
@@ -3390,8 +3397,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
3390
3397
|
params = self.omit(params, 'tradingUnit')
|
3391
3398
|
request['tradingUnit'] = tradingUnit
|
3392
3399
|
response = self.swapV2PrivateGetTradeAllFillOrders(self.extend(request, params))
|
3393
|
-
data = self.
|
3394
|
-
fills = self.
|
3400
|
+
data = self.safe_dict(response, 'data', {})
|
3401
|
+
fills = self.safe_list(data, 'fill_orders', [])
|
3395
3402
|
#
|
3396
3403
|
# {
|
3397
3404
|
# "code": "0",
|
@@ -3443,7 +3450,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3443
3450
|
# ]
|
3444
3451
|
# }
|
3445
3452
|
#
|
3446
|
-
networkList = self.
|
3453
|
+
networkList = self.safe_list(fee, 'networkList', [])
|
3447
3454
|
networkListLength = len(networkList)
|
3448
3455
|
result = {
|
3449
3456
|
'info': fee,
|
@@ -3461,7 +3468,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3461
3468
|
for i in range(0, networkListLength):
|
3462
3469
|
network = networkList[i]
|
3463
3470
|
networkId = self.safe_string(network, 'network')
|
3464
|
-
isDefault = self.
|
3471
|
+
isDefault = self.safe_bool(network, 'isDefault')
|
3465
3472
|
currencyCode = self.safe_string(currency, 'code')
|
3466
3473
|
networkCode = self.network_id_to_code(networkId, currencyCode)
|
3467
3474
|
result['networks'][networkCode] = {
|
@@ -3597,8 +3604,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
3597
3604
|
# }
|
3598
3605
|
# }
|
3599
3606
|
#
|
3600
|
-
data = self.
|
3601
|
-
liquidations = self.
|
3607
|
+
data = self.safe_dict(response, 'data', {})
|
3608
|
+
liquidations = self.safe_list(data, 'orders', [])
|
3602
3609
|
return self.parse_liquidations(liquidations, market, since, limit)
|
3603
3610
|
|
3604
3611
|
def parse_liquidation(self, liquidation, market: Market = None):
|
@@ -3669,7 +3676,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3669
3676
|
# }
|
3670
3677
|
# }
|
3671
3678
|
#
|
3672
|
-
data = self.
|
3679
|
+
data = self.safe_dict(response, 'data')
|
3673
3680
|
return self.parse_order(data)
|
3674
3681
|
|
3675
3682
|
def close_all_positions(self, params={}) -> List[Position]:
|
@@ -3704,8 +3711,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
3704
3711
|
# }
|
3705
3712
|
# }
|
3706
3713
|
#
|
3707
|
-
data = self.
|
3708
|
-
success = self.
|
3714
|
+
data = self.safe_dict(response, 'data', {})
|
3715
|
+
success = self.safe_list(data, 'success', [])
|
3709
3716
|
positions = []
|
3710
3717
|
for i in range(0, len(success)):
|
3711
3718
|
position = self.parse_position({'positionId': success[i]})
|
@@ -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
|
"""
|
@@ -3905,7 +3912,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3905
3912
|
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Mode
|
3906
3913
|
:param str symbol: unified symbol of the market to fetch the margin mode for
|
3907
3914
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3908
|
-
:returns dict:
|
3915
|
+
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
3909
3916
|
"""
|
3910
3917
|
self.load_markets()
|
3911
3918
|
market = self.market(symbol)
|