ccxt 4.4.6 → 4.4.8
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.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +21 -2
- package/dist/cjs/src/binance.js +51 -12
- package/dist/cjs/src/bingx.js +3 -0
- package/dist/cjs/src/bitget.js +10 -6
- package/dist/cjs/src/bitmart.js +124 -1
- package/dist/cjs/src/bybit.js +377 -10
- package/dist/cjs/src/gate.js +3 -0
- package/dist/cjs/src/htx.js +22 -0
- package/dist/cjs/src/kucoin.js +2 -2
- package/dist/cjs/src/mexc.js +97 -13
- package/dist/cjs/src/okx.js +4 -0
- package/dist/cjs/src/pro/bitget.js +66 -0
- package/dist/cjs/src/pro/bitmart.js +81 -0
- package/dist/cjs/src/pro/bitvavo.js +92 -1
- package/dist/cjs/src/pro/blofin.js +64 -0
- package/dist/cjs/src/pro/okx.js +11 -5
- package/examples/js/cli.js +2 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/bybit.d.ts +5 -0
- package/js/src/abstract/okx.d.ts +2 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +21 -2
- package/js/src/binance.d.ts +15 -15
- package/js/src/binance.js +51 -12
- package/js/src/bingx.js +3 -0
- package/js/src/bitget.js +10 -6
- package/js/src/bitmart.d.ts +1 -0
- package/js/src/bitmart.js +124 -1
- package/js/src/bybit.d.ts +7 -1
- package/js/src/bybit.js +377 -10
- package/js/src/gate.js +3 -0
- package/js/src/htx.js +22 -0
- package/js/src/kucoin.js +2 -2
- package/js/src/mexc.d.ts +2 -0
- package/js/src/mexc.js +97 -13
- package/js/src/okx.js +4 -0
- package/js/src/pro/bitget.d.ts +3 -0
- package/js/src/pro/bitget.js +66 -0
- package/js/src/pro/bitmart.d.ts +3 -0
- package/js/src/pro/bitmart.js +81 -0
- package/js/src/pro/bitvavo.d.ts +7 -2
- package/js/src/pro/bitvavo.js +92 -1
- package/js/src/pro/blofin.d.ts +3 -0
- package/js/src/pro/blofin.js +64 -0
- package/js/src/pro/okx.d.ts +1 -0
- package/js/src/pro/okx.js +11 -5
- package/package.json +1 -1
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -1952,6 +1952,12 @@ class okx extends okx$1 {
|
|
|
1952
1952
|
client.resolve(this.orders, symbolMessageHash);
|
|
1953
1953
|
}
|
|
1954
1954
|
}
|
|
1955
|
+
requestId() {
|
|
1956
|
+
const ts = this.milliseconds().toString();
|
|
1957
|
+
const randomNumber = this.randNumber(4);
|
|
1958
|
+
const randomPart = randomNumber.toString();
|
|
1959
|
+
return ts + randomPart;
|
|
1960
|
+
}
|
|
1955
1961
|
async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1956
1962
|
/**
|
|
1957
1963
|
* @method
|
|
@@ -1970,7 +1976,7 @@ class okx extends okx$1 {
|
|
|
1970
1976
|
await this.loadMarkets();
|
|
1971
1977
|
await this.authenticate();
|
|
1972
1978
|
const url = this.getUrl('private', 'private');
|
|
1973
|
-
const messageHash = this.
|
|
1979
|
+
const messageHash = this.requestId();
|
|
1974
1980
|
let op = undefined;
|
|
1975
1981
|
[op, params] = this.handleOptionAndParams(params, 'createOrderWs', 'op', 'batch-orders');
|
|
1976
1982
|
const args = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
@@ -2040,7 +2046,7 @@ class okx extends okx$1 {
|
|
|
2040
2046
|
await this.loadMarkets();
|
|
2041
2047
|
await this.authenticate();
|
|
2042
2048
|
const url = this.getUrl('private', 'private');
|
|
2043
|
-
const messageHash = this.
|
|
2049
|
+
const messageHash = this.requestId();
|
|
2044
2050
|
let op = undefined;
|
|
2045
2051
|
[op, params] = this.handleOptionAndParams(params, 'editOrderWs', 'op', 'amend-order');
|
|
2046
2052
|
const args = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
@@ -2069,7 +2075,7 @@ class okx extends okx$1 {
|
|
|
2069
2075
|
await this.loadMarkets();
|
|
2070
2076
|
await this.authenticate();
|
|
2071
2077
|
const url = this.getUrl('private', 'private');
|
|
2072
|
-
const messageHash = this.
|
|
2078
|
+
const messageHash = this.requestId();
|
|
2073
2079
|
const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
|
|
2074
2080
|
params = this.omit(params, ['clientOrderId', 'clOrdId']);
|
|
2075
2081
|
const arg = {
|
|
@@ -2109,7 +2115,7 @@ class okx extends okx$1 {
|
|
|
2109
2115
|
await this.loadMarkets();
|
|
2110
2116
|
await this.authenticate();
|
|
2111
2117
|
const url = this.getUrl('private', 'private');
|
|
2112
|
-
const messageHash = this.
|
|
2118
|
+
const messageHash = this.requestId();
|
|
2113
2119
|
const args = [];
|
|
2114
2120
|
for (let i = 0; i < idsLength; i++) {
|
|
2115
2121
|
const arg = {
|
|
@@ -2145,7 +2151,7 @@ class okx extends okx$1 {
|
|
|
2145
2151
|
throw new errors.BadRequest(this.id + 'cancelAllOrdersWs is only applicable to Option in Portfolio Margin mode, and MMP privilege is required.');
|
|
2146
2152
|
}
|
|
2147
2153
|
const url = this.getUrl('private', 'private');
|
|
2148
|
-
const messageHash = this.
|
|
2154
|
+
const messageHash = this.requestId();
|
|
2149
2155
|
const request = {
|
|
2150
2156
|
'id': messageHash,
|
|
2151
2157
|
'op': 'mass-cancel',
|
package/examples/js/cli.js
CHANGED
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.4.
|
|
7
|
+
declare const version = "4.4.7";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.4.
|
|
41
|
+
const version = '4.4.8';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -701,6 +701,7 @@ interface Exchange {
|
|
|
701
701
|
papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
|
|
702
702
|
papiPostListenKey(params?: {}): Promise<implicitReturnType>;
|
|
703
703
|
papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
704
|
+
papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
|
|
704
705
|
papiPutListenKey(params?: {}): Promise<implicitReturnType>;
|
|
705
706
|
papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
|
|
706
707
|
papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
|
|
@@ -701,6 +701,7 @@ interface binance {
|
|
|
701
701
|
papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
|
|
702
702
|
papiPostListenKey(params?: {}): Promise<implicitReturnType>;
|
|
703
703
|
papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
704
|
+
papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
|
|
704
705
|
papiPutListenKey(params?: {}): Promise<implicitReturnType>;
|
|
705
706
|
papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
|
|
706
707
|
papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
|
|
@@ -753,6 +753,7 @@ interface binance {
|
|
|
753
753
|
papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
|
|
754
754
|
papiPostListenKey(params?: {}): Promise<implicitReturnType>;
|
|
755
755
|
papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
756
|
+
papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
|
|
756
757
|
papiPutListenKey(params?: {}): Promise<implicitReturnType>;
|
|
757
758
|
papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
|
|
758
759
|
papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
|
|
@@ -701,6 +701,7 @@ interface binance {
|
|
|
701
701
|
papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
|
|
702
702
|
papiPostListenKey(params?: {}): Promise<implicitReturnType>;
|
|
703
703
|
papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
704
|
+
papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
|
|
704
705
|
papiPutListenKey(params?: {}): Promise<implicitReturnType>;
|
|
705
706
|
papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
|
|
706
707
|
papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
|
|
@@ -131,6 +131,9 @@ interface Exchange {
|
|
|
131
131
|
privateGetV5AccountContractTransactionLog(params?: {}): Promise<implicitReturnType>;
|
|
132
132
|
privateGetV5AccountSmpGroup(params?: {}): Promise<implicitReturnType>;
|
|
133
133
|
privateGetV5AccountMmpState(params?: {}): Promise<implicitReturnType>;
|
|
134
|
+
privateGetV5AssetExchangeQueryCoinList(params?: {}): Promise<implicitReturnType>;
|
|
135
|
+
privateGetV5AssetExchangeConvertResultQuery(params?: {}): Promise<implicitReturnType>;
|
|
136
|
+
privateGetV5AssetExchangeQueryConvertHistory(params?: {}): Promise<implicitReturnType>;
|
|
134
137
|
privateGetV5AssetExchangeOrderRecord(params?: {}): Promise<implicitReturnType>;
|
|
135
138
|
privateGetV5AssetDeliveryRecord(params?: {}): Promise<implicitReturnType>;
|
|
136
139
|
privateGetV5AssetSettlementRecord(params?: {}): Promise<implicitReturnType>;
|
|
@@ -269,6 +272,8 @@ interface Exchange {
|
|
|
269
272
|
privatePostV5AccountSetHedgingMode(params?: {}): Promise<implicitReturnType>;
|
|
270
273
|
privatePostV5AccountMmpModify(params?: {}): Promise<implicitReturnType>;
|
|
271
274
|
privatePostV5AccountMmpReset(params?: {}): Promise<implicitReturnType>;
|
|
275
|
+
privatePostV5AssetExchangeQuoteApply(params?: {}): Promise<implicitReturnType>;
|
|
276
|
+
privatePostV5AssetExchangeConvertExecute(params?: {}): Promise<implicitReturnType>;
|
|
272
277
|
privatePostV5AssetTransferInterTransfer(params?: {}): Promise<implicitReturnType>;
|
|
273
278
|
privatePostV5AssetTransferSaveTransferSubMember(params?: {}): Promise<implicitReturnType>;
|
|
274
279
|
privatePostV5AssetTransferUniversalTransfer(params?: {}): Promise<implicitReturnType>;
|
package/js/src/abstract/okx.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ interface Exchange {
|
|
|
78
78
|
publicGetCopytradingPublicPreferenceCurrency(params?: {}): Promise<implicitReturnType>;
|
|
79
79
|
publicGetCopytradingPublicCurrentSubpositions(params?: {}): Promise<implicitReturnType>;
|
|
80
80
|
publicGetCopytradingPublicSubpositionsHistory(params?: {}): Promise<implicitReturnType>;
|
|
81
|
+
publicGetSupportAnnouncementsTypes(params?: {}): Promise<implicitReturnType>;
|
|
81
82
|
privateGetRfqCounterparties(params?: {}): Promise<implicitReturnType>;
|
|
82
83
|
privateGetRfqMakerInstrumentSettings(params?: {}): Promise<implicitReturnType>;
|
|
83
84
|
privateGetRfqMmpConfig(params?: {}): Promise<implicitReturnType>;
|
|
@@ -207,6 +208,7 @@ interface Exchange {
|
|
|
207
208
|
privateGetBrokerFdIfRebate(params?: {}): Promise<implicitReturnType>;
|
|
208
209
|
privateGetAffiliateInviteeDetail(params?: {}): Promise<implicitReturnType>;
|
|
209
210
|
privateGetUsersPartnerIfRebate(params?: {}): Promise<implicitReturnType>;
|
|
211
|
+
privateGetSupportAnnouncements(params?: {}): Promise<implicitReturnType>;
|
|
210
212
|
privatePostRfqCreateRfq(params?: {}): Promise<implicitReturnType>;
|
|
211
213
|
privatePostRfqCancelRfq(params?: {}): Promise<implicitReturnType>;
|
|
212
214
|
privatePostRfqCancelBatchRfqs(params?: {}): Promise<implicitReturnType>;
|
|
@@ -379,6 +379,7 @@ export default class Exchange {
|
|
|
379
379
|
extendExchangeOptions(newOptions: Dict): void;
|
|
380
380
|
createSafeDictionary(): {};
|
|
381
381
|
randomBytes(length: number): string;
|
|
382
|
+
randNumber(size: number): number;
|
|
382
383
|
describe(): {
|
|
383
384
|
id: any;
|
|
384
385
|
name: any;
|
|
@@ -809,6 +810,9 @@ export default class Exchange {
|
|
|
809
810
|
CRO: {
|
|
810
811
|
CRC20: string;
|
|
811
812
|
};
|
|
813
|
+
BRC20: {
|
|
814
|
+
BRC20: string;
|
|
815
|
+
};
|
|
812
816
|
};
|
|
813
817
|
};
|
|
814
818
|
safeLedgerEntry(entry: object, currency?: Currency): {
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -1220,6 +1220,13 @@ export default class Exchange {
|
|
|
1220
1220
|
rng.nextBytes(x);
|
|
1221
1221
|
return Buffer.from(x).toString('hex');
|
|
1222
1222
|
}
|
|
1223
|
+
randNumber(size) {
|
|
1224
|
+
let number = '';
|
|
1225
|
+
for (let i = 0; i < size; i++) {
|
|
1226
|
+
number += Math.floor(Math.random() * 10);
|
|
1227
|
+
}
|
|
1228
|
+
return parseInt(number, 10);
|
|
1229
|
+
}
|
|
1223
1230
|
/* eslint-enable */
|
|
1224
1231
|
// ------------------------------------------------------------------------
|
|
1225
1232
|
// ########################################################################
|
|
@@ -2248,6 +2255,7 @@ export default class Exchange {
|
|
|
2248
2255
|
'ETH': { 'ERC20': 'ETH' },
|
|
2249
2256
|
'TRX': { 'TRC20': 'TRX' },
|
|
2250
2257
|
'CRO': { 'CRC20': 'CRONOS' },
|
|
2258
|
+
'BRC20': { 'BRC20': 'BTC' },
|
|
2251
2259
|
},
|
|
2252
2260
|
};
|
|
2253
2261
|
}
|
|
@@ -6105,8 +6113,19 @@ export default class Exchange {
|
|
|
6105
6113
|
break;
|
|
6106
6114
|
}
|
|
6107
6115
|
result = this.arrayConcat(result, response);
|
|
6108
|
-
const last = this.
|
|
6109
|
-
cursorValue = this.safeValue(last['info'], cursorReceived);
|
|
6116
|
+
const last = this.safeDict(response, responseLength - 1);
|
|
6117
|
+
// cursorValue = this.safeValue (last['info'], cursorReceived);
|
|
6118
|
+
cursorValue = undefined; // search for the cursor
|
|
6119
|
+
for (let j = 0; j < responseLength; j++) {
|
|
6120
|
+
const index = responseLength - j - 1;
|
|
6121
|
+
const entry = this.safeDict(response, index);
|
|
6122
|
+
const info = this.safeDict(entry, 'info');
|
|
6123
|
+
const cursor = this.safeValue(info, cursorReceived);
|
|
6124
|
+
if (cursor !== undefined) {
|
|
6125
|
+
cursorValue = cursor;
|
|
6126
|
+
break;
|
|
6127
|
+
}
|
|
6128
|
+
}
|
|
6110
6129
|
if (cursorValue === undefined) {
|
|
6111
6130
|
break;
|
|
6112
6131
|
}
|
package/js/src/binance.d.ts
CHANGED
|
@@ -303,46 +303,46 @@ export default class binance extends Exchange {
|
|
|
303
303
|
repayCrossMargin(code: string, amount: any, params?: {}): Promise<{
|
|
304
304
|
id: number;
|
|
305
305
|
currency: string;
|
|
306
|
-
amount:
|
|
306
|
+
amount: number;
|
|
307
307
|
symbol: any;
|
|
308
|
-
timestamp:
|
|
309
|
-
datetime:
|
|
308
|
+
timestamp: number;
|
|
309
|
+
datetime: string;
|
|
310
310
|
info: any;
|
|
311
311
|
}>;
|
|
312
312
|
repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
|
|
313
313
|
id: number;
|
|
314
314
|
currency: string;
|
|
315
|
-
amount:
|
|
315
|
+
amount: number;
|
|
316
316
|
symbol: any;
|
|
317
|
-
timestamp:
|
|
318
|
-
datetime:
|
|
317
|
+
timestamp: number;
|
|
318
|
+
datetime: string;
|
|
319
319
|
info: any;
|
|
320
320
|
}>;
|
|
321
321
|
borrowCrossMargin(code: string, amount: number, params?: {}): Promise<{
|
|
322
322
|
id: number;
|
|
323
323
|
currency: string;
|
|
324
|
-
amount:
|
|
324
|
+
amount: number;
|
|
325
325
|
symbol: any;
|
|
326
|
-
timestamp:
|
|
327
|
-
datetime:
|
|
326
|
+
timestamp: number;
|
|
327
|
+
datetime: string;
|
|
328
328
|
info: any;
|
|
329
329
|
}>;
|
|
330
330
|
borrowIsolatedMargin(symbol: string, code: string, amount: number, params?: {}): Promise<{
|
|
331
331
|
id: number;
|
|
332
332
|
currency: string;
|
|
333
|
-
amount:
|
|
333
|
+
amount: number;
|
|
334
334
|
symbol: any;
|
|
335
|
-
timestamp:
|
|
336
|
-
datetime:
|
|
335
|
+
timestamp: number;
|
|
336
|
+
datetime: string;
|
|
337
337
|
info: any;
|
|
338
338
|
}>;
|
|
339
339
|
parseMarginLoan(info: any, currency?: Currency): {
|
|
340
340
|
id: number;
|
|
341
341
|
currency: string;
|
|
342
|
-
amount:
|
|
342
|
+
amount: number;
|
|
343
343
|
symbol: any;
|
|
344
|
-
timestamp:
|
|
345
|
-
datetime:
|
|
344
|
+
timestamp: number;
|
|
345
|
+
datetime: string;
|
|
346
346
|
info: any;
|
|
347
347
|
};
|
|
348
348
|
fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
|
package/js/src/binance.js
CHANGED
|
@@ -1094,6 +1094,7 @@ export default class binance extends Exchange {
|
|
|
1094
1094
|
'repay-futures-negative-balance': 150,
|
|
1095
1095
|
'listenKey': 1,
|
|
1096
1096
|
'asset-collection': 3,
|
|
1097
|
+
'margin/repay-debt': 0.4, // Weight(Order): 0.4 => (1000 / (50 * 0.4)) * 60 = 3000
|
|
1097
1098
|
},
|
|
1098
1099
|
'put': {
|
|
1099
1100
|
'listenKey': 1, // 1
|
|
@@ -1211,6 +1212,7 @@ export default class binance extends Exchange {
|
|
|
1211
1212
|
],
|
|
1212
1213
|
'fetchCurrencies': true,
|
|
1213
1214
|
// 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades, eapiPublicGetTrades
|
|
1215
|
+
// 'repayCrossMarginMethod': 'papiPostRepayLoan', // papiPostMarginRepayDebt
|
|
1214
1216
|
'defaultTimeInForce': 'GTC',
|
|
1215
1217
|
'defaultType': 'spot',
|
|
1216
1218
|
'defaultSubType': undefined,
|
|
@@ -2907,7 +2909,7 @@ export default class binance extends Exchange {
|
|
|
2907
2909
|
const res = this.safeValue(results, i);
|
|
2908
2910
|
if (fetchMargins && Array.isArray(res)) {
|
|
2909
2911
|
const keysList = Object.keys(this.indexBy(res, 'symbol'));
|
|
2910
|
-
const length =
|
|
2912
|
+
const length = this.options['crossMarginPairsData'].length;
|
|
2911
2913
|
// first one is the cross-margin promise
|
|
2912
2914
|
if (length === 0) {
|
|
2913
2915
|
this.options['crossMarginPairsData'] = keysList;
|
|
@@ -12220,10 +12222,13 @@ export default class binance extends Exchange {
|
|
|
12220
12222
|
* @description repay borrowed margin and interest
|
|
12221
12223
|
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay
|
|
12222
12224
|
* @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
|
|
12225
|
+
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay-Debt
|
|
12223
12226
|
* @param {string} code unified currency code of the currency to repay
|
|
12224
12227
|
* @param {float} amount the amount to repay
|
|
12225
12228
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
12226
12229
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to repay margin in a portfolio margin account
|
|
12230
|
+
* @param {string} [params.repayCrossMarginMethod] *portfolio margin only* 'papiPostRepayLoan' (default), 'papiPostMarginRepayDebt' (alternative)
|
|
12231
|
+
* @param {string} [params.specifyRepayAssets] *portfolio margin papiPostMarginRepayDebt only* specific asset list to repay debt
|
|
12227
12232
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
12228
12233
|
*/
|
|
12229
12234
|
await this.loadMarkets();
|
|
@@ -12236,19 +12241,41 @@ export default class binance extends Exchange {
|
|
|
12236
12241
|
let isPortfolioMargin = undefined;
|
|
12237
12242
|
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'repayCrossMargin', 'papi', 'portfolioMargin', false);
|
|
12238
12243
|
if (isPortfolioMargin) {
|
|
12239
|
-
|
|
12244
|
+
let method = undefined;
|
|
12245
|
+
[method, params] = this.handleOptionAndParams2(params, 'repayCrossMargin', 'repayCrossMarginMethod', 'method');
|
|
12246
|
+
if (method === 'papiPostMarginRepayDebt') {
|
|
12247
|
+
response = await this.papiPostMarginRepayDebt(this.extend(request, params));
|
|
12248
|
+
//
|
|
12249
|
+
// {
|
|
12250
|
+
// "asset": "USDC",
|
|
12251
|
+
// "amount": 10,
|
|
12252
|
+
// "specifyRepayAssets": null,
|
|
12253
|
+
// "updateTime": 1727170761267,
|
|
12254
|
+
// "success": true
|
|
12255
|
+
// }
|
|
12256
|
+
//
|
|
12257
|
+
}
|
|
12258
|
+
else {
|
|
12259
|
+
response = await this.papiPostRepayLoan(this.extend(request, params));
|
|
12260
|
+
//
|
|
12261
|
+
// {
|
|
12262
|
+
// "tranId": 108988250265,
|
|
12263
|
+
// "clientTag":""
|
|
12264
|
+
// }
|
|
12265
|
+
//
|
|
12266
|
+
}
|
|
12240
12267
|
}
|
|
12241
12268
|
else {
|
|
12242
12269
|
request['isIsolated'] = 'FALSE';
|
|
12243
12270
|
request['type'] = 'REPAY';
|
|
12244
12271
|
response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
|
|
12272
|
+
//
|
|
12273
|
+
// {
|
|
12274
|
+
// "tranId": 108988250265,
|
|
12275
|
+
// "clientTag":""
|
|
12276
|
+
// }
|
|
12277
|
+
//
|
|
12245
12278
|
}
|
|
12246
|
-
//
|
|
12247
|
-
// {
|
|
12248
|
-
// "tranId": 108988250265,
|
|
12249
|
-
// "clientTag":""
|
|
12250
|
-
// }
|
|
12251
|
-
//
|
|
12252
12279
|
return this.parseMarginLoan(response, currency);
|
|
12253
12280
|
}
|
|
12254
12281
|
async repayIsolatedMargin(symbol, code, amount, params = {}) {
|
|
@@ -12358,13 +12385,25 @@ export default class binance extends Exchange {
|
|
|
12358
12385
|
// "clientTag":""
|
|
12359
12386
|
// }
|
|
12360
12387
|
//
|
|
12388
|
+
// repayCrossMargin alternative endpoint
|
|
12389
|
+
//
|
|
12390
|
+
// {
|
|
12391
|
+
// "asset": "USDC",
|
|
12392
|
+
// "amount": 10,
|
|
12393
|
+
// "specifyRepayAssets": null,
|
|
12394
|
+
// "updateTime": 1727170761267,
|
|
12395
|
+
// "success": true
|
|
12396
|
+
// }
|
|
12397
|
+
//
|
|
12398
|
+
const currencyId = this.safeString(info, 'asset');
|
|
12399
|
+
const timestamp = this.safeInteger(info, 'updateTime');
|
|
12361
12400
|
return {
|
|
12362
12401
|
'id': this.safeInteger(info, 'tranId'),
|
|
12363
|
-
'currency': this.safeCurrencyCode(
|
|
12364
|
-
'amount':
|
|
12402
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
12403
|
+
'amount': this.safeNumber(info, 'amount'),
|
|
12365
12404
|
'symbol': undefined,
|
|
12366
|
-
'timestamp':
|
|
12367
|
-
'datetime':
|
|
12405
|
+
'timestamp': timestamp,
|
|
12406
|
+
'datetime': this.iso8601(timestamp),
|
|
12368
12407
|
'info': info,
|
|
12369
12408
|
};
|
|
12370
12409
|
}
|
package/js/src/bingx.js
CHANGED
package/js/src/bitget.js
CHANGED
|
@@ -1418,12 +1418,13 @@ export default class bitget extends Exchange {
|
|
|
1418
1418
|
'networks': {
|
|
1419
1419
|
'TRX': 'TRC20',
|
|
1420
1420
|
'ETH': 'ERC20',
|
|
1421
|
-
'
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
'
|
|
1425
|
-
'
|
|
1421
|
+
'BEP20': 'BSC',
|
|
1422
|
+
'ZKSYNC': 'zkSyncEra',
|
|
1423
|
+
'STARKNET': 'Starknet',
|
|
1424
|
+
'OPTIMISM': 'Optimism',
|
|
1425
|
+
'ARBITRUM': 'Arbitrum',
|
|
1426
1426
|
},
|
|
1427
|
+
'networksById': {},
|
|
1427
1428
|
'fetchPositions': {
|
|
1428
1429
|
'method': 'privateMixGetV2MixPositionAllPosition', // or privateMixGetV2MixPositionHistoryPosition
|
|
1429
1430
|
},
|
|
@@ -1865,7 +1866,10 @@ export default class bitget extends Exchange {
|
|
|
1865
1866
|
for (let j = 0; j < chains.length; j++) {
|
|
1866
1867
|
const chain = chains[j];
|
|
1867
1868
|
const networkId = this.safeString(chain, 'chain');
|
|
1868
|
-
|
|
1869
|
+
let network = this.networkIdToCode(networkId, code);
|
|
1870
|
+
if (network !== undefined) {
|
|
1871
|
+
network = network.toUpperCase();
|
|
1872
|
+
}
|
|
1869
1873
|
const withdrawEnabled = this.safeString(chain, 'withdrawable');
|
|
1870
1874
|
const canWithdraw = withdrawEnabled === 'true';
|
|
1871
1875
|
withdraw = (canWithdraw) ? canWithdraw : withdraw;
|
package/js/src/bitmart.d.ts
CHANGED
|
@@ -167,6 +167,7 @@ export default class bitmart extends Exchange {
|
|
|
167
167
|
parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
|
|
168
168
|
fetchMyLiquidations(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
|
|
169
169
|
parseLiquidation(liquidation: any, market?: Market): import("./base/types.js").Liquidation;
|
|
170
|
+
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
170
171
|
nonce(): number;
|
|
171
172
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
172
173
|
url: string;
|
package/js/src/bitmart.js
CHANGED
|
@@ -2297,7 +2297,7 @@ export default class bitmart extends Exchange {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
parseOrder(order, market = undefined) {
|
|
2299
2299
|
//
|
|
2300
|
-
// createOrder
|
|
2300
|
+
// createOrder, editOrder
|
|
2301
2301
|
//
|
|
2302
2302
|
// {
|
|
2303
2303
|
// "order_id": 2707217580
|
|
@@ -4780,6 +4780,129 @@ export default class bitmart extends Exchange {
|
|
|
4780
4780
|
'datetime': this.iso8601(timestamp),
|
|
4781
4781
|
});
|
|
4782
4782
|
}
|
|
4783
|
+
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
4784
|
+
/**
|
|
4785
|
+
* @method
|
|
4786
|
+
* @name bitmart#editOrder
|
|
4787
|
+
* @description edits an open order
|
|
4788
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#modify-plan-order-signed
|
|
4789
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#modify-tp-sl-order-signed
|
|
4790
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#modify-preset-plan-order-signed
|
|
4791
|
+
* @param {string} id order id
|
|
4792
|
+
* @param {string} symbol unified symbol of the market to edit an order in
|
|
4793
|
+
* @param {string} type 'market' or 'limit'
|
|
4794
|
+
* @param {string} side 'buy' or 'sell'
|
|
4795
|
+
* @param {float} [amount] how much you want to trade in units of the base currency
|
|
4796
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
4797
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4798
|
+
* @param {string} [params.triggerPrice] *swap only* the price to trigger a stop order
|
|
4799
|
+
* @param {string} [params.stopLossPrice] *swap only* the price to trigger a stop-loss order
|
|
4800
|
+
* @param {string} [params.takeProfitPrice] *swap only* the price to trigger a take-profit order
|
|
4801
|
+
* @param {string} [params.stopLoss.triggerPrice] *swap only* the price to trigger a preset stop-loss order
|
|
4802
|
+
* @param {string} [params.takeProfit.triggerPrice] *swap only* the price to trigger a preset take-profit order
|
|
4803
|
+
* @param {string} [params.clientOrderId] client order id of the order
|
|
4804
|
+
* @param {int} [params.price_type] *swap only* 1: last price, 2: fair price, default is 1
|
|
4805
|
+
* @param {int} [params.plan_category] *swap tp/sl only* 1: tp/sl, 2: position tp/sl, default is 1
|
|
4806
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4807
|
+
*/
|
|
4808
|
+
await this.loadMarkets();
|
|
4809
|
+
const market = this.market(symbol);
|
|
4810
|
+
if (!market['swap']) {
|
|
4811
|
+
throw new NotSupported(this.id + ' editOrder() does not support ' + market['type'] + ' markets, only swap markets are supported');
|
|
4812
|
+
}
|
|
4813
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
4814
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
4815
|
+
const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
|
|
4816
|
+
const stopLoss = this.safeDict(params, 'stopLoss', {});
|
|
4817
|
+
const takeProfit = this.safeDict(params, 'takeProfit', {});
|
|
4818
|
+
const presetStopLoss = this.safeString(stopLoss, 'triggerPrice');
|
|
4819
|
+
const presetTakeProfit = this.safeString(takeProfit, 'triggerPrice');
|
|
4820
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
4821
|
+
const isStopLoss = stopLossPrice !== undefined;
|
|
4822
|
+
const isTakeProfit = takeProfitPrice !== undefined;
|
|
4823
|
+
const isPresetStopLoss = presetStopLoss !== undefined;
|
|
4824
|
+
const isPresetTakeProfit = presetTakeProfit !== undefined;
|
|
4825
|
+
const request = {
|
|
4826
|
+
'symbol': market['id'],
|
|
4827
|
+
};
|
|
4828
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
4829
|
+
if (clientOrderId !== undefined) {
|
|
4830
|
+
params = this.omit(params, 'clientOrderId');
|
|
4831
|
+
request['client_order_id'] = clientOrderId;
|
|
4832
|
+
}
|
|
4833
|
+
if (id !== undefined) {
|
|
4834
|
+
request['order_id'] = id;
|
|
4835
|
+
}
|
|
4836
|
+
params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit']);
|
|
4837
|
+
let response = undefined;
|
|
4838
|
+
if (isTriggerOrder || isStopLoss || isTakeProfit) {
|
|
4839
|
+
request['price_type'] = this.safeInteger(params, 'price_type', 1);
|
|
4840
|
+
if (price !== undefined) {
|
|
4841
|
+
request['executive_price'] = this.priceToPrecision(symbol, price);
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
if (isTriggerOrder) {
|
|
4845
|
+
request['type'] = type;
|
|
4846
|
+
request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
|
|
4847
|
+
response = await this.privatePostContractPrivateModifyPlanOrder(this.extend(request, params));
|
|
4848
|
+
//
|
|
4849
|
+
// {
|
|
4850
|
+
// "code": 1000,
|
|
4851
|
+
// "message": "Ok",
|
|
4852
|
+
// "data": {
|
|
4853
|
+
// "order_id": "3000023150003503"
|
|
4854
|
+
// },
|
|
4855
|
+
// "trace": "324523453245.108.1734567125596324575"
|
|
4856
|
+
// }
|
|
4857
|
+
//
|
|
4858
|
+
}
|
|
4859
|
+
else if (isStopLoss || isTakeProfit) {
|
|
4860
|
+
request['category'] = type;
|
|
4861
|
+
if (isStopLoss) {
|
|
4862
|
+
request['trigger_price'] = this.priceToPrecision(symbol, stopLossPrice);
|
|
4863
|
+
}
|
|
4864
|
+
else {
|
|
4865
|
+
request['trigger_price'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
4866
|
+
}
|
|
4867
|
+
response = await this.privatePostContractPrivateModifyTpSlOrder(this.extend(request, params));
|
|
4868
|
+
//
|
|
4869
|
+
// {
|
|
4870
|
+
// "code": 1000,
|
|
4871
|
+
// "message": "Ok",
|
|
4872
|
+
// "data": {
|
|
4873
|
+
// "order_id": "3000023150003480"
|
|
4874
|
+
// },
|
|
4875
|
+
// "trace": "23452345.104.1724536582682345459"
|
|
4876
|
+
// }
|
|
4877
|
+
//
|
|
4878
|
+
}
|
|
4879
|
+
else if (isPresetStopLoss || isPresetTakeProfit) {
|
|
4880
|
+
if (isPresetStopLoss) {
|
|
4881
|
+
request['preset_stop_loss_price_type'] = this.safeInteger(params, 'price_type', 1);
|
|
4882
|
+
request['preset_stop_loss_price'] = this.priceToPrecision(symbol, presetStopLoss);
|
|
4883
|
+
}
|
|
4884
|
+
else {
|
|
4885
|
+
request['preset_take_profit_price_type'] = this.safeInteger(params, 'price_type', 1);
|
|
4886
|
+
request['preset_take_profit_price'] = this.priceToPrecision(symbol, presetTakeProfit);
|
|
4887
|
+
}
|
|
4888
|
+
response = await this.privatePostContractPrivateModifyPresetPlanOrder(this.extend(request, params));
|
|
4889
|
+
//
|
|
4890
|
+
// {
|
|
4891
|
+
// "code": 1000,
|
|
4892
|
+
// "message": "Ok",
|
|
4893
|
+
// "data": {
|
|
4894
|
+
// "order_id": "3000023150003496"
|
|
4895
|
+
// },
|
|
4896
|
+
// "trace": "a5c3234534534a836bc476a203.123452.172716624359200197"
|
|
4897
|
+
// }
|
|
4898
|
+
//
|
|
4899
|
+
}
|
|
4900
|
+
else {
|
|
4901
|
+
throw new NotSupported(this.id + ' editOrder() only supports trigger, stop loss and take profit orders');
|
|
4902
|
+
}
|
|
4903
|
+
const data = this.safeDict(response, 'data', {});
|
|
4904
|
+
return this.parseOrder(data, market);
|
|
4905
|
+
}
|
|
4783
4906
|
nonce() {
|
|
4784
4907
|
return this.milliseconds();
|
|
4785
4908
|
}
|
package/js/src/bybit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bybit.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest, Position, CrossBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest, Position, CrossBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry, Conversion } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bybit
|
|
5
5
|
* @augments Exchange
|
|
@@ -204,6 +204,12 @@ export default class bybit extends Exchange {
|
|
|
204
204
|
fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
|
|
205
205
|
parseOption(chain: Dict, currency?: Currency, market?: Market): Option;
|
|
206
206
|
fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
207
|
+
fetchConvertCurrencies(params?: {}): Promise<Currencies>;
|
|
208
|
+
fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
|
|
209
|
+
createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
|
|
210
|
+
fetchConvertTrade(id: string, code?: Str, params?: {}): Promise<Conversion>;
|
|
211
|
+
fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
|
|
212
|
+
parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
|
|
207
213
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
208
214
|
url: string;
|
|
209
215
|
method: string;
|