ccxt 4.4.1 → 4.4.2
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 +4 -4
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +69 -0
- package/dist/cjs/src/binance.js +78 -8
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/currencycom.js +1 -2
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/mexc.js +69 -1
- package/dist/cjs/src/pro/binance.js +3 -63
- package/dist/cjs/src/pro/bitget.js +1 -9
- package/dist/cjs/src/pro/bitmex.js +11 -1
- package/dist/cjs/src/pro/bybit.js +2 -54
- package/dist/cjs/src/pro/cryptocom.js +2 -40
- package/dist/cjs/src/pro/gate.js +1 -9
- package/dist/cjs/src/pro/hyperliquid.js +4 -36
- package/dist/cjs/src/pro/kucoin.js +2 -59
- package/dist/cjs/src/pro/kucoinfutures.js +139 -1
- package/dist/cjs/src/pro/okx.js +8 -36
- package/dist/cjs/src/xt.js +1 -1
- package/examples/js/cli.js +8 -4
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +70 -1
- package/js/src/base/types.d.ts +5 -4
- package/js/src/binance.js +78 -8
- package/js/src/cryptocom.js +1 -1
- package/js/src/currencycom.js +1 -2
- package/js/src/htx.js +1 -1
- package/js/src/mexc.js +69 -1
- package/js/src/pro/binance.d.ts +0 -1
- package/js/src/pro/binance.js +4 -64
- package/js/src/pro/bitget.js +1 -9
- package/js/src/pro/bitmex.js +11 -1
- package/js/src/pro/bybit.d.ts +1 -2
- package/js/src/pro/bybit.js +3 -55
- package/js/src/pro/cryptocom.d.ts +1 -2
- package/js/src/pro/cryptocom.js +3 -41
- package/js/src/pro/gate.js +2 -10
- package/js/src/pro/hyperliquid.js +5 -37
- package/js/src/pro/kucoin.d.ts +0 -1
- package/js/src/pro/kucoin.js +3 -60
- package/js/src/pro/kucoinfutures.d.ts +7 -1
- package/js/src/pro/kucoinfutures.js +139 -1
- package/js/src/pro/okx.js +9 -37
- package/js/src/xt.js +1 -1
- package/package.json +1 -1
|
@@ -1147,5 +1147,7 @@ export default class Exchange {
|
|
|
1147
1147
|
parseMarginModifications(response: object[], symbols?: Strings, symbolKey?: Str, marketType?: MarketType): MarginModification[];
|
|
1148
1148
|
fetchTransfer(id: string, code?: Str, params?: {}): Promise<TransferEntry>;
|
|
1149
1149
|
fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
|
|
1150
|
+
cleanUnsubscription(client: any, subHash: string, unsubHash: string): void;
|
|
1151
|
+
cleanCache(subscription: Dict): void;
|
|
1150
1152
|
}
|
|
1151
1153
|
export { Exchange, };
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -11,7 +11,7 @@ const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sor
|
|
|
11
11
|
import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
|
|
12
12
|
// import exceptions from "./errors.js"
|
|
13
13
|
import { // eslint-disable-line object-curly-newline
|
|
14
|
-
ExchangeError, BadSymbol, NullResponse, InvalidAddress, InvalidOrder, NotSupported, BadResponse, AuthenticationError, DDoSProtection, RequestTimeout, NetworkError, InvalidProxySettings, ExchangeNotAvailable, ArgumentsRequired, RateLimitExceeded, BadRequest, ExchangeClosedByUser } from "./errors.js";
|
|
14
|
+
ExchangeError, BadSymbol, NullResponse, InvalidAddress, InvalidOrder, NotSupported, BadResponse, AuthenticationError, DDoSProtection, RequestTimeout, NetworkError, InvalidProxySettings, ExchangeNotAvailable, ArgumentsRequired, RateLimitExceeded, BadRequest, ExchangeClosedByUser, UnsubscribeError } from "./errors.js";
|
|
15
15
|
import { Precise } from './Precise.js';
|
|
16
16
|
//-----------------------------------------------------------------------------
|
|
17
17
|
import WsClient from './ws/WsClient.js';
|
|
@@ -2381,6 +2381,10 @@ export default class Exchange {
|
|
|
2381
2381
|
'max': undefined,
|
|
2382
2382
|
},
|
|
2383
2383
|
},
|
|
2384
|
+
'marginModes': {
|
|
2385
|
+
'cross': undefined,
|
|
2386
|
+
'isolated': undefined,
|
|
2387
|
+
},
|
|
2384
2388
|
'created': undefined,
|
|
2385
2389
|
'info': undefined,
|
|
2386
2390
|
};
|
|
@@ -6487,5 +6491,70 @@ export default class Exchange {
|
|
|
6487
6491
|
*/
|
|
6488
6492
|
throw new NotSupported(this.id + ' fetchTransfers () is not supported yet');
|
|
6489
6493
|
}
|
|
6494
|
+
cleanUnsubscription(client, subHash, unsubHash) {
|
|
6495
|
+
if (unsubHash in client.subscriptions) {
|
|
6496
|
+
delete client.subscriptions[unsubHash];
|
|
6497
|
+
}
|
|
6498
|
+
if (subHash in client.subscriptions) {
|
|
6499
|
+
delete client.subscriptions[subHash];
|
|
6500
|
+
}
|
|
6501
|
+
if (subHash in client.futures) {
|
|
6502
|
+
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
6503
|
+
client.reject(error, subHash);
|
|
6504
|
+
}
|
|
6505
|
+
client.resolve(true, unsubHash);
|
|
6506
|
+
}
|
|
6507
|
+
cleanCache(subscription) {
|
|
6508
|
+
const topic = this.safeString(subscription, 'topic');
|
|
6509
|
+
const symbols = this.safeList(subscription, 'symbols', []);
|
|
6510
|
+
const symbolsLength = symbols.length;
|
|
6511
|
+
if (topic === 'ohlcv') {
|
|
6512
|
+
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
6513
|
+
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
6514
|
+
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
6515
|
+
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
6516
|
+
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
6517
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
6518
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
6519
|
+
}
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6522
|
+
else if (symbolsLength > 0) {
|
|
6523
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
6524
|
+
const symbol = symbols[i];
|
|
6525
|
+
if (topic === 'trades') {
|
|
6526
|
+
delete this.trades[symbol];
|
|
6527
|
+
}
|
|
6528
|
+
else if (topic === 'orderbook') {
|
|
6529
|
+
delete this.orderbooks[symbol];
|
|
6530
|
+
}
|
|
6531
|
+
else if (topic === 'ticker') {
|
|
6532
|
+
delete this.tickers[symbol];
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6535
|
+
}
|
|
6536
|
+
else {
|
|
6537
|
+
if (topic === 'myTrades') {
|
|
6538
|
+
// don't reset this.myTrades directly here
|
|
6539
|
+
// because in c# we need to use a different object
|
|
6540
|
+
const keys = Object.keys(this.myTrades);
|
|
6541
|
+
for (let i = 0; i < keys.length; i++) {
|
|
6542
|
+
delete this.myTrades[keys[i]];
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
else if (topic === 'orders') {
|
|
6546
|
+
const orderSymbols = Object.keys(this.orders);
|
|
6547
|
+
for (let i = 0; i < orderSymbols.length; i++) {
|
|
6548
|
+
delete this.orders[orderSymbols[i]];
|
|
6549
|
+
}
|
|
6550
|
+
}
|
|
6551
|
+
else if (topic === 'ticker') {
|
|
6552
|
+
const tickerSymbols = Object.keys(this.tickers);
|
|
6553
|
+
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
6554
|
+
delete this.tickers[tickerSymbols[i]];
|
|
6555
|
+
}
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6490
6559
|
}
|
|
6491
6560
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export interface TradingFeeInterface {
|
|
|
35
35
|
tierBased: Bool;
|
|
36
36
|
}
|
|
37
37
|
export declare type Fee = FeeInterface | undefined;
|
|
38
|
+
export interface MarketMarginModes {
|
|
39
|
+
isolated: boolean;
|
|
40
|
+
cross: boolean;
|
|
41
|
+
}
|
|
38
42
|
export interface MarketInterface {
|
|
39
43
|
id: Str;
|
|
40
44
|
numericId?: Num;
|
|
@@ -74,10 +78,7 @@ export interface MarketInterface {
|
|
|
74
78
|
price: Num;
|
|
75
79
|
cost?: Num;
|
|
76
80
|
};
|
|
77
|
-
|
|
78
|
-
isolated: boolean;
|
|
79
|
-
cross: boolean;
|
|
80
|
-
};
|
|
81
|
+
marginModes?: MarketMarginModes;
|
|
81
82
|
limits: {
|
|
82
83
|
amount?: MinMax;
|
|
83
84
|
cost?: MinMax;
|
package/js/src/binance.js
CHANGED
|
@@ -2644,6 +2644,7 @@ export default class binance extends Exchange {
|
|
|
2644
2644
|
* @name binance#fetchCurrencies
|
|
2645
2645
|
* @description fetches all available currencies on an exchange
|
|
2646
2646
|
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
|
|
2647
|
+
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Margin-Assets
|
|
2647
2648
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2648
2649
|
* @returns {object} an associative dictionary of currencies
|
|
2649
2650
|
*/
|
|
@@ -2663,9 +2664,13 @@ export default class binance extends Exchange {
|
|
|
2663
2664
|
if (apiBackup !== undefined) {
|
|
2664
2665
|
return undefined;
|
|
2665
2666
|
}
|
|
2666
|
-
const
|
|
2667
|
+
const promises = [this.sapiGetCapitalConfigGetall(params), this.sapiGetMarginAllAssets(params)];
|
|
2668
|
+
const results = await Promise.all(promises);
|
|
2669
|
+
const responseCurrencies = results[0];
|
|
2670
|
+
const responseMarginables = results[1];
|
|
2671
|
+
const marginablesById = this.indexBy(responseMarginables, 'assetName');
|
|
2667
2672
|
const result = {};
|
|
2668
|
-
for (let i = 0; i <
|
|
2673
|
+
for (let i = 0; i < responseCurrencies.length; i++) {
|
|
2669
2674
|
//
|
|
2670
2675
|
// {
|
|
2671
2676
|
// "coin": "LINK",
|
|
@@ -2761,7 +2766,7 @@ export default class binance extends Exchange {
|
|
|
2761
2766
|
// ]
|
|
2762
2767
|
// }
|
|
2763
2768
|
//
|
|
2764
|
-
const entry =
|
|
2769
|
+
const entry = responseCurrencies[i];
|
|
2765
2770
|
const id = this.safeString(entry, 'coin');
|
|
2766
2771
|
const name = this.safeString(entry, 'name');
|
|
2767
2772
|
const code = this.safeCurrencyCode(id);
|
|
@@ -2816,6 +2821,17 @@ export default class binance extends Exchange {
|
|
|
2816
2821
|
}
|
|
2817
2822
|
const trading = this.safeBool(entry, 'trading');
|
|
2818
2823
|
const active = (isWithdrawEnabled && isDepositEnabled && trading);
|
|
2824
|
+
const marginEntry = this.safeDict(marginablesById, id, {});
|
|
2825
|
+
//
|
|
2826
|
+
// {
|
|
2827
|
+
// assetName: "BTC",
|
|
2828
|
+
// assetFullName: "Bitcoin",
|
|
2829
|
+
// isBorrowable: true,
|
|
2830
|
+
// isMortgageable: true,
|
|
2831
|
+
// userMinBorrow: "0",
|
|
2832
|
+
// userMinRepay: "0",
|
|
2833
|
+
// }
|
|
2834
|
+
//
|
|
2819
2835
|
result[code] = {
|
|
2820
2836
|
'id': id,
|
|
2821
2837
|
'name': name,
|
|
@@ -2829,6 +2845,7 @@ export default class binance extends Exchange {
|
|
|
2829
2845
|
'fee': fee,
|
|
2830
2846
|
'fees': fees,
|
|
2831
2847
|
'limits': this.limits,
|
|
2848
|
+
'margin': this.safeBool(marginEntry, 'isBorrowable'),
|
|
2832
2849
|
};
|
|
2833
2850
|
}
|
|
2834
2851
|
return result;
|
|
@@ -2842,6 +2859,8 @@ export default class binance extends Exchange {
|
|
|
2842
2859
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Exchange-Information // swap
|
|
2843
2860
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Exchange-Information // future
|
|
2844
2861
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Exchange-Information // option
|
|
2862
|
+
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs // cross margin
|
|
2863
|
+
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol // isolated margin
|
|
2845
2864
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2846
2865
|
* @returns {object[]} an array of objects representing market data
|
|
2847
2866
|
*/
|
|
@@ -2856,10 +2875,16 @@ export default class binance extends Exchange {
|
|
|
2856
2875
|
}
|
|
2857
2876
|
fetchMarkets.push(type);
|
|
2858
2877
|
}
|
|
2878
|
+
let fetchMargins = false;
|
|
2859
2879
|
for (let i = 0; i < fetchMarkets.length; i++) {
|
|
2860
2880
|
const marketType = fetchMarkets[i];
|
|
2861
2881
|
if (marketType === 'spot') {
|
|
2862
2882
|
promisesRaw.push(this.publicGetExchangeInfo(params));
|
|
2883
|
+
if (this.checkRequiredCredentials(false) && !sandboxMode) {
|
|
2884
|
+
fetchMargins = true;
|
|
2885
|
+
promisesRaw.push(this.sapiGetMarginAllPairs(params));
|
|
2886
|
+
promisesRaw.push(this.sapiGetMarginIsolatedAllPairs(params));
|
|
2887
|
+
}
|
|
2863
2888
|
}
|
|
2864
2889
|
else if (marketType === 'linear') {
|
|
2865
2890
|
promisesRaw.push(this.fapiPublicGetExchangeInfo(params));
|
|
@@ -2874,12 +2899,27 @@ export default class binance extends Exchange {
|
|
|
2874
2899
|
throw new ExchangeError(this.id + ' fetchMarkets() this.options fetchMarkets "' + marketType + '" is not a supported market type');
|
|
2875
2900
|
}
|
|
2876
2901
|
}
|
|
2877
|
-
const
|
|
2902
|
+
const results = await Promise.all(promisesRaw);
|
|
2878
2903
|
let markets = [];
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2904
|
+
this.options['crossMarginPairsData'] = [];
|
|
2905
|
+
this.options['isolatedMarginPairsData'] = [];
|
|
2906
|
+
for (let i = 0; i < results.length; i++) {
|
|
2907
|
+
const res = this.safeValue(results, i);
|
|
2908
|
+
if (fetchMargins && Array.isArray(res)) {
|
|
2909
|
+
const keysList = Object.keys(this.indexBy(res, 'symbol'));
|
|
2910
|
+
const length = (Object.keys(this.options['crossMarginPairsData'])).length;
|
|
2911
|
+
// first one is the cross-margin promise
|
|
2912
|
+
if (length === 0) {
|
|
2913
|
+
this.options['crossMarginPairsData'] = keysList;
|
|
2914
|
+
}
|
|
2915
|
+
else {
|
|
2916
|
+
this.options['isolatedMarginPairsData'] = keysList;
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
else {
|
|
2920
|
+
const resultMarkets = this.safeList2(res, 'symbols', 'optionSymbols', []);
|
|
2921
|
+
markets = this.arrayConcat(markets, resultMarkets);
|
|
2922
|
+
}
|
|
2883
2923
|
}
|
|
2884
2924
|
//
|
|
2885
2925
|
// spot / margin
|
|
@@ -2925,6 +2965,20 @@ export default class binance extends Exchange {
|
|
|
2925
2965
|
// ],
|
|
2926
2966
|
// }
|
|
2927
2967
|
//
|
|
2968
|
+
// cross & isolated pairs response:
|
|
2969
|
+
//
|
|
2970
|
+
// [
|
|
2971
|
+
// {
|
|
2972
|
+
// symbol: "BTCUSDT",
|
|
2973
|
+
// base: "BTC",
|
|
2974
|
+
// quote: "USDT",
|
|
2975
|
+
// isMarginTrade: true,
|
|
2976
|
+
// isBuyAllowed: true,
|
|
2977
|
+
// isSellAllowed: true,
|
|
2978
|
+
// id: "376870555451677893", // doesn't exist in isolated
|
|
2979
|
+
// },
|
|
2980
|
+
// ]
|
|
2981
|
+
//
|
|
2928
2982
|
// futures/usdt-margined (fapi)
|
|
2929
2983
|
//
|
|
2930
2984
|
// {
|
|
@@ -3159,6 +3213,21 @@ export default class binance extends Exchange {
|
|
|
3159
3213
|
}
|
|
3160
3214
|
}
|
|
3161
3215
|
const isMarginTradingAllowed = this.safeBool(market, 'isMarginTradingAllowed', false);
|
|
3216
|
+
let marginModes = undefined;
|
|
3217
|
+
if (spot) {
|
|
3218
|
+
const hasCrossMargin = this.inArray(id, this.options['crossMarginPairsData']);
|
|
3219
|
+
const hasIsolatedMargin = this.inArray(id, this.options['isolatedMarginPairsData']);
|
|
3220
|
+
marginModes = {
|
|
3221
|
+
'cross': hasCrossMargin,
|
|
3222
|
+
'isolated': hasIsolatedMargin,
|
|
3223
|
+
};
|
|
3224
|
+
}
|
|
3225
|
+
else if (linear || inverse) {
|
|
3226
|
+
marginModes = {
|
|
3227
|
+
'cross': true,
|
|
3228
|
+
'isolated': true,
|
|
3229
|
+
};
|
|
3230
|
+
}
|
|
3162
3231
|
let unifiedType = undefined;
|
|
3163
3232
|
if (spot) {
|
|
3164
3233
|
unifiedType = 'spot';
|
|
@@ -3190,6 +3259,7 @@ export default class binance extends Exchange {
|
|
|
3190
3259
|
'type': unifiedType,
|
|
3191
3260
|
'spot': spot,
|
|
3192
3261
|
'margin': spot && isMarginTradingAllowed,
|
|
3262
|
+
'marginModes': marginModes,
|
|
3193
3263
|
'swap': swap,
|
|
3194
3264
|
'future': future,
|
|
3195
3265
|
'option': option,
|
package/js/src/cryptocom.js
CHANGED
|
@@ -141,7 +141,7 @@ export default class cryptocom extends Exchange {
|
|
|
141
141
|
'www': 'https://crypto.com/',
|
|
142
142
|
'referral': {
|
|
143
143
|
'url': 'https://crypto.com/exch/kdacthrnxt',
|
|
144
|
-
'discount': 0.
|
|
144
|
+
'discount': 0.75,
|
|
145
145
|
},
|
|
146
146
|
'doc': [
|
|
147
147
|
'https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html',
|
package/js/src/currencycom.js
CHANGED
|
@@ -1992,7 +1992,7 @@ export default class currencycom extends Exchange {
|
|
|
1992
1992
|
'collateral': undefined,
|
|
1993
1993
|
'side': side,
|
|
1994
1994
|
// 'realizedProfit': this.safeNumber (position, 'rpl'),
|
|
1995
|
-
'
|
|
1995
|
+
'unrealizedPnl': unrealizedProfit,
|
|
1996
1996
|
'leverage': leverage,
|
|
1997
1997
|
'percentage': undefined,
|
|
1998
1998
|
'marginMode': undefined,
|
|
@@ -2006,7 +2006,6 @@ export default class currencycom extends Exchange {
|
|
|
2006
2006
|
'maintenanceMarginPercentage': undefined,
|
|
2007
2007
|
'marginRatio': undefined,
|
|
2008
2008
|
'id': undefined,
|
|
2009
|
-
'unrealizedPnl': undefined,
|
|
2010
2009
|
'hedged': undefined,
|
|
2011
2010
|
'stopLossPrice': undefined,
|
|
2012
2011
|
'takeProfitPrice': undefined,
|
package/js/src/htx.js
CHANGED
|
@@ -7645,7 +7645,7 @@ export default class htx extends Exchange {
|
|
|
7645
7645
|
'entryPrice': entryPrice,
|
|
7646
7646
|
'collateral': this.parseNumber(collateral),
|
|
7647
7647
|
'side': side,
|
|
7648
|
-
'
|
|
7648
|
+
'unrealizedPnl': unrealizedProfit,
|
|
7649
7649
|
'leverage': this.parseNumber(leverage),
|
|
7650
7650
|
'percentage': this.parseNumber(percentage),
|
|
7651
7651
|
'marginMode': marginMode,
|
package/js/src/mexc.js
CHANGED
|
@@ -1022,6 +1022,15 @@ export default class mexc extends Exchange {
|
|
|
1022
1022
|
return this.arrayConcat(spotMarket, swapMarket);
|
|
1023
1023
|
}
|
|
1024
1024
|
async fetchSpotMarkets(params = {}) {
|
|
1025
|
+
/**
|
|
1026
|
+
* @ignore
|
|
1027
|
+
* @method
|
|
1028
|
+
* @name mexc#fetchMarkets
|
|
1029
|
+
* @description retrieves data on all spot markets for mexc
|
|
1030
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
|
|
1031
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1032
|
+
* @returns {object[]} an array of objects representing market data
|
|
1033
|
+
*/
|
|
1025
1034
|
const response = await this.spotPublicGetExchangeInfo(params);
|
|
1026
1035
|
//
|
|
1027
1036
|
// {
|
|
@@ -1139,6 +1148,15 @@ export default class mexc extends Exchange {
|
|
|
1139
1148
|
return result;
|
|
1140
1149
|
}
|
|
1141
1150
|
async fetchSwapMarkets(params = {}) {
|
|
1151
|
+
/**
|
|
1152
|
+
* @ignore
|
|
1153
|
+
* @method
|
|
1154
|
+
* @name mexc#fetchMarkets
|
|
1155
|
+
* @description retrieves data on all swap markets for mexc
|
|
1156
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
|
|
1157
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1158
|
+
* @returns {object[]} an array of objects representing market data
|
|
1159
|
+
*/
|
|
1142
1160
|
const response = await this.contractPublicGetDetail(params);
|
|
1143
1161
|
//
|
|
1144
1162
|
// {
|
|
@@ -1730,6 +1748,8 @@ export default class mexc extends Exchange {
|
|
|
1730
1748
|
* @method
|
|
1731
1749
|
* @name mexc#fetchTickers
|
|
1732
1750
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1751
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
1752
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
|
1733
1753
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1734
1754
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1735
1755
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -1818,6 +1838,8 @@ export default class mexc extends Exchange {
|
|
|
1818
1838
|
* @method
|
|
1819
1839
|
* @name mexc#fetchTicker
|
|
1820
1840
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1841
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
1842
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
|
1821
1843
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1822
1844
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1823
1845
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2008,6 +2030,7 @@ export default class mexc extends Exchange {
|
|
|
2008
2030
|
* @method
|
|
2009
2031
|
* @name mexc#fetchBidsAsks
|
|
2010
2032
|
* @description fetches the bid and ask price and volume for multiple markets
|
|
2033
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
|
|
2011
2034
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
2012
2035
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2013
2036
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2153,6 +2176,23 @@ export default class mexc extends Exchange {
|
|
|
2153
2176
|
return this.extend(request, params);
|
|
2154
2177
|
}
|
|
2155
2178
|
async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2179
|
+
/**
|
|
2180
|
+
* @ignore
|
|
2181
|
+
* @method
|
|
2182
|
+
* @name mexc#createSpotOrder
|
|
2183
|
+
* @description create a trade order
|
|
2184
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
2185
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2186
|
+
* @param {string} type 'market' or 'limit'
|
|
2187
|
+
* @param {string} side 'buy' or 'sell'
|
|
2188
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2189
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
2190
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2191
|
+
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2192
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2193
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2194
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2195
|
+
*/
|
|
2156
2196
|
await this.loadMarkets();
|
|
2157
2197
|
const request = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, params);
|
|
2158
2198
|
const response = await this.spotPrivatePostOrder(this.extend(request, params));
|
|
@@ -2183,6 +2223,32 @@ export default class mexc extends Exchange {
|
|
|
2183
2223
|
return order;
|
|
2184
2224
|
}
|
|
2185
2225
|
async createSwapOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2226
|
+
/**
|
|
2227
|
+
* @ignore
|
|
2228
|
+
* @method
|
|
2229
|
+
* @name mexc#createOrder
|
|
2230
|
+
* @description create a trade order
|
|
2231
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
2232
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
|
|
2233
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
|
|
2234
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2235
|
+
* @param {string} type 'market' or 'limit'
|
|
2236
|
+
* @param {string} side 'buy' or 'sell'
|
|
2237
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2238
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
2239
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2240
|
+
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2241
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2242
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2243
|
+
* @param {bool} [params.reduceOnly] indicates if this order is to reduce the size of a position
|
|
2244
|
+
*
|
|
2245
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
2246
|
+
* @param {int} [params.leverage] leverage is necessary on isolated margin
|
|
2247
|
+
* @param {long} [params.positionId] it is recommended to fill in this parameter when closing a position
|
|
2248
|
+
* @param {string} [params.externalOid] external order ID
|
|
2249
|
+
* @param {int} [params.positionMode] 1:hedge, 2:one-way, default: the user's current config
|
|
2250
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2251
|
+
*/
|
|
2186
2252
|
await this.loadMarkets();
|
|
2187
2253
|
const symbol = market['symbol'];
|
|
2188
2254
|
const unavailableContracts = this.safeValue(this.options, 'unavailableContracts', {});
|
|
@@ -2358,6 +2424,8 @@ export default class mexc extends Exchange {
|
|
|
2358
2424
|
* @method
|
|
2359
2425
|
* @name mexc#fetchOrder
|
|
2360
2426
|
* @description fetches information on an order made by the user
|
|
2427
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
|
|
2428
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
|
|
2361
2429
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2362
2430
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2363
2431
|
* @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
|
|
@@ -4816,7 +4884,7 @@ export default class mexc extends Exchange {
|
|
|
4816
4884
|
'entryPrice': entryPrice,
|
|
4817
4885
|
'collateral': undefined,
|
|
4818
4886
|
'side': side,
|
|
4819
|
-
'
|
|
4887
|
+
'unrealizedPnl': undefined,
|
|
4820
4888
|
'leverage': this.parseNumber(leverage),
|
|
4821
4889
|
'percentage': undefined,
|
|
4822
4890
|
'marginMode': marginType,
|
package/js/src/pro/binance.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ export default class binance extends binanceRest {
|
|
|
26
26
|
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
27
27
|
handleSubscriptionStatus(client: Client, message: any): any;
|
|
28
28
|
handleUnSubscription(client: Client, subscription: Dict): void;
|
|
29
|
-
cleanCache(subscription: Dict): void;
|
|
30
29
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
31
30
|
unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
32
31
|
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
package/js/src/pro/binance.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ----------------------------------------------------------------------------
|
|
8
8
|
import binanceRest from '../binance.js';
|
|
9
9
|
import { Precise } from '../base/Precise.js';
|
|
10
|
-
import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported
|
|
10
|
+
import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
|
|
11
11
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
12
12
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
13
13
|
import { rsa } from '../base/functions/rsa.js';
|
|
@@ -1026,70 +1026,10 @@ export default class binance extends binanceRest {
|
|
|
1026
1026
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1027
1027
|
const unsubHash = messageHashes[j];
|
|
1028
1028
|
const subHash = subMessageHashes[j];
|
|
1029
|
-
|
|
1030
|
-
delete client.subscriptions[unsubHash];
|
|
1031
|
-
}
|
|
1032
|
-
if (subHash in client.subscriptions) {
|
|
1033
|
-
delete client.subscriptions[subHash];
|
|
1034
|
-
}
|
|
1035
|
-
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
1036
|
-
client.reject(error, subHash);
|
|
1037
|
-
client.resolve(true, unsubHash);
|
|
1029
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1038
1030
|
}
|
|
1039
1031
|
this.cleanCache(subscription);
|
|
1040
1032
|
}
|
|
1041
|
-
cleanCache(subscription) {
|
|
1042
|
-
const topic = this.safeString(subscription, 'topic');
|
|
1043
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1044
|
-
const symbolsLength = symbols.length;
|
|
1045
|
-
if (topic === 'ohlcv') {
|
|
1046
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1047
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1048
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1049
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1050
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1051
|
-
if (timeframe in this.ohlcvs[symbol]) {
|
|
1052
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
else if (symbolsLength > 0) {
|
|
1057
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
1058
|
-
const symbol = symbols[i];
|
|
1059
|
-
if (topic === 'trade') {
|
|
1060
|
-
delete this.trades[symbol];
|
|
1061
|
-
}
|
|
1062
|
-
else if (topic === 'orderbook') {
|
|
1063
|
-
delete this.orderbooks[symbol];
|
|
1064
|
-
}
|
|
1065
|
-
else if (topic === 'ticker') {
|
|
1066
|
-
delete this.tickers[symbol];
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
else {
|
|
1071
|
-
if (topic === 'myTrades') {
|
|
1072
|
-
// don't reset this.myTrades directly here
|
|
1073
|
-
// because in c# we need to use a different object
|
|
1074
|
-
const keys = Object.keys(this.myTrades);
|
|
1075
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1076
|
-
delete this.myTrades[keys[i]];
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
else if (topic === 'orders') {
|
|
1080
|
-
const orderSymbols = Object.keys(this.orders);
|
|
1081
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
1082
|
-
delete this.orders[orderSymbols[i]];
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
else if (topic === 'ticker') {
|
|
1086
|
-
const tickerSymbols = Object.keys(this.tickers);
|
|
1087
|
-
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
1088
|
-
delete this.tickers[tickerSymbols[i]];
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
1033
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
1094
1034
|
/**
|
|
1095
1035
|
* @method
|
|
@@ -1211,7 +1151,7 @@ export default class binance extends binanceRest {
|
|
|
1211
1151
|
'subMessageHashes': subMessageHashes,
|
|
1212
1152
|
'messageHashes': messageHashes,
|
|
1213
1153
|
'symbols': symbols,
|
|
1214
|
-
'topic': '
|
|
1154
|
+
'topic': 'trades',
|
|
1215
1155
|
};
|
|
1216
1156
|
return await this.watchMultiple(url, messageHashes, this.extend(request, query), messageHashes, subscription);
|
|
1217
1157
|
}
|
|
@@ -1979,7 +1919,7 @@ export default class binance extends binanceRest {
|
|
|
1979
1919
|
if (this.newUpdates) {
|
|
1980
1920
|
return result;
|
|
1981
1921
|
}
|
|
1982
|
-
return this.filterByArray(this.
|
|
1922
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
1983
1923
|
}
|
|
1984
1924
|
async watchMultiTickerHelper(methodName, channelName, symbols = undefined, params = {}) {
|
|
1985
1925
|
await this.loadMarkets();
|
package/js/src/pro/bitget.js
CHANGED
|
@@ -2013,15 +2013,7 @@ export default class bitget extends bitgetRest {
|
|
|
2013
2013
|
delete this.ohlcvs[symbol][timeframe];
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
|
-
|
|
2017
|
-
delete client.subscriptions[subMessageHash];
|
|
2018
|
-
}
|
|
2019
|
-
if (messageHash in client.subscriptions) {
|
|
2020
|
-
delete client.subscriptions[messageHash];
|
|
2021
|
-
}
|
|
2022
|
-
const error = new UnsubscribeError(this.id + ' ohlcv ' + timeframe + ' ' + symbol);
|
|
2023
|
-
client.reject(error, subMessageHash);
|
|
2024
|
-
client.resolve(true, messageHash);
|
|
2016
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2025
2017
|
}
|
|
2026
2018
|
handleUnSubscriptionStatus(client, message) {
|
|
2027
2019
|
//
|