ccxt 4.4.8__py2.py3-none-any.whl → 4.4.9__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/__init__.py +1 -1
- ccxt/abstract/bigone.py +1 -1
- ccxt/abstract/kucoinfutures.py +5 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bigone.py +35 -86
- ccxt/async_support/bingx.py +7 -2
- ccxt/async_support/bitget.py +3 -0
- ccxt/async_support/bybit.py +4 -1
- ccxt/async_support/gate.py +30 -1
- ccxt/async_support/htx.py +2 -0
- ccxt/async_support/kucoin.py +1 -0
- ccxt/async_support/kucoinfutures.py +152 -3
- ccxt/base/exchange.py +1 -1
- ccxt/bigone.py +35 -86
- ccxt/bingx.py +7 -2
- ccxt/bitget.py +3 -0
- ccxt/bybit.py +4 -1
- ccxt/gate.py +30 -1
- ccxt/htx.py +2 -0
- ccxt/kucoin.py +1 -0
- ccxt/kucoinfutures.py +152 -3
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +3 -3
- ccxt/pro/hitbtc.py +112 -44
- ccxt/pro/hollaex.py +5 -0
- ccxt/pro/okx.py +12 -1
- ccxt/pro/p2b.py +33 -2
- ccxt/pro/whitebit.py +29 -1
- {ccxt-4.4.8.dist-info → ccxt-4.4.9.dist-info}/METADATA +4 -4
- {ccxt-4.4.8.dist-info → ccxt-4.4.9.dist-info}/RECORD +34 -34
- {ccxt-4.4.8.dist-info → ccxt-4.4.9.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.8.dist-info → ccxt-4.4.9.dist-info}/WHEEL +0 -0
- {ccxt-4.4.8.dist-info → ccxt-4.4.9.dist-info}/top_level.txt +0 -0
ccxt/bigone.py
CHANGED
@@ -167,7 +167,7 @@ class bigone(Exchange, ImplicitAPI):
|
|
167
167
|
},
|
168
168
|
'webExchange': {
|
169
169
|
'get': [
|
170
|
-
'
|
170
|
+
'v3/assets',
|
171
171
|
],
|
172
172
|
},
|
173
173
|
},
|
@@ -346,7 +346,7 @@ class bigone(Exchange, ImplicitAPI):
|
|
346
346
|
:returns dict: an associative dictionary of currencies
|
347
347
|
"""
|
348
348
|
# we use undocumented link(possible, less informative alternative is : https://big.one/api/uc/v3/assets/accounts)
|
349
|
-
data = self.fetch_web_endpoint('fetchCurrencies', '
|
349
|
+
data = self.fetch_web_endpoint('fetchCurrencies', 'webExchangeGetV3Assets', True)
|
350
350
|
if data is None:
|
351
351
|
return None
|
352
352
|
#
|
@@ -355,91 +355,40 @@ class bigone(Exchange, ImplicitAPI):
|
|
355
355
|
# "message": "",
|
356
356
|
# "data": [
|
357
357
|
# {
|
358
|
-
#
|
359
|
-
#
|
360
|
-
#
|
361
|
-
#
|
362
|
-
#
|
363
|
-
#
|
364
|
-
#
|
365
|
-
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
358
|
+
# "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
|
359
|
+
# "symbol": "USDT",
|
360
|
+
# "name": "TetherUS",
|
361
|
+
# "scale": 12,
|
362
|
+
# "is_fiat": False,
|
363
|
+
# "is_transfer_enabled": True,
|
364
|
+
# "transfer_scale": 12,
|
365
|
+
# "binding_gateways": [
|
366
|
+
# {
|
367
|
+
# "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
|
368
|
+
# "is_deposit_enabled": True,
|
369
|
+
# "gateway_name": "Ethereum",
|
370
|
+
# "min_withdrawal_amount": "0.000001",
|
371
|
+
# "withdrawal_fee": "5.71",
|
372
|
+
# "is_withdrawal_enabled": True,
|
373
|
+
# "min_deposit_amount": "0.000001",
|
374
|
+
# "is_memo_required": False,
|
375
|
+
# "withdrawal_scale": 6,
|
376
|
+
# "scale": 12
|
377
|
+
# },
|
378
|
+
# {
|
379
|
+
# "guid": "4e387a9a-a480-40a3-b4ae-ed1773c2db5a",
|
380
|
+
# "is_deposit_enabled": True,
|
381
|
+
# "gateway_name": "BinanceSmartChain",
|
382
|
+
# "min_withdrawal_amount": "10",
|
383
|
+
# "withdrawal_fee": "5",
|
384
|
+
# "is_withdrawal_enabled": False,
|
385
|
+
# "min_deposit_amount": "1",
|
386
|
+
# "is_memo_required": False,
|
387
|
+
# "withdrawal_scale": 8,
|
388
|
+
# "scale": 12
|
389
|
+
# }
|
390
|
+
# ]
|
370
391
|
# },
|
371
|
-
# "info_link": null,
|
372
|
-
# "scale": "12",
|
373
|
-
# "default_gateway": ..., # one object from "gateways"
|
374
|
-
# "gateways": [
|
375
|
-
# {
|
376
|
-
# "uuid": "f0fa5a85-7f65-428a-b7b7-13aad55c2837",
|
377
|
-
# "name": "Mixin",
|
378
|
-
# "kind": "CHAIN",
|
379
|
-
# "required_confirmations": "0",
|
380
|
-
# },
|
381
|
-
# {
|
382
|
-
# "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
|
383
|
-
# "name": "Ethereum",
|
384
|
-
# "kind": "CHAIN",
|
385
|
-
# "required_confirmations": "18",
|
386
|
-
# },
|
387
|
-
# {
|
388
|
-
# "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
|
389
|
-
# "name": "Tron",
|
390
|
-
# "kind": "CHAIN",
|
391
|
-
# "required_confirmations": "1",
|
392
|
-
# },
|
393
|
-
# ...
|
394
|
-
# ],
|
395
|
-
# "payments": [],
|
396
|
-
# "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
|
397
|
-
# "binding_gateways": [
|
398
|
-
# {
|
399
|
-
# "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
|
400
|
-
# "contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
401
|
-
# "is_deposit_enabled": True,
|
402
|
-
# "display_name": "Ethereum(ERC20)",
|
403
|
-
# "gateway_name": "Ethereum",
|
404
|
-
# "min_withdrawal_amount": "0.000001",
|
405
|
-
# "min_internal_withdrawal_amount": "0.00000001",
|
406
|
-
# "withdrawal_fee": "14",
|
407
|
-
# "is_withdrawal_enabled": True,
|
408
|
-
# "min_deposit_amount": "0.000001",
|
409
|
-
# "is_memo_required": False,
|
410
|
-
# "withdrawal_scale": "2",
|
411
|
-
# "gateway": {
|
412
|
-
# "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
|
413
|
-
# "name": "Ethereum",
|
414
|
-
# "kind": "CHAIN",
|
415
|
-
# "required_confirmations": "18",
|
416
|
-
# },
|
417
|
-
# "scale": "12",
|
418
|
-
# },
|
419
|
-
# {
|
420
|
-
# "guid": "b80a4d13-cac7-4319-842d-b33c3bfab8ec",
|
421
|
-
# "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
422
|
-
# "is_deposit_enabled": True,
|
423
|
-
# "display_name": "Tron(TRC20)",
|
424
|
-
# "gateway_name": "Tron",
|
425
|
-
# "min_withdrawal_amount": "0.000001",
|
426
|
-
# "min_internal_withdrawal_amount": "0.00000001",
|
427
|
-
# "withdrawal_fee": "1",
|
428
|
-
# "is_withdrawal_enabled": True,
|
429
|
-
# "min_deposit_amount": "0.000001",
|
430
|
-
# "is_memo_required": False,
|
431
|
-
# "withdrawal_scale": "6",
|
432
|
-
# "gateway": {
|
433
|
-
# "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
|
434
|
-
# "name": "Tron",
|
435
|
-
# "kind": "CHAIN",
|
436
|
-
# "required_confirmations": "1",
|
437
|
-
# },
|
438
|
-
# "scale": "12",
|
439
|
-
# },
|
440
|
-
# ...
|
441
|
-
# ],
|
442
|
-
# },
|
443
392
|
# ...
|
444
393
|
# ],
|
445
394
|
# }
|
ccxt/bingx.py
CHANGED
@@ -654,7 +654,12 @@ class bingx(Exchange, ImplicitAPI):
|
|
654
654
|
# "maxNotional": 20000,
|
655
655
|
# "status": 1,
|
656
656
|
# "tickSize": 0.000001,
|
657
|
-
# "stepSize": 1
|
657
|
+
# "stepSize": 1,
|
658
|
+
# "apiStateSell": True,
|
659
|
+
# "apiStateBuy": True,
|
660
|
+
# "timeOnline": 0,
|
661
|
+
# "offTime": 0,
|
662
|
+
# "maintainTime": 0
|
658
663
|
# },
|
659
664
|
# ...
|
660
665
|
# ]
|
@@ -758,7 +763,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
758
763
|
isActive = False
|
759
764
|
if (self.safe_string(market, 'apiStateOpen') == 'true') and (self.safe_string(market, 'apiStateClose') == 'true'):
|
760
765
|
isActive = True # swap active
|
761
|
-
elif self.safe_bool(market, 'apiStateSell') and self.safe_bool(market, 'apiStateBuy'):
|
766
|
+
elif self.safe_bool(market, 'apiStateSell') and self.safe_bool(market, 'apiStateBuy') and (self.safe_number(market, 'status') == 1):
|
762
767
|
isActive = True # spot active
|
763
768
|
isInverse = None if (spot) else checkIsInverse
|
764
769
|
isLinear = None if (spot) else checkIsLinear
|
ccxt/bitget.py
CHANGED
ccxt/bybit.py
CHANGED
@@ -3516,6 +3516,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3516
3516
|
# Valid for option only.
|
3517
3517
|
# 'orderIv': '0', # Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
|
3518
3518
|
}
|
3519
|
+
hedged = self.safe_bool(params, 'hedged', False)
|
3519
3520
|
triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
|
3520
3521
|
stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
|
3521
3522
|
takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
|
@@ -3665,7 +3666,9 @@ class bybit(Exchange, ImplicitAPI):
|
|
3665
3666
|
request['tpslMode'] = 'Partial'
|
3666
3667
|
request['tpOrderType'] = 'Limit'
|
3667
3668
|
request['tpLimitPrice'] = self.get_price(symbol, tpLimitPrice)
|
3668
|
-
|
3669
|
+
if not market['spot'] and hedged:
|
3670
|
+
request['positionIdx'] = 1 if (side == 'buy') else 2
|
3671
|
+
params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged'])
|
3669
3672
|
return self.extend(request, params)
|
3670
3673
|
|
3671
3674
|
def create_orders(self, orders: List[OrderRequest], params={}):
|
ccxt/gate.py
CHANGED
@@ -611,6 +611,8 @@ class gate(Exchange, ImplicitAPI):
|
|
611
611
|
},
|
612
612
|
# copied from gatev2
|
613
613
|
'commonCurrencies': {
|
614
|
+
'ORT': 'XREATORS',
|
615
|
+
'ASS': 'ASSF',
|
614
616
|
'88MPH': 'MPH',
|
615
617
|
'AXIS': 'AXISDEFI',
|
616
618
|
'BIFI': 'BITCOINFILE',
|
@@ -645,6 +647,8 @@ class gate(Exchange, ImplicitAPI):
|
|
645
647
|
},
|
646
648
|
'createMarketBuyOrderRequiresPrice': True,
|
647
649
|
'networks': {
|
650
|
+
'LINEA': 'LINEAETH',
|
651
|
+
'KON': 'KONET',
|
648
652
|
'AVAXC': 'AVAX_C',
|
649
653
|
'BEP20': 'BSC',
|
650
654
|
'EOS': 'EOS',
|
@@ -4393,6 +4397,7 @@ class gate(Exchange, ImplicitAPI):
|
|
4393
4397
|
:see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
|
4394
4398
|
:see: https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
|
4395
4399
|
:see: https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
|
4400
|
+
:see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-by-time-range
|
4396
4401
|
:param str symbol: unified market symbol of the market orders were made in
|
4397
4402
|
:param int [since]: the earliest time in ms to fetch orders for
|
4398
4403
|
:param int [limit]: the maximum number of order structures to retrieve
|
@@ -4400,9 +4405,33 @@ class gate(Exchange, ImplicitAPI):
|
|
4400
4405
|
:param bool [params.stop]: True for fetching stop orders
|
4401
4406
|
:param str [params.type]: spot, swap or future, if not provided self.options['defaultType'] is used
|
4402
4407
|
:param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
|
4408
|
+
:param boolean [params.historical]: *swap only* True for using historical endpoint
|
4403
4409
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4404
4410
|
"""
|
4405
|
-
|
4411
|
+
self.load_markets()
|
4412
|
+
until = self.safe_integer(params, 'until')
|
4413
|
+
params = self.omit(params, 'until')
|
4414
|
+
market = None
|
4415
|
+
if symbol is not None:
|
4416
|
+
market = self.market(symbol)
|
4417
|
+
symbol = market['symbol']
|
4418
|
+
res = self.handle_market_type_and_params('fetchClosedOrders', market, params)
|
4419
|
+
type = self.safe_string(res, 0)
|
4420
|
+
useHistorical = False
|
4421
|
+
useHistorical, params = self.handle_option_and_params(params, 'fetchClosedOrders', 'historical', False)
|
4422
|
+
if not useHistorical and ((since is None and until is None) or (type != 'swap')):
|
4423
|
+
return self.fetch_orders_by_status('finished', symbol, since, limit, params)
|
4424
|
+
params = self.omit(params, 'type')
|
4425
|
+
request = {}
|
4426
|
+
request, params = self.prepare_request(market, type, params)
|
4427
|
+
if since is not None:
|
4428
|
+
request['from'] = self.parse_to_int(since / 1000)
|
4429
|
+
if until is not None:
|
4430
|
+
request['to'] = self.parse_to_int(until / 1000)
|
4431
|
+
if limit is not None:
|
4432
|
+
request['limit'] = limit
|
4433
|
+
response = self.privateFuturesGetSettleOrdersTimerange(self.extend(request, params))
|
4434
|
+
return self.parse_orders(response, market, since, limit)
|
4406
4435
|
|
4407
4436
|
def fetch_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4408
4437
|
market = None
|
ccxt/htx.py
CHANGED
@@ -2955,6 +2955,7 @@ class htx(Exchange, ImplicitAPI):
|
|
2955
2955
|
def fetch_accounts(self, params={}) -> List[Account]:
|
2956
2956
|
"""
|
2957
2957
|
fetch all the accounts associated with a profile
|
2958
|
+
:see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
2958
2959
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2959
2960
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
2960
2961
|
"""
|
@@ -3018,6 +3019,7 @@ class htx(Exchange, ImplicitAPI):
|
|
3018
3019
|
def fetch_currencies(self, params={}) -> Currencies:
|
3019
3020
|
"""
|
3020
3021
|
fetches all available currencies on an exchange
|
3022
|
+
:see: https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
|
3021
3023
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3022
3024
|
:returns dict: an associative dictionary of currencies
|
3023
3025
|
"""
|
ccxt/kucoin.py
CHANGED
ccxt/kucoinfutures.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.kucoin import kucoin
|
7
7
|
from ccxt.abstract.kucoinfutures import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currency, Int, LeverageTier, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Balances, Currency, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import AuthenticationError
|
11
11
|
from ccxt.base.errors import PermissionDenied
|
@@ -80,9 +80,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
80
80
|
'fetchIsolatedBorrowRates': False,
|
81
81
|
'fetchL3OrderBook': True,
|
82
82
|
'fetchLedger': True,
|
83
|
+
'fetchLeverage': True,
|
83
84
|
'fetchLeverageTiers': False,
|
84
85
|
'fetchMarginAdjustmentHistory': False,
|
85
|
-
'fetchMarginMode':
|
86
|
+
'fetchMarginMode': True,
|
86
87
|
'fetchMarketLeverageTiers': True,
|
87
88
|
'fetchMarkets': True,
|
88
89
|
'fetchMarkOHLCV': False,
|
@@ -106,7 +107,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
106
107
|
'fetchTransactionFee': False,
|
107
108
|
'fetchWithdrawals': True,
|
108
109
|
'setLeverage': False,
|
109
|
-
'setMarginMode':
|
110
|
+
'setMarginMode': True,
|
110
111
|
'transfer': True,
|
111
112
|
'withdraw': None,
|
112
113
|
},
|
@@ -183,12 +184,15 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
183
184
|
'trade-fees': 1,
|
184
185
|
'history-positions': 1,
|
185
186
|
'getMaxOpenSize': 1,
|
187
|
+
'getCrossUserLeverage': 1,
|
188
|
+
'position/getMarginMode': 1,
|
186
189
|
},
|
187
190
|
'post': {
|
188
191
|
'withdrawals': 1,
|
189
192
|
'transfer-out': 1, # v2
|
190
193
|
'transfer-in': 1,
|
191
194
|
'orders': 1.33,
|
195
|
+
'st-orders': 1.33,
|
192
196
|
'orders/test': 1.33,
|
193
197
|
'position/margin/auto-deposit-status': 1,
|
194
198
|
'position/margin/deposit-margin': 1,
|
@@ -196,6 +200,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
196
200
|
'bullet-private': 1,
|
197
201
|
'sub/api-key': 1,
|
198
202
|
'sub/api-key/update': 1,
|
203
|
+
'changeCrossUserLeverage': 1,
|
204
|
+
'position/changeMarginMode': 1,
|
199
205
|
},
|
200
206
|
'delete': {
|
201
207
|
'withdrawals/{withdrawalId}': 1,
|
@@ -330,9 +336,13 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
330
336
|
'futuresPrivate': {
|
331
337
|
'GET': {
|
332
338
|
'getMaxOpenSize': 'v2',
|
339
|
+
'getCrossUserLeverage': 'v2',
|
340
|
+
'position/getMarginMode': 'v2',
|
333
341
|
},
|
334
342
|
'POST': {
|
335
343
|
'transfer-out': 'v2',
|
344
|
+
'changeCrossUserLeverage': 'v2',
|
345
|
+
'position/changeMarginMode': 'v2',
|
336
346
|
},
|
337
347
|
},
|
338
348
|
'futuresPublic': {
|
@@ -2721,3 +2731,142 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2721
2731
|
'percentage': True,
|
2722
2732
|
'tierBased': True,
|
2723
2733
|
}
|
2734
|
+
|
2735
|
+
def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
2736
|
+
"""
|
2737
|
+
fetches the margin mode of a trading pair
|
2738
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/get-margin-mode
|
2739
|
+
:param str symbol: unified symbol of the market to fetch the margin mode for
|
2740
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2741
|
+
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
2742
|
+
"""
|
2743
|
+
self.load_markets()
|
2744
|
+
market = self.market(symbol)
|
2745
|
+
request: dict = {
|
2746
|
+
'symbol': market['id'],
|
2747
|
+
}
|
2748
|
+
response = self.futuresPrivateGetPositionGetMarginMode(self.extend(request, params))
|
2749
|
+
#
|
2750
|
+
# {
|
2751
|
+
# "code": "200000",
|
2752
|
+
# "data": {
|
2753
|
+
# "symbol": "XBTUSDTM",
|
2754
|
+
# "marginMode": "ISOLATED"
|
2755
|
+
# }
|
2756
|
+
# }
|
2757
|
+
#
|
2758
|
+
data = self.safe_dict(response, 'data', {})
|
2759
|
+
return self.parse_margin_mode(data, market)
|
2760
|
+
|
2761
|
+
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
2762
|
+
marginType = self.safe_string(marginMode, 'marginMode')
|
2763
|
+
marginType = 'isolated' if (marginType == 'ISOLATED') else 'cross'
|
2764
|
+
return {
|
2765
|
+
'info': marginMode,
|
2766
|
+
'symbol': market['symbol'],
|
2767
|
+
'marginMode': marginType,
|
2768
|
+
}
|
2769
|
+
|
2770
|
+
def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
2771
|
+
"""
|
2772
|
+
set margin mode to 'cross' or 'isolated'
|
2773
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/modify-margin-mode
|
2774
|
+
:param str marginMode: 'cross' or 'isolated'
|
2775
|
+
:param str symbol: unified market symbol
|
2776
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2777
|
+
:returns dict: response from the exchange
|
2778
|
+
"""
|
2779
|
+
if symbol is None:
|
2780
|
+
raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
|
2781
|
+
self.check_required_argument('setMarginMode', marginMode, 'marginMode', ['cross', 'isolated'])
|
2782
|
+
self.load_markets()
|
2783
|
+
market = self.market(symbol)
|
2784
|
+
request: dict = {
|
2785
|
+
'symbol': market['id'],
|
2786
|
+
'marginMode': marginMode.upper(),
|
2787
|
+
}
|
2788
|
+
response = self.futuresPrivatePostPositionChangeMarginMode(self.extend(request, params))
|
2789
|
+
#
|
2790
|
+
# {
|
2791
|
+
# "code": "200000",
|
2792
|
+
# "data": {
|
2793
|
+
# "symbol": "XBTUSDTM",
|
2794
|
+
# "marginMode": "ISOLATED"
|
2795
|
+
# }
|
2796
|
+
# }
|
2797
|
+
#
|
2798
|
+
data = self.safe_dict(response, 'data', {})
|
2799
|
+
return self.parse_margin_mode(data, market)
|
2800
|
+
|
2801
|
+
def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
2802
|
+
"""
|
2803
|
+
fetch the set leverage for a market
|
2804
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/get-cross-margin-leverage
|
2805
|
+
:param str symbol: unified market symbol
|
2806
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2807
|
+
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
2808
|
+
"""
|
2809
|
+
marginMode = None
|
2810
|
+
marginMode, params = self.handle_margin_mode_and_params(symbol, params)
|
2811
|
+
if marginMode != 'cross':
|
2812
|
+
raise NotSupported(self.id + ' fetchLeverage() currently supports only params["marginMode"] = "cross"')
|
2813
|
+
self.load_markets()
|
2814
|
+
market = self.market(symbol)
|
2815
|
+
request: dict = {
|
2816
|
+
'symbol': market['id'],
|
2817
|
+
}
|
2818
|
+
response = self.futuresPrivateGetGetCrossUserLeverage(self.extend(request, params))
|
2819
|
+
#
|
2820
|
+
# {
|
2821
|
+
# "code": "200000",
|
2822
|
+
# "data": {
|
2823
|
+
# "symbol": "XBTUSDTM",
|
2824
|
+
# "leverage": "3"
|
2825
|
+
# }
|
2826
|
+
# }
|
2827
|
+
#
|
2828
|
+
data = self.safe_dict(response, 'data', {})
|
2829
|
+
parsed = self.parse_leverage(data, market)
|
2830
|
+
return self.extend(parsed, {
|
2831
|
+
'marginMode': marginMode,
|
2832
|
+
})
|
2833
|
+
|
2834
|
+
def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
2835
|
+
"""
|
2836
|
+
set the level of leverage for a market
|
2837
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/modify-cross-margin-leverage
|
2838
|
+
:param float leverage: the rate of leverage
|
2839
|
+
:param str symbol: unified market symbol
|
2840
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2841
|
+
:returns dict: response from the exchange
|
2842
|
+
"""
|
2843
|
+
marginMode = None
|
2844
|
+
marginMode, params = self.handle_margin_mode_and_params(symbol, params)
|
2845
|
+
if marginMode != 'cross':
|
2846
|
+
raise NotSupported(self.id + ' setLeverage() currently supports only params["marginMode"] = "cross"')
|
2847
|
+
self.load_markets()
|
2848
|
+
market = self.market(symbol)
|
2849
|
+
request: dict = {
|
2850
|
+
'symbol': market['id'],
|
2851
|
+
'leverage': str(leverage),
|
2852
|
+
}
|
2853
|
+
response = self.futuresPrivatePostChangeCrossUserLeverage(self.extend(request, params))
|
2854
|
+
#
|
2855
|
+
# {
|
2856
|
+
# "code": "200000",
|
2857
|
+
# "data": True
|
2858
|
+
# }
|
2859
|
+
#
|
2860
|
+
return self.parse_leverage(response, market)
|
2861
|
+
|
2862
|
+
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
2863
|
+
marketId = self.safe_string(leverage, 'symbol')
|
2864
|
+
market = self.safe_market(marketId, market)
|
2865
|
+
leverageNum = self.safe_integer(leverage, 'leverage')
|
2866
|
+
return {
|
2867
|
+
'info': leverage,
|
2868
|
+
'symbol': market['symbol'],
|
2869
|
+
'marginMode': None,
|
2870
|
+
'longLeverage': leverageNum,
|
2871
|
+
'shortLeverage': leverageNum,
|
2872
|
+
}
|
ccxt/pro/__init__.py
CHANGED
ccxt/pro/binance.py
CHANGED
@@ -2417,13 +2417,13 @@ class binance(ccxt.async_support.binance):
|
|
2417
2417
|
subType, params = self.handle_sub_type_and_params('watchBalance', None, params)
|
2418
2418
|
isPortfolioMargin = None
|
2419
2419
|
isPortfolioMargin, params = self.handle_option_and_params_2(params, 'watchBalance', 'papi', 'portfolioMargin', False)
|
2420
|
-
urlType = type
|
2421
|
-
if isPortfolioMargin:
|
2422
|
-
urlType = 'papi'
|
2423
2420
|
if self.isLinear(type, subType):
|
2424
2421
|
type = 'future'
|
2425
2422
|
elif self.isInverse(type, subType):
|
2426
2423
|
type = 'delivery'
|
2424
|
+
urlType = type
|
2425
|
+
if isPortfolioMargin:
|
2426
|
+
urlType = 'papi'
|
2427
2427
|
url = self.urls['api']['ws'][urlType] + '/' + self.options[type]['listenKey']
|
2428
2428
|
client = self.client(url)
|
2429
2429
|
self.set_balance_cache(client, type, isPortfolioMargin)
|