ccxt 4.4.6__py2.py3-none-any.whl → 4.4.8__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/binance.py +1 -0
- ccxt/abstract/binancecoinm.py +1 -0
- ccxt/abstract/binanceus.py +1 -0
- ccxt/abstract/binanceusdm.py +1 -0
- ccxt/abstract/bybit.py +5 -0
- ccxt/abstract/okx.py +2 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +12 -3
- ccxt/async_support/binance.py +49 -12
- ccxt/async_support/bingx.py +3 -0
- ccxt/async_support/bitget.py +8 -4
- ccxt/async_support/bitmart.py +109 -1
- ccxt/async_support/bybit.py +364 -11
- ccxt/async_support/gate.py +3 -0
- ccxt/async_support/htx.py +20 -0
- ccxt/async_support/kucoin.py +2 -2
- ccxt/async_support/mexc.py +85 -13
- ccxt/async_support/okx.py +4 -0
- ccxt/base/exchange.py +16 -3
- ccxt/binance.py +49 -12
- ccxt/bingx.py +3 -0
- ccxt/bitget.py +8 -4
- ccxt/bitmart.py +109 -1
- ccxt/bybit.py +364 -11
- ccxt/gate.py +3 -0
- ccxt/htx.py +20 -0
- ccxt/kucoin.py +2 -2
- ccxt/mexc.py +85 -13
- ccxt/okx.py +4 -0
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitget.py +62 -0
- ccxt/pro/bitmart.py +72 -0
- ccxt/pro/bitvavo.py +87 -2
- ccxt/pro/blofin.py +59 -0
- ccxt/pro/okx.py +11 -5
- {ccxt-4.4.6.dist-info → ccxt-4.4.8.dist-info}/METADATA +4 -4
- {ccxt-4.4.6.dist-info → ccxt-4.4.8.dist-info}/RECORD +41 -41
- {ccxt-4.4.6.dist-info → ccxt-4.4.8.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.6.dist-info → ccxt-4.4.8.dist-info}/WHEEL +0 -0
- {ccxt-4.4.6.dist-info → ccxt-4.4.8.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/binance.py
CHANGED
@@ -702,6 +702,7 @@ class ImplicitAPI:
|
|
702
702
|
papi_post_repay_futures_negative_balance = papiPostRepayFuturesNegativeBalance = Entry('repay-futures-negative-balance', 'papi', 'POST', {'cost': 150})
|
703
703
|
papi_post_listenkey = papiPostListenKey = Entry('listenKey', 'papi', 'POST', {'cost': 1})
|
704
704
|
papi_post_asset_collection = papiPostAssetCollection = Entry('asset-collection', 'papi', 'POST', {'cost': 3})
|
705
|
+
papi_post_margin_repay_debt = papiPostMarginRepayDebt = Entry('margin/repay-debt', 'papi', 'POST', {'cost': 0.4})
|
705
706
|
papi_put_listenkey = papiPutListenKey = Entry('listenKey', 'papi', 'PUT', {'cost': 1})
|
706
707
|
papi_delete_um_order = papiDeleteUmOrder = Entry('um/order', 'papi', 'DELETE', {'cost': 1})
|
707
708
|
papi_delete_um_conditional_order = papiDeleteUmConditionalOrder = Entry('um/conditional/order', 'papi', 'DELETE', {'cost': 1})
|
ccxt/abstract/binancecoinm.py
CHANGED
@@ -702,6 +702,7 @@ class ImplicitAPI:
|
|
702
702
|
papi_post_repay_futures_negative_balance = papiPostRepayFuturesNegativeBalance = Entry('repay-futures-negative-balance', 'papi', 'POST', {'cost': 150})
|
703
703
|
papi_post_listenkey = papiPostListenKey = Entry('listenKey', 'papi', 'POST', {'cost': 1})
|
704
704
|
papi_post_asset_collection = papiPostAssetCollection = Entry('asset-collection', 'papi', 'POST', {'cost': 3})
|
705
|
+
papi_post_margin_repay_debt = papiPostMarginRepayDebt = Entry('margin/repay-debt', 'papi', 'POST', {'cost': 0.4})
|
705
706
|
papi_put_listenkey = papiPutListenKey = Entry('listenKey', 'papi', 'PUT', {'cost': 1})
|
706
707
|
papi_delete_um_order = papiDeleteUmOrder = Entry('um/order', 'papi', 'DELETE', {'cost': 1})
|
707
708
|
papi_delete_um_conditional_order = papiDeleteUmConditionalOrder = Entry('um/conditional/order', 'papi', 'DELETE', {'cost': 1})
|
ccxt/abstract/binanceus.py
CHANGED
@@ -754,6 +754,7 @@ class ImplicitAPI:
|
|
754
754
|
papi_post_repay_futures_negative_balance = papiPostRepayFuturesNegativeBalance = Entry('repay-futures-negative-balance', 'papi', 'POST', {'cost': 150})
|
755
755
|
papi_post_listenkey = papiPostListenKey = Entry('listenKey', 'papi', 'POST', {'cost': 1})
|
756
756
|
papi_post_asset_collection = papiPostAssetCollection = Entry('asset-collection', 'papi', 'POST', {'cost': 3})
|
757
|
+
papi_post_margin_repay_debt = papiPostMarginRepayDebt = Entry('margin/repay-debt', 'papi', 'POST', {'cost': 0.4})
|
757
758
|
papi_put_listenkey = papiPutListenKey = Entry('listenKey', 'papi', 'PUT', {'cost': 1})
|
758
759
|
papi_delete_um_order = papiDeleteUmOrder = Entry('um/order', 'papi', 'DELETE', {'cost': 1})
|
759
760
|
papi_delete_um_conditional_order = papiDeleteUmConditionalOrder = Entry('um/conditional/order', 'papi', 'DELETE', {'cost': 1})
|
ccxt/abstract/binanceusdm.py
CHANGED
@@ -702,6 +702,7 @@ class ImplicitAPI:
|
|
702
702
|
papi_post_repay_futures_negative_balance = papiPostRepayFuturesNegativeBalance = Entry('repay-futures-negative-balance', 'papi', 'POST', {'cost': 150})
|
703
703
|
papi_post_listenkey = papiPostListenKey = Entry('listenKey', 'papi', 'POST', {'cost': 1})
|
704
704
|
papi_post_asset_collection = papiPostAssetCollection = Entry('asset-collection', 'papi', 'POST', {'cost': 3})
|
705
|
+
papi_post_margin_repay_debt = papiPostMarginRepayDebt = Entry('margin/repay-debt', 'papi', 'POST', {'cost': 0.4})
|
705
706
|
papi_put_listenkey = papiPutListenKey = Entry('listenKey', 'papi', 'PUT', {'cost': 1})
|
706
707
|
papi_delete_um_order = papiDeleteUmOrder = Entry('um/order', 'papi', 'DELETE', {'cost': 1})
|
707
708
|
papi_delete_um_conditional_order = papiDeleteUmConditionalOrder = Entry('um/conditional/order', 'papi', 'DELETE', {'cost': 1})
|
ccxt/abstract/bybit.py
CHANGED
@@ -132,6 +132,9 @@ class ImplicitAPI:
|
|
132
132
|
private_get_v5_account_contract_transaction_log = privateGetV5AccountContractTransactionLog = Entry('v5/account/contract-transaction-log', 'private', 'GET', {'cost': 1})
|
133
133
|
private_get_v5_account_smp_group = privateGetV5AccountSmpGroup = Entry('v5/account/smp-group', 'private', 'GET', {'cost': 1})
|
134
134
|
private_get_v5_account_mmp_state = privateGetV5AccountMmpState = Entry('v5/account/mmp-state', 'private', 'GET', {'cost': 5})
|
135
|
+
private_get_v5_asset_exchange_query_coin_list = privateGetV5AssetExchangeQueryCoinList = Entry('v5/asset/exchange/query-coin-list', 'private', 'GET', {'cost': 0.5})
|
136
|
+
private_get_v5_asset_exchange_convert_result_query = privateGetV5AssetExchangeConvertResultQuery = Entry('v5/asset/exchange/convert-result-query', 'private', 'GET', {'cost': 0.5})
|
137
|
+
private_get_v5_asset_exchange_query_convert_history = privateGetV5AssetExchangeQueryConvertHistory = Entry('v5/asset/exchange/query-convert-history', 'private', 'GET', {'cost': 0.5})
|
135
138
|
private_get_v5_asset_exchange_order_record = privateGetV5AssetExchangeOrderRecord = Entry('v5/asset/exchange/order-record', 'private', 'GET', {'cost': 5})
|
136
139
|
private_get_v5_asset_delivery_record = privateGetV5AssetDeliveryRecord = Entry('v5/asset/delivery-record', 'private', 'GET', {'cost': 5})
|
137
140
|
private_get_v5_asset_settlement_record = privateGetV5AssetSettlementRecord = Entry('v5/asset/settlement-record', 'private', 'GET', {'cost': 5})
|
@@ -270,6 +273,8 @@ class ImplicitAPI:
|
|
270
273
|
private_post_v5_account_set_hedging_mode = privatePostV5AccountSetHedgingMode = Entry('v5/account/set-hedging-mode', 'private', 'POST', {'cost': 5})
|
271
274
|
private_post_v5_account_mmp_modify = privatePostV5AccountMmpModify = Entry('v5/account/mmp-modify', 'private', 'POST', {'cost': 5})
|
272
275
|
private_post_v5_account_mmp_reset = privatePostV5AccountMmpReset = Entry('v5/account/mmp-reset', 'private', 'POST', {'cost': 5})
|
276
|
+
private_post_v5_asset_exchange_quote_apply = privatePostV5AssetExchangeQuoteApply = Entry('v5/asset/exchange/quote-apply', 'private', 'POST', {'cost': 1})
|
277
|
+
private_post_v5_asset_exchange_convert_execute = privatePostV5AssetExchangeConvertExecute = Entry('v5/asset/exchange/convert-execute', 'private', 'POST', {'cost': 1})
|
273
278
|
private_post_v5_asset_transfer_inter_transfer = privatePostV5AssetTransferInterTransfer = Entry('v5/asset/transfer/inter-transfer', 'private', 'POST', {'cost': 50})
|
274
279
|
private_post_v5_asset_transfer_save_transfer_sub_member = privatePostV5AssetTransferSaveTransferSubMember = Entry('v5/asset/transfer/save-transfer-sub-member', 'private', 'POST', {'cost': 150})
|
275
280
|
private_post_v5_asset_transfer_universal_transfer = privatePostV5AssetTransferUniversalTransfer = Entry('v5/asset/transfer/universal-transfer', 'private', 'POST', {'cost': 10})
|
ccxt/abstract/okx.py
CHANGED
@@ -79,6 +79,7 @@ class ImplicitAPI:
|
|
79
79
|
public_get_copytrading_public_preference_currency = publicGetCopytradingPublicPreferenceCurrency = Entry('copytrading/public-preference-currency', 'public', 'GET', {'cost': 4})
|
80
80
|
public_get_copytrading_public_current_subpositions = publicGetCopytradingPublicCurrentSubpositions = Entry('copytrading/public-current-subpositions', 'public', 'GET', {'cost': 4})
|
81
81
|
public_get_copytrading_public_subpositions_history = publicGetCopytradingPublicSubpositionsHistory = Entry('copytrading/public-subpositions-history', 'public', 'GET', {'cost': 4})
|
82
|
+
public_get_support_announcements_types = publicGetSupportAnnouncementsTypes = Entry('support/announcements-types', 'public', 'GET', {'cost': 20})
|
82
83
|
private_get_rfq_counterparties = privateGetRfqCounterparties = Entry('rfq/counterparties', 'private', 'GET', {'cost': 4})
|
83
84
|
private_get_rfq_maker_instrument_settings = privateGetRfqMakerInstrumentSettings = Entry('rfq/maker-instrument-settings', 'private', 'GET', {'cost': 4})
|
84
85
|
private_get_rfq_mmp_config = privateGetRfqMmpConfig = Entry('rfq/mmp-config', 'private', 'GET', {'cost': 4})
|
@@ -208,6 +209,7 @@ class ImplicitAPI:
|
|
208
209
|
private_get_broker_fd_if_rebate = privateGetBrokerFdIfRebate = Entry('broker/fd/if-rebate', 'private', 'GET', {'cost': 5})
|
209
210
|
private_get_affiliate_invitee_detail = privateGetAffiliateInviteeDetail = Entry('affiliate/invitee/detail', 'private', 'GET', {'cost': 1})
|
210
211
|
private_get_users_partner_if_rebate = privateGetUsersPartnerIfRebate = Entry('users/partner/if-rebate', 'private', 'GET', {'cost': 1})
|
212
|
+
private_get_support_announcements = privateGetSupportAnnouncements = Entry('support/announcements', 'private', 'GET', {'cost': 4})
|
211
213
|
private_post_rfq_create_rfq = privatePostRfqCreateRfq = Entry('rfq/create-rfq', 'private', 'POST', {'cost': 4})
|
212
214
|
private_post_rfq_cancel_rfq = privatePostRfqCancelRfq = Entry('rfq/cancel-rfq', 'private', 'POST', {'cost': 4})
|
213
215
|
private_post_rfq_cancel_batch_rfqs = privatePostRfqCancelBatchRfqs = Entry('rfq/cancel-batch-rfqs', 'private', 'POST', {'cost': 10})
|
ccxt/async_support/__init__.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.4.
|
5
|
+
__version__ = '4.4.8'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -1895,8 +1895,17 @@ class Exchange(BaseExchange):
|
|
1895
1895
|
if responseLength == 0:
|
1896
1896
|
break
|
1897
1897
|
result = self.array_concat(result, response)
|
1898
|
-
last = self.
|
1899
|
-
cursorValue = self.safe_value(last['info'], cursorReceived)
|
1898
|
+
last = self.safe_dict(response, responseLength - 1)
|
1899
|
+
# cursorValue = self.safe_value(last['info'], cursorReceived)
|
1900
|
+
cursorValue = None # search for the cursor
|
1901
|
+
for j in range(0, responseLength):
|
1902
|
+
index = responseLength - j - 1
|
1903
|
+
entry = self.safe_dict(response, index)
|
1904
|
+
info = self.safe_dict(entry, 'info')
|
1905
|
+
cursor = self.safe_value(info, cursorReceived)
|
1906
|
+
if cursor is not None:
|
1907
|
+
cursorValue = cursor
|
1908
|
+
break
|
1900
1909
|
if cursorValue is None:
|
1901
1910
|
break
|
1902
1911
|
lastTimestamp = self.safe_integer(last, 'timestamp')
|
ccxt/async_support/binance.py
CHANGED
@@ -1115,6 +1115,7 @@ class binance(Exchange, ImplicitAPI):
|
|
1115
1115
|
'repay-futures-negative-balance': 150, # Weight(IP): 1500 => cost = 0.1 * 1500 = 150
|
1116
1116
|
'listenKey': 1, # 1
|
1117
1117
|
'asset-collection': 3,
|
1118
|
+
'margin/repay-debt': 0.4, # Weight(Order): 0.4 =>(1000 / (50 * 0.4)) * 60 = 3000
|
1118
1119
|
},
|
1119
1120
|
'put': {
|
1120
1121
|
'listenKey': 1, # 1
|
@@ -1232,6 +1233,7 @@ class binance(Exchange, ImplicitAPI):
|
|
1232
1233
|
],
|
1233
1234
|
'fetchCurrencies': True, # self is a private call and it requires API keys
|
1234
1235
|
# 'fetchTradesMethod': 'publicGetAggTrades', # publicGetTrades, publicGetHistoricalTrades, eapiPublicGetTrades
|
1236
|
+
# 'repayCrossMarginMethod': 'papiPostRepayLoan', # papiPostMarginRepayDebt
|
1235
1237
|
'defaultTimeInForce': 'GTC', # 'GTC' = Good To Cancel(default), 'IOC' = Immediate Or Cancel
|
1236
1238
|
'defaultType': 'spot', # 'spot', 'future', 'margin', 'delivery', 'option'
|
1237
1239
|
'defaultSubType': None, # 'linear', 'inverse'
|
@@ -2879,7 +2881,7 @@ class binance(Exchange, ImplicitAPI):
|
|
2879
2881
|
res = self.safe_value(results, i)
|
2880
2882
|
if fetchMargins and isinstance(res, list):
|
2881
2883
|
keysList = list(self.index_by(res, 'symbol').keys())
|
2882
|
-
length = (self.options['crossMarginPairsData'])
|
2884
|
+
length = len(self.options['crossMarginPairsData'])
|
2883
2885
|
# first one is the cross-margin promise
|
2884
2886
|
if length == 0:
|
2885
2887
|
self.options['crossMarginPairsData'] = keysList
|
@@ -11242,10 +11244,13 @@ class binance(Exchange, ImplicitAPI):
|
|
11242
11244
|
repay borrowed margin and interest
|
11243
11245
|
:see: https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay
|
11244
11246
|
:see: https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
|
11247
|
+
:see: https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay-Debt
|
11245
11248
|
:param str code: unified currency code of the currency to repay
|
11246
11249
|
:param float amount: the amount to repay
|
11247
11250
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11248
11251
|
:param boolean [params.portfolioMargin]: set to True if you would like to repay margin in a portfolio margin account
|
11252
|
+
:param str [params.repayCrossMarginMethod]: *portfolio margin only* 'papiPostRepayLoan'(default), 'papiPostMarginRepayDebt'(alternative)
|
11253
|
+
:param str [params.specifyRepayAssets]: *portfolio margin papiPostMarginRepayDebt only* specific asset list to repay debt
|
11249
11254
|
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
11250
11255
|
"""
|
11251
11256
|
await self.load_markets()
|
@@ -11258,17 +11263,37 @@ class binance(Exchange, ImplicitAPI):
|
|
11258
11263
|
isPortfolioMargin = None
|
11259
11264
|
isPortfolioMargin, params = self.handle_option_and_params_2(params, 'repayCrossMargin', 'papi', 'portfolioMargin', False)
|
11260
11265
|
if isPortfolioMargin:
|
11261
|
-
|
11266
|
+
method = None
|
11267
|
+
method, params = self.handle_option_and_params_2(params, 'repayCrossMargin', 'repayCrossMarginMethod', 'method')
|
11268
|
+
if method == 'papiPostMarginRepayDebt':
|
11269
|
+
response = await self.papiPostMarginRepayDebt(self.extend(request, params))
|
11270
|
+
#
|
11271
|
+
# {
|
11272
|
+
# "asset": "USDC",
|
11273
|
+
# "amount": 10,
|
11274
|
+
# "specifyRepayAssets": null,
|
11275
|
+
# "updateTime": 1727170761267,
|
11276
|
+
# "success": True
|
11277
|
+
# }
|
11278
|
+
#
|
11279
|
+
else:
|
11280
|
+
response = await self.papiPostRepayLoan(self.extend(request, params))
|
11281
|
+
#
|
11282
|
+
# {
|
11283
|
+
# "tranId": 108988250265,
|
11284
|
+
# "clientTag":""
|
11285
|
+
# }
|
11286
|
+
#
|
11262
11287
|
else:
|
11263
11288
|
request['isIsolated'] = 'FALSE'
|
11264
11289
|
request['type'] = 'REPAY'
|
11265
11290
|
response = await self.sapiPostMarginBorrowRepay(self.extend(request, params))
|
11266
|
-
|
11267
|
-
|
11268
|
-
|
11269
|
-
|
11270
|
-
|
11271
|
-
|
11291
|
+
#
|
11292
|
+
# {
|
11293
|
+
# "tranId": 108988250265,
|
11294
|
+
# "clientTag":""
|
11295
|
+
# }
|
11296
|
+
#
|
11272
11297
|
return self.parse_margin_loan(response, currency)
|
11273
11298
|
|
11274
11299
|
async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
@@ -11370,13 +11395,25 @@ class binance(Exchange, ImplicitAPI):
|
|
11370
11395
|
# "clientTag":""
|
11371
11396
|
# }
|
11372
11397
|
#
|
11398
|
+
# repayCrossMargin alternative endpoint
|
11399
|
+
#
|
11400
|
+
# {
|
11401
|
+
# "asset": "USDC",
|
11402
|
+
# "amount": 10,
|
11403
|
+
# "specifyRepayAssets": null,
|
11404
|
+
# "updateTime": 1727170761267,
|
11405
|
+
# "success": True
|
11406
|
+
# }
|
11407
|
+
#
|
11408
|
+
currencyId = self.safe_string(info, 'asset')
|
11409
|
+
timestamp = self.safe_integer(info, 'updateTime')
|
11373
11410
|
return {
|
11374
11411
|
'id': self.safe_integer(info, 'tranId'),
|
11375
|
-
'currency': self.safe_currency_code(
|
11376
|
-
'amount':
|
11412
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
11413
|
+
'amount': self.safe_number(info, 'amount'),
|
11377
11414
|
'symbol': None,
|
11378
|
-
'timestamp':
|
11379
|
-
'datetime':
|
11415
|
+
'timestamp': timestamp,
|
11416
|
+
'datetime': self.iso8601(timestamp),
|
11380
11417
|
'info': info,
|
11381
11418
|
}
|
11382
11419
|
|
ccxt/async_support/bingx.py
CHANGED
ccxt/async_support/bitget.py
CHANGED
@@ -1437,11 +1437,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
1437
1437
|
'networks': {
|
1438
1438
|
'TRX': 'TRC20',
|
1439
1439
|
'ETH': 'ERC20',
|
1440
|
-
'
|
1440
|
+
'BEP20': 'BSC',
|
1441
|
+
'ZKSYNC': 'zkSyncEra',
|
1442
|
+
'STARKNET': 'Starknet',
|
1443
|
+
'OPTIMISM': 'Optimism',
|
1444
|
+
'ARBITRUM': 'Arbitrum',
|
1441
1445
|
},
|
1442
1446
|
'networksById': {
|
1443
|
-
'TRC20': 'TRX',
|
1444
|
-
'BSC': 'BEP20',
|
1445
1447
|
},
|
1446
1448
|
'fetchPositions': {
|
1447
1449
|
'method': 'privateMixGetV2MixPositionAllPosition', # or privateMixGetV2MixPositionHistoryPosition
|
@@ -1840,7 +1842,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
1840
1842
|
for j in range(0, len(chains)):
|
1841
1843
|
chain = chains[j]
|
1842
1844
|
networkId = self.safe_string(chain, 'chain')
|
1843
|
-
network = self.
|
1845
|
+
network = self.network_id_to_code(networkId, code)
|
1846
|
+
if network is not None:
|
1847
|
+
network = network.upper()
|
1844
1848
|
withdrawEnabled = self.safe_string(chain, 'withdrawable')
|
1845
1849
|
canWithdraw = withdrawEnabled == 'true'
|
1846
1850
|
withdraw = canWithdraw if (canWithdraw) else withdraw
|
ccxt/async_support/bitmart.py
CHANGED
@@ -2206,7 +2206,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2206
2206
|
|
2207
2207
|
def parse_order(self, order: dict, market: Market = None) -> Order:
|
2208
2208
|
#
|
2209
|
-
# createOrder
|
2209
|
+
# createOrder, editOrder
|
2210
2210
|
#
|
2211
2211
|
# {
|
2212
2212
|
# "order_id": 2707217580
|
@@ -4466,6 +4466,114 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4466
4466
|
'datetime': self.iso8601(timestamp),
|
4467
4467
|
})
|
4468
4468
|
|
4469
|
+
async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
|
4470
|
+
"""
|
4471
|
+
edits an open order
|
4472
|
+
:see: https://developer-pro.bitmart.com/en/futuresv2/#modify-plan-order-signed
|
4473
|
+
:see: https://developer-pro.bitmart.com/en/futuresv2/#modify-tp-sl-order-signed
|
4474
|
+
:see: https://developer-pro.bitmart.com/en/futuresv2/#modify-preset-plan-order-signed
|
4475
|
+
:param str id: order id
|
4476
|
+
:param str symbol: unified symbol of the market to edit an order in
|
4477
|
+
:param str type: 'market' or 'limit'
|
4478
|
+
:param str side: 'buy' or 'sell'
|
4479
|
+
:param float [amount]: how much you want to trade in units of the base currency
|
4480
|
+
:param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
|
4481
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4482
|
+
:param str [params.triggerPrice]: *swap only* the price to trigger a stop order
|
4483
|
+
:param str [params.stopLossPrice]: *swap only* the price to trigger a stop-loss order
|
4484
|
+
:param str [params.takeProfitPrice]: *swap only* the price to trigger a take-profit order
|
4485
|
+
:param str [params.stopLoss.triggerPrice]: *swap only* the price to trigger a preset stop-loss order
|
4486
|
+
:param str [params.takeProfit.triggerPrice]: *swap only* the price to trigger a preset take-profit order
|
4487
|
+
:param str [params.clientOrderId]: client order id of the order
|
4488
|
+
:param int [params.price_type]: *swap only* 1: last price, 2: fair price, default is 1
|
4489
|
+
:param int [params.plan_category]: *swap tp/sl only* 1: tp/sl, 2: position tp/sl, default is 1
|
4490
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4491
|
+
"""
|
4492
|
+
await self.load_markets()
|
4493
|
+
market = self.market(symbol)
|
4494
|
+
if not market['swap']:
|
4495
|
+
raise NotSupported(self.id + ' editOrder() does not support ' + market['type'] + ' markets, only swap markets are supported')
|
4496
|
+
stopLossPrice = self.safe_string(params, 'stopLossPrice')
|
4497
|
+
takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
|
4498
|
+
triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'trigger_price'])
|
4499
|
+
stopLoss = self.safe_dict(params, 'stopLoss', {})
|
4500
|
+
takeProfit = self.safe_dict(params, 'takeProfit', {})
|
4501
|
+
presetStopLoss = self.safe_string(stopLoss, 'triggerPrice')
|
4502
|
+
presetTakeProfit = self.safe_string(takeProfit, 'triggerPrice')
|
4503
|
+
isTriggerOrder = triggerPrice is not None
|
4504
|
+
isStopLoss = stopLossPrice is not None
|
4505
|
+
isTakeProfit = takeProfitPrice is not None
|
4506
|
+
isPresetStopLoss = presetStopLoss is not None
|
4507
|
+
isPresetTakeProfit = presetTakeProfit is not None
|
4508
|
+
request: dict = {
|
4509
|
+
'symbol': market['id'],
|
4510
|
+
}
|
4511
|
+
clientOrderId = self.safe_string(params, 'clientOrderId')
|
4512
|
+
if clientOrderId is not None:
|
4513
|
+
params = self.omit(params, 'clientOrderId')
|
4514
|
+
request['client_order_id'] = clientOrderId
|
4515
|
+
if id is not None:
|
4516
|
+
request['order_id'] = id
|
4517
|
+
params = self.omit(params, ['triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit'])
|
4518
|
+
response = None
|
4519
|
+
if isTriggerOrder or isStopLoss or isTakeProfit:
|
4520
|
+
request['price_type'] = self.safe_integer(params, 'price_type', 1)
|
4521
|
+
if price is not None:
|
4522
|
+
request['executive_price'] = self.price_to_precision(symbol, price)
|
4523
|
+
if isTriggerOrder:
|
4524
|
+
request['type'] = type
|
4525
|
+
request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
|
4526
|
+
response = await self.privatePostContractPrivateModifyPlanOrder(self.extend(request, params))
|
4527
|
+
#
|
4528
|
+
# {
|
4529
|
+
# "code": 1000,
|
4530
|
+
# "message": "Ok",
|
4531
|
+
# "data": {
|
4532
|
+
# "order_id": "3000023150003503"
|
4533
|
+
# },
|
4534
|
+
# "trace": "324523453245.108.1734567125596324575"
|
4535
|
+
# }
|
4536
|
+
#
|
4537
|
+
elif isStopLoss or isTakeProfit:
|
4538
|
+
request['category'] = type
|
4539
|
+
if isStopLoss:
|
4540
|
+
request['trigger_price'] = self.price_to_precision(symbol, stopLossPrice)
|
4541
|
+
else:
|
4542
|
+
request['trigger_price'] = self.price_to_precision(symbol, takeProfitPrice)
|
4543
|
+
response = await self.privatePostContractPrivateModifyTpSlOrder(self.extend(request, params))
|
4544
|
+
#
|
4545
|
+
# {
|
4546
|
+
# "code": 1000,
|
4547
|
+
# "message": "Ok",
|
4548
|
+
# "data": {
|
4549
|
+
# "order_id": "3000023150003480"
|
4550
|
+
# },
|
4551
|
+
# "trace": "23452345.104.1724536582682345459"
|
4552
|
+
# }
|
4553
|
+
#
|
4554
|
+
elif isPresetStopLoss or isPresetTakeProfit:
|
4555
|
+
if isPresetStopLoss:
|
4556
|
+
request['preset_stop_loss_price_type'] = self.safe_integer(params, 'price_type', 1)
|
4557
|
+
request['preset_stop_loss_price'] = self.price_to_precision(symbol, presetStopLoss)
|
4558
|
+
else:
|
4559
|
+
request['preset_take_profit_price_type'] = self.safe_integer(params, 'price_type', 1)
|
4560
|
+
request['preset_take_profit_price'] = self.price_to_precision(symbol, presetTakeProfit)
|
4561
|
+
response = await self.privatePostContractPrivateModifyPresetPlanOrder(self.extend(request, params))
|
4562
|
+
#
|
4563
|
+
# {
|
4564
|
+
# "code": 1000,
|
4565
|
+
# "message": "Ok",
|
4566
|
+
# "data": {
|
4567
|
+
# "order_id": "3000023150003496"
|
4568
|
+
# },
|
4569
|
+
# "trace": "a5c3234534534a836bc476a203.123452.172716624359200197"
|
4570
|
+
# }
|
4571
|
+
#
|
4572
|
+
else:
|
4573
|
+
raise NotSupported(self.id + ' editOrder() only supports trigger, stop loss and take profit orders')
|
4574
|
+
data = self.safe_dict(response, 'data', {})
|
4575
|
+
return self.parse_order(data, market)
|
4576
|
+
|
4469
4577
|
def nonce(self):
|
4470
4578
|
return self.milliseconds()
|
4471
4579
|
|