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 CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.4.8'
25
+ __version__ = '4.4.9'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/abstract/bigone.py CHANGED
@@ -42,4 +42,4 @@ class ImplicitAPI:
42
42
  contractprivate_put_positions_symbol_risk_limit = contractPrivatePutPositionsSymbolRiskLimit = Entry('positions/{symbol}/risk-limit', 'contractPrivate', 'PUT', {})
43
43
  contractprivate_delete_orders_id = contractPrivateDeleteOrdersId = Entry('orders/{id}', 'contractPrivate', 'DELETE', {})
44
44
  contractprivate_delete_orders_batch = contractPrivateDeleteOrdersBatch = Entry('orders/batch', 'contractPrivate', 'DELETE', {})
45
- webexchange_get_uc_v2_assets = webExchangeGetUcV2Assets = Entry('uc/v2/assets', 'webExchange', 'GET', {})
45
+ webexchange_get_v3_assets = webExchangeGetV3Assets = Entry('v3/assets', 'webExchange', 'GET', {})
@@ -194,6 +194,8 @@ class ImplicitAPI:
194
194
  futuresprivate_get_trade_fees = futuresPrivateGetTradeFees = Entry('trade-fees', 'futuresPrivate', 'GET', {'cost': 1})
195
195
  futuresprivate_get_history_positions = futuresPrivateGetHistoryPositions = Entry('history-positions', 'futuresPrivate', 'GET', {'cost': 1})
196
196
  futuresprivate_get_getmaxopensize = futuresPrivateGetGetMaxOpenSize = Entry('getMaxOpenSize', 'futuresPrivate', 'GET', {'cost': 1})
197
+ futuresprivate_get_getcrossuserleverage = futuresPrivateGetGetCrossUserLeverage = Entry('getCrossUserLeverage', 'futuresPrivate', 'GET', {'cost': 1})
198
+ futuresprivate_get_position_getmarginmode = futuresPrivateGetPositionGetMarginMode = Entry('position/getMarginMode', 'futuresPrivate', 'GET', {'cost': 1})
197
199
  futuresprivate_post_transfer_out = futuresPrivatePostTransferOut = Entry('transfer-out', 'futuresPrivate', 'POST', {'cost': 1})
198
200
  futuresprivate_post_transfer_in = futuresPrivatePostTransferIn = Entry('transfer-in', 'futuresPrivate', 'POST', {'cost': 1})
199
201
  futuresprivate_post_orders = futuresPrivatePostOrders = Entry('orders', 'futuresPrivate', 'POST', {'cost': 1.33})
@@ -205,8 +207,11 @@ class ImplicitAPI:
205
207
  futuresprivate_post_position_risk_limit_level_change = futuresPrivatePostPositionRiskLimitLevelChange = Entry('position/risk-limit-level/change', 'futuresPrivate', 'POST', {'cost': 1})
206
208
  futuresprivate_post_bullet_private = futuresPrivatePostBulletPrivate = Entry('bullet-private', 'futuresPrivate', 'POST', {'cost': 1})
207
209
  futuresprivate_post_withdrawals = futuresPrivatePostWithdrawals = Entry('withdrawals', 'futuresPrivate', 'POST', {'cost': 1})
210
+ futuresprivate_post_st_orders = futuresPrivatePostStOrders = Entry('st-orders', 'futuresPrivate', 'POST', {'cost': 1.33})
208
211
  futuresprivate_post_sub_api_key = futuresPrivatePostSubApiKey = Entry('sub/api-key', 'futuresPrivate', 'POST', {'cost': 1})
209
212
  futuresprivate_post_sub_api_key_update = futuresPrivatePostSubApiKeyUpdate = Entry('sub/api-key/update', 'futuresPrivate', 'POST', {'cost': 1})
213
+ futuresprivate_post_changecrossuserleverage = futuresPrivatePostChangeCrossUserLeverage = Entry('changeCrossUserLeverage', 'futuresPrivate', 'POST', {'cost': 1})
214
+ futuresprivate_post_position_changemarginmode = futuresPrivatePostPositionChangeMarginMode = Entry('position/changeMarginMode', 'futuresPrivate', 'POST', {'cost': 1})
210
215
  futuresprivate_delete_orders_orderid = futuresPrivateDeleteOrdersOrderId = Entry('orders/{orderId}', 'futuresPrivate', 'DELETE', {'cost': 1})
211
216
  futuresprivate_delete_orders_client_order_clientoid = futuresPrivateDeleteOrdersClientOrderClientOid = Entry('orders/client-order/{clientOid}', 'futuresPrivate', 'DELETE', {'cost': 1})
212
217
  futuresprivate_delete_orders = futuresPrivateDeleteOrders = Entry('orders', 'futuresPrivate', 'DELETE', {'cost': 4.44})
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.8'
7
+ __version__ = '4.4.9'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.8'
5
+ __version__ = '4.4.9'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -168,7 +168,7 @@ class bigone(Exchange, ImplicitAPI):
168
168
  },
169
169
  'webExchange': {
170
170
  'get': [
171
- 'uc/v2/assets',
171
+ 'v3/assets',
172
172
  ],
173
173
  },
174
174
  },
@@ -347,7 +347,7 @@ class bigone(Exchange, ImplicitAPI):
347
347
  :returns dict: an associative dictionary of currencies
348
348
  """
349
349
  # we use undocumented link(possible, less informative alternative is : https://big.one/api/uc/v3/assets/accounts)
350
- data = await self.fetch_web_endpoint('fetchCurrencies', 'webExchangeGetUcV2Assets', True)
350
+ data = await self.fetch_web_endpoint('fetchCurrencies', 'webExchangeGetV3Assets', True)
351
351
  if data is None:
352
352
  return None
353
353
  #
@@ -356,91 +356,40 @@ class bigone(Exchange, ImplicitAPI):
356
356
  # "message": "",
357
357
  # "data": [
358
358
  # {
359
- # "name": "TetherUS",
360
- # "symbol": "USDT",
361
- # "contract_address": "31",
362
- # "is_deposit_enabled": True,
363
- # "is_withdrawal_enabled": True,
364
- # "is_stub": False,
365
- # "withdrawal_fee": "5.0",
366
- # "is_fiat": False,
367
- # "is_memo_required": False,
368
- # "logo": {
369
- # "default": "https://assets.peatio.com/assets/v1/color/normal/usdt.png",
370
- # "white": "https://assets.peatio.com/assets/v1/white/normal/usdt.png",
359
+ # "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
360
+ # "symbol": "USDT",
361
+ # "name": "TetherUS",
362
+ # "scale": 12,
363
+ # "is_fiat": False,
364
+ # "is_transfer_enabled": True,
365
+ # "transfer_scale": 12,
366
+ # "binding_gateways": [
367
+ # {
368
+ # "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
369
+ # "is_deposit_enabled": True,
370
+ # "gateway_name": "Ethereum",
371
+ # "min_withdrawal_amount": "0.000001",
372
+ # "withdrawal_fee": "5.71",
373
+ # "is_withdrawal_enabled": True,
374
+ # "min_deposit_amount": "0.000001",
375
+ # "is_memo_required": False,
376
+ # "withdrawal_scale": 6,
377
+ # "scale": 12
378
+ # },
379
+ # {
380
+ # "guid": "4e387a9a-a480-40a3-b4ae-ed1773c2db5a",
381
+ # "is_deposit_enabled": True,
382
+ # "gateway_name": "BinanceSmartChain",
383
+ # "min_withdrawal_amount": "10",
384
+ # "withdrawal_fee": "5",
385
+ # "is_withdrawal_enabled": False,
386
+ # "min_deposit_amount": "1",
387
+ # "is_memo_required": False,
388
+ # "withdrawal_scale": 8,
389
+ # "scale": 12
390
+ # }
391
+ # ]
371
392
  # },
372
- # "info_link": null,
373
- # "scale": "12",
374
- # "default_gateway": ..., # one object from "gateways"
375
- # "gateways": [
376
- # {
377
- # "uuid": "f0fa5a85-7f65-428a-b7b7-13aad55c2837",
378
- # "name": "Mixin",
379
- # "kind": "CHAIN",
380
- # "required_confirmations": "0",
381
- # },
382
- # {
383
- # "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
384
- # "name": "Ethereum",
385
- # "kind": "CHAIN",
386
- # "required_confirmations": "18",
387
- # },
388
- # {
389
- # "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
390
- # "name": "Tron",
391
- # "kind": "CHAIN",
392
- # "required_confirmations": "1",
393
- # },
394
- # ...
395
- # ],
396
- # "payments": [],
397
- # "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
398
- # "binding_gateways": [
399
- # {
400
- # "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
401
- # "contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
402
- # "is_deposit_enabled": True,
403
- # "display_name": "Ethereum(ERC20)",
404
- # "gateway_name": "Ethereum",
405
- # "min_withdrawal_amount": "0.000001",
406
- # "min_internal_withdrawal_amount": "0.00000001",
407
- # "withdrawal_fee": "14",
408
- # "is_withdrawal_enabled": True,
409
- # "min_deposit_amount": "0.000001",
410
- # "is_memo_required": False,
411
- # "withdrawal_scale": "2",
412
- # "gateway": {
413
- # "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
414
- # "name": "Ethereum",
415
- # "kind": "CHAIN",
416
- # "required_confirmations": "18",
417
- # },
418
- # "scale": "12",
419
- # },
420
- # {
421
- # "guid": "b80a4d13-cac7-4319-842d-b33c3bfab8ec",
422
- # "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
423
- # "is_deposit_enabled": True,
424
- # "display_name": "Tron(TRC20)",
425
- # "gateway_name": "Tron",
426
- # "min_withdrawal_amount": "0.000001",
427
- # "min_internal_withdrawal_amount": "0.00000001",
428
- # "withdrawal_fee": "1",
429
- # "is_withdrawal_enabled": True,
430
- # "min_deposit_amount": "0.000001",
431
- # "is_memo_required": False,
432
- # "withdrawal_scale": "6",
433
- # "gateway": {
434
- # "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
435
- # "name": "Tron",
436
- # "kind": "CHAIN",
437
- # "required_confirmations": "1",
438
- # },
439
- # "scale": "12",
440
- # },
441
- # ...
442
- # ],
443
- # },
444
393
  # ...
445
394
  # ],
446
395
  # }
@@ -655,7 +655,12 @@ class bingx(Exchange, ImplicitAPI):
655
655
  # "maxNotional": 20000,
656
656
  # "status": 1,
657
657
  # "tickSize": 0.000001,
658
- # "stepSize": 1
658
+ # "stepSize": 1,
659
+ # "apiStateSell": True,
660
+ # "apiStateBuy": True,
661
+ # "timeOnline": 0,
662
+ # "offTime": 0,
663
+ # "maintainTime": 0
659
664
  # },
660
665
  # ...
661
666
  # ]
@@ -759,7 +764,7 @@ class bingx(Exchange, ImplicitAPI):
759
764
  isActive = False
760
765
  if (self.safe_string(market, 'apiStateOpen') == 'true') and (self.safe_string(market, 'apiStateClose') == 'true'):
761
766
  isActive = True # swap active
762
- elif self.safe_bool(market, 'apiStateSell') and self.safe_bool(market, 'apiStateBuy'):
767
+ elif self.safe_bool(market, 'apiStateSell') and self.safe_bool(market, 'apiStateBuy') and (self.safe_number(market, 'status') == 1):
763
768
  isActive = True # spot active
764
769
  isInverse = None if (spot) else checkIsInverse
765
770
  isLinear = None if (spot) else checkIsLinear
@@ -1442,6 +1442,9 @@ class bitget(Exchange, ImplicitAPI):
1442
1442
  'STARKNET': 'Starknet',
1443
1443
  'OPTIMISM': 'Optimism',
1444
1444
  'ARBITRUM': 'Arbitrum',
1445
+ 'APT': 'APTOS',
1446
+ 'MATIC': 'POLYGON',
1447
+ 'VIC': 'VICTION',
1445
1448
  },
1446
1449
  'networksById': {
1447
1450
  },
@@ -3517,6 +3517,7 @@ class bybit(Exchange, ImplicitAPI):
3517
3517
  # Valid for option only.
3518
3518
  # 'orderIv': '0', # Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3519
3519
  }
3520
+ hedged = self.safe_bool(params, 'hedged', False)
3520
3521
  triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
3521
3522
  stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
3522
3523
  takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
@@ -3666,7 +3667,9 @@ class bybit(Exchange, ImplicitAPI):
3666
3667
  request['tpslMode'] = 'Partial'
3667
3668
  request['tpOrderType'] = 'Limit'
3668
3669
  request['tpLimitPrice'] = self.get_price(symbol, tpLimitPrice)
3669
- params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice'])
3670
+ if not market['spot'] and hedged:
3671
+ request['positionIdx'] = 1 if (side == 'buy') else 2
3672
+ params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged'])
3670
3673
  return self.extend(request, params)
3671
3674
 
3672
3675
  async def create_orders(self, orders: List[OrderRequest], params={}):
@@ -612,6 +612,8 @@ class gate(Exchange, ImplicitAPI):
612
612
  },
613
613
  # copied from gatev2
614
614
  'commonCurrencies': {
615
+ 'ORT': 'XREATORS',
616
+ 'ASS': 'ASSF',
615
617
  '88MPH': 'MPH',
616
618
  'AXIS': 'AXISDEFI',
617
619
  'BIFI': 'BITCOINFILE',
@@ -646,6 +648,8 @@ class gate(Exchange, ImplicitAPI):
646
648
  },
647
649
  'createMarketBuyOrderRequiresPrice': True,
648
650
  'networks': {
651
+ 'LINEA': 'LINEAETH',
652
+ 'KON': 'KONET',
649
653
  'AVAXC': 'AVAX_C',
650
654
  'BEP20': 'BSC',
651
655
  'EOS': 'EOS',
@@ -4394,6 +4398,7 @@ class gate(Exchange, ImplicitAPI):
4394
4398
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
4395
4399
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
4396
4400
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
4401
+ :see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-by-time-range
4397
4402
  :param str symbol: unified market symbol of the market orders were made in
4398
4403
  :param int [since]: the earliest time in ms to fetch orders for
4399
4404
  :param int [limit]: the maximum number of order structures to retrieve
@@ -4401,9 +4406,33 @@ class gate(Exchange, ImplicitAPI):
4401
4406
  :param bool [params.stop]: True for fetching stop orders
4402
4407
  :param str [params.type]: spot, swap or future, if not provided self.options['defaultType'] is used
4403
4408
  :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
4409
+ :param boolean [params.historical]: *swap only* True for using historical endpoint
4404
4410
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4405
4411
  """
4406
- return await self.fetch_orders_by_status('finished', symbol, since, limit, params)
4412
+ await self.load_markets()
4413
+ until = self.safe_integer(params, 'until')
4414
+ params = self.omit(params, 'until')
4415
+ market = None
4416
+ if symbol is not None:
4417
+ market = self.market(symbol)
4418
+ symbol = market['symbol']
4419
+ res = self.handle_market_type_and_params('fetchClosedOrders', market, params)
4420
+ type = self.safe_string(res, 0)
4421
+ useHistorical = False
4422
+ useHistorical, params = self.handle_option_and_params(params, 'fetchClosedOrders', 'historical', False)
4423
+ if not useHistorical and ((since is None and until is None) or (type != 'swap')):
4424
+ return await self.fetch_orders_by_status('finished', symbol, since, limit, params)
4425
+ params = self.omit(params, 'type')
4426
+ request = {}
4427
+ request, params = self.prepare_request(market, type, params)
4428
+ if since is not None:
4429
+ request['from'] = self.parse_to_int(since / 1000)
4430
+ if until is not None:
4431
+ request['to'] = self.parse_to_int(until / 1000)
4432
+ if limit is not None:
4433
+ request['limit'] = limit
4434
+ response = await self.privateFuturesGetSettleOrdersTimerange(self.extend(request, params))
4435
+ return self.parse_orders(response, market, since, limit)
4407
4436
 
4408
4437
  def fetch_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4409
4438
  market = None
ccxt/async_support/htx.py CHANGED
@@ -2956,6 +2956,7 @@ class htx(Exchange, ImplicitAPI):
2956
2956
  async def fetch_accounts(self, params={}) -> List[Account]:
2957
2957
  """
2958
2958
  fetch all the accounts associated with a profile
2959
+ :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
2959
2960
  :param dict [params]: extra parameters specific to the exchange API endpoint
2960
2961
  :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
2961
2962
  """
@@ -3019,6 +3020,7 @@ class htx(Exchange, ImplicitAPI):
3019
3020
  async def fetch_currencies(self, params={}) -> Currencies:
3020
3021
  """
3021
3022
  fetches all available currencies on an exchange
3023
+ :see: https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
3022
3024
  :param dict [params]: extra parameters specific to the exchange API endpoint
3023
3025
  :returns dict: an associative dictionary of currencies
3024
3026
  """
@@ -643,6 +643,7 @@ class kucoin(Exchange, ImplicitAPI):
643
643
  'WAX': 'WAXP',
644
644
  'ALT': 'APTOSLAUNCHTOKEN',
645
645
  'KALT': 'ALT', # ALTLAYER
646
+ 'FUD': 'FTX Users\' Debt',
646
647
  },
647
648
  'options': {
648
649
  'hf': False,
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.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': False,
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': False,
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
+ async 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
+ await self.load_markets()
2744
+ market = self.market(symbol)
2745
+ request: dict = {
2746
+ 'symbol': market['id'],
2747
+ }
2748
+ response = await 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
+ async 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
+ await self.load_markets()
2783
+ market = self.market(symbol)
2784
+ request: dict = {
2785
+ 'symbol': market['id'],
2786
+ 'marginMode': marginMode.upper(),
2787
+ }
2788
+ response = await 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
+ async 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
+ await self.load_markets()
2814
+ market = self.market(symbol)
2815
+ request: dict = {
2816
+ 'symbol': market['id'],
2817
+ }
2818
+ response = await 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
+ async 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
+ await self.load_markets()
2848
+ market = self.market(symbol)
2849
+ request: dict = {
2850
+ 'symbol': market['id'],
2851
+ 'leverage': str(leverage),
2852
+ }
2853
+ response = await 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/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.8'
7
+ __version__ = '4.4.9'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10