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
package/js/src/coincatch.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export default class coincatch extends Exchange {
|
|
|
60
60
|
parseDepositAddress(depositAddress: any, currency?: Currency): DepositAddress;
|
|
61
61
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
62
62
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
63
|
-
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<
|
|
63
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
64
64
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
65
65
|
createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
|
|
66
66
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
|
package/js/src/coincatch.js
CHANGED
|
@@ -2076,13 +2076,23 @@ export default class coincatch extends Exchange {
|
|
|
2076
2076
|
request['chain'] = this.networkCodeToId(networkCode);
|
|
2077
2077
|
}
|
|
2078
2078
|
const response = await this.privatePostApiSpotV1WalletWithdrawalV2(this.extend(request, params));
|
|
2079
|
-
// todo add after withdrawal
|
|
2080
2079
|
//
|
|
2081
|
-
|
|
2080
|
+
// {
|
|
2081
|
+
// "code": "00000",
|
|
2082
|
+
// "msg": "success",
|
|
2083
|
+
// "data": {
|
|
2084
|
+
// "orderId":888291686266343424",
|
|
2085
|
+
// "clientOrderId":"123"
|
|
2086
|
+
// }
|
|
2087
|
+
// }
|
|
2088
|
+
//
|
|
2089
|
+
const data = this.safeDict(response, 'data', {});
|
|
2090
|
+
return this.parseTransaction(data, currency);
|
|
2082
2091
|
}
|
|
2083
2092
|
parseTransaction(transaction, currency = undefined) {
|
|
2084
2093
|
//
|
|
2085
2094
|
// fetchDeposits
|
|
2095
|
+
//
|
|
2086
2096
|
// {
|
|
2087
2097
|
// "id": "1213046466852196352",
|
|
2088
2098
|
// "txId": "824246b030cd84d56400661303547f43a1d9fef66cf968628dd5112f362053ff",
|
|
@@ -2102,7 +2112,17 @@ export default class coincatch extends Exchange {
|
|
|
2102
2112
|
// "uTime": "1724938746015"
|
|
2103
2113
|
// }
|
|
2104
2114
|
//
|
|
2105
|
-
|
|
2115
|
+
// withdraw
|
|
2116
|
+
//
|
|
2117
|
+
// {
|
|
2118
|
+
// "code": "00000",
|
|
2119
|
+
// "msg": "success",
|
|
2120
|
+
// "data": {
|
|
2121
|
+
// "orderId":888291686266343424",
|
|
2122
|
+
// "clientOrderId":"123"
|
|
2123
|
+
// }
|
|
2124
|
+
// }
|
|
2125
|
+
//
|
|
2106
2126
|
let status = this.safeString(transaction, 'status');
|
|
2107
2127
|
if (status === 'success') {
|
|
2108
2128
|
status = 'ok';
|
|
@@ -2128,7 +2148,7 @@ export default class coincatch extends Exchange {
|
|
|
2128
2148
|
}
|
|
2129
2149
|
return {
|
|
2130
2150
|
'info': transaction,
|
|
2131
|
-
'id': id,
|
|
2151
|
+
'id': this.safeString2(transaction, 'id', 'orderId'),
|
|
2132
2152
|
'txid': txid,
|
|
2133
2153
|
'timestamp': timestamp,
|
|
2134
2154
|
'datetime': this.iso8601(timestamp),
|
package/js/src/deribit.js
CHANGED
|
@@ -857,6 +857,8 @@ export default class deribit extends Exchange {
|
|
|
857
857
|
else if (isSpot) {
|
|
858
858
|
type = 'spot';
|
|
859
859
|
}
|
|
860
|
+
let inverse = undefined;
|
|
861
|
+
let linear = undefined;
|
|
860
862
|
if (isSpot) {
|
|
861
863
|
symbol = base + '/' + quote;
|
|
862
864
|
}
|
|
@@ -871,6 +873,8 @@ export default class deribit extends Exchange {
|
|
|
871
873
|
symbol = symbol + '-' + this.numberToString(strike) + '-' + letter;
|
|
872
874
|
}
|
|
873
875
|
}
|
|
876
|
+
inverse = (quote !== settle);
|
|
877
|
+
linear = (settle === quote);
|
|
874
878
|
}
|
|
875
879
|
const parsedMarketValue = this.safeValue(parsedMarkets, symbol);
|
|
876
880
|
if (parsedMarketValue) {
|
|
@@ -896,8 +900,8 @@ export default class deribit extends Exchange {
|
|
|
896
900
|
'option': option,
|
|
897
901
|
'active': this.safeValue(market, 'is_active'),
|
|
898
902
|
'contract': !isSpot,
|
|
899
|
-
'linear':
|
|
900
|
-
'inverse':
|
|
903
|
+
'linear': linear,
|
|
904
|
+
'inverse': inverse,
|
|
901
905
|
'taker': this.safeNumber(market, 'taker_commission'),
|
|
902
906
|
'maker': this.safeNumber(market, 'maker_commission'),
|
|
903
907
|
'contractSize': this.safeNumber(market, 'contract_size'),
|
|
@@ -1763,7 +1767,7 @@ export default class deribit extends Exchange {
|
|
|
1763
1767
|
const filledString = this.safeString(order, 'filled_amount');
|
|
1764
1768
|
const amount = this.safeString(order, 'amount');
|
|
1765
1769
|
let cost = Precise.stringMul(filledString, averageString);
|
|
1766
|
-
if (market
|
|
1770
|
+
if (this.safeBool(market, 'inverse')) {
|
|
1767
1771
|
if (averageString !== '0') {
|
|
1768
1772
|
cost = Precise.stringDiv(amount, averageString);
|
|
1769
1773
|
}
|
package/js/src/hyperliquid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/hyperliquid.js';
|
|
2
|
-
import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification, Currencies, CancellationRequest, int, Transaction, Currency, TradingFeeInterface, Ticker, Tickers, LedgerEntry } from './base/types.js';
|
|
2
|
+
import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification, Currencies, CancellationRequest, int, Transaction, Currency, TradingFeeInterface, Ticker, Tickers, LedgerEntry, FundingRates, FundingRate } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class hyperliquid
|
|
5
5
|
* @augments Exchange
|
|
@@ -15,6 +15,8 @@ export default class hyperliquid extends Exchange {
|
|
|
15
15
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
16
16
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
17
17
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
18
|
+
fetchFundingRates(symbols?: Strings, params?: {}): Promise<FundingRates>;
|
|
19
|
+
parseFundingRate(info: any, market?: Market): FundingRate;
|
|
18
20
|
parseTicker(ticker: Dict, market?: Market): Ticker;
|
|
19
21
|
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
20
22
|
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
|
package/js/src/hyperliquid.js
CHANGED
|
@@ -71,7 +71,7 @@ export default class hyperliquid extends Exchange {
|
|
|
71
71
|
'fetchFundingHistory': false,
|
|
72
72
|
'fetchFundingRate': false,
|
|
73
73
|
'fetchFundingRateHistory': true,
|
|
74
|
-
'fetchFundingRates':
|
|
74
|
+
'fetchFundingRates': true,
|
|
75
75
|
'fetchIndexOHLCV': false,
|
|
76
76
|
'fetchIsolatedBorrowRate': false,
|
|
77
77
|
'fetchIsolatedBorrowRates': false,
|
|
@@ -127,12 +127,12 @@ export default class hyperliquid extends Exchange {
|
|
|
127
127
|
'1h': '1h',
|
|
128
128
|
'2h': '2h',
|
|
129
129
|
'4h': '4h',
|
|
130
|
-
'
|
|
130
|
+
'8h': '8h',
|
|
131
131
|
'12h': '12h',
|
|
132
132
|
'1d': '1d',
|
|
133
133
|
'3d': '3d',
|
|
134
134
|
'1w': '1w',
|
|
135
|
-
'1M': '
|
|
135
|
+
'1M': '1M',
|
|
136
136
|
},
|
|
137
137
|
'hostname': 'hyperliquid.xyz',
|
|
138
138
|
'urls': {
|
|
@@ -749,6 +749,110 @@ export default class hyperliquid extends Exchange {
|
|
|
749
749
|
}
|
|
750
750
|
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
751
751
|
}
|
|
752
|
+
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
753
|
+
/**
|
|
754
|
+
* @method
|
|
755
|
+
* @name hyperliquid#fetchFundingRates
|
|
756
|
+
* @description retrieves data on all swap markets for hyperliquid
|
|
757
|
+
* @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
|
|
758
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
759
|
+
* @returns {object[]} an array of objects representing market data
|
|
760
|
+
*/
|
|
761
|
+
const request = {
|
|
762
|
+
'type': 'metaAndAssetCtxs',
|
|
763
|
+
};
|
|
764
|
+
const response = await this.publicPostInfo(this.extend(request, params));
|
|
765
|
+
//
|
|
766
|
+
// [
|
|
767
|
+
// {
|
|
768
|
+
// "universe": [
|
|
769
|
+
// {
|
|
770
|
+
// "maxLeverage": 50,
|
|
771
|
+
// "name": "SOL",
|
|
772
|
+
// "onlyIsolated": false,
|
|
773
|
+
// "szDecimals": 2
|
|
774
|
+
// }
|
|
775
|
+
// ]
|
|
776
|
+
// },
|
|
777
|
+
// [
|
|
778
|
+
// {
|
|
779
|
+
// "dayNtlVlm": "9450588.2273",
|
|
780
|
+
// "funding": "0.0000198",
|
|
781
|
+
// "impactPxs": [
|
|
782
|
+
// "108.04",
|
|
783
|
+
// "108.06"
|
|
784
|
+
// ],
|
|
785
|
+
// "markPx": "108.04",
|
|
786
|
+
// "midPx": "108.05",
|
|
787
|
+
// "openInterest": "10764.48",
|
|
788
|
+
// "oraclePx": "107.99",
|
|
789
|
+
// "premium": "0.00055561",
|
|
790
|
+
// "prevDayPx": "111.81"
|
|
791
|
+
// }
|
|
792
|
+
// ]
|
|
793
|
+
// ]
|
|
794
|
+
//
|
|
795
|
+
//
|
|
796
|
+
const meta = this.safeDict(response, 0, {});
|
|
797
|
+
const universe = this.safeList(meta, 'universe', []);
|
|
798
|
+
const assetCtxs = this.safeList(response, 1, []);
|
|
799
|
+
const result = [];
|
|
800
|
+
for (let i = 0; i < universe.length; i++) {
|
|
801
|
+
const data = this.extend(this.safeDict(universe, i, {}), this.safeDict(assetCtxs, i, {}));
|
|
802
|
+
result.push(data);
|
|
803
|
+
}
|
|
804
|
+
const funding_rates = this.parseFundingRates(result);
|
|
805
|
+
return this.filterByArray(funding_rates, 'symbol', symbols);
|
|
806
|
+
}
|
|
807
|
+
parseFundingRate(info, market = undefined) {
|
|
808
|
+
//
|
|
809
|
+
// {
|
|
810
|
+
// "maxLeverage": "50",
|
|
811
|
+
// "name": "ETH",
|
|
812
|
+
// "onlyIsolated": false,
|
|
813
|
+
// "szDecimals": "4",
|
|
814
|
+
// "dayNtlVlm": "1709813.11535",
|
|
815
|
+
// "funding": "0.00004807",
|
|
816
|
+
// "impactPxs": [
|
|
817
|
+
// "2369.3",
|
|
818
|
+
// "2369.6"
|
|
819
|
+
// ],
|
|
820
|
+
// "markPx": "2369.6",
|
|
821
|
+
// "midPx": "2369.45",
|
|
822
|
+
// "openInterest": "1815.4712",
|
|
823
|
+
// "oraclePx": "2367.3",
|
|
824
|
+
// "premium": "0.00090821",
|
|
825
|
+
// "prevDayPx": "2381.5"
|
|
826
|
+
// }
|
|
827
|
+
//
|
|
828
|
+
const base = this.safeString(info, 'name');
|
|
829
|
+
const marketId = this.coinToMarketId(base);
|
|
830
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
831
|
+
const funding = this.safeNumber(info, 'funding');
|
|
832
|
+
const markPx = this.safeNumber(info, 'markPx');
|
|
833
|
+
const oraclePx = this.safeNumber(info, 'oraclePx');
|
|
834
|
+
const fundingTimestamp = (Math.floor(this.milliseconds() / 60 / 60 / 1000) + 1) * 60 * 60 * 1000;
|
|
835
|
+
return {
|
|
836
|
+
'info': info,
|
|
837
|
+
'symbol': symbol,
|
|
838
|
+
'markPrice': markPx,
|
|
839
|
+
'indexPrice': oraclePx,
|
|
840
|
+
'interestRate': undefined,
|
|
841
|
+
'estimatedSettlePrice': undefined,
|
|
842
|
+
'timestamp': undefined,
|
|
843
|
+
'datetime': undefined,
|
|
844
|
+
'fundingRate': funding,
|
|
845
|
+
'fundingTimestamp': fundingTimestamp,
|
|
846
|
+
'fundingDatetime': this.iso8601(fundingTimestamp),
|
|
847
|
+
'nextFundingRate': undefined,
|
|
848
|
+
'nextFundingTimestamp': undefined,
|
|
849
|
+
'nextFundingDatetime': undefined,
|
|
850
|
+
'previousFundingRate': undefined,
|
|
851
|
+
'previousFundingTimestamp': undefined,
|
|
852
|
+
'previousFundingDatetime': undefined,
|
|
853
|
+
'interval': '1h',
|
|
854
|
+
};
|
|
855
|
+
}
|
|
752
856
|
parseTicker(ticker, market = undefined) {
|
|
753
857
|
//
|
|
754
858
|
// {
|
|
@@ -813,7 +917,7 @@ export default class hyperliquid extends Exchange {
|
|
|
813
917
|
'type': 'candleSnapshot',
|
|
814
918
|
'req': {
|
|
815
919
|
'coin': market['swap'] ? market['base'] : market['id'],
|
|
816
|
-
'interval': timeframe,
|
|
920
|
+
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
817
921
|
'startTime': since,
|
|
818
922
|
'endTime': until,
|
|
819
923
|
},
|
package/js/src/lbank.js
CHANGED
|
@@ -1196,6 +1196,12 @@ export default class lbank extends Exchange {
|
|
|
1196
1196
|
const indexPrice = this.safeNumber(ticker, 'underlyingPrice');
|
|
1197
1197
|
const fundingRate = this.safeNumber(ticker, 'fundingRate');
|
|
1198
1198
|
const fundingTime = this.safeInteger(ticker, 'nextFeeTime');
|
|
1199
|
+
const positionFeeTime = this.safeInteger(ticker, 'positionFeeTime');
|
|
1200
|
+
let intervalString = undefined;
|
|
1201
|
+
if (positionFeeTime !== undefined) {
|
|
1202
|
+
const interval = this.parseToInt(positionFeeTime / 60 / 60);
|
|
1203
|
+
intervalString = interval.toString() + 'h';
|
|
1204
|
+
}
|
|
1199
1205
|
return {
|
|
1200
1206
|
'info': ticker,
|
|
1201
1207
|
'symbol': symbol,
|
|
@@ -1212,7 +1218,7 @@ export default class lbank extends Exchange {
|
|
|
1212
1218
|
'previousFundingRate': undefined,
|
|
1213
1219
|
'previousFundingTimestamp': undefined,
|
|
1214
1220
|
'previousFundingDatetime': undefined,
|
|
1215
|
-
'interval':
|
|
1221
|
+
'interval': intervalString,
|
|
1216
1222
|
};
|
|
1217
1223
|
}
|
|
1218
1224
|
async fetchFundingRate(symbol, params = {}) {
|
package/js/src/pro/bitvavo.js
CHANGED
|
@@ -776,7 +776,8 @@ export default class bitvavo extends bitvavoRest {
|
|
|
776
776
|
const messageHash = this.buildMessageHash(action, request);
|
|
777
777
|
this.checkMessageHashDoesNotExist(messageHash);
|
|
778
778
|
const url = this.urls['api']['ws'];
|
|
779
|
-
|
|
779
|
+
const randomSubHash = this.randNumber(5).toString() + ':' + messageHash;
|
|
780
|
+
return await this.watch(url, messageHash, request, randomSubHash);
|
|
780
781
|
}
|
|
781
782
|
async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
782
783
|
/**
|
package/js/src/pro/blofin.js
CHANGED
|
@@ -688,7 +688,8 @@ export default class blofin extends blofinRest {
|
|
|
688
688
|
return;
|
|
689
689
|
}
|
|
690
690
|
else if (event === 'login') {
|
|
691
|
-
client.
|
|
691
|
+
const future = this.safeValue(client.futures, 'authenticate_hash');
|
|
692
|
+
future.resolve(true);
|
|
692
693
|
return;
|
|
693
694
|
}
|
|
694
695
|
else if (event === 'error') {
|
package/js/src/pro/mexc.js
CHANGED
|
@@ -78,15 +78,25 @@ export default class mexc extends mexcRest {
|
|
|
78
78
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
79
79
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
|
|
80
80
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
|
|
81
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#miniticker
|
|
81
82
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
82
83
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
84
|
+
* @param {boolean} [params.miniTicker] set to true for using the miniTicker endpoint
|
|
83
85
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
84
86
|
*/
|
|
85
87
|
await this.loadMarkets();
|
|
86
88
|
const market = this.market(symbol);
|
|
87
89
|
const messageHash = 'ticker:' + market['symbol'];
|
|
88
90
|
if (market['spot']) {
|
|
89
|
-
|
|
91
|
+
let miniTicker = false;
|
|
92
|
+
[miniTicker, params] = this.handleOptionAndParams(params, 'watchTicker', 'miniTicker');
|
|
93
|
+
let channel = undefined;
|
|
94
|
+
if (miniTicker) {
|
|
95
|
+
channel = 'spot@public.miniTicker.v3.api@' + market['id'] + '@UTC+8';
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
channel = 'spot@public.bookTicker.v3.api@' + market['id'];
|
|
99
|
+
}
|
|
90
100
|
return await this.watchSpotPublic(channel, messageHash, params);
|
|
91
101
|
}
|
|
92
102
|
else {
|
|
@@ -98,6 +108,38 @@ export default class mexc extends mexcRest {
|
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
handleTicker(client, message) {
|
|
111
|
+
//
|
|
112
|
+
// swap
|
|
113
|
+
//
|
|
114
|
+
// {
|
|
115
|
+
// "symbol": "BTC_USDT",
|
|
116
|
+
// "data": {
|
|
117
|
+
// "symbol": "BTC_USDT",
|
|
118
|
+
// "lastPrice": 76376.2,
|
|
119
|
+
// "riseFallRate": -0.0006,
|
|
120
|
+
// "fairPrice": 76374.4,
|
|
121
|
+
// "indexPrice": 76385.8,
|
|
122
|
+
// "volume24": 962062810,
|
|
123
|
+
// "amount24": 7344207079.96768,
|
|
124
|
+
// "maxBidPrice": 84024.3,
|
|
125
|
+
// "minAskPrice": 68747.2,
|
|
126
|
+
// "lower24Price": 75620.2,
|
|
127
|
+
// "high24Price": 77210,
|
|
128
|
+
// "timestamp": 1731137509138,
|
|
129
|
+
// "bid1": 76376.2,
|
|
130
|
+
// "ask1": 76376.3,
|
|
131
|
+
// "holdVol": 95479623,
|
|
132
|
+
// "riseFallValue": -46.5,
|
|
133
|
+
// "fundingRate": 0.0001,
|
|
134
|
+
// "zone": "UTC+8",
|
|
135
|
+
// "riseFallRates": [ -0.0006, 0.1008, 0.2262, 0.2628, 0.2439, 1.0564 ],
|
|
136
|
+
// "riseFallRatesOfTimezone": [ 0.0065, -0.0013, -0.0006 ]
|
|
137
|
+
// },
|
|
138
|
+
// "channel": "push.ticker",
|
|
139
|
+
// "ts": 1731137509138
|
|
140
|
+
// }
|
|
141
|
+
//
|
|
142
|
+
// spot
|
|
101
143
|
//
|
|
102
144
|
// {
|
|
103
145
|
// "c": "spot@public.bookTicker.v3.api@BTCUSDT",
|
|
@@ -111,8 +153,30 @@ export default class mexc extends mexcRest {
|
|
|
111
153
|
// "t": 1678643605721
|
|
112
154
|
// }
|
|
113
155
|
//
|
|
156
|
+
// spot miniTicker
|
|
157
|
+
//
|
|
158
|
+
// {
|
|
159
|
+
// "d": {
|
|
160
|
+
// "s": "BTCUSDT",
|
|
161
|
+
// "p": "76522",
|
|
162
|
+
// "r": "0.0012",
|
|
163
|
+
// "tr": "0.0012",
|
|
164
|
+
// "h": "77196.3",
|
|
165
|
+
// "l": "75630.77",
|
|
166
|
+
// "v": "584664223.92",
|
|
167
|
+
// "q": "7666.720258",
|
|
168
|
+
// "lastRT": "-1",
|
|
169
|
+
// "MT": "0",
|
|
170
|
+
// "NV": "--",
|
|
171
|
+
// "t": "1731135533126"
|
|
172
|
+
// },
|
|
173
|
+
// "c": "spot@public.miniTicker.v3.api@BTCUSDT@UTC+8",
|
|
174
|
+
// "t": 1731135533126,
|
|
175
|
+
// "s": "BTCUSDT"
|
|
176
|
+
// }
|
|
177
|
+
//
|
|
114
178
|
this.handleBidAsk(client, message);
|
|
115
|
-
const rawTicker = this.
|
|
179
|
+
const rawTicker = this.safeDict2(message, 'd', 'data');
|
|
116
180
|
const marketId = this.safeString2(message, 's', 'symbol');
|
|
117
181
|
const timestamp = this.safeInteger(message, 't');
|
|
118
182
|
const market = this.safeMarket(marketId);
|
|
@@ -137,24 +201,51 @@ export default class mexc extends mexcRest {
|
|
|
137
201
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
138
202
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
|
|
139
203
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
|
|
204
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#minitickers
|
|
140
205
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
141
206
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
207
|
+
* @param {boolean} [params.miniTicker] set to true for using the miniTicker endpoint
|
|
142
208
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
143
209
|
*/
|
|
144
210
|
await this.loadMarkets();
|
|
145
|
-
symbols = this.marketSymbols(symbols, undefined
|
|
211
|
+
symbols = this.marketSymbols(symbols, undefined);
|
|
146
212
|
const messageHashes = [];
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
213
|
+
const firstSymbol = this.safeString(symbols, 0);
|
|
214
|
+
let market = undefined;
|
|
215
|
+
if (firstSymbol !== undefined) {
|
|
216
|
+
market = this.market(firstSymbol);
|
|
217
|
+
}
|
|
218
|
+
let type = undefined;
|
|
219
|
+
[type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
|
|
220
|
+
const isSpot = (type === 'spot');
|
|
150
221
|
const url = (isSpot) ? this.urls['api']['ws']['spot'] : this.urls['api']['ws']['swap'];
|
|
151
222
|
const request = {};
|
|
152
223
|
if (isSpot) {
|
|
224
|
+
let miniTicker = false;
|
|
225
|
+
[miniTicker, params] = this.handleOptionAndParams(params, 'watchTickers', 'miniTicker');
|
|
153
226
|
const topics = [];
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
227
|
+
if (!miniTicker) {
|
|
228
|
+
if (symbols === undefined) {
|
|
229
|
+
throw new ArgumentsRequired(this.id + 'watchTickers required symbols argument for the bookTicker channel');
|
|
230
|
+
}
|
|
231
|
+
const marketIds = this.marketIds(symbols);
|
|
232
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
233
|
+
const marketId = marketIds[i];
|
|
234
|
+
messageHashes.push('ticker:' + symbols[i]);
|
|
235
|
+
const channel = 'spot@public.bookTicker.v3.api@' + marketId;
|
|
236
|
+
topics.push(channel);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
topics.push('spot@public.miniTickers.v3.api@UTC+8');
|
|
241
|
+
if (symbols === undefined) {
|
|
242
|
+
messageHashes.push('spot:ticker');
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
246
|
+
messageHashes.push('ticker:' + symbols[i]);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
158
249
|
}
|
|
159
250
|
request['method'] = 'SUBSCRIPTION';
|
|
160
251
|
request['params'] = topics;
|
|
@@ -173,6 +264,8 @@ export default class mexc extends mexcRest {
|
|
|
173
264
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
174
265
|
}
|
|
175
266
|
handleTickers(client, message) {
|
|
267
|
+
//
|
|
268
|
+
// swap
|
|
176
269
|
//
|
|
177
270
|
// {
|
|
178
271
|
// "channel": "push.tickers",
|
|
@@ -195,15 +288,66 @@ export default class mexc extends mexcRest {
|
|
|
195
288
|
// "ts": 1725872514111
|
|
196
289
|
// }
|
|
197
290
|
//
|
|
198
|
-
|
|
199
|
-
|
|
291
|
+
// spot
|
|
292
|
+
//
|
|
293
|
+
// {
|
|
294
|
+
// "c": "spot@public.bookTicker.v3.api@BTCUSDT",
|
|
295
|
+
// "d": {
|
|
296
|
+
// "A": "4.70432",
|
|
297
|
+
// "B": "6.714863",
|
|
298
|
+
// "a": "20744.54",
|
|
299
|
+
// "b": "20744.17"
|
|
300
|
+
// },
|
|
301
|
+
// "s": "BTCUSDT",
|
|
302
|
+
// "t": 1678643605721
|
|
303
|
+
// }
|
|
304
|
+
//
|
|
305
|
+
// spot miniTicker
|
|
306
|
+
//
|
|
307
|
+
// {
|
|
308
|
+
// "d": {
|
|
309
|
+
// "s": "BTCUSDT",
|
|
310
|
+
// "p": "76522",
|
|
311
|
+
// "r": "0.0012",
|
|
312
|
+
// "tr": "0.0012",
|
|
313
|
+
// "h": "77196.3",
|
|
314
|
+
// "l": "75630.77",
|
|
315
|
+
// "v": "584664223.92",
|
|
316
|
+
// "q": "7666.720258",
|
|
317
|
+
// "lastRT": "-1",
|
|
318
|
+
// "MT": "0",
|
|
319
|
+
// "NV": "--",
|
|
320
|
+
// "t": "1731135533126"
|
|
321
|
+
// },
|
|
322
|
+
// "c": "spot@public.miniTicker.v3.api@BTCUSDT@UTC+8",
|
|
323
|
+
// "t": 1731135533126,
|
|
324
|
+
// "s": "BTCUSDT"
|
|
325
|
+
// }
|
|
326
|
+
//
|
|
327
|
+
const data = this.safeList2(message, 'data', 'd');
|
|
328
|
+
const channel = this.safeString(message, 'c', '');
|
|
329
|
+
const marketId = this.safeString(message, 's');
|
|
330
|
+
const market = this.safeMarket(marketId);
|
|
331
|
+
const channelStartsWithSpot = channel.startsWith('spot');
|
|
332
|
+
const marketIdIsUndefined = marketId === undefined;
|
|
333
|
+
const isSpot = marketIdIsUndefined ? channelStartsWithSpot : market['spot'];
|
|
334
|
+
const spotPrefix = 'spot:';
|
|
335
|
+
const messageHashPrefix = isSpot ? spotPrefix : '';
|
|
336
|
+
const topic = messageHashPrefix + 'ticker';
|
|
200
337
|
const result = [];
|
|
201
338
|
for (let i = 0; i < data.length; i++) {
|
|
202
|
-
const
|
|
339
|
+
const entry = data[i];
|
|
340
|
+
let ticker = undefined;
|
|
341
|
+
if (isSpot) {
|
|
342
|
+
ticker = this.parseWsTicker(entry, market);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
ticker = this.parseTicker(entry);
|
|
346
|
+
}
|
|
203
347
|
const symbol = ticker['symbol'];
|
|
204
348
|
this.tickers[symbol] = ticker;
|
|
205
349
|
result.push(ticker);
|
|
206
|
-
const messageHash =
|
|
350
|
+
const messageHash = 'ticker:' + symbol;
|
|
207
351
|
client.resolve(ticker, messageHash);
|
|
208
352
|
}
|
|
209
353
|
client.resolve(result, topic);
|
|
@@ -211,21 +355,44 @@ export default class mexc extends mexcRest {
|
|
|
211
355
|
parseWsTicker(ticker, market = undefined) {
|
|
212
356
|
//
|
|
213
357
|
// spot
|
|
214
|
-
// {
|
|
215
|
-
// "A": "4.70432",
|
|
216
|
-
// "B": "6.714863",
|
|
217
|
-
// "a": "20744.54",
|
|
218
|
-
// "b": "20744.17"
|
|
219
|
-
// }
|
|
220
358
|
//
|
|
359
|
+
// {
|
|
360
|
+
// "A": "4.70432",
|
|
361
|
+
// "B": "6.714863",
|
|
362
|
+
// "a": "20744.54",
|
|
363
|
+
// "b": "20744.17"
|
|
364
|
+
// }
|
|
365
|
+
//
|
|
366
|
+
// spot miniTicker
|
|
367
|
+
//
|
|
368
|
+
// {
|
|
369
|
+
// "s": "BTCUSDT",
|
|
370
|
+
// "p": "76522",
|
|
371
|
+
// "r": "0.0012",
|
|
372
|
+
// "tr": "0.0012",
|
|
373
|
+
// "h": "77196.3",
|
|
374
|
+
// "l": "75630.77",
|
|
375
|
+
// "v": "584664223.92",
|
|
376
|
+
// "q": "7666.720258",
|
|
377
|
+
// "lastRT": "-1",
|
|
378
|
+
// "MT": "0",
|
|
379
|
+
// "NV": "--",
|
|
380
|
+
// "t": "1731135533126"
|
|
381
|
+
// }
|
|
382
|
+
//
|
|
383
|
+
const marketId = this.safeString(ticker, 's');
|
|
384
|
+
const timestamp = this.safeInteger(ticker, 't');
|
|
385
|
+
const price = this.safeString(ticker, 'p');
|
|
221
386
|
return this.safeTicker({
|
|
222
|
-
'
|
|
223
|
-
'
|
|
224
|
-
'
|
|
387
|
+
'info': ticker,
|
|
388
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
389
|
+
'timestamp': timestamp,
|
|
390
|
+
'datetime': this.iso8601(timestamp),
|
|
225
391
|
'open': undefined,
|
|
226
|
-
'high':
|
|
227
|
-
'low':
|
|
228
|
-
'close':
|
|
392
|
+
'high': this.safeNumber(ticker, 'h'),
|
|
393
|
+
'low': this.safeNumber(ticker, 'l'),
|
|
394
|
+
'close': price,
|
|
395
|
+
'last': price,
|
|
229
396
|
'bid': this.safeNumber(ticker, 'b'),
|
|
230
397
|
'bidVolume': this.safeNumber(ticker, 'B'),
|
|
231
398
|
'ask': this.safeNumber(ticker, 'a'),
|
|
@@ -233,11 +400,10 @@ export default class mexc extends mexcRest {
|
|
|
233
400
|
'vwap': undefined,
|
|
234
401
|
'previousClose': undefined,
|
|
235
402
|
'change': undefined,
|
|
236
|
-
'percentage':
|
|
403
|
+
'percentage': this.safeNumber(ticker, 'tr'),
|
|
237
404
|
'average': undefined,
|
|
238
|
-
'baseVolume':
|
|
239
|
-
'quoteVolume':
|
|
240
|
-
'info': ticker,
|
|
405
|
+
'baseVolume': this.safeNumber(ticker, 'v'),
|
|
406
|
+
'quoteVolume': this.safeNumber(ticker, 'q'),
|
|
241
407
|
}, market);
|
|
242
408
|
}
|
|
243
409
|
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
@@ -1340,6 +1506,8 @@ export default class mexc extends mexcRest {
|
|
|
1340
1506
|
'public.kline.v3.api': this.handleOHLCV,
|
|
1341
1507
|
'push.kline': this.handleOHLCV,
|
|
1342
1508
|
'public.bookTicker.v3.api': this.handleTicker,
|
|
1509
|
+
'public.miniTicker.v3.api': this.handleTicker,
|
|
1510
|
+
'public.miniTickers.v3.api': this.handleTickers,
|
|
1343
1511
|
'push.ticker': this.handleTicker,
|
|
1344
1512
|
'push.tickers': this.handleTickers,
|
|
1345
1513
|
'public.increase.depth.v3.api': this.handleOrderBook,
|
package/js/src/vertex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/vertex.js';
|
|
2
|
-
import type { Market, Ticker, Tickers, TradingFees, Balances, Int, OrderBook, OHLCV, Str, Order, OrderType, OrderSide, Trade, Strings, Dict, Num, Currencies, FundingRate, FundingRates } from './base/types.js';
|
|
2
|
+
import type { Market, Ticker, Tickers, TradingFees, Balances, Int, OrderBook, OHLCV, Str, Order, OrderType, OrderSide, Trade, Strings, Dict, Num, Currencies, FundingRate, FundingRates, Currency, Transaction } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class vertex
|
|
5
5
|
* @augments Exchange
|
|
@@ -64,7 +64,9 @@ export default class vertex extends Exchange {
|
|
|
64
64
|
parsePosition(position: any, market?: Market): import("./base/types.js").Position;
|
|
65
65
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
66
66
|
queryNonces(): Promise<import("./base/types.js").Dictionary<any>>;
|
|
67
|
-
withdraw(code: string, amount:
|
|
67
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
68
|
+
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
69
|
+
parseTransactionStatus(status: Str): string;
|
|
68
70
|
handlePublicAddress(methodName: string, params: Dict): any[];
|
|
69
71
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
70
72
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|