ccxt 4.5.40 → 4.5.42
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 +6 -5
- package/dist/ccxt.browser.min.js +18 -18
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/lighter.js +11 -0
- package/dist/cjs/src/ascendex.js +73 -1
- package/dist/cjs/src/base/Exchange.js +149 -17
- package/dist/cjs/src/base/functions/generic.js +1 -0
- package/dist/cjs/src/base/functions/io.js +160 -0
- package/dist/cjs/src/base/functions.js +6 -0
- package/dist/cjs/src/base/ws/Client.js +1 -0
- package/dist/cjs/src/base/ws/WsClient.js +1 -0
- package/dist/cjs/src/binance.js +1 -0
- package/dist/cjs/src/bingx.js +13 -3
- package/dist/cjs/src/bitmex.js +20 -0
- package/dist/cjs/src/blofin.js +2 -2
- package/dist/cjs/src/bybit.js +1 -1
- package/dist/cjs/src/coinspot.js +7 -2
- package/dist/cjs/src/delta.js +1 -1
- package/dist/cjs/src/gate.js +11 -4
- package/dist/cjs/src/gemini.js +76 -1
- package/dist/cjs/src/htx.js +2 -2
- package/dist/cjs/src/hyperliquid.js +20 -7
- package/dist/cjs/src/independentreserve.js +7 -7
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/krakenfutures.js +96 -5
- package/dist/cjs/src/kucoin.js +3 -3
- package/dist/cjs/src/kucoinfutures.js +1 -1
- package/dist/cjs/src/lighter.js +2931 -0
- package/dist/cjs/src/mexc.js +0 -1
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/binance.js +2 -2
- package/dist/cjs/src/pro/bingx.js +215 -2
- package/dist/cjs/src/pro/bitget.js +1 -0
- package/dist/cjs/src/pro/defx.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/lighter.js +787 -0
- package/dist/cjs/src/pro/mexc.js +1 -1
- package/dist/cjs/src/pro/paradex.js +1 -1
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/interface.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -0
- package/dist/cjs/src/whitebit.js +118 -16
- package/dist/cjs/src/woo.js +1 -1
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/gemini.d.ts +27 -0
- package/js/src/abstract/lighter.d.ts +53 -0
- package/js/src/abstract/lighter.js +11 -0
- package/js/src/ascendex.d.ts +12 -1
- package/js/src/ascendex.js +73 -1
- package/js/src/base/Exchange.d.ts +18 -6
- package/js/src/base/Exchange.js +154 -21
- package/js/src/base/functions/generic.js +1 -0
- package/js/src/base/functions/io.d.ts +32 -0
- package/js/src/base/functions/io.js +137 -0
- package/js/src/base/functions.d.ts +1 -0
- package/js/src/base/functions.js +1 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +1 -0
- package/js/src/bingx.js +13 -3
- package/js/src/bitmex.js +20 -0
- package/js/src/blofin.js +2 -2
- package/js/src/bybit.js +1 -1
- package/js/src/coinspot.js +7 -2
- package/js/src/delta.js +1 -1
- package/js/src/gate.d.ts +1 -0
- package/js/src/gate.js +11 -4
- package/js/src/gemini.d.ts +11 -0
- package/js/src/gemini.js +76 -1
- package/js/src/htx.js +2 -2
- package/js/src/hyperliquid.js +20 -7
- package/js/src/independentreserve.js +7 -7
- package/js/src/kraken.js +1 -1
- package/js/src/krakenfutures.d.ts +1 -1
- package/js/src/krakenfutures.js +96 -5
- package/js/src/kucoin.d.ts +3 -3
- package/js/src/kucoin.js +3 -3
- package/js/src/kucoinfutures.js +1 -1
- package/js/src/lighter.d.ts +424 -0
- package/js/src/lighter.js +2930 -0
- package/js/src/mexc.js +0 -1
- package/js/src/phemex.js +1 -1
- package/js/src/pro/binance.js +2 -2
- package/js/src/pro/bingx.d.ts +17 -1
- package/js/src/pro/bingx.js +216 -3
- package/js/src/pro/bitget.js +1 -0
- package/js/src/pro/defx.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/lighter.d.ts +161 -0
- package/js/src/pro/lighter.js +786 -0
- package/js/src/pro/mexc.js +1 -1
- package/js/src/pro/paradex.js +1 -1
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +118 -16
- package/js/src/woo.js +1 -1
- package/package.json +1 -1
package/js/src/mexc.js
CHANGED
|
@@ -4716,7 +4716,6 @@ export default class mexc extends Exchange {
|
|
|
4716
4716
|
const address = this.safeString(depositAddress, 'address');
|
|
4717
4717
|
const currencyId = this.safeString(depositAddress, 'coin');
|
|
4718
4718
|
const networkId = this.safeString(depositAddress, 'netWork');
|
|
4719
|
-
this.checkAddress(address);
|
|
4720
4719
|
return {
|
|
4721
4720
|
'info': depositAddress,
|
|
4722
4721
|
'currency': this.safeCurrencyCode(currencyId, currency),
|
package/js/src/phemex.js
CHANGED
|
@@ -90,8 +90,8 @@ export default class phemex extends Exchange {
|
|
|
90
90
|
'fetchOrderBook': true,
|
|
91
91
|
'fetchOrders': true,
|
|
92
92
|
'fetchPositionADLRank': true,
|
|
93
|
-
'fetchPositionsADLRank': true,
|
|
94
93
|
'fetchPositions': true,
|
|
94
|
+
'fetchPositionsADLRank': true,
|
|
95
95
|
'fetchPositionsRisk': false,
|
|
96
96
|
'fetchPremiumIndexOHLCV': false,
|
|
97
97
|
'fetchTicker': true,
|
package/js/src/pro/binance.js
CHANGED
|
@@ -157,7 +157,7 @@ export default class binance extends binanceRest {
|
|
|
157
157
|
'name': 'ticker', // ticker or miniTicker or ticker_<window_size>
|
|
158
158
|
},
|
|
159
159
|
'watchTickers': {
|
|
160
|
-
'name': '
|
|
160
|
+
'name': 'miniTicker', // miniTicker or ticker_<window_size>
|
|
161
161
|
},
|
|
162
162
|
'watchOHLCV': {
|
|
163
163
|
'name': 'kline', // or indexPriceKline or markPriceKline (coin-m futures)
|
|
@@ -1868,7 +1868,7 @@ export default class binance extends binanceRest {
|
|
|
1868
1868
|
*/
|
|
1869
1869
|
async watchTickers(symbols = undefined, params = {}) {
|
|
1870
1870
|
let channelName = undefined;
|
|
1871
|
-
[channelName, params] = this.handleOptionAndParams(params, 'watchTickers', 'name', '
|
|
1871
|
+
[channelName, params] = this.handleOptionAndParams(params, 'watchTickers', 'name', 'miniTicker');
|
|
1872
1872
|
if (channelName === 'bookTicker') {
|
|
1873
1873
|
throw new BadRequest(this.id + ' deprecation notice - to subscribe for bids-asks, use watch_bids_asks() method instead');
|
|
1874
1874
|
}
|
package/js/src/pro/bingx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import bingxRest from '../bingx.js';
|
|
2
|
-
import type { Int, Market, OHLCV, Str, OrderBook, Order, Trade, Balances, Ticker, Dict } from '../base/types.js';
|
|
2
|
+
import type { Int, Market, OHLCV, Str, Strings, OrderBook, Order, Trade, Balances, Ticker, Position, Dict } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class bingx extends bingxRest {
|
|
5
5
|
describe(): any;
|
|
@@ -158,6 +158,22 @@ export default class bingx extends bingxRest {
|
|
|
158
158
|
watchBalance(params?: {}): Promise<Balances>;
|
|
159
159
|
setBalanceCache(client: Client, type: any, subType: any, subscriptionHash: any, params: any): void;
|
|
160
160
|
loadBalanceSnapshot(client: any, messageHash: any, type: any, subType: any): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* @method
|
|
163
|
+
* @name bingx#watchPositions
|
|
164
|
+
* @description watch all open positions
|
|
165
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/socket/account.html#Account%20balance%20and%20position%20update%20push
|
|
166
|
+
* @param {string[]|undefined} [symbols] list of unified market symbols
|
|
167
|
+
* @param {int} [since] the earliest time in ms to fetch positions for
|
|
168
|
+
* @param {int} [limit] the maximum number of position structures to retrieve
|
|
169
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
170
|
+
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
171
|
+
*/
|
|
172
|
+
watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
173
|
+
setPositionsCache(client: Client, type: any, symbols?: Strings): void;
|
|
174
|
+
loadPositionsSnapshot(client: any, messageHash: any, type: any): Promise<void>;
|
|
175
|
+
parseWsPosition(position: any, market?: any): Position;
|
|
176
|
+
handlePositions(client: Client, message: any): void;
|
|
161
177
|
handleErrorMessage(client: any, message: any): boolean;
|
|
162
178
|
keepAliveListenKey(params?: {}): Promise<void>;
|
|
163
179
|
authenticate(params?: {}): Promise<void>;
|
package/js/src/pro/bingx.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import bingxRest from '../bingx.js';
|
|
9
9
|
import { BadRequest, NetworkError, NotSupported } from '../base/errors.js';
|
|
10
|
-
import {
|
|
10
|
+
import { Precise } from '../base/Precise.js';
|
|
11
|
+
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
export default class bingx extends bingxRest {
|
|
13
14
|
describe() {
|
|
@@ -25,12 +26,18 @@ export default class bingx extends bingxRest {
|
|
|
25
26
|
'watchTicker': true,
|
|
26
27
|
'watchTickers': false,
|
|
27
28
|
'watchBalance': true,
|
|
29
|
+
'watchPositions': true,
|
|
28
30
|
'unWatchOHLCV': true,
|
|
29
31
|
'unWatchOrderBook': true,
|
|
30
32
|
'unWatchTicker': true,
|
|
31
33
|
'unWatchTrades': true,
|
|
32
34
|
},
|
|
33
35
|
'urls': {
|
|
36
|
+
'test': {
|
|
37
|
+
'ws': {
|
|
38
|
+
'linear': 'wss://vst-open-api-ws.bingx.com/swap-market',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
34
41
|
'api': {
|
|
35
42
|
'ws': {
|
|
36
43
|
'spot': 'wss://open-api-ws.bingx.com/market',
|
|
@@ -74,7 +81,11 @@ export default class bingx extends bingxRest {
|
|
|
74
81
|
},
|
|
75
82
|
'watchBalance': {
|
|
76
83
|
'fetchBalanceSnapshot': true,
|
|
77
|
-
'awaitBalanceSnapshot':
|
|
84
|
+
'awaitBalanceSnapshot': true, // whether to wait for the balance snapshot before providing updates
|
|
85
|
+
},
|
|
86
|
+
'watchPositions': {
|
|
87
|
+
'fetchPositionsSnapshot': true,
|
|
88
|
+
'awaitPositionsSnapshot': false,
|
|
78
89
|
},
|
|
79
90
|
'watchOrderBook': {
|
|
80
91
|
'depth': 100, // 5, 10, 20, 50, 100
|
|
@@ -1141,6 +1152,203 @@ export default class bingx extends bingxRest {
|
|
|
1141
1152
|
client.resolve(this.balance[type], type + ':balance');
|
|
1142
1153
|
}
|
|
1143
1154
|
}
|
|
1155
|
+
/**
|
|
1156
|
+
* @method
|
|
1157
|
+
* @name bingx#watchPositions
|
|
1158
|
+
* @description watch all open positions
|
|
1159
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/socket/account.html#Account%20balance%20and%20position%20update%20push
|
|
1160
|
+
* @param {string[]|undefined} [symbols] list of unified market symbols
|
|
1161
|
+
* @param {int} [since] the earliest time in ms to fetch positions for
|
|
1162
|
+
* @param {int} [limit] the maximum number of position structures to retrieve
|
|
1163
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1164
|
+
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
1165
|
+
*/
|
|
1166
|
+
async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1167
|
+
await this.loadMarkets();
|
|
1168
|
+
await this.authenticate();
|
|
1169
|
+
let market = undefined;
|
|
1170
|
+
let messageHash = '';
|
|
1171
|
+
symbols = this.marketSymbols(symbols);
|
|
1172
|
+
if (!this.isEmpty(symbols)) {
|
|
1173
|
+
market = this.getMarketFromSymbols(symbols);
|
|
1174
|
+
messageHash = '::' + symbols.join(',');
|
|
1175
|
+
}
|
|
1176
|
+
let type = undefined;
|
|
1177
|
+
let subType = undefined;
|
|
1178
|
+
[type, params] = this.handleMarketTypeAndParams('watchPositions', market, params);
|
|
1179
|
+
[subType, params] = this.handleSubTypeAndParams('watchPositions', market, params, 'linear');
|
|
1180
|
+
if (type === 'spot') {
|
|
1181
|
+
throw new NotSupported(this.id + ' watchPositions is not supported for spot markets');
|
|
1182
|
+
}
|
|
1183
|
+
if (subType === 'inverse') {
|
|
1184
|
+
throw new NotSupported(this.id + ' watchPositions is not supported for inverse swap markets yet');
|
|
1185
|
+
}
|
|
1186
|
+
const subscriptionHash = 'swap:private';
|
|
1187
|
+
messageHash = 'swap:positions' + messageHash;
|
|
1188
|
+
const baseUrl = this.safeString(this.urls['api']['ws'], subType);
|
|
1189
|
+
const url = baseUrl + '?listenKey=' + this.options['listenKey'];
|
|
1190
|
+
const client = this.client(url);
|
|
1191
|
+
this.setPositionsCache(client, type, symbols);
|
|
1192
|
+
let fetchPositionsSnapshot = undefined;
|
|
1193
|
+
let awaitPositionsSnapshot = undefined;
|
|
1194
|
+
[fetchPositionsSnapshot, params] = this.handleOptionAndParams(params, 'watchPositions', 'fetchPositionsSnapshot', true);
|
|
1195
|
+
[awaitPositionsSnapshot, params] = this.handleOptionAndParams(params, 'watchPositions', 'awaitPositionsSnapshot', false);
|
|
1196
|
+
const uuid = this.uuid();
|
|
1197
|
+
const subscription = {
|
|
1198
|
+
'unsubscribe': false,
|
|
1199
|
+
'id': uuid,
|
|
1200
|
+
};
|
|
1201
|
+
if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
|
|
1202
|
+
const snapshot = await client.future(type + ':fetchPositionsSnapshot');
|
|
1203
|
+
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
|
1204
|
+
}
|
|
1205
|
+
const newPositions = await this.watch(url, messageHash, undefined, subscriptionHash, subscription);
|
|
1206
|
+
if (this.newUpdates) {
|
|
1207
|
+
return newPositions;
|
|
1208
|
+
}
|
|
1209
|
+
return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
|
|
1210
|
+
}
|
|
1211
|
+
setPositionsCache(client, type, symbols = undefined) {
|
|
1212
|
+
if (this.positions !== undefined) {
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
1216
|
+
if (fetchPositionsSnapshot) {
|
|
1217
|
+
const messageHash = type + ':fetchPositionsSnapshot';
|
|
1218
|
+
if (!(messageHash in client.futures)) {
|
|
1219
|
+
client.future(messageHash);
|
|
1220
|
+
this.spawn(this.loadPositionsSnapshot, client, messageHash, type);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
else {
|
|
1224
|
+
this.positions = new ArrayCacheBySymbolBySide();
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
async loadPositionsSnapshot(client, messageHash, type) {
|
|
1228
|
+
const positions = await this.fetchPositions(undefined, { 'type': type, 'subType': 'linear' });
|
|
1229
|
+
this.positions = new ArrayCacheBySymbolBySide();
|
|
1230
|
+
const cache = this.positions;
|
|
1231
|
+
for (let i = 0; i < positions.length; i++) {
|
|
1232
|
+
const position = positions[i];
|
|
1233
|
+
const contracts = this.safeNumber(position, 'contracts', 0);
|
|
1234
|
+
if (contracts > 0) {
|
|
1235
|
+
cache.append(position);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
// don't remove the future from the .futures cache
|
|
1239
|
+
if (messageHash in client.futures) {
|
|
1240
|
+
const future = client.futures[messageHash];
|
|
1241
|
+
future.resolve(cache);
|
|
1242
|
+
client.resolve(cache, 'swap:positions');
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
parseWsPosition(position, market = undefined) {
|
|
1246
|
+
//
|
|
1247
|
+
// {
|
|
1248
|
+
// "s": "LINK-USDT", // Symbol
|
|
1249
|
+
// "pa": "5.000", // Position Amount
|
|
1250
|
+
// "ep": "11.2345", // Entry Price
|
|
1251
|
+
// "up": "0.5000", // Unrealized PnL
|
|
1252
|
+
// "mt": "isolated", // Margin Type
|
|
1253
|
+
// "iw": "50.00000000", // Isolated Wallet
|
|
1254
|
+
// "ps": "LONG" // Position Side
|
|
1255
|
+
// }
|
|
1256
|
+
//
|
|
1257
|
+
const marketId = this.safeString(position, 's');
|
|
1258
|
+
const contracts = this.safeString(position, 'pa');
|
|
1259
|
+
const contractsAbs = Precise.stringAbs(contracts);
|
|
1260
|
+
let positionSide = this.safeStringLower(position, 'ps');
|
|
1261
|
+
let hedged = true;
|
|
1262
|
+
if (positionSide === 'both') {
|
|
1263
|
+
hedged = false;
|
|
1264
|
+
if (!Precise.stringEq(contracts, '0')) {
|
|
1265
|
+
if (Precise.stringLt(contracts, '0')) {
|
|
1266
|
+
positionSide = 'short';
|
|
1267
|
+
}
|
|
1268
|
+
else {
|
|
1269
|
+
positionSide = 'long';
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
const marginMode = this.safeString(position, 'mt');
|
|
1274
|
+
const collateral = (marginMode === 'isolated') ? this.safeNumber(position, 'iw') : undefined;
|
|
1275
|
+
return this.safePosition({
|
|
1276
|
+
'info': position,
|
|
1277
|
+
'id': undefined,
|
|
1278
|
+
'symbol': this.safeSymbol(marketId, undefined, undefined, 'swap'),
|
|
1279
|
+
'notional': undefined,
|
|
1280
|
+
'marginMode': marginMode,
|
|
1281
|
+
'liquidationPrice': undefined,
|
|
1282
|
+
'entryPrice': this.safeNumber(position, 'ep'),
|
|
1283
|
+
'unrealizedPnl': this.safeNumber(position, 'up'),
|
|
1284
|
+
'percentage': undefined,
|
|
1285
|
+
'contracts': this.parseNumber(contractsAbs),
|
|
1286
|
+
'contractSize': undefined,
|
|
1287
|
+
'markPrice': undefined,
|
|
1288
|
+
'side': positionSide,
|
|
1289
|
+
'hedged': hedged,
|
|
1290
|
+
'timestamp': undefined,
|
|
1291
|
+
'datetime': undefined,
|
|
1292
|
+
'maintenanceMargin': undefined,
|
|
1293
|
+
'maintenanceMarginPercentage': undefined,
|
|
1294
|
+
'collateral': collateral,
|
|
1295
|
+
'initialMargin': undefined,
|
|
1296
|
+
'initialMarginPercentage': undefined,
|
|
1297
|
+
'leverage': undefined,
|
|
1298
|
+
'marginRatio': undefined,
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
handlePositions(client, message) {
|
|
1302
|
+
//
|
|
1303
|
+
// {
|
|
1304
|
+
// "e": "ACCOUNT_UPDATE",
|
|
1305
|
+
// "E": 1696244249320,
|
|
1306
|
+
// "a": {
|
|
1307
|
+
// "m": "ORDER",
|
|
1308
|
+
// "B": [...],
|
|
1309
|
+
// "P": [
|
|
1310
|
+
// {
|
|
1311
|
+
// "s": "LINK-USDT",
|
|
1312
|
+
// "pa": "5.000",
|
|
1313
|
+
// "ep": "11.2345",
|
|
1314
|
+
// "up": "0.5000",
|
|
1315
|
+
// "mt": "isolated",
|
|
1316
|
+
// "iw": "50.00000000",
|
|
1317
|
+
// "ps": "LONG"
|
|
1318
|
+
// }
|
|
1319
|
+
// ]
|
|
1320
|
+
// }
|
|
1321
|
+
// }
|
|
1322
|
+
//
|
|
1323
|
+
if (this.positions === undefined) {
|
|
1324
|
+
this.positions = new ArrayCacheBySymbolBySide();
|
|
1325
|
+
}
|
|
1326
|
+
const cache = this.positions;
|
|
1327
|
+
const data = this.safeDict(message, 'a', {});
|
|
1328
|
+
const rawPositions = this.safeList(data, 'P', []);
|
|
1329
|
+
const newPositions = [];
|
|
1330
|
+
for (let i = 0; i < rawPositions.length; i++) {
|
|
1331
|
+
const rawPosition = rawPositions[i];
|
|
1332
|
+
const position = this.parseWsPosition(rawPosition);
|
|
1333
|
+
const timestamp = this.safeInteger(message, 'E');
|
|
1334
|
+
position['timestamp'] = timestamp;
|
|
1335
|
+
position['datetime'] = this.iso8601(timestamp);
|
|
1336
|
+
newPositions.push(position);
|
|
1337
|
+
cache.append(position);
|
|
1338
|
+
}
|
|
1339
|
+
const messageHashes = this.findMessageHashes(client, 'swap:positions::');
|
|
1340
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
1341
|
+
const messageHash = messageHashes[i];
|
|
1342
|
+
const parts = messageHash.split('::');
|
|
1343
|
+
const symbolsString = parts[1];
|
|
1344
|
+
const filteredSymbols = symbolsString.split(',');
|
|
1345
|
+
const positions = this.filterByArray(newPositions, 'symbol', filteredSymbols, false);
|
|
1346
|
+
if (!this.isEmpty(positions)) {
|
|
1347
|
+
client.resolve(positions, messageHash);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
client.resolve(newPositions, 'swap:positions');
|
|
1351
|
+
}
|
|
1144
1352
|
handleErrorMessage(client, message) {
|
|
1145
1353
|
//
|
|
1146
1354
|
// { code: 100400, msg: '', timestamp: 1696245808833 }
|
|
@@ -1176,7 +1384,11 @@ export default class bingx extends bingxRest {
|
|
|
1176
1384
|
const types = ['spot', 'linear', 'inverse'];
|
|
1177
1385
|
for (let i = 0; i < types.length; i++) {
|
|
1178
1386
|
const type = types[i];
|
|
1179
|
-
const
|
|
1387
|
+
const baseUrl = this.safeString(this.urls['api']['ws'], type);
|
|
1388
|
+
if (baseUrl === undefined) {
|
|
1389
|
+
continue;
|
|
1390
|
+
}
|
|
1391
|
+
const url = baseUrl + '?listenKey=' + listenKey;
|
|
1180
1392
|
const client = this.client(url);
|
|
1181
1393
|
const messageHashes = Object.keys(client.futures);
|
|
1182
1394
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
@@ -1506,6 +1718,7 @@ export default class bingx extends bingxRest {
|
|
|
1506
1718
|
const e = this.safeString(message, 'e');
|
|
1507
1719
|
if (e === 'ACCOUNT_UPDATE') {
|
|
1508
1720
|
this.handleBalance(client, message);
|
|
1721
|
+
this.handlePositions(client, message);
|
|
1509
1722
|
}
|
|
1510
1723
|
if (e === 'ORDER_TRADE_UPDATE') {
|
|
1511
1724
|
this.handleOrder(client, message);
|
package/js/src/pro/bitget.js
CHANGED
package/js/src/pro/defx.js
CHANGED
|
@@ -719,9 +719,9 @@ export default class kucoinfutures extends kucoinfuturesRest {
|
|
|
719
719
|
const parsed = [
|
|
720
720
|
this.safeInteger(ohlcv, 0),
|
|
721
721
|
this.safeNumber(ohlcv, 1),
|
|
722
|
-
this.safeNumber(ohlcv, 2),
|
|
723
722
|
this.safeNumber(ohlcv, 3),
|
|
724
723
|
this.safeNumber(ohlcv, 4),
|
|
724
|
+
this.safeNumber(ohlcv, 2),
|
|
725
725
|
this.safeNumber(ohlcv, 6), // Note value 5 is incorrect and will be fixed in subsequent versions of kucoin
|
|
726
726
|
];
|
|
727
727
|
this.ohlcvs[symbol] = this.safeDict(this.ohlcvs, symbol, {});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { Dict, Int, Liquidation, OrderBook, Str, Strings, Ticker, Tickers, Trade } from '../base/types.js';
|
|
2
|
+
import Client from '../base/ws/Client.js';
|
|
3
|
+
import lighterRest from '../lighter.js';
|
|
4
|
+
export default class lighter extends lighterRest {
|
|
5
|
+
describe(): any;
|
|
6
|
+
getMessageHash(unifiedChannel: string, symbol?: Str, extra?: Str): string;
|
|
7
|
+
subscribePublic(messageHash: any, params?: {}): Promise<any>;
|
|
8
|
+
subscribePublicMultiple(messageHashes: any, params?: {}): Promise<any>;
|
|
9
|
+
unsubscribePublic(messageHash: any, params?: {}): Promise<any>;
|
|
10
|
+
handleDelta(bookside: any, delta: any): void;
|
|
11
|
+
handleDeltas(bookside: any, deltas: any): void;
|
|
12
|
+
handleOrderBookMessage(client: Client, message: any, orderbook: any): any;
|
|
13
|
+
handleOrderBook(client: Client, message: any): void;
|
|
14
|
+
/**
|
|
15
|
+
* @method
|
|
16
|
+
* @name lighter#watchOrderBook
|
|
17
|
+
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
18
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#order-book
|
|
19
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
20
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
21
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
22
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
23
|
+
*/
|
|
24
|
+
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
25
|
+
/**
|
|
26
|
+
* @method
|
|
27
|
+
* @name lighter#unWatchOrderBook
|
|
28
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
29
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#order-book
|
|
30
|
+
* @param {string} symbol unified symbol of the market
|
|
31
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
32
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
33
|
+
*/
|
|
34
|
+
unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
|
|
35
|
+
handleTicker(client: Client, message: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* @method
|
|
38
|
+
* @name lighter#watchTicker
|
|
39
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
40
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
41
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
42
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
43
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
44
|
+
*/
|
|
45
|
+
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
46
|
+
/**
|
|
47
|
+
* @method
|
|
48
|
+
* @name lighter#unWatchTicker
|
|
49
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
50
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
51
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
52
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
53
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
54
|
+
*/
|
|
55
|
+
unWatchTicker(symbol: string, params?: {}): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* @method
|
|
58
|
+
* @name lighter#watchTickers
|
|
59
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
60
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
61
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
62
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
63
|
+
* @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
|
|
64
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
65
|
+
*/
|
|
66
|
+
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
67
|
+
/**
|
|
68
|
+
* @method
|
|
69
|
+
* @name lighter#unWatchTickers
|
|
70
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
71
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
72
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
73
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
74
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
75
|
+
*/
|
|
76
|
+
unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
|
|
77
|
+
/**
|
|
78
|
+
* @method
|
|
79
|
+
* @name lighter#watchMarkPrice
|
|
80
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
81
|
+
* @description watches a mark price
|
|
82
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
83
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
84
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
85
|
+
*/
|
|
86
|
+
watchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
|
|
87
|
+
/**
|
|
88
|
+
* @method
|
|
89
|
+
* @name lighter#watchMarkPrices
|
|
90
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
91
|
+
* @description watches mark prices
|
|
92
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
93
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
94
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
95
|
+
*/
|
|
96
|
+
watchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
97
|
+
/**
|
|
98
|
+
* @method
|
|
99
|
+
* @name lighter#unWatchMarkPrice
|
|
100
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
101
|
+
* @description unWatches a mark price
|
|
102
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
103
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
104
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
105
|
+
*/
|
|
106
|
+
unWatchMarkPrice(symbol: string, params?: {}): Promise<any>;
|
|
107
|
+
/**
|
|
108
|
+
* @method
|
|
109
|
+
* @name lighter#unWatchMarkPrices
|
|
110
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#market-stats
|
|
111
|
+
* @description unWatches mark prices
|
|
112
|
+
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
113
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
114
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
115
|
+
*/
|
|
116
|
+
unWatchMarkPrices(symbols?: Strings, params?: {}): Promise<any>;
|
|
117
|
+
parseWsTrade(trade: any, market?: any): Trade;
|
|
118
|
+
handleTrades(client: Client, message: any): void;
|
|
119
|
+
/**
|
|
120
|
+
* @method
|
|
121
|
+
* @name lighter#watchTrades
|
|
122
|
+
* @description get the list of most recent trades for a particular symbol
|
|
123
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#trade
|
|
124
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
125
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
126
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
127
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
128
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
129
|
+
*/
|
|
130
|
+
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
131
|
+
/**
|
|
132
|
+
* @method
|
|
133
|
+
* @name lighter#unWatchTrades
|
|
134
|
+
* @description unsubscribe from the trades channel
|
|
135
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#trade
|
|
136
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
137
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
138
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
139
|
+
*/
|
|
140
|
+
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
|
141
|
+
parseWsLiquidation(liquidation: any, market?: any): Liquidation;
|
|
142
|
+
handleLiquidation(client: Client, message: any): void;
|
|
143
|
+
/**
|
|
144
|
+
* @method
|
|
145
|
+
* @name lighter#watchLiquidations
|
|
146
|
+
* @description watch the public liquidations of a trading pair
|
|
147
|
+
* @see https://apidocs.lighter.xyz/docs/websocket-reference#trade
|
|
148
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
149
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
150
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
151
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
152
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
153
|
+
*/
|
|
154
|
+
watchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
|
|
155
|
+
handleErrorMessage(client: any, message: any): boolean;
|
|
156
|
+
handleMessage(client: Client, message: any): void;
|
|
157
|
+
handleSubscriptionStatus(client: Client, message: any): any;
|
|
158
|
+
handleUnSubscription(client: Client, subscription: Dict): void;
|
|
159
|
+
handlePing(client: Client, message: any): void;
|
|
160
|
+
pong(client: any, message: any): Promise<void>;
|
|
161
|
+
}
|