ccxt 4.2.54__py2.py3-none-any.whl → 4.2.56__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/async_support/woo.py CHANGED
@@ -106,6 +106,7 @@ class woo(Exchange, ImplicitAPI):
106
106
  'reduceMargin': False,
107
107
  'setLeverage': True,
108
108
  'setMargin': False,
109
+ 'setPositionMode': True,
109
110
  'transfer': True,
110
111
  'withdraw': True, # exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://kronosresearch.github.io/wootrade-documents/#token-withdraw
111
112
  },
@@ -180,10 +181,16 @@ class woo(Exchange, ImplicitAPI):
180
181
  'client/trade/{tid}': 1,
181
182
  'order/{oid}/trades': 1,
182
183
  'client/trades': 1,
184
+ 'client/hist_trades': 1,
185
+ 'staking/yield_history': 1,
186
+ 'client/holding': 1,
183
187
  'asset/deposit': 10,
184
188
  'asset/history': 60,
185
189
  'sub_account/all': 60,
186
190
  'sub_account/assets': 60,
191
+ 'sub_account/asset_detail': 60,
192
+ 'sub_account/ip_restriction': 10,
193
+ 'asset/main_sub_transfer_history': 30,
187
194
  'token_interest': 60,
188
195
  'token_interest/{token}': 60,
189
196
  'interest/history': 60,
@@ -196,9 +203,12 @@ class woo(Exchange, ImplicitAPI):
196
203
  'post': {
197
204
  'order': 5, # 2 requests per 1 second per symbol
198
205
  'asset/main_sub_transfer': 30, # 20 requests per 60 seconds
206
+ 'asset/ltv': 30,
199
207
  'asset/withdraw': 30, # implemented in ccxt, disabled on the exchange side https://kronosresearch.github.io/wootrade-documents/#token-withdraw
208
+ 'asset/internal_withdraw': 30,
200
209
  'interest/repay': 60,
201
210
  'client/account_mode': 120,
211
+ 'client/position_mode': 5,
202
212
  'client/leverage': 120,
203
213
  },
204
214
  'delete': {
@@ -2434,6 +2444,33 @@ class woo(Exchange, ImplicitAPI):
2434
2444
  sorted = self.sort_by(rates, 'timestamp')
2435
2445
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
2436
2446
 
2447
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
2448
+ """
2449
+ set hedged to True or False for a market
2450
+ :see: https://docs.woo.org/#update-position-mode
2451
+ :param bool hedged: set to True to use HEDGE_MODE, False for ONE_WAY
2452
+ :param str symbol: not used by woo setPositionMode
2453
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2454
+ :returns dict: response from the exchange
2455
+ """
2456
+ hedgeMode = None
2457
+ if hedged:
2458
+ hedgeMode = 'HEDGE_MODE'
2459
+ else:
2460
+ hedgeMode = 'ONE_WAY'
2461
+ request = {
2462
+ 'position_mode': hedgeMode,
2463
+ }
2464
+ response = await self.v1PrivatePostClientPositionMode(self.extend(request, params))
2465
+ #
2466
+ # {
2467
+ # "success": True,
2468
+ # "data": {},
2469
+ # "timestamp": "1709195608551"
2470
+ # }
2471
+ #
2472
+ return response
2473
+
2437
2474
  async def fetch_leverage(self, symbol: str, params={}):
2438
2475
  await self.load_markets()
2439
2476
  response = await self.v3PrivateGetAccountinfo(params)
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.54'
7
+ __version__ = '4.2.56'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2032,7 +2032,7 @@ class Exchange(object):
2032
2032
  return self.arraySlice(result, -limit)
2033
2033
  return self.filter_by_limit(result, limit, key, sinceIsDefined)
2034
2034
 
2035
- def set_sandbox_mode(self, enabled):
2035
+ def set_sandbox_mode(self, enabled: bool):
2036
2036
  if enabled:
2037
2037
  if 'test' in self.urls:
2038
2038
  if isinstance(self.urls['api'], str):
ccxt/base/types.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import sys
2
2
  import types
3
- from typing import Union, List, Optional, Any
3
+ from typing import Union, List, Optional, Any as PythonAny
4
4
  from decimal import Decimal
5
5
 
6
6
 
@@ -20,6 +20,7 @@ else:
20
20
  OrderSide = Literal['buy', 'sell']
21
21
  OrderType = Literal['limit', 'market']
22
22
  PositionSide = Literal['long', 'short']
23
+ Any = PythonAny
23
24
 
24
25
 
25
26
  class Entry:
ccxt/bingx.py CHANGED
@@ -722,7 +722,7 @@ class bingx(Exchange, ImplicitAPI):
722
722
  if paginate:
723
723
  return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1440)
724
724
  market = self.market(symbol)
725
- request = {
725
+ request: dict = {
726
726
  'symbol': market['id'],
727
727
  }
728
728
  request['interval'] = self.safe_string(self.timeframes, timeframe, timeframe)
@@ -849,7 +849,7 @@ class bingx(Exchange, ImplicitAPI):
849
849
  """
850
850
  self.load_markets()
851
851
  market = self.market(symbol)
852
- request = {
852
+ request: dict = {
853
853
  'symbol': market['id'],
854
854
  }
855
855
  if limit is not None:
@@ -1037,7 +1037,7 @@ class bingx(Exchange, ImplicitAPI):
1037
1037
  """
1038
1038
  self.load_markets()
1039
1039
  market = self.market(symbol)
1040
- request = {
1040
+ request: dict = {
1041
1041
  'symbol': market['id'],
1042
1042
  }
1043
1043
  if limit is not None:
@@ -1120,7 +1120,7 @@ class bingx(Exchange, ImplicitAPI):
1120
1120
  """
1121
1121
  self.load_markets()
1122
1122
  market = self.market(symbol)
1123
- request = {
1123
+ request: dict = {
1124
1124
  'symbol': market['id'],
1125
1125
  }
1126
1126
  response = self.swapV2PublicGetQuotePremiumIndex(self.extend(request, params))
@@ -1216,7 +1216,7 @@ class bingx(Exchange, ImplicitAPI):
1216
1216
  if paginate:
1217
1217
  return self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params)
1218
1218
  market = self.market(symbol)
1219
- request = {
1219
+ request: dict = {
1220
1220
  'symbol': market['id'],
1221
1221
  }
1222
1222
  if since is not None:
@@ -1269,7 +1269,7 @@ class bingx(Exchange, ImplicitAPI):
1269
1269
  """
1270
1270
  self.load_markets()
1271
1271
  market = self.market(symbol)
1272
- request = {
1272
+ request: dict = {
1273
1273
  'symbol': market['id'],
1274
1274
  }
1275
1275
  response = self.swapV2PublicGetQuoteOpenInterest(self.extend(request, params))
@@ -1321,7 +1321,7 @@ class bingx(Exchange, ImplicitAPI):
1321
1321
  """
1322
1322
  self.load_markets()
1323
1323
  market = self.market(symbol)
1324
- request = {
1324
+ request: dict = {
1325
1325
  'symbol': market['id'],
1326
1326
  }
1327
1327
  response = None
@@ -1346,7 +1346,8 @@ class bingx(Exchange, ImplicitAPI):
1346
1346
  if symbols is not None:
1347
1347
  symbols = self.market_symbols(symbols)
1348
1348
  firstSymbol = self.safe_string(symbols, 0)
1349
- market = self.market(firstSymbol)
1349
+ if firstSymbol is not None:
1350
+ market = self.market(firstSymbol)
1350
1351
  type = None
1351
1352
  type, params = self.handle_market_type_and_params('fetchTickers', market, params)
1352
1353
  response = None
@@ -1357,7 +1358,7 @@ class bingx(Exchange, ImplicitAPI):
1357
1358
  tickers = self.safe_value(response, 'data')
1358
1359
  return self.parse_tickers(tickers, symbols)
1359
1360
 
1360
- def parse_ticker(self, ticker, market: Market = None) -> Ticker:
1361
+ def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
1361
1362
  #
1362
1363
  # spot
1363
1364
  # {
@@ -1715,7 +1716,7 @@ class bingx(Exchange, ImplicitAPI):
1715
1716
  marketType = None
1716
1717
  marketType, params = self.handle_market_type_and_params('createOrder', market, params)
1717
1718
  type = type.upper()
1718
- request = {
1719
+ request: dict = {
1719
1720
  'symbol': market['id'],
1720
1721
  'type': type,
1721
1722
  'side': side.upper(),
@@ -1814,7 +1815,7 @@ class bingx(Exchange, ImplicitAPI):
1814
1815
  slTriggerPrice = self.safe_string_2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss)
1815
1816
  slWorkingType = self.safe_string(stopLoss, 'workingType', 'MARK_PRICE')
1816
1817
  slType = self.safe_string(stopLoss, 'type', 'STOP_MARKET')
1817
- slRequest = {
1818
+ slRequest: dict = {
1818
1819
  'stopPrice': self.parse_to_numeric(self.price_to_precision(symbol, slTriggerPrice)),
1819
1820
  'workingType': slWorkingType,
1820
1821
  'type': slType,
@@ -1829,7 +1830,7 @@ class bingx(Exchange, ImplicitAPI):
1829
1830
  tkTriggerPrice = self.safe_string_2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit)
1830
1831
  tkWorkingType = self.safe_string(takeProfit, 'workingType', 'MARK_PRICE')
1831
1832
  tpType = self.safe_string(takeProfit, 'type', 'TAKE_PROFIT_MARKET')
1832
- tpRequest = {
1833
+ tpRequest: dict = {
1833
1834
  'stopPrice': self.parse_to_numeric(self.price_to_precision(symbol, tkTriggerPrice)),
1834
1835
  'workingType': tkWorkingType,
1835
1836
  'type': tpType,
@@ -1960,7 +1961,7 @@ class bingx(Exchange, ImplicitAPI):
1960
1961
  orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
1961
1962
  ordersRequests.append(orderRequest)
1962
1963
  market = self.market(symbol)
1963
- request = {}
1964
+ request: dict = {}
1964
1965
  response = None
1965
1966
  if market['swap']:
1966
1967
  request['batchOrders'] = self.json(ordersRequests)
@@ -2334,7 +2335,7 @@ class bingx(Exchange, ImplicitAPI):
2334
2335
  raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
2335
2336
  self.load_markets()
2336
2337
  market = self.market(symbol)
2337
- request = {
2338
+ request: dict = {
2338
2339
  'symbol': market['id'],
2339
2340
  }
2340
2341
  clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clientOrderID')
@@ -2412,7 +2413,7 @@ class bingx(Exchange, ImplicitAPI):
2412
2413
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
2413
2414
  self.load_markets()
2414
2415
  market = self.market(symbol)
2415
- request = {
2416
+ request: dict = {
2416
2417
  'symbol': market['id'],
2417
2418
  }
2418
2419
  response = None
@@ -2490,7 +2491,7 @@ class bingx(Exchange, ImplicitAPI):
2490
2491
  raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
2491
2492
  self.load_markets()
2492
2493
  market = self.market(symbol)
2493
- request = {
2494
+ request: dict = {
2494
2495
  'symbol': market['id'],
2495
2496
  }
2496
2497
  clientOrderIds = self.safe_value(params, 'clientOrderIds')
@@ -2559,7 +2560,7 @@ class bingx(Exchange, ImplicitAPI):
2559
2560
  raise ArgumentsRequired(self.id + ' fetchOrders() requires a symbol argument')
2560
2561
  self.load_markets()
2561
2562
  market = self.market(symbol)
2562
- request = {
2563
+ request: dict = {
2563
2564
  'symbol': market['id'],
2564
2565
  'orderId': id,
2565
2566
  }
@@ -2637,7 +2638,7 @@ class bingx(Exchange, ImplicitAPI):
2637
2638
  """
2638
2639
  self.load_markets()
2639
2640
  market = None
2640
- request = {}
2641
+ request: dict = {}
2641
2642
  if symbol is not None:
2642
2643
  market = self.market(symbol)
2643
2644
  request['symbol'] = market['id']
@@ -2724,7 +2725,7 @@ class bingx(Exchange, ImplicitAPI):
2724
2725
  raise ArgumentsRequired(self.id + ' fetchClosedOrders() requires a symbol argument')
2725
2726
  self.load_markets()
2726
2727
  market = self.market(symbol)
2727
- request = {
2728
+ request: dict = {
2728
2729
  'symbol': market['id'],
2729
2730
  }
2730
2731
  response = None
@@ -2812,7 +2813,7 @@ class bingx(Exchange, ImplicitAPI):
2812
2813
  accountsByType = self.safe_value(self.options, 'accountsByType', {})
2813
2814
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
2814
2815
  toId = self.safe_string(accountsByType, toAccount, toAccount)
2815
- request = {
2816
+ request: dict = {
2816
2817
  'asset': currency['id'],
2817
2818
  'amount': self.currency_to_precision(code, amount),
2818
2819
  'type': fromId + '_' + toId,
@@ -2856,7 +2857,7 @@ class bingx(Exchange, ImplicitAPI):
2856
2857
  toId = self.safe_string(accountsByType, toAccount, toAccount)
2857
2858
  if fromId is None or toId is None:
2858
2859
  raise ExchangeError(self.id + ' fromAccount & toAccount parameter are required')
2859
- request = {
2860
+ request: dict = {
2860
2861
  'type': fromId + '_' + toId,
2861
2862
  }
2862
2863
  if since is not None:
@@ -2918,7 +2919,7 @@ class bingx(Exchange, ImplicitAPI):
2918
2919
  currency = self.currency(code)
2919
2920
  defaultRecvWindow = self.safe_integer(self.options, 'recvWindow')
2920
2921
  recvWindow = self.safe_integer(self.parse_params, 'recvWindow', defaultRecvWindow)
2921
- request = {
2922
+ request: dict = {
2922
2923
  'coin': currency['id'],
2923
2924
  'offset': 0,
2924
2925
  'limit': 1000,
@@ -3007,7 +3008,7 @@ class bingx(Exchange, ImplicitAPI):
3007
3008
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
3008
3009
  """
3009
3010
  self.load_markets()
3010
- request = {
3011
+ request: dict = {
3011
3012
  }
3012
3013
  currency = None
3013
3014
  if code is not None:
@@ -3048,7 +3049,7 @@ class bingx(Exchange, ImplicitAPI):
3048
3049
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
3049
3050
  """
3050
3051
  self.load_markets()
3051
- request = {
3052
+ request: dict = {
3052
3053
  }
3053
3054
  currency = None
3054
3055
  if code is not None:
@@ -3173,7 +3174,7 @@ class bingx(Exchange, ImplicitAPI):
3173
3174
  'internal': None,
3174
3175
  }
3175
3176
 
3176
- def parse_transaction_status(self, status):
3177
+ def parse_transaction_status(self, status: str):
3177
3178
  statuses = {
3178
3179
  '0': 'pending',
3179
3180
  '1': 'ok',
@@ -3212,7 +3213,7 @@ class bingx(Exchange, ImplicitAPI):
3212
3213
  marginMode = 'CROSSED'
3213
3214
  if marginMode != 'ISOLATED' and marginMode != 'CROSSED':
3214
3215
  raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
3215
- request = {
3216
+ request: dict = {
3216
3217
  'symbol': market['id'],
3217
3218
  'marginType': marginMode,
3218
3219
  }
@@ -3234,7 +3235,7 @@ class bingx(Exchange, ImplicitAPI):
3234
3235
  raise ArgumentsRequired(self.id + ' setMargin() requires a type parameter either 1(increase margin) or 2(decrease margin)')
3235
3236
  self.load_markets()
3236
3237
  market = self.market(symbol)
3237
- request = {
3238
+ request: dict = {
3238
3239
  'symbol': market['id'],
3239
3240
  'amount': self.amount_to_precision(market['symbol'], amount),
3240
3241
  'type': type,
@@ -3260,7 +3261,7 @@ class bingx(Exchange, ImplicitAPI):
3260
3261
  """
3261
3262
  self.load_markets()
3262
3263
  market = self.market(symbol)
3263
- request = {
3264
+ request: dict = {
3264
3265
  'symbol': market['id'],
3265
3266
  }
3266
3267
  response = self.swapV2PrivateGetTradeLeverage(self.extend(request, params))
@@ -3292,7 +3293,7 @@ class bingx(Exchange, ImplicitAPI):
3292
3293
  self.check_required_argument('setLeverage', side, 'side', ['LONG', 'SHORT', 'BOTH'])
3293
3294
  self.load_markets()
3294
3295
  market = self.market(symbol)
3295
- request = {
3296
+ request: dict = {
3296
3297
  'symbol': market['id'],
3297
3298
  'side': side,
3298
3299
  'leverage': leverage,
@@ -3328,7 +3329,7 @@ class bingx(Exchange, ImplicitAPI):
3328
3329
  market = self.market(symbol)
3329
3330
  now = self.milliseconds()
3330
3331
  response = None
3331
- request = {
3332
+ request: dict = {
3332
3333
  'symbol': market['id'],
3333
3334
  }
3334
3335
  if since is not None:
@@ -3492,7 +3493,7 @@ class bingx(Exchange, ImplicitAPI):
3492
3493
  walletType = 1
3493
3494
  if not self.in_array(walletType, [1, 2, 3]):
3494
3495
  raise BadRequest(self.id + ' withdraw() requires either 1 fund account, 2 standard futures account, 3 perpetual account for walletType')
3495
- request = {
3496
+ request: dict = {
3496
3497
  'coin': currency['id'],
3497
3498
  'address': address,
3498
3499
  'amount': self.number_to_string(amount),
@@ -3640,7 +3641,7 @@ class bingx(Exchange, ImplicitAPI):
3640
3641
  """
3641
3642
  self.load_markets()
3642
3643
  market = self.market(symbol)
3643
- request = {
3644
+ request: dict = {
3644
3645
  'symbol': market['id'],
3645
3646
  }
3646
3647
  response = self.swapV2PrivatePostTradeCloseAllPositions(self.extend(request, params))
@@ -3674,7 +3675,7 @@ class bingx(Exchange, ImplicitAPI):
3674
3675
  marketType, params = self.handle_market_type_and_params('closeAllPositions', None, params)
3675
3676
  if marketType == 'margin':
3676
3677
  raise BadRequest(self.id + ' closePositions() cannot be used for ' + marketType + ' markets')
3677
- request = {
3678
+ request: dict = {
3678
3679
  'recvWindow': recvWindow,
3679
3680
  }
3680
3681
  response = self.swapV2PrivatePostTradeCloseAllPositions(self.extend(request, params))
@@ -3739,7 +3740,7 @@ class bingx(Exchange, ImplicitAPI):
3739
3740
  dualSidePosition = 'true'
3740
3741
  else:
3741
3742
  dualSidePosition = 'false'
3742
- request = {
3743
+ request: dict = {
3743
3744
  'dualSidePosition': dualSidePosition,
3744
3745
  }
3745
3746
  #
@@ -3928,7 +3929,7 @@ class bingx(Exchange, ImplicitAPI):
3928
3929
  def nonce(self):
3929
3930
  return self.milliseconds()
3930
3931
 
3931
- def set_sandbox_mode(self, enable):
3932
+ def set_sandbox_mode(self, enable: bool):
3932
3933
  super(bingx, self).set_sandbox_mode(enable)
3933
3934
  self.options['sandboxMode'] = enable
3934
3935
 
ccxt/gate.py CHANGED
@@ -63,7 +63,7 @@ class gate(Exchange, ImplicitAPI):
63
63
  'spot': 'https://api.gateio.ws/api/v4',
64
64
  'options': 'https://api.gateio.ws/api/v4',
65
65
  'subAccounts': 'https://api.gateio.ws/api/v4',
66
- 'portfolio': 'https://api.gateio.ws/api/v4',
66
+ 'unified': 'https://api.gateio.ws/api/v4',
67
67
  'rebate': 'https://api.gateio.ws/api/v4',
68
68
  'earn': 'https://api.gateio.ws/api/v4',
69
69
  'account': 'https://api.gateio.ws/api/v4',
@@ -286,11 +286,14 @@ class gate(Exchange, ImplicitAPI):
286
286
  'saved_address': 1,
287
287
  'fee': 1,
288
288
  'total_balance': 2.5,
289
+ 'small_balance': 1,
290
+ 'small_balance_history': 1,
289
291
  },
290
292
  'post': {
291
293
  'transfers': 2.5, # 8r/s cost = 20 / 8 = 2.5
292
294
  'sub_account_transfers': 2.5,
293
295
  'sub_account_to_sub_account': 2.5,
296
+ 'small_balance': 1,
294
297
  },
295
298
  },
296
299
  'subAccounts': {
@@ -313,7 +316,7 @@ class gate(Exchange, ImplicitAPI):
313
316
  'sub_accounts/{user_id}/keys/{key}': 2.5,
314
317
  },
315
318
  },
316
- 'portfolio': {
319
+ 'unified': {
317
320
  'get': {
318
321
  'accounts': 20 / 15,
319
322
  'account_mode': 20 / 15,
@@ -322,6 +325,7 @@ class gate(Exchange, ImplicitAPI):
322
325
  'loans': 20 / 15,
323
326
  'loan_records': 20 / 15,
324
327
  'interest_records': 20 / 15,
328
+ 'estimate_rate': 20 / 15,
325
329
  },
326
330
  'post': {
327
331
  'account_mode': 20 / 15,
ccxt/okx.py CHANGED
@@ -595,6 +595,7 @@ class okx(Exchange, ImplicitAPI):
595
595
  '50027': PermissionDenied, # The account is restricted from trading
596
596
  '50028': ExchangeError, # Unable to take the order, please reach out to support center for details
597
597
  '50044': BadRequest, # Must select one broker type
598
+ '50062': ExchangeError, # This feature is currently unavailable.
598
599
  # API Class
599
600
  '50100': ExchangeError, # API frozen, please contact customer service
600
601
  '50101': AuthenticationError, # Broker id of APIKey does not match current environment
@@ -649,6 +650,15 @@ class okx(Exchange, ImplicitAPI):
649
650
  '51072': InvalidOrder, # As a spot lead trader, you need to set tdMode to 'spot_isolated' when configured buying lead trade pairs
650
651
  '51073': InvalidOrder, # As a spot lead trader, you need to use '/copytrading/close-subposition' for selling assets through lead trades
651
652
  '51074': InvalidOrder, # Only the tdMode for lead trade pairs configured by spot lead traders can be set to 'spot_isolated'
653
+ '51090': InvalidOrder, # You can't modify the amount of an SL order placed with a TP limit order.
654
+ '51091': InvalidOrder, # All TP orders in one order must be of the same type.
655
+ '51092': InvalidOrder, # TP order prices(tpOrdPx) in one order must be different.
656
+ '51093': InvalidOrder, # TP limit order prices(tpOrdPx) in one order can't be –1(market price).
657
+ '51094': InvalidOrder, # You can't place TP limit orders in spot, margin, or options trading.
658
+ '51095': InvalidOrder, # To place TP limit orders at self endpoint, you must place an SL order at the same time.
659
+ '51096': InvalidOrder, # cxlOnClosePos needs to be True to place a TP limit order
660
+ '51098': InvalidOrder, # You can't add a new TP order to an SL order placed with a TP limit order.
661
+ '51099': InvalidOrder, # You can't place TP limit orders lead trader.
652
662
  '51100': InvalidOrder, # Trading amount does not meet the min tradable amount
653
663
  '51101': InvalidOrder, # Entered amount exceeds the max pending order amount(Cont) per transaction
654
664
  '51102': InvalidOrder, # Entered amount exceeds the max pending count
@@ -2634,7 +2644,7 @@ class okx(Exchange, ImplicitAPI):
2634
2644
  raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"], or params["takeProfit"]["stopPrice"], or params["takeProfit"]["tpTriggerPx"] for a take profit order')
2635
2645
  request['tpTriggerPx'] = self.price_to_precision(symbol, takeProfitTriggerPrice)
2636
2646
  takeProfitLimitPrice = self.safe_value_n(takeProfit, ['price', 'takeProfitPrice', 'tpOrdPx'])
2637
- takeProfitOrderType = self.safe_string(takeProfit, 'type')
2647
+ takeProfitOrderType = self.safe_string_2(takeProfit, 'type', 'tpOrdKind')
2638
2648
  if takeProfitOrderType is not None:
2639
2649
  takeProfitLimitOrderType = (takeProfitOrderType == 'limit')
2640
2650
  takeProfitMarketOrderType = (takeProfitOrderType == 'market')
@@ -2644,10 +2654,12 @@ class okx(Exchange, ImplicitAPI):
2644
2654
  if takeProfitLimitPrice is None:
2645
2655
  raise InvalidOrder(self.id + ' createOrder() requires a limit price in params["takeProfit"]["price"] or params["takeProfit"]["tpOrdPx"] for a take profit limit order')
2646
2656
  else:
2657
+ request['tpOrdKind'] = takeProfitOrderType
2647
2658
  request['tpOrdPx'] = self.price_to_precision(symbol, takeProfitLimitPrice)
2648
2659
  elif takeProfitOrderType == 'market':
2649
2660
  request['tpOrdPx'] = '-1'
2650
2661
  elif takeProfitLimitPrice is not None:
2662
+ request['tpOrdKind'] = 'limit'
2651
2663
  request['tpOrdPx'] = self.price_to_precision(symbol, takeProfitLimitPrice) # limit tp order
2652
2664
  else:
2653
2665
  request['tpOrdPx'] = '-1' # market tp order
@@ -2665,6 +2677,7 @@ class okx(Exchange, ImplicitAPI):
2665
2677
  twoWayCondition = ((takeProfitPrice is not None) and (stopLossPrice is not None))
2666
2678
  # if TP and SL are sent together
2667
2679
  # 'conditional' only stop-loss order will be applied
2680
+ # tpOrdKind is 'condition' which is the default
2668
2681
  if twoWayCondition:
2669
2682
  request['ordType'] = 'oco'
2670
2683
  if takeProfitPrice is not None:
@@ -2709,6 +2722,7 @@ class okx(Exchange, ImplicitAPI):
2709
2722
  :param str [params.stopLoss.type]: 'market' or 'limit' used to specify the stop loss price type
2710
2723
  :param str [params.positionSide]: if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
2711
2724
  :param str [params.trailingPercent]: the percent to trail away from the current market price
2725
+ :param str [params.tpOrdKind]: 'condition' or 'limit', the default is 'condition'
2712
2726
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2713
2727
  """
2714
2728
  self.load_markets()
@@ -2849,6 +2863,7 @@ class okx(Exchange, ImplicitAPI):
2849
2863
  takeProfitTriggerPrice = self.safe_value(takeProfit, 'triggerPrice')
2850
2864
  takeProfitPrice = self.safe_value(takeProfit, 'price')
2851
2865
  takeProfitType = self.safe_string(takeProfit, 'type')
2866
+ request['newTpOrdKind'] = takeProfitType if (takeProfitType == 'limit') else 'condition'
2852
2867
  request['newTpTriggerPx'] = self.price_to_precision(symbol, takeProfitTriggerPrice)
2853
2868
  request['newTpOrdPx'] = '-1' if (takeProfitType == 'market') else self.price_to_precision(symbol, takeProfitPrice)
2854
2869
  request['newTpTriggerPxType'] = takeProfitTriggerPriceType
@@ -2887,6 +2902,7 @@ class okx(Exchange, ImplicitAPI):
2887
2902
  :param float [params.takeProfit.triggerPrice]: take profit trigger price
2888
2903
  :param float [params.takeProfit.price]: used for take profit limit orders, not used for take profit market price orders
2889
2904
  :param str [params.takeProfit.type]: 'market' or 'limit' used to specify the take profit price type
2905
+ :param str [params.newTpOrdKind]: 'condition' or 'limit', the default is 'condition'
2890
2906
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2891
2907
  """
2892
2908
  self.load_markets()
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.54'
7
+ __version__ = '4.2.56'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10