ccxt 4.4.31__py2.py3-none-any.whl → 4.4.33__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/coinbaseexchange.py +1 -0
- ccxt/abstract/kraken.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/base/ws/aiohttp_client.py +25 -3
- ccxt/async_support/binance.py +153 -0
- ccxt/async_support/bitvavo.py +0 -3
- ccxt/async_support/bybit.py +134 -6
- ccxt/async_support/cex.py +4 -2
- ccxt/async_support/coinbase.py +2 -22
- ccxt/async_support/coinbaseexchange.py +2 -1
- ccxt/async_support/coinex.py +2 -1
- ccxt/async_support/deribit.py +2 -2
- ccxt/async_support/gate.py +15 -2
- ccxt/async_support/hitbtc.py +3 -3
- ccxt/async_support/htx.py +1 -1
- ccxt/async_support/hyperliquid.py +11 -2
- ccxt/async_support/indodax.py +1 -1
- ccxt/async_support/kraken.py +3 -2
- ccxt/async_support/kucoin.py +5 -3
- ccxt/async_support/kucoinfutures.py +94 -26
- ccxt/async_support/lbank.py +1 -0
- ccxt/async_support/okx.py +94 -3
- ccxt/async_support/phemex.py +34 -21
- ccxt/async_support/wavesexchange.py +3 -0
- ccxt/async_support/woofipro.py +2 -2
- ccxt/base/exchange.py +92 -2
- ccxt/binance.py +153 -0
- ccxt/bitvavo.py +0 -3
- ccxt/bybit.py +134 -6
- ccxt/cex.py +4 -2
- ccxt/coinbase.py +2 -22
- ccxt/coinbaseexchange.py +2 -1
- ccxt/coinex.py +2 -1
- ccxt/deribit.py +2 -2
- ccxt/gate.py +15 -2
- ccxt/hitbtc.py +3 -3
- ccxt/htx.py +1 -1
- ccxt/hyperliquid.py +11 -2
- ccxt/indodax.py +1 -1
- ccxt/kraken.py +3 -2
- ccxt/kucoin.py +5 -3
- ccxt/kucoinfutures.py +94 -26
- ccxt/lbank.py +1 -0
- ccxt/okx.py +94 -3
- ccxt/phemex.py +34 -21
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +8 -8
- ccxt/pro/bitget.py +4 -4
- ccxt/pro/bitmart.py +2 -2
- ccxt/pro/bitmex.py +2 -2
- ccxt/pro/bitvavo.py +46 -45
- ccxt/pro/blofin.py +2 -2
- ccxt/pro/bybit.py +2 -2
- ccxt/pro/cryptocom.py +4 -4
- ccxt/pro/gate.py +4 -4
- ccxt/pro/hashkey.py +3 -3
- ccxt/pro/mexc.py +1 -2
- ccxt/pro/okx.py +8 -0
- ccxt/test/tests_async.py +3 -1
- ccxt/test/tests_helpers.py +1 -1
- ccxt/test/tests_sync.py +3 -1
- ccxt/wavesexchange.py +3 -0
- ccxt/woofipro.py +2 -2
- {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/METADATA +10 -4
- {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/RECORD +70 -70
- {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/WHEEL +0 -0
- {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/top_level.txt +0 -0
ccxt/htx.py
CHANGED
@@ -3070,7 +3070,7 @@ class htx(Exchange, ImplicitAPI):
|
|
3070
3070
|
|
3071
3071
|
:param str type: 'spot', 'swap' or 'future
|
3072
3072
|
:param str [marginMode]: 'cross' or 'isolated'
|
3073
|
-
|
3073
|
+
:param str [symbol]: unified ccxt market symbol
|
3074
3074
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3075
3075
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
3076
3076
|
"""
|
ccxt/hyperliquid.py
CHANGED
@@ -733,14 +733,23 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
733
733
|
https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
|
734
734
|
https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
|
735
735
|
|
736
|
-
:param str[]
|
736
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
737
737
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
738
|
+
:param str [params.type]: 'spot' or 'swap', by default fetches both
|
738
739
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
739
740
|
"""
|
740
741
|
self.load_markets()
|
741
742
|
symbols = self.market_symbols(symbols)
|
742
743
|
# at self stage, to get tickers data, we use fetchMarkets endpoints
|
743
|
-
response =
|
744
|
+
response = []
|
745
|
+
type = self.safe_string(params, 'type')
|
746
|
+
params = self.omit(params, 'type')
|
747
|
+
if type == 'spot':
|
748
|
+
response = self.fetch_spot_markets(params)
|
749
|
+
elif type == 'swap':
|
750
|
+
response = self.fetch_swap_markets(params)
|
751
|
+
else:
|
752
|
+
response = self.fetch_markets(params)
|
744
753
|
# same response "fetchMarkets"
|
745
754
|
result: dict = {}
|
746
755
|
for i in range(0, len(response)):
|
ccxt/indodax.py
CHANGED
@@ -29,7 +29,7 @@ class indodax(Exchange, ImplicitAPI):
|
|
29
29
|
'countries': ['ID'], # Indonesia
|
30
30
|
# 10 requests per second for making trades => 1000ms / 10 = 100ms
|
31
31
|
# 180 requests per minute(public endpoints) = 2 requests per second => cost = (1000ms / rateLimit) / 2 = 5
|
32
|
-
'rateLimit':
|
32
|
+
'rateLimit': 50,
|
33
33
|
'has': {
|
34
34
|
'CORS': None,
|
35
35
|
'spot': True,
|
ccxt/kraken.py
CHANGED
@@ -197,6 +197,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
197
197
|
'AddOrder': 0,
|
198
198
|
'AddOrderBatch': 0,
|
199
199
|
'AddExport': 3,
|
200
|
+
'AmendOrder': 0,
|
200
201
|
'Balance': 3,
|
201
202
|
'CancelAll': 3,
|
202
203
|
'CancelAllOrdersAfter': 3,
|
@@ -2045,8 +2046,8 @@ class kraken(Exchange, ImplicitAPI):
|
|
2045
2046
|
|
2046
2047
|
https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
|
2047
2048
|
|
2048
|
-
:param str[]
|
2049
|
-
|
2049
|
+
:param str[] [ids]: list of order id
|
2050
|
+
:param str [symbol]: unified ccxt market symbol
|
2050
2051
|
:param dict [params]: extra parameters specific to the kraken api endpoint
|
2051
2052
|
:returns dict[]: a list of `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2052
2053
|
"""
|
ccxt/kucoin.py
CHANGED
@@ -590,6 +590,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
590
590
|
'400303': PermissionDenied, # {"msg":"To enjoy the full range of our products and services, we kindly request you complete the identity verification process.","code":"400303"}
|
591
591
|
'500000': ExchangeNotAvailable, # {"code":"500000","msg":"Internal Server Error"}
|
592
592
|
'260220': InvalidAddress, # {"code": "260220", "msg": "deposit.address.not.exists"}
|
593
|
+
'600100': InsufficientFunds, # {"msg":"Funds below the minimum requirement.","code":"600100"}
|
594
|
+
'600101': InvalidOrder, # {"msg":"The order funds should more then 0.1 USDT.","code":"600101"}
|
593
595
|
'900014': BadRequest, # {"code":"900014","msg":"Invalid chainId"}
|
594
596
|
},
|
595
597
|
'broad': {
|
@@ -1244,7 +1246,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1244
1246
|
|
1245
1247
|
def load_migration_status(self, force: bool = False):
|
1246
1248
|
"""
|
1247
|
-
|
1249
|
+
:param boolean force: load account state for non hf
|
1248
1250
|
loads the migration status for the account(hf or not)
|
1249
1251
|
|
1250
1252
|
https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-user-type
|
@@ -4739,8 +4741,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4739
4741
|
|
4740
4742
|
https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/modify-leverage-multiplier
|
4741
4743
|
|
4742
|
-
|
4743
|
-
:param str symbol: unified market symbol
|
4744
|
+
:param int [leverage]: New leverage multiplier. Must be greater than 1 and up to two decimal places, and cannot be less than the user's current debt leverage or greater than the system's maximum leverage
|
4745
|
+
:param str [symbol]: unified market symbol
|
4744
4746
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4745
4747
|
:returns dict: response from the exchange
|
4746
4748
|
"""
|
ccxt/kucoinfutures.py
CHANGED
@@ -1212,8 +1212,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1212
1212
|
https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
|
1213
1213
|
|
1214
1214
|
:param str[] [symbols]: list of unified market symbols
|
1215
|
-
|
1216
|
-
|
1215
|
+
:param int [since]: the earliest time in ms to fetch position history for
|
1216
|
+
:param int [limit]: the maximum number of entries to retrieve
|
1217
1217
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1218
1218
|
:param int [params.until]: closing end time
|
1219
1219
|
:param int [params.pageId]: page id
|
@@ -1404,7 +1404,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1404
1404
|
"""
|
1405
1405
|
Create an order on the exchange
|
1406
1406
|
|
1407
|
-
https://
|
1407
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
|
1408
1408
|
https://www.kucoin.com/docs/rest/futures-trading/orders/place-take-profit-and-stop-loss-order#http-request
|
1409
1409
|
|
1410
1410
|
:param str symbol: Unified CCXT market symbol
|
@@ -1421,8 +1421,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1421
1421
|
:param bool [params.reduceOnly]: A mark to reduce the position size only. Set to False by default. Need to set the position size when reduceOnly is True.
|
1422
1422
|
:param str [params.timeInForce]: GTC, GTT, IOC, or FOK, default is GTC, limit orders only
|
1423
1423
|
:param str [params.postOnly]: Post only flag, invalid when timeInForce is IOC or FOK
|
1424
|
+
:param float [params.cost]: the cost of the order in units of USDT
|
1424
1425
|
----------------- Exchange Specific Parameters -----------------
|
1425
|
-
:param float [params.leverage]: Leverage size of the order
|
1426
|
+
:param float [params.leverage]: Leverage size of the order(mandatory param in request, default is 1)
|
1426
1427
|
:param str [params.clientOid]: client order id, defaults to uuid if not passed
|
1427
1428
|
:param str [params.remark]: remark for the order, length cannot exceed 100 utf8 characters
|
1428
1429
|
:param str [params.stop]: 'up' or 'down', the direction the stopPrice is triggered from, requires stopPrice. down: Triggers when the price reaches or goes below the stopPrice. up: Triggers when the price reaches or goes above the stopPrice.
|
@@ -1510,17 +1511,21 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1510
1511
|
# required param, cannot be used twice
|
1511
1512
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId', self.uuid())
|
1512
1513
|
params = self.omit(params, ['clientOid', 'clientOrderId'])
|
1513
|
-
if amount < 1:
|
1514
|
-
raise InvalidOrder(self.id + ' createOrder() minimum contract order amount is 1')
|
1515
|
-
preciseAmount = int(self.amount_to_precision(symbol, amount))
|
1516
1514
|
request: dict = {
|
1517
1515
|
'clientOid': clientOrderId,
|
1518
1516
|
'side': side,
|
1519
1517
|
'symbol': market['id'],
|
1520
1518
|
'type': type, # limit or market
|
1521
|
-
'size': preciseAmount,
|
1522
1519
|
'leverage': 1,
|
1523
1520
|
}
|
1521
|
+
cost = self.safe_string(params, 'cost')
|
1522
|
+
params = self.omit(params, 'cost')
|
1523
|
+
if cost is not None:
|
1524
|
+
request['valueQty'] = self.cost_to_precision(symbol, cost)
|
1525
|
+
else:
|
1526
|
+
if amount < 1:
|
1527
|
+
raise InvalidOrder(self.id + ' createOrder() minimum contract order amount is 1')
|
1528
|
+
request['size'] = int(self.amount_to_precision(symbol, amount))
|
1524
1529
|
triggerPrice, stopLossPrice, takeProfitPrice = self.handle_trigger_prices(params)
|
1525
1530
|
stopLoss = self.safe_dict(params, 'stopLoss')
|
1526
1531
|
takeProfit = self.safe_dict(params, 'takeProfit')
|
@@ -2349,6 +2354,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2349
2354
|
def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
2350
2355
|
"""
|
2351
2356
|
transfer currency internally between wallets on the same account
|
2357
|
+
|
2358
|
+
https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-main-or-trade-account
|
2359
|
+
https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-futures-account
|
2360
|
+
|
2352
2361
|
:param str code: unified currency code
|
2353
2362
|
:param float amount: amount to transfer
|
2354
2363
|
:param str fromAccount: account to transfer from
|
@@ -2356,47 +2365,99 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2356
2365
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2357
2366
|
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
|
2358
2367
|
"""
|
2359
|
-
if (toAccount != 'main' and toAccount != 'funding') or (fromAccount != 'futures' and fromAccount != 'future' and fromAccount != 'contract'):
|
2360
|
-
raise BadRequest(self.id + ' transfer() only supports transfers from contract(future) account to main(funding) account')
|
2361
2368
|
self.load_markets()
|
2362
2369
|
currency = self.currency(code)
|
2363
2370
|
amountToPrecision = self.currency_to_precision(code, amount)
|
2364
2371
|
request: dict = {
|
2365
|
-
'currency': self.safe_string(currency, 'id'),
|
2372
|
+
'currency': self.safe_string(currency, 'id'),
|
2366
2373
|
'amount': amountToPrecision,
|
2367
2374
|
}
|
2368
|
-
|
2369
|
-
response =
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
2375
|
+
toAccountString = self.parse_transfer_type(toAccount)
|
2376
|
+
response = None
|
2377
|
+
if toAccountString == 'TRADE' or toAccountString == 'MAIN':
|
2378
|
+
request['recAccountType'] = toAccountString
|
2379
|
+
response = self.futuresPrivatePostTransferOut(self.extend(request, params))
|
2380
|
+
#
|
2381
|
+
# {
|
2382
|
+
# "code": "200000",
|
2383
|
+
# "data": {
|
2384
|
+
# "applyId": "6738754373ceee00011ec3f8",
|
2385
|
+
# "bizNo": "6738754373ceee00011ec3f7",
|
2386
|
+
# "payAccountType": "CONTRACT",
|
2387
|
+
# "payTag": "DEFAULT",
|
2388
|
+
# "remark": "",
|
2389
|
+
# "recAccountType": "MAIN",
|
2390
|
+
# "recTag": "DEFAULT",
|
2391
|
+
# "recRemark": "",
|
2392
|
+
# "recSystem": "KUCOIN",
|
2393
|
+
# "status": "PROCESSING",
|
2394
|
+
# "currency": "USDT",
|
2395
|
+
# "amount": "5",
|
2396
|
+
# "fee": "0",
|
2397
|
+
# "sn": 1519769124846692,
|
2398
|
+
# "reason": "",
|
2399
|
+
# "createdAt": 1731753283000,
|
2400
|
+
# "updatedAt": 1731753283000
|
2401
|
+
# }
|
2402
|
+
# }
|
2403
|
+
#
|
2404
|
+
elif toAccount == 'future' or toAccount == 'swap' or toAccount == 'contract':
|
2405
|
+
request['payAccountType'] = self.parse_transfer_type(fromAccount)
|
2406
|
+
response = self.futuresPrivatePostTransferIn(self.extend(request, params))
|
2407
|
+
#
|
2408
|
+
# {
|
2409
|
+
# "code": "200000",
|
2410
|
+
# "data": {
|
2411
|
+
# "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
|
2412
|
+
# }
|
2413
|
+
# }
|
2414
|
+
#
|
2415
|
+
else:
|
2416
|
+
raise BadRequest(self.id + ' transfer() only supports transfers between future/swap, spot and funding accounts')
|
2417
|
+
data = self.safe_dict(response, 'data', {})
|
2379
2418
|
return self.extend(self.parse_transfer(data, currency), {
|
2380
2419
|
'amount': self.parse_number(amountToPrecision),
|
2381
|
-
'fromAccount':
|
2382
|
-
'toAccount':
|
2420
|
+
'fromAccount': fromAccount,
|
2421
|
+
'toAccount': toAccount,
|
2383
2422
|
})
|
2384
2423
|
|
2385
2424
|
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
2386
2425
|
#
|
2387
|
-
# transfer
|
2426
|
+
# transfer to spot or funding account
|
2388
2427
|
#
|
2389
2428
|
# {
|
2390
2429
|
# "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
|
2391
2430
|
# }
|
2392
2431
|
#
|
2432
|
+
# transfer to future account
|
2433
|
+
#
|
2434
|
+
# {
|
2435
|
+
# "applyId": "6738754373ceee00011ec3f8",
|
2436
|
+
# "bizNo": "6738754373ceee00011ec3f7",
|
2437
|
+
# "payAccountType": "CONTRACT",
|
2438
|
+
# "payTag": "DEFAULT",
|
2439
|
+
# "remark": "",
|
2440
|
+
# "recAccountType": "MAIN",
|
2441
|
+
# "recTag": "DEFAULT",
|
2442
|
+
# "recRemark": "",
|
2443
|
+
# "recSystem": "KUCOIN",
|
2444
|
+
# "status": "PROCESSING",
|
2445
|
+
# "currency": "USDT",
|
2446
|
+
# "amount": "5",
|
2447
|
+
# "fee": "0",
|
2448
|
+
# "sn": 1519769124846692,
|
2449
|
+
# "reason": "",
|
2450
|
+
# "createdAt": 1731753283000,
|
2451
|
+
# "updatedAt": 1731753283000
|
2452
|
+
# }
|
2453
|
+
#
|
2393
2454
|
timestamp = self.safe_integer(transfer, 'updatedAt')
|
2394
2455
|
return {
|
2395
2456
|
'id': self.safe_string(transfer, 'applyId'),
|
2396
2457
|
'timestamp': timestamp,
|
2397
2458
|
'datetime': self.iso8601(timestamp),
|
2398
2459
|
'currency': self.safe_currency_code(None, currency),
|
2399
|
-
'amount':
|
2460
|
+
'amount': self.safe_number(transfer, 'amount'),
|
2400
2461
|
'fromAccount': None,
|
2401
2462
|
'toAccount': None,
|
2402
2463
|
'status': self.safe_string(transfer, 'status'),
|
@@ -2409,6 +2470,13 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2409
2470
|
}
|
2410
2471
|
return self.safe_string(statuses, status, status)
|
2411
2472
|
|
2473
|
+
def parse_transfer_type(self, transferType: Str) -> Str:
|
2474
|
+
transferTypes: dict = {
|
2475
|
+
'spot': 'TRADE',
|
2476
|
+
'funding': 'MAIN',
|
2477
|
+
}
|
2478
|
+
return self.safe_string_upper(transferTypes, transferType, transferType)
|
2479
|
+
|
2412
2480
|
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2413
2481
|
"""
|
2414
2482
|
|
ccxt/lbank.py
CHANGED
ccxt/okx.py
CHANGED
@@ -1199,6 +1199,97 @@ class okx(Exchange, ImplicitAPI):
|
|
1199
1199
|
},
|
1200
1200
|
'brokerId': 'e847386590ce4dBC',
|
1201
1201
|
},
|
1202
|
+
'features': {
|
1203
|
+
# https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
|
1204
|
+
'default': {
|
1205
|
+
'sandbox': True,
|
1206
|
+
'createOrder': {
|
1207
|
+
'triggerPrice': True,
|
1208
|
+
'triggerPriceType': {
|
1209
|
+
'last': True,
|
1210
|
+
'mark': True,
|
1211
|
+
'index': True,
|
1212
|
+
},
|
1213
|
+
'triggerDirection': False,
|
1214
|
+
'stopLossPrice': True,
|
1215
|
+
'takeProfitPrice': True,
|
1216
|
+
'marginMode': True,
|
1217
|
+
'attachedStopLossTakeProfit': {
|
1218
|
+
'triggerPriceType': {
|
1219
|
+
'last': True,
|
1220
|
+
'mark': True,
|
1221
|
+
'index': True,
|
1222
|
+
},
|
1223
|
+
'limitPrice': True,
|
1224
|
+
},
|
1225
|
+
'timeInForce': {
|
1226
|
+
'GTC': True,
|
1227
|
+
'IOC': True,
|
1228
|
+
'FOK': True,
|
1229
|
+
'PO': True,
|
1230
|
+
'GTD': False,
|
1231
|
+
},
|
1232
|
+
'hedged': True,
|
1233
|
+
# even though the below params not unified yet, it's useful metadata for users to know that exchange supports them
|
1234
|
+
'selfTradePrevention': True,
|
1235
|
+
'trailing': True,
|
1236
|
+
'twap': True,
|
1237
|
+
'iceberg': True,
|
1238
|
+
'oco': True,
|
1239
|
+
},
|
1240
|
+
'createOrders': {
|
1241
|
+
'max': 20,
|
1242
|
+
},
|
1243
|
+
'fetchMyTrades': {
|
1244
|
+
'daysBack': 90,
|
1245
|
+
'limit': 100,
|
1246
|
+
'untilDays': 10000,
|
1247
|
+
},
|
1248
|
+
'fetchOrder': {
|
1249
|
+
'marginMode': False,
|
1250
|
+
'trigger': True,
|
1251
|
+
'trailing': True,
|
1252
|
+
},
|
1253
|
+
'fetchOpenOrders': {
|
1254
|
+
'limit': 100,
|
1255
|
+
'marginMode': False,
|
1256
|
+
'trigger': True,
|
1257
|
+
'trailing': True,
|
1258
|
+
},
|
1259
|
+
'fetchOrders': None, # not supported
|
1260
|
+
'fetchClosedOrders': {
|
1261
|
+
'limit': 100,
|
1262
|
+
'daysBackClosed': 90, # 3 months
|
1263
|
+
'daysBackCanceled': 1 / 12, # 2 hour
|
1264
|
+
'untilDays': None,
|
1265
|
+
'marginMode': False,
|
1266
|
+
'trigger': True,
|
1267
|
+
'trailing': True,
|
1268
|
+
},
|
1269
|
+
'fetchOHLCV': {
|
1270
|
+
'limit': 300,
|
1271
|
+
},
|
1272
|
+
},
|
1273
|
+
'spot': {
|
1274
|
+
'extends': 'default',
|
1275
|
+
},
|
1276
|
+
'swap': {
|
1277
|
+
'linear': {
|
1278
|
+
'extends': 'default',
|
1279
|
+
},
|
1280
|
+
'inverse': {
|
1281
|
+
'extends': 'default',
|
1282
|
+
},
|
1283
|
+
},
|
1284
|
+
'future': {
|
1285
|
+
'linear': {
|
1286
|
+
'extends': 'default',
|
1287
|
+
},
|
1288
|
+
'inverse': {
|
1289
|
+
'extends': 'default',
|
1290
|
+
},
|
1291
|
+
},
|
1292
|
+
},
|
1202
1293
|
'commonCurrencies': {
|
1203
1294
|
# the exchange refers to ERC20 version of Aeternity(AEToken)
|
1204
1295
|
'AE': 'AET', # https://github.com/ccxt/ccxt/issues/4981
|
@@ -3077,7 +3168,7 @@ class okx(Exchange, ImplicitAPI):
|
|
3077
3168
|
if not isAlgoOrder:
|
3078
3169
|
if price is not None:
|
3079
3170
|
request['newPx'] = self.price_to_precision(symbol, price)
|
3080
|
-
params = self.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit'])
|
3171
|
+
params = self.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit', 'postOnly'])
|
3081
3172
|
return self.extend(request, params)
|
3082
3173
|
|
3083
3174
|
def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
@@ -7932,8 +8023,8 @@ class okx(Exchange, ImplicitAPI):
|
|
7932
8023
|
|
7933
8024
|
:param str [symbol]: not used by okx fetchMarginAdjustmentHistory
|
7934
8025
|
:param str [type]: "add" or "reduce"
|
7935
|
-
|
7936
|
-
|
8026
|
+
:param int [since]: the earliest time in ms to fetch margin adjustment history for
|
8027
|
+
:param int [limit]: the maximum number of entries to retrieve
|
7937
8028
|
:param dict params: extra parameters specific to the exchange api endpoint
|
7938
8029
|
:param boolean [params.auto]: True if fetching auto margin increases
|
7939
8030
|
:returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
ccxt/phemex.py
CHANGED
@@ -504,6 +504,13 @@ class phemex(Exchange, ImplicitAPI):
|
|
504
504
|
'transfer': {
|
505
505
|
'fillResponseFromRequest': True,
|
506
506
|
},
|
507
|
+
'triggerPriceTypesMap': {
|
508
|
+
'last': 'ByLastPrice',
|
509
|
+
'mark': 'ByMarkPrice',
|
510
|
+
'index': 'ByIndexPrice',
|
511
|
+
'ask': 'ByAskPrice',
|
512
|
+
'bid': 'ByBidPrice',
|
513
|
+
},
|
507
514
|
},
|
508
515
|
})
|
509
516
|
|
@@ -518,7 +525,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
518
525
|
def parse_swap_market(self, market: dict):
|
519
526
|
#
|
520
527
|
# {
|
521
|
-
# "symbol":"BTCUSD",
|
528
|
+
# "symbol":"BTCUSD", #
|
522
529
|
# "code":"1",
|
523
530
|
# "type":"Perpetual",
|
524
531
|
# "displaySymbol":"BTC / USD",
|
@@ -526,7 +533,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
526
533
|
# "markSymbol":".MBTC",
|
527
534
|
# "fundingRateSymbol":".BTCFR",
|
528
535
|
# "fundingRate8hSymbol":".BTCFR8H",
|
529
|
-
# "contractUnderlyingAssets":"USD",
|
536
|
+
# "contractUnderlyingAssets":"USD", # or eg. `1000 SHIB`
|
530
537
|
# "settleCurrency":"BTC",
|
531
538
|
# "quoteCurrency":"USD",
|
532
539
|
# "contractSize":"1 USD",
|
@@ -570,6 +577,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
570
577
|
quoteId = self.safe_string(market, 'quoteCurrency')
|
571
578
|
settleId = self.safe_string(market, 'settleCurrency')
|
572
579
|
base = self.safe_currency_code(baseId)
|
580
|
+
base = base.replace(' ', '') # replace space for junction codes, eg. `1000 SHIB`
|
573
581
|
quote = self.safe_currency_code(quoteId)
|
574
582
|
settle = self.safe_currency_code(settleId)
|
575
583
|
inverse = False
|
@@ -2070,6 +2078,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
2070
2078
|
'PartiallyFilled': 'open',
|
2071
2079
|
'Filled': 'closed',
|
2072
2080
|
'Canceled': 'canceled',
|
2081
|
+
'Suspended': 'canceled',
|
2073
2082
|
'1': 'open',
|
2074
2083
|
'2': 'canceled',
|
2075
2084
|
'3': 'closed',
|
@@ -2532,37 +2541,31 @@ class phemex(Exchange, ImplicitAPI):
|
|
2532
2541
|
if stopLossDefined:
|
2533
2542
|
stopLossTriggerPrice = self.safe_value_2(stopLoss, 'triggerPrice', 'stopPrice')
|
2534
2543
|
if stopLossTriggerPrice is None:
|
2535
|
-
raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"]
|
2544
|
+
raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"] for a stop loss order')
|
2536
2545
|
if market['settle'] == 'USDT':
|
2537
2546
|
request['stopLossRp'] = self.price_to_precision(symbol, stopLossTriggerPrice)
|
2538
2547
|
else:
|
2539
2548
|
request['stopLossEp'] = self.to_ep(stopLossTriggerPrice, market)
|
2540
2549
|
stopLossTriggerPriceType = self.safe_string_2(stopLoss, 'triggerPriceType', 'slTrigger')
|
2541
2550
|
if stopLossTriggerPriceType is not None:
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
if (stopLossTriggerPriceType != 'ByMarkPrice') and (stopLossTriggerPriceType != 'ByLastPrice'):
|
2547
|
-
raise InvalidOrder(self.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", or "ByLastPrice"')
|
2548
|
-
request['slTrigger'] = stopLossTriggerPriceType
|
2551
|
+
request['slTrigger'] = self.safe_string(self.options['triggerPriceTypesMap'], stopLossTriggerPriceType, stopLossTriggerPriceType)
|
2552
|
+
slLimitPrice = self.safe_string(stopLoss, 'price')
|
2553
|
+
if slLimitPrice is not None:
|
2554
|
+
request['slPxRp'] = self.price_to_precision(symbol, slLimitPrice)
|
2549
2555
|
if takeProfitDefined:
|
2550
2556
|
takeProfitTriggerPrice = self.safe_value_2(takeProfit, 'triggerPrice', 'stopPrice')
|
2551
2557
|
if takeProfitTriggerPrice is None:
|
2552
|
-
raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"]
|
2558
|
+
raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"] for a take profit order')
|
2553
2559
|
if market['settle'] == 'USDT':
|
2554
2560
|
request['takeProfitRp'] = self.price_to_precision(symbol, takeProfitTriggerPrice)
|
2555
2561
|
else:
|
2556
2562
|
request['takeProfitEp'] = self.to_ep(takeProfitTriggerPrice, market)
|
2557
|
-
takeProfitTriggerPriceType = self.safe_string_2(
|
2563
|
+
takeProfitTriggerPriceType = self.safe_string_2(takeProfit, 'triggerPriceType', 'tpTrigger')
|
2558
2564
|
if takeProfitTriggerPriceType is not None:
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
if (takeProfitTriggerPriceType != 'ByMarkPrice') and (takeProfitTriggerPriceType != 'ByLastPrice'):
|
2564
|
-
raise InvalidOrder(self.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", or "ByLastPrice"')
|
2565
|
-
request['tpTrigger'] = takeProfitTriggerPriceType
|
2565
|
+
request['tpTrigger'] = self.safe_string(self.options['triggerPriceTypesMap'], takeProfitTriggerPriceType, takeProfitTriggerPriceType)
|
2566
|
+
tpLimitPrice = self.safe_string(takeProfit, 'price')
|
2567
|
+
if tpLimitPrice is not None:
|
2568
|
+
request['tpPxRp'] = self.price_to_precision(symbol, tpLimitPrice)
|
2566
2569
|
if (type == 'Limit') or (type == 'StopLimit') or (type == 'LimitIfTouched'):
|
2567
2570
|
if market['settle'] == 'USDT':
|
2568
2571
|
request['priceRp'] = self.price_to_precision(symbol, price)
|
@@ -2713,13 +2716,13 @@ class phemex(Exchange, ImplicitAPI):
|
|
2713
2716
|
request['orderQtyRq'] = self.amount_to_precision(market['symbol'], amount)
|
2714
2717
|
else:
|
2715
2718
|
request['baseQtyEV'] = self.to_ev(amount, market)
|
2716
|
-
stopPrice = self.
|
2719
|
+
stopPrice = self.safe_string_n(params, ['triggerPrice', 'stopPx', 'stopPrice'])
|
2717
2720
|
if stopPrice is not None:
|
2718
2721
|
if isUSDTSettled:
|
2719
2722
|
request['stopPxRp'] = self.price_to_precision(symbol, stopPrice)
|
2720
2723
|
else:
|
2721
2724
|
request['stopPxEp'] = self.to_ep(stopPrice, market)
|
2722
|
-
params = self.omit(params, ['stopPx', 'stopPrice'])
|
2725
|
+
params = self.omit(params, ['triggerPrice', 'stopPx', 'stopPrice'])
|
2723
2726
|
response = None
|
2724
2727
|
if isUSDTSettled:
|
2725
2728
|
posSide = self.safe_string(params, 'posSide')
|
@@ -3958,6 +3961,9 @@ class phemex(Exchange, ImplicitAPI):
|
|
3958
3961
|
def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
3959
3962
|
"""
|
3960
3963
|
set margin mode to 'cross' or 'isolated'
|
3964
|
+
|
3965
|
+
https://phemex-docs.github.io/#set-leverage
|
3966
|
+
|
3961
3967
|
:param str marginMode: 'cross' or 'isolated'
|
3962
3968
|
:param str symbol: unified market symbol
|
3963
3969
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -4221,6 +4227,10 @@ class phemex(Exchange, ImplicitAPI):
|
|
4221
4227
|
def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
4222
4228
|
"""
|
4223
4229
|
transfer currency internally between wallets on the same account
|
4230
|
+
|
4231
|
+
https://phemex-docs.github.io/#transfer-between-spot-and-futures
|
4232
|
+
https://phemex-docs.github.io/#universal-transfer-main-account-only-transfer-between-sub-to-main-main-to-sub-or-sub-to-sub
|
4233
|
+
|
4224
4234
|
:param str code: unified currency code
|
4225
4235
|
:param float amount: amount to transfer
|
4226
4236
|
:param str fromAccount: account to transfer from
|
@@ -4297,6 +4307,9 @@ class phemex(Exchange, ImplicitAPI):
|
|
4297
4307
|
def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
4298
4308
|
"""
|
4299
4309
|
fetch a history of internal transfers made on an account
|
4310
|
+
|
4311
|
+
https://phemex-docs.github.io/#query-transfer-history
|
4312
|
+
|
4300
4313
|
:param str code: unified currency code of the currency transferred
|
4301
4314
|
:param int [since]: the earliest time in ms to fetch transfers for
|
4302
4315
|
:param int [limit]: the maximum number of transfers structures to retrieve
|
ccxt/pro/__init__.py
CHANGED
ccxt/pro/binance.py
CHANGED
@@ -223,7 +223,7 @@ class binance(ccxt.async_support.binance):
|
|
223
223
|
https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/All-Market-Liquidation-Order-Streams
|
224
224
|
https://developers.binance.com/docs/derivatives/coin-margined-futures/websocket-market-streams/All-Market-Liquidation-Order-Streams
|
225
225
|
|
226
|
-
:param str[] symbols:
|
226
|
+
:param str[] symbols: list of unified market symbols
|
227
227
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
228
228
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
229
229
|
:param dict [params]: exchange specific parameters for the bitmex api endpoint
|
@@ -436,7 +436,7 @@ class binance(ccxt.async_support.binance):
|
|
436
436
|
https://developers.binance.com/docs/derivatives/usds-margined-futures/user-data-streams/Event-Order-Update
|
437
437
|
https://developers.binance.com/docs/derivatives/coin-margined-futures/user-data-streams/Event-Order-Update
|
438
438
|
|
439
|
-
|
439
|
+
:param str[] symbols: list of unified market symbols
|
440
440
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
441
441
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
442
442
|
:param dict [params]: exchange specific parameters for the bitmex api endpoint
|
@@ -2971,7 +2971,7 @@ class binance(ccxt.async_support.binance):
|
|
2971
2971
|
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Cancel-Order
|
2972
2972
|
|
2973
2973
|
:param str id: order id
|
2974
|
-
:param str symbol: unified market symbol, default is None
|
2974
|
+
:param str [symbol]: unified market symbol, default is None
|
2975
2975
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2976
2976
|
:param str|None [params.cancelRestrictions]: Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW. ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED.
|
2977
2977
|
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -3012,7 +3012,7 @@ class binance(ccxt.async_support.binance):
|
|
3012
3012
|
|
3013
3013
|
https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#cancel-open-orders-trade
|
3014
3014
|
|
3015
|
-
:param str symbol: unified market symbol of the market to cancel orders in
|
3015
|
+
:param str [symbol]: unified market symbol of the market to cancel orders in
|
3016
3016
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3017
3017
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3018
3018
|
"""
|
@@ -3048,8 +3048,8 @@ class binance(ccxt.async_support.binance):
|
|
3048
3048
|
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Query-Order
|
3049
3049
|
|
3050
3050
|
:param str id: order id
|
3051
|
-
:param str symbol: unified symbol of the market the order was made in
|
3052
|
-
:param dict params: extra parameters specific to the exchange API endpoint
|
3051
|
+
:param str [symbol]: unified symbol of the market the order was made in
|
3052
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3053
3053
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3054
3054
|
"""
|
3055
3055
|
await self.load_markets()
|
@@ -3474,8 +3474,8 @@ class binance(ccxt.async_support.binance):
|
|
3474
3474
|
"""
|
3475
3475
|
watch all open positions
|
3476
3476
|
:param str[]|None symbols: list of unified market symbols
|
3477
|
-
|
3478
|
-
|
3477
|
+
:param number [since]: since timestamp
|
3478
|
+
:param number [limit]: limit
|
3479
3479
|
:param dict params: extra parameters specific to the exchange API endpoint
|
3480
3480
|
:param boolean [params.portfolioMargin]: set to True if you would like to watch positions in a portfolio margin account
|
3481
3481
|
:returns dict[]: a list of `position structure <https://docs.ccxt.com/en/latest/manual.html#position-structure>`
|