ccxt 4.4.28 → 4.4.30
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 +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +59 -7
- package/dist/cjs/src/base/Exchange.js +3 -0
- package/dist/cjs/src/binance.js +9 -0
- package/dist/cjs/src/bitbns.js +12 -12
- package/dist/cjs/src/bitfinex.js +9 -9
- package/dist/cjs/src/bitget.js +99 -6
- package/dist/cjs/src/bitmart.js +53 -53
- package/dist/cjs/src/bitopro.js +21 -21
- package/dist/cjs/src/bitrue.js +28 -28
- package/dist/cjs/src/bitvavo.js +4 -0
- package/dist/cjs/src/bybit.js +51 -646
- package/dist/cjs/src/coincatch.js +24 -4
- package/dist/cjs/src/deribit.js +7 -3
- package/dist/cjs/src/hyperliquid.js +108 -4
- package/dist/cjs/src/lbank.js +7 -1
- package/dist/cjs/src/pro/bitvavo.js +2 -1
- package/dist/cjs/src/pro/blofin.js +2 -1
- package/dist/cjs/src/pro/mexc.js +198 -30
- package/dist/cjs/src/vertex.js +51 -6
- package/examples/README.md +0 -2
- package/examples/js/cli.js +7 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/alpaca.d.ts +1 -0
- package/js/src/abstract/binance.d.ts +9 -0
- package/js/src/abstract/binancecoinm.d.ts +9 -0
- package/js/src/abstract/binanceus.d.ts +9 -0
- package/js/src/abstract/binanceusdm.d.ts +9 -0
- package/js/src/abstract/bybit.d.ts +0 -13
- package/js/src/alpaca.d.ts +2 -0
- package/js/src/alpaca.js +59 -7
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +3 -0
- package/js/src/binance.js +9 -0
- package/js/src/bitbns.js +12 -12
- package/js/src/bitfinex.js +9 -9
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitget.d.ts +2 -1
- package/js/src/bitget.js +99 -6
- package/js/src/bitmart.d.ts +1 -1
- package/js/src/bitmart.js +53 -53
- package/js/src/bitopro.js +21 -21
- package/js/src/bitrue.js +28 -28
- package/js/src/bitvavo.js +4 -0
- package/js/src/bybit.d.ts +0 -8
- package/js/src/bybit.js +51 -646
- package/js/src/coincatch.d.ts +1 -1
- package/js/src/coincatch.js +24 -4
- package/js/src/deribit.js +7 -3
- package/js/src/hyperliquid.d.ts +3 -1
- package/js/src/hyperliquid.js +108 -4
- package/js/src/lbank.js +7 -1
- package/js/src/pro/bitvavo.js +2 -1
- package/js/src/pro/blofin.js +2 -1
- package/js/src/pro/mexc.js +198 -30
- package/js/src/vertex.d.ts +4 -2
- package/js/src/vertex.js +51 -6
- package/js/src/whitebit.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2073,13 +2073,23 @@ class coincatch extends coincatch$1 {
|
|
|
2073
2073
|
request['chain'] = this.networkCodeToId(networkCode);
|
|
2074
2074
|
}
|
|
2075
2075
|
const response = await this.privatePostApiSpotV1WalletWithdrawalV2(this.extend(request, params));
|
|
2076
|
-
// todo add after withdrawal
|
|
2077
2076
|
//
|
|
2078
|
-
|
|
2077
|
+
// {
|
|
2078
|
+
// "code": "00000",
|
|
2079
|
+
// "msg": "success",
|
|
2080
|
+
// "data": {
|
|
2081
|
+
// "orderId":888291686266343424",
|
|
2082
|
+
// "clientOrderId":"123"
|
|
2083
|
+
// }
|
|
2084
|
+
// }
|
|
2085
|
+
//
|
|
2086
|
+
const data = this.safeDict(response, 'data', {});
|
|
2087
|
+
return this.parseTransaction(data, currency);
|
|
2079
2088
|
}
|
|
2080
2089
|
parseTransaction(transaction, currency = undefined) {
|
|
2081
2090
|
//
|
|
2082
2091
|
// fetchDeposits
|
|
2092
|
+
//
|
|
2083
2093
|
// {
|
|
2084
2094
|
// "id": "1213046466852196352",
|
|
2085
2095
|
// "txId": "824246b030cd84d56400661303547f43a1d9fef66cf968628dd5112f362053ff",
|
|
@@ -2099,7 +2109,17 @@ class coincatch extends coincatch$1 {
|
|
|
2099
2109
|
// "uTime": "1724938746015"
|
|
2100
2110
|
// }
|
|
2101
2111
|
//
|
|
2102
|
-
|
|
2112
|
+
// withdraw
|
|
2113
|
+
//
|
|
2114
|
+
// {
|
|
2115
|
+
// "code": "00000",
|
|
2116
|
+
// "msg": "success",
|
|
2117
|
+
// "data": {
|
|
2118
|
+
// "orderId":888291686266343424",
|
|
2119
|
+
// "clientOrderId":"123"
|
|
2120
|
+
// }
|
|
2121
|
+
// }
|
|
2122
|
+
//
|
|
2103
2123
|
let status = this.safeString(transaction, 'status');
|
|
2104
2124
|
if (status === 'success') {
|
|
2105
2125
|
status = 'ok';
|
|
@@ -2125,7 +2145,7 @@ class coincatch extends coincatch$1 {
|
|
|
2125
2145
|
}
|
|
2126
2146
|
return {
|
|
2127
2147
|
'info': transaction,
|
|
2128
|
-
'id': id,
|
|
2148
|
+
'id': this.safeString2(transaction, 'id', 'orderId'),
|
|
2129
2149
|
'txid': txid,
|
|
2130
2150
|
'timestamp': timestamp,
|
|
2131
2151
|
'datetime': this.iso8601(timestamp),
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -854,6 +854,8 @@ class deribit extends deribit$1 {
|
|
|
854
854
|
else if (isSpot) {
|
|
855
855
|
type = 'spot';
|
|
856
856
|
}
|
|
857
|
+
let inverse = undefined;
|
|
858
|
+
let linear = undefined;
|
|
857
859
|
if (isSpot) {
|
|
858
860
|
symbol = base + '/' + quote;
|
|
859
861
|
}
|
|
@@ -868,6 +870,8 @@ class deribit extends deribit$1 {
|
|
|
868
870
|
symbol = symbol + '-' + this.numberToString(strike) + '-' + letter;
|
|
869
871
|
}
|
|
870
872
|
}
|
|
873
|
+
inverse = (quote !== settle);
|
|
874
|
+
linear = (settle === quote);
|
|
871
875
|
}
|
|
872
876
|
const parsedMarketValue = this.safeValue(parsedMarkets, symbol);
|
|
873
877
|
if (parsedMarketValue) {
|
|
@@ -893,8 +897,8 @@ class deribit extends deribit$1 {
|
|
|
893
897
|
'option': option,
|
|
894
898
|
'active': this.safeValue(market, 'is_active'),
|
|
895
899
|
'contract': !isSpot,
|
|
896
|
-
'linear':
|
|
897
|
-
'inverse':
|
|
900
|
+
'linear': linear,
|
|
901
|
+
'inverse': inverse,
|
|
898
902
|
'taker': this.safeNumber(market, 'taker_commission'),
|
|
899
903
|
'maker': this.safeNumber(market, 'maker_commission'),
|
|
900
904
|
'contractSize': this.safeNumber(market, 'contract_size'),
|
|
@@ -1760,7 +1764,7 @@ class deribit extends deribit$1 {
|
|
|
1760
1764
|
const filledString = this.safeString(order, 'filled_amount');
|
|
1761
1765
|
const amount = this.safeString(order, 'amount');
|
|
1762
1766
|
let cost = Precise["default"].stringMul(filledString, averageString);
|
|
1763
|
-
if (market
|
|
1767
|
+
if (this.safeBool(market, 'inverse')) {
|
|
1764
1768
|
if (averageString !== '0') {
|
|
1765
1769
|
cost = Precise["default"].stringDiv(amount, averageString);
|
|
1766
1770
|
}
|
|
@@ -68,7 +68,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
68
68
|
'fetchFundingHistory': false,
|
|
69
69
|
'fetchFundingRate': false,
|
|
70
70
|
'fetchFundingRateHistory': true,
|
|
71
|
-
'fetchFundingRates':
|
|
71
|
+
'fetchFundingRates': true,
|
|
72
72
|
'fetchIndexOHLCV': false,
|
|
73
73
|
'fetchIsolatedBorrowRate': false,
|
|
74
74
|
'fetchIsolatedBorrowRates': false,
|
|
@@ -124,12 +124,12 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
124
124
|
'1h': '1h',
|
|
125
125
|
'2h': '2h',
|
|
126
126
|
'4h': '4h',
|
|
127
|
-
'
|
|
127
|
+
'8h': '8h',
|
|
128
128
|
'12h': '12h',
|
|
129
129
|
'1d': '1d',
|
|
130
130
|
'3d': '3d',
|
|
131
131
|
'1w': '1w',
|
|
132
|
-
'1M': '
|
|
132
|
+
'1M': '1M',
|
|
133
133
|
},
|
|
134
134
|
'hostname': 'hyperliquid.xyz',
|
|
135
135
|
'urls': {
|
|
@@ -746,6 +746,110 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
746
746
|
}
|
|
747
747
|
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
748
748
|
}
|
|
749
|
+
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
750
|
+
/**
|
|
751
|
+
* @method
|
|
752
|
+
* @name hyperliquid#fetchFundingRates
|
|
753
|
+
* @description retrieves data on all swap markets for hyperliquid
|
|
754
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
|
|
755
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
756
|
+
* @returns {object[]} an array of objects representing market data
|
|
757
|
+
*/
|
|
758
|
+
const request = {
|
|
759
|
+
'type': 'metaAndAssetCtxs',
|
|
760
|
+
};
|
|
761
|
+
const response = await this.publicPostInfo(this.extend(request, params));
|
|
762
|
+
//
|
|
763
|
+
// [
|
|
764
|
+
// {
|
|
765
|
+
// "universe": [
|
|
766
|
+
// {
|
|
767
|
+
// "maxLeverage": 50,
|
|
768
|
+
// "name": "SOL",
|
|
769
|
+
// "onlyIsolated": false,
|
|
770
|
+
// "szDecimals": 2
|
|
771
|
+
// }
|
|
772
|
+
// ]
|
|
773
|
+
// },
|
|
774
|
+
// [
|
|
775
|
+
// {
|
|
776
|
+
// "dayNtlVlm": "9450588.2273",
|
|
777
|
+
// "funding": "0.0000198",
|
|
778
|
+
// "impactPxs": [
|
|
779
|
+
// "108.04",
|
|
780
|
+
// "108.06"
|
|
781
|
+
// ],
|
|
782
|
+
// "markPx": "108.04",
|
|
783
|
+
// "midPx": "108.05",
|
|
784
|
+
// "openInterest": "10764.48",
|
|
785
|
+
// "oraclePx": "107.99",
|
|
786
|
+
// "premium": "0.00055561",
|
|
787
|
+
// "prevDayPx": "111.81"
|
|
788
|
+
// }
|
|
789
|
+
// ]
|
|
790
|
+
// ]
|
|
791
|
+
//
|
|
792
|
+
//
|
|
793
|
+
const meta = this.safeDict(response, 0, {});
|
|
794
|
+
const universe = this.safeList(meta, 'universe', []);
|
|
795
|
+
const assetCtxs = this.safeList(response, 1, []);
|
|
796
|
+
const result = [];
|
|
797
|
+
for (let i = 0; i < universe.length; i++) {
|
|
798
|
+
const data = this.extend(this.safeDict(universe, i, {}), this.safeDict(assetCtxs, i, {}));
|
|
799
|
+
result.push(data);
|
|
800
|
+
}
|
|
801
|
+
const funding_rates = this.parseFundingRates(result);
|
|
802
|
+
return this.filterByArray(funding_rates, 'symbol', symbols);
|
|
803
|
+
}
|
|
804
|
+
parseFundingRate(info, market = undefined) {
|
|
805
|
+
//
|
|
806
|
+
// {
|
|
807
|
+
// "maxLeverage": "50",
|
|
808
|
+
// "name": "ETH",
|
|
809
|
+
// "onlyIsolated": false,
|
|
810
|
+
// "szDecimals": "4",
|
|
811
|
+
// "dayNtlVlm": "1709813.11535",
|
|
812
|
+
// "funding": "0.00004807",
|
|
813
|
+
// "impactPxs": [
|
|
814
|
+
// "2369.3",
|
|
815
|
+
// "2369.6"
|
|
816
|
+
// ],
|
|
817
|
+
// "markPx": "2369.6",
|
|
818
|
+
// "midPx": "2369.45",
|
|
819
|
+
// "openInterest": "1815.4712",
|
|
820
|
+
// "oraclePx": "2367.3",
|
|
821
|
+
// "premium": "0.00090821",
|
|
822
|
+
// "prevDayPx": "2381.5"
|
|
823
|
+
// }
|
|
824
|
+
//
|
|
825
|
+
const base = this.safeString(info, 'name');
|
|
826
|
+
const marketId = this.coinToMarketId(base);
|
|
827
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
828
|
+
const funding = this.safeNumber(info, 'funding');
|
|
829
|
+
const markPx = this.safeNumber(info, 'markPx');
|
|
830
|
+
const oraclePx = this.safeNumber(info, 'oraclePx');
|
|
831
|
+
const fundingTimestamp = (Math.floor(this.milliseconds() / 60 / 60 / 1000) + 1) * 60 * 60 * 1000;
|
|
832
|
+
return {
|
|
833
|
+
'info': info,
|
|
834
|
+
'symbol': symbol,
|
|
835
|
+
'markPrice': markPx,
|
|
836
|
+
'indexPrice': oraclePx,
|
|
837
|
+
'interestRate': undefined,
|
|
838
|
+
'estimatedSettlePrice': undefined,
|
|
839
|
+
'timestamp': undefined,
|
|
840
|
+
'datetime': undefined,
|
|
841
|
+
'fundingRate': funding,
|
|
842
|
+
'fundingTimestamp': fundingTimestamp,
|
|
843
|
+
'fundingDatetime': this.iso8601(fundingTimestamp),
|
|
844
|
+
'nextFundingRate': undefined,
|
|
845
|
+
'nextFundingTimestamp': undefined,
|
|
846
|
+
'nextFundingDatetime': undefined,
|
|
847
|
+
'previousFundingRate': undefined,
|
|
848
|
+
'previousFundingTimestamp': undefined,
|
|
849
|
+
'previousFundingDatetime': undefined,
|
|
850
|
+
'interval': '1h',
|
|
851
|
+
};
|
|
852
|
+
}
|
|
749
853
|
parseTicker(ticker, market = undefined) {
|
|
750
854
|
//
|
|
751
855
|
// {
|
|
@@ -810,7 +914,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
810
914
|
'type': 'candleSnapshot',
|
|
811
915
|
'req': {
|
|
812
916
|
'coin': market['swap'] ? market['base'] : market['id'],
|
|
813
|
-
'interval': timeframe,
|
|
917
|
+
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
814
918
|
'startTime': since,
|
|
815
919
|
'endTime': until,
|
|
816
920
|
},
|
package/dist/cjs/src/lbank.js
CHANGED
|
@@ -1193,6 +1193,12 @@ class lbank extends lbank$1 {
|
|
|
1193
1193
|
const indexPrice = this.safeNumber(ticker, 'underlyingPrice');
|
|
1194
1194
|
const fundingRate = this.safeNumber(ticker, 'fundingRate');
|
|
1195
1195
|
const fundingTime = this.safeInteger(ticker, 'nextFeeTime');
|
|
1196
|
+
const positionFeeTime = this.safeInteger(ticker, 'positionFeeTime');
|
|
1197
|
+
let intervalString = undefined;
|
|
1198
|
+
if (positionFeeTime !== undefined) {
|
|
1199
|
+
const interval = this.parseToInt(positionFeeTime / 60 / 60);
|
|
1200
|
+
intervalString = interval.toString() + 'h';
|
|
1201
|
+
}
|
|
1196
1202
|
return {
|
|
1197
1203
|
'info': ticker,
|
|
1198
1204
|
'symbol': symbol,
|
|
@@ -1209,7 +1215,7 @@ class lbank extends lbank$1 {
|
|
|
1209
1215
|
'previousFundingRate': undefined,
|
|
1210
1216
|
'previousFundingTimestamp': undefined,
|
|
1211
1217
|
'previousFundingDatetime': undefined,
|
|
1212
|
-
'interval':
|
|
1218
|
+
'interval': intervalString,
|
|
1213
1219
|
};
|
|
1214
1220
|
}
|
|
1215
1221
|
async fetchFundingRate(symbol, params = {}) {
|
|
@@ -773,7 +773,8 @@ class bitvavo extends bitvavo$1 {
|
|
|
773
773
|
const messageHash = this.buildMessageHash(action, request);
|
|
774
774
|
this.checkMessageHashDoesNotExist(messageHash);
|
|
775
775
|
const url = this.urls['api']['ws'];
|
|
776
|
-
|
|
776
|
+
const randomSubHash = this.randNumber(5).toString() + ':' + messageHash;
|
|
777
|
+
return await this.watch(url, messageHash, request, randomSubHash);
|
|
777
778
|
}
|
|
778
779
|
async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
779
780
|
/**
|
|
@@ -683,7 +683,8 @@ class blofin extends blofin$1 {
|
|
|
683
683
|
return;
|
|
684
684
|
}
|
|
685
685
|
else if (event === 'login') {
|
|
686
|
-
client.
|
|
686
|
+
const future = this.safeValue(client.futures, 'authenticate_hash');
|
|
687
|
+
future.resolve(true);
|
|
687
688
|
return;
|
|
688
689
|
}
|
|
689
690
|
else if (event === 'error') {
|
package/dist/cjs/src/pro/mexc.js
CHANGED
|
@@ -75,15 +75,25 @@ class mexc extends mexc$1 {
|
|
|
75
75
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
76
76
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
|
|
77
77
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
|
|
78
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#miniticker
|
|
78
79
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
79
80
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
81
|
+
* @param {boolean} [params.miniTicker] set to true for using the miniTicker endpoint
|
|
80
82
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
81
83
|
*/
|
|
82
84
|
await this.loadMarkets();
|
|
83
85
|
const market = this.market(symbol);
|
|
84
86
|
const messageHash = 'ticker:' + market['symbol'];
|
|
85
87
|
if (market['spot']) {
|
|
86
|
-
|
|
88
|
+
let miniTicker = false;
|
|
89
|
+
[miniTicker, params] = this.handleOptionAndParams(params, 'watchTicker', 'miniTicker');
|
|
90
|
+
let channel = undefined;
|
|
91
|
+
if (miniTicker) {
|
|
92
|
+
channel = 'spot@public.miniTicker.v3.api@' + market['id'] + '@UTC+8';
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
channel = 'spot@public.bookTicker.v3.api@' + market['id'];
|
|
96
|
+
}
|
|
87
97
|
return await this.watchSpotPublic(channel, messageHash, params);
|
|
88
98
|
}
|
|
89
99
|
else {
|
|
@@ -95,6 +105,38 @@ class mexc extends mexc$1 {
|
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
107
|
handleTicker(client, message) {
|
|
108
|
+
//
|
|
109
|
+
// swap
|
|
110
|
+
//
|
|
111
|
+
// {
|
|
112
|
+
// "symbol": "BTC_USDT",
|
|
113
|
+
// "data": {
|
|
114
|
+
// "symbol": "BTC_USDT",
|
|
115
|
+
// "lastPrice": 76376.2,
|
|
116
|
+
// "riseFallRate": -0.0006,
|
|
117
|
+
// "fairPrice": 76374.4,
|
|
118
|
+
// "indexPrice": 76385.8,
|
|
119
|
+
// "volume24": 962062810,
|
|
120
|
+
// "amount24": 7344207079.96768,
|
|
121
|
+
// "maxBidPrice": 84024.3,
|
|
122
|
+
// "minAskPrice": 68747.2,
|
|
123
|
+
// "lower24Price": 75620.2,
|
|
124
|
+
// "high24Price": 77210,
|
|
125
|
+
// "timestamp": 1731137509138,
|
|
126
|
+
// "bid1": 76376.2,
|
|
127
|
+
// "ask1": 76376.3,
|
|
128
|
+
// "holdVol": 95479623,
|
|
129
|
+
// "riseFallValue": -46.5,
|
|
130
|
+
// "fundingRate": 0.0001,
|
|
131
|
+
// "zone": "UTC+8",
|
|
132
|
+
// "riseFallRates": [ -0.0006, 0.1008, 0.2262, 0.2628, 0.2439, 1.0564 ],
|
|
133
|
+
// "riseFallRatesOfTimezone": [ 0.0065, -0.0013, -0.0006 ]
|
|
134
|
+
// },
|
|
135
|
+
// "channel": "push.ticker",
|
|
136
|
+
// "ts": 1731137509138
|
|
137
|
+
// }
|
|
138
|
+
//
|
|
139
|
+
// spot
|
|
98
140
|
//
|
|
99
141
|
// {
|
|
100
142
|
// "c": "spot@public.bookTicker.v3.api@BTCUSDT",
|
|
@@ -108,8 +150,30 @@ class mexc extends mexc$1 {
|
|
|
108
150
|
// "t": 1678643605721
|
|
109
151
|
// }
|
|
110
152
|
//
|
|
153
|
+
// spot miniTicker
|
|
154
|
+
//
|
|
155
|
+
// {
|
|
156
|
+
// "d": {
|
|
157
|
+
// "s": "BTCUSDT",
|
|
158
|
+
// "p": "76522",
|
|
159
|
+
// "r": "0.0012",
|
|
160
|
+
// "tr": "0.0012",
|
|
161
|
+
// "h": "77196.3",
|
|
162
|
+
// "l": "75630.77",
|
|
163
|
+
// "v": "584664223.92",
|
|
164
|
+
// "q": "7666.720258",
|
|
165
|
+
// "lastRT": "-1",
|
|
166
|
+
// "MT": "0",
|
|
167
|
+
// "NV": "--",
|
|
168
|
+
// "t": "1731135533126"
|
|
169
|
+
// },
|
|
170
|
+
// "c": "spot@public.miniTicker.v3.api@BTCUSDT@UTC+8",
|
|
171
|
+
// "t": 1731135533126,
|
|
172
|
+
// "s": "BTCUSDT"
|
|
173
|
+
// }
|
|
174
|
+
//
|
|
111
175
|
this.handleBidAsk(client, message);
|
|
112
|
-
const rawTicker = this.
|
|
176
|
+
const rawTicker = this.safeDict2(message, 'd', 'data');
|
|
113
177
|
const marketId = this.safeString2(message, 's', 'symbol');
|
|
114
178
|
const timestamp = this.safeInteger(message, 't');
|
|
115
179
|
const market = this.safeMarket(marketId);
|
|
@@ -134,24 +198,51 @@ class mexc extends mexc$1 {
|
|
|
134
198
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
135
199
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
|
|
136
200
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
|
|
201
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#minitickers
|
|
137
202
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
138
203
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
204
|
+
* @param {boolean} [params.miniTicker] set to true for using the miniTicker endpoint
|
|
139
205
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
140
206
|
*/
|
|
141
207
|
await this.loadMarkets();
|
|
142
|
-
symbols = this.marketSymbols(symbols, undefined
|
|
208
|
+
symbols = this.marketSymbols(symbols, undefined);
|
|
143
209
|
const messageHashes = [];
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
210
|
+
const firstSymbol = this.safeString(symbols, 0);
|
|
211
|
+
let market = undefined;
|
|
212
|
+
if (firstSymbol !== undefined) {
|
|
213
|
+
market = this.market(firstSymbol);
|
|
214
|
+
}
|
|
215
|
+
let type = undefined;
|
|
216
|
+
[type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
|
|
217
|
+
const isSpot = (type === 'spot');
|
|
147
218
|
const url = (isSpot) ? this.urls['api']['ws']['spot'] : this.urls['api']['ws']['swap'];
|
|
148
219
|
const request = {};
|
|
149
220
|
if (isSpot) {
|
|
221
|
+
let miniTicker = false;
|
|
222
|
+
[miniTicker, params] = this.handleOptionAndParams(params, 'watchTickers', 'miniTicker');
|
|
150
223
|
const topics = [];
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
224
|
+
if (!miniTicker) {
|
|
225
|
+
if (symbols === undefined) {
|
|
226
|
+
throw new errors.ArgumentsRequired(this.id + 'watchTickers required symbols argument for the bookTicker channel');
|
|
227
|
+
}
|
|
228
|
+
const marketIds = this.marketIds(symbols);
|
|
229
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
230
|
+
const marketId = marketIds[i];
|
|
231
|
+
messageHashes.push('ticker:' + symbols[i]);
|
|
232
|
+
const channel = 'spot@public.bookTicker.v3.api@' + marketId;
|
|
233
|
+
topics.push(channel);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
topics.push('spot@public.miniTickers.v3.api@UTC+8');
|
|
238
|
+
if (symbols === undefined) {
|
|
239
|
+
messageHashes.push('spot:ticker');
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
243
|
+
messageHashes.push('ticker:' + symbols[i]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
155
246
|
}
|
|
156
247
|
request['method'] = 'SUBSCRIPTION';
|
|
157
248
|
request['params'] = topics;
|
|
@@ -170,6 +261,8 @@ class mexc extends mexc$1 {
|
|
|
170
261
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
171
262
|
}
|
|
172
263
|
handleTickers(client, message) {
|
|
264
|
+
//
|
|
265
|
+
// swap
|
|
173
266
|
//
|
|
174
267
|
// {
|
|
175
268
|
// "channel": "push.tickers",
|
|
@@ -192,15 +285,66 @@ class mexc extends mexc$1 {
|
|
|
192
285
|
// "ts": 1725872514111
|
|
193
286
|
// }
|
|
194
287
|
//
|
|
195
|
-
|
|
196
|
-
|
|
288
|
+
// spot
|
|
289
|
+
//
|
|
290
|
+
// {
|
|
291
|
+
// "c": "spot@public.bookTicker.v3.api@BTCUSDT",
|
|
292
|
+
// "d": {
|
|
293
|
+
// "A": "4.70432",
|
|
294
|
+
// "B": "6.714863",
|
|
295
|
+
// "a": "20744.54",
|
|
296
|
+
// "b": "20744.17"
|
|
297
|
+
// },
|
|
298
|
+
// "s": "BTCUSDT",
|
|
299
|
+
// "t": 1678643605721
|
|
300
|
+
// }
|
|
301
|
+
//
|
|
302
|
+
// spot miniTicker
|
|
303
|
+
//
|
|
304
|
+
// {
|
|
305
|
+
// "d": {
|
|
306
|
+
// "s": "BTCUSDT",
|
|
307
|
+
// "p": "76522",
|
|
308
|
+
// "r": "0.0012",
|
|
309
|
+
// "tr": "0.0012",
|
|
310
|
+
// "h": "77196.3",
|
|
311
|
+
// "l": "75630.77",
|
|
312
|
+
// "v": "584664223.92",
|
|
313
|
+
// "q": "7666.720258",
|
|
314
|
+
// "lastRT": "-1",
|
|
315
|
+
// "MT": "0",
|
|
316
|
+
// "NV": "--",
|
|
317
|
+
// "t": "1731135533126"
|
|
318
|
+
// },
|
|
319
|
+
// "c": "spot@public.miniTicker.v3.api@BTCUSDT@UTC+8",
|
|
320
|
+
// "t": 1731135533126,
|
|
321
|
+
// "s": "BTCUSDT"
|
|
322
|
+
// }
|
|
323
|
+
//
|
|
324
|
+
const data = this.safeList2(message, 'data', 'd');
|
|
325
|
+
const channel = this.safeString(message, 'c', '');
|
|
326
|
+
const marketId = this.safeString(message, 's');
|
|
327
|
+
const market = this.safeMarket(marketId);
|
|
328
|
+
const channelStartsWithSpot = channel.startsWith('spot');
|
|
329
|
+
const marketIdIsUndefined = marketId === undefined;
|
|
330
|
+
const isSpot = marketIdIsUndefined ? channelStartsWithSpot : market['spot'];
|
|
331
|
+
const spotPrefix = 'spot:';
|
|
332
|
+
const messageHashPrefix = isSpot ? spotPrefix : '';
|
|
333
|
+
const topic = messageHashPrefix + 'ticker';
|
|
197
334
|
const result = [];
|
|
198
335
|
for (let i = 0; i < data.length; i++) {
|
|
199
|
-
const
|
|
336
|
+
const entry = data[i];
|
|
337
|
+
let ticker = undefined;
|
|
338
|
+
if (isSpot) {
|
|
339
|
+
ticker = this.parseWsTicker(entry, market);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
ticker = this.parseTicker(entry);
|
|
343
|
+
}
|
|
200
344
|
const symbol = ticker['symbol'];
|
|
201
345
|
this.tickers[symbol] = ticker;
|
|
202
346
|
result.push(ticker);
|
|
203
|
-
const messageHash =
|
|
347
|
+
const messageHash = 'ticker:' + symbol;
|
|
204
348
|
client.resolve(ticker, messageHash);
|
|
205
349
|
}
|
|
206
350
|
client.resolve(result, topic);
|
|
@@ -208,21 +352,44 @@ class mexc extends mexc$1 {
|
|
|
208
352
|
parseWsTicker(ticker, market = undefined) {
|
|
209
353
|
//
|
|
210
354
|
// spot
|
|
211
|
-
// {
|
|
212
|
-
// "A": "4.70432",
|
|
213
|
-
// "B": "6.714863",
|
|
214
|
-
// "a": "20744.54",
|
|
215
|
-
// "b": "20744.17"
|
|
216
|
-
// }
|
|
217
355
|
//
|
|
356
|
+
// {
|
|
357
|
+
// "A": "4.70432",
|
|
358
|
+
// "B": "6.714863",
|
|
359
|
+
// "a": "20744.54",
|
|
360
|
+
// "b": "20744.17"
|
|
361
|
+
// }
|
|
362
|
+
//
|
|
363
|
+
// spot miniTicker
|
|
364
|
+
//
|
|
365
|
+
// {
|
|
366
|
+
// "s": "BTCUSDT",
|
|
367
|
+
// "p": "76522",
|
|
368
|
+
// "r": "0.0012",
|
|
369
|
+
// "tr": "0.0012",
|
|
370
|
+
// "h": "77196.3",
|
|
371
|
+
// "l": "75630.77",
|
|
372
|
+
// "v": "584664223.92",
|
|
373
|
+
// "q": "7666.720258",
|
|
374
|
+
// "lastRT": "-1",
|
|
375
|
+
// "MT": "0",
|
|
376
|
+
// "NV": "--",
|
|
377
|
+
// "t": "1731135533126"
|
|
378
|
+
// }
|
|
379
|
+
//
|
|
380
|
+
const marketId = this.safeString(ticker, 's');
|
|
381
|
+
const timestamp = this.safeInteger(ticker, 't');
|
|
382
|
+
const price = this.safeString(ticker, 'p');
|
|
218
383
|
return this.safeTicker({
|
|
219
|
-
'
|
|
220
|
-
'
|
|
221
|
-
'
|
|
384
|
+
'info': ticker,
|
|
385
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
386
|
+
'timestamp': timestamp,
|
|
387
|
+
'datetime': this.iso8601(timestamp),
|
|
222
388
|
'open': undefined,
|
|
223
|
-
'high':
|
|
224
|
-
'low':
|
|
225
|
-
'close':
|
|
389
|
+
'high': this.safeNumber(ticker, 'h'),
|
|
390
|
+
'low': this.safeNumber(ticker, 'l'),
|
|
391
|
+
'close': price,
|
|
392
|
+
'last': price,
|
|
226
393
|
'bid': this.safeNumber(ticker, 'b'),
|
|
227
394
|
'bidVolume': this.safeNumber(ticker, 'B'),
|
|
228
395
|
'ask': this.safeNumber(ticker, 'a'),
|
|
@@ -230,11 +397,10 @@ class mexc extends mexc$1 {
|
|
|
230
397
|
'vwap': undefined,
|
|
231
398
|
'previousClose': undefined,
|
|
232
399
|
'change': undefined,
|
|
233
|
-
'percentage':
|
|
400
|
+
'percentage': this.safeNumber(ticker, 'tr'),
|
|
234
401
|
'average': undefined,
|
|
235
|
-
'baseVolume':
|
|
236
|
-
'quoteVolume':
|
|
237
|
-
'info': ticker,
|
|
402
|
+
'baseVolume': this.safeNumber(ticker, 'v'),
|
|
403
|
+
'quoteVolume': this.safeNumber(ticker, 'q'),
|
|
238
404
|
}, market);
|
|
239
405
|
}
|
|
240
406
|
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
@@ -1337,6 +1503,8 @@ class mexc extends mexc$1 {
|
|
|
1337
1503
|
'public.kline.v3.api': this.handleOHLCV,
|
|
1338
1504
|
'push.kline': this.handleOHLCV,
|
|
1339
1505
|
'public.bookTicker.v3.api': this.handleTicker,
|
|
1506
|
+
'public.miniTicker.v3.api': this.handleTicker,
|
|
1507
|
+
'public.miniTickers.v3.api': this.handleTickers,
|
|
1340
1508
|
'push.ticker': this.handleTicker,
|
|
1341
1509
|
'push.tickers': this.handleTickers,
|
|
1342
1510
|
'public.increase.depth.v3.api': this.handleOrderBook,
|
package/dist/cjs/src/vertex.js
CHANGED
|
@@ -2892,13 +2892,58 @@ class vertex extends vertex$1 {
|
|
|
2892
2892
|
};
|
|
2893
2893
|
const response = await this.v1GatewayPostExecute(this.extend(request, params));
|
|
2894
2894
|
//
|
|
2895
|
-
//
|
|
2896
|
-
//
|
|
2897
|
-
//
|
|
2898
|
-
//
|
|
2899
|
-
//
|
|
2895
|
+
// {
|
|
2896
|
+
// "status": "success",
|
|
2897
|
+
// "signature": {signature},
|
|
2898
|
+
// "request_type": "execute_withdraw_collateral"
|
|
2899
|
+
// }
|
|
2900
2900
|
//
|
|
2901
|
-
|
|
2901
|
+
const transaction = this.parseTransaction(response, currency);
|
|
2902
|
+
return this.extend(transaction, {
|
|
2903
|
+
'amount': amount,
|
|
2904
|
+
'address': address,
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
parseTransaction(transaction, currency = undefined) {
|
|
2908
|
+
//
|
|
2909
|
+
// {
|
|
2910
|
+
// "status": "success",
|
|
2911
|
+
// "signature": {signature},
|
|
2912
|
+
// "request_type": "execute_withdraw_collateral"
|
|
2913
|
+
// }
|
|
2914
|
+
//
|
|
2915
|
+
let code = undefined;
|
|
2916
|
+
if (currency !== undefined) {
|
|
2917
|
+
code = currency['code'];
|
|
2918
|
+
}
|
|
2919
|
+
return {
|
|
2920
|
+
'info': transaction,
|
|
2921
|
+
'id': undefined,
|
|
2922
|
+
'txid': undefined,
|
|
2923
|
+
'timestamp': undefined,
|
|
2924
|
+
'datetime': undefined,
|
|
2925
|
+
'addressFrom': undefined,
|
|
2926
|
+
'address': undefined,
|
|
2927
|
+
'addressTo': undefined,
|
|
2928
|
+
'tagFrom': undefined,
|
|
2929
|
+
'tag': undefined,
|
|
2930
|
+
'tagTo': undefined,
|
|
2931
|
+
'type': 'withdrawal',
|
|
2932
|
+
'amount': undefined,
|
|
2933
|
+
'currency': code,
|
|
2934
|
+
'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
|
|
2935
|
+
'updated': undefined,
|
|
2936
|
+
'network': undefined,
|
|
2937
|
+
'comment': undefined,
|
|
2938
|
+
'internal': undefined,
|
|
2939
|
+
'fee': undefined,
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
parseTransactionStatus(status) {
|
|
2943
|
+
const statuses = {
|
|
2944
|
+
'success': 'ok',
|
|
2945
|
+
};
|
|
2946
|
+
return this.safeString(statuses, status, status);
|
|
2902
2947
|
}
|
|
2903
2948
|
handlePublicAddress(methodName, params) {
|
|
2904
2949
|
let userAux = undefined;
|