ccxt 4.3.72 → 4.3.74
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 +5 -5
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +1 -1
- package/dist/cjs/src/base/ws/Client.js +2 -2
- package/dist/cjs/src/binance.js +236 -87
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/pro/alpaca.js +5 -0
- package/dist/cjs/src/pro/binance.js +31 -3
- package/dist/cjs/src/pro/bitfinex.js +5 -0
- package/dist/cjs/src/pro/kucoin.js +7 -2
- package/dist/cjs/src/pro/woo.js +129 -12
- package/dist/cjs/src/woo.js +1 -1
- package/dist/cjs/src/yobit.js +55 -29
- package/examples/js/cli.js +13 -10
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +5 -0
- package/js/src/abstract/binancecoinm.d.ts +5 -0
- package/js/src/abstract/binanceus.d.ts +5 -0
- package/js/src/abstract/binanceusdm.d.ts +5 -0
- package/js/src/ace.js +1 -1
- package/js/src/base/ws/Client.js +2 -2
- package/js/src/binance.js +236 -87
- package/js/src/bybit.js +2 -2
- package/js/src/pro/alpaca.js +5 -0
- package/js/src/pro/binance.js +31 -3
- package/js/src/pro/bitfinex.js +5 -0
- package/js/src/pro/kucoin.js +7 -2
- package/js/src/pro/woo.d.ts +5 -0
- package/js/src/pro/woo.js +129 -12
- package/js/src/woo.js +1 -1
- package/js/src/yobit.d.ts +1 -0
- package/js/src/yobit.js +55 -29
- package/package.json +1 -1
package/js/src/pro/binance.js
CHANGED
|
@@ -934,10 +934,15 @@ export default class binance extends binanceRest {
|
|
|
934
934
|
* @method
|
|
935
935
|
* @name binance#watchTradesForSymbols
|
|
936
936
|
* @description get the list of most recent trades for a list of symbols
|
|
937
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
|
|
938
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
|
|
939
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
|
|
940
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
|
|
937
941
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
938
942
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
939
943
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
940
944
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
945
|
+
* @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
|
|
941
946
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
942
947
|
*/
|
|
943
948
|
await this.loadMarkets();
|
|
@@ -950,8 +955,9 @@ export default class binance extends binanceRest {
|
|
|
950
955
|
}
|
|
951
956
|
streamHash += '::' + symbols.join(',');
|
|
952
957
|
}
|
|
953
|
-
|
|
954
|
-
|
|
958
|
+
let name = undefined;
|
|
959
|
+
[name, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'name', 'trade');
|
|
960
|
+
params = this.omit(params, 'callerMethodName');
|
|
955
961
|
const firstMarket = this.market(symbols[0]);
|
|
956
962
|
let type = firstMarket['type'];
|
|
957
963
|
if (firstMarket['contract']) {
|
|
@@ -991,12 +997,18 @@ export default class binance extends binanceRest {
|
|
|
991
997
|
* @method
|
|
992
998
|
* @name binance#watchTrades
|
|
993
999
|
* @description get the list of most recent trades for a particular symbol
|
|
1000
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
|
|
1001
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
|
|
1002
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
|
|
1003
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
|
|
994
1004
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
995
1005
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
996
1006
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
997
1007
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1008
|
+
* @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
|
|
998
1009
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
999
1010
|
*/
|
|
1011
|
+
params['callerMethodName'] = 'watchTrades';
|
|
1000
1012
|
return await this.watchTradesForSymbols([symbol], since, limit, params);
|
|
1001
1013
|
}
|
|
1002
1014
|
parseWsTrade(trade, market = undefined) {
|
|
@@ -1185,11 +1197,15 @@ export default class binance extends binanceRest {
|
|
|
1185
1197
|
* @method
|
|
1186
1198
|
* @name binance#watchOHLCV
|
|
1187
1199
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1200
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
|
|
1201
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data
|
|
1202
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
|
|
1188
1203
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1189
1204
|
* @param {string} timeframe the length of time each candle represents
|
|
1190
1205
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1191
1206
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
1192
1207
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1208
|
+
* @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
|
|
1193
1209
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1194
1210
|
*/
|
|
1195
1211
|
params['callerMethodName'] = 'watchOHLCV';
|
|
@@ -1201,10 +1217,14 @@ export default class binance extends binanceRest {
|
|
|
1201
1217
|
* @method
|
|
1202
1218
|
* @name binance#watchOHLCVForSymbols
|
|
1203
1219
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1220
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
|
|
1221
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data
|
|
1222
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
|
|
1204
1223
|
* @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
|
|
1205
1224
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1206
1225
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
1207
1226
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1227
|
+
* @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
|
|
1208
1228
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1209
1229
|
*/
|
|
1210
1230
|
await this.loadMarkets();
|
|
@@ -1217,6 +1237,10 @@ export default class binance extends binanceRest {
|
|
|
1217
1237
|
if (firstMarket['contract']) {
|
|
1218
1238
|
type = firstMarket['linear'] ? 'future' : 'delivery';
|
|
1219
1239
|
}
|
|
1240
|
+
const isSpot = (type === 'spot');
|
|
1241
|
+
let timezone = undefined;
|
|
1242
|
+
[timezone, params] = this.handleParamString(params, 'timezone', undefined);
|
|
1243
|
+
const isUtc8 = (timezone !== undefined) && ((timezone === '+08:00') || Precise.stringEq(timezone, '8'));
|
|
1220
1244
|
const rawHashes = [];
|
|
1221
1245
|
const messageHashes = [];
|
|
1222
1246
|
for (let i = 0; i < symbolsAndTimeframes.length; i++) {
|
|
@@ -1230,7 +1254,10 @@ export default class binance extends binanceRest {
|
|
|
1230
1254
|
// weird behavior for index price kline we can't use the perp suffix
|
|
1231
1255
|
marketId = marketId.replace('_perp', '');
|
|
1232
1256
|
}
|
|
1233
|
-
|
|
1257
|
+
const shouldUseUTC8 = (isUtc8 && isSpot);
|
|
1258
|
+
const suffix = '@+08:00';
|
|
1259
|
+
const utcSuffix = shouldUseUTC8 ? suffix : '';
|
|
1260
|
+
rawHashes.push(marketId + '@' + klineType + '_' + interval + utcSuffix);
|
|
1234
1261
|
messageHashes.push('ohlcv::' + symbolString + '::' + timeframeString);
|
|
1235
1262
|
}
|
|
1236
1263
|
const url = this.urls['api']['ws'][type] + '/' + this.stream(type, 'multipleOHLCV');
|
|
@@ -1243,6 +1270,7 @@ export default class binance extends binanceRest {
|
|
|
1243
1270
|
const subscribe = {
|
|
1244
1271
|
'id': requestId,
|
|
1245
1272
|
};
|
|
1273
|
+
params = this.omit(params, 'callerMethodName');
|
|
1246
1274
|
const [symbol, timeframe, candles] = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscribe);
|
|
1247
1275
|
if (this.newUpdates) {
|
|
1248
1276
|
limit = candles.getLimit(symbol, limit);
|
package/js/src/pro/bitfinex.js
CHANGED
|
@@ -60,6 +60,7 @@ export default class bitfinex extends bitfinexRest {
|
|
|
60
60
|
* @method
|
|
61
61
|
* @name bitfinex#watchTrades
|
|
62
62
|
* @description get the list of most recent trades for a particular symbol
|
|
63
|
+
* @see https://docs.bitfinex.com/v1/reference/ws-public-trades
|
|
63
64
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
64
65
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
65
66
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -79,6 +80,7 @@ export default class bitfinex extends bitfinexRest {
|
|
|
79
80
|
* @method
|
|
80
81
|
* @name bitfinex#watchTicker
|
|
81
82
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
83
|
+
* @see https://docs.bitfinex.com/v1/reference/ws-public-ticker
|
|
82
84
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
83
85
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
84
86
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -251,6 +253,7 @@ export default class bitfinex extends bitfinexRest {
|
|
|
251
253
|
* @method
|
|
252
254
|
* @name bitfinex#watchOrderBook
|
|
253
255
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
256
|
+
* @see https://docs.bitfinex.com/v1/reference/ws-public-order-books
|
|
254
257
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
255
258
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
256
259
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -461,6 +464,8 @@ export default class bitfinex extends bitfinexRest {
|
|
|
461
464
|
* @method
|
|
462
465
|
* @name bitfinex#watchOrders
|
|
463
466
|
* @description watches information on multiple orders made by the user
|
|
467
|
+
* @see https://docs.bitfinex.com/v1/reference/ws-auth-order-updates
|
|
468
|
+
* @see https://docs.bitfinex.com/v1/reference/ws-auth-order-snapshots
|
|
464
469
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
465
470
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
466
471
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
package/js/src/pro/kucoin.js
CHANGED
|
@@ -1099,8 +1099,13 @@ export default class kucoin extends kucoinRest {
|
|
|
1099
1099
|
const type = this.safeString(trade, 'orderType');
|
|
1100
1100
|
const side = this.safeString(trade, 'side');
|
|
1101
1101
|
const tradeId = this.safeString(trade, 'tradeId');
|
|
1102
|
-
|
|
1103
|
-
|
|
1102
|
+
let price = this.safeString(trade, 'matchPrice');
|
|
1103
|
+
let amount = this.safeString(trade, 'matchSize');
|
|
1104
|
+
if (price === undefined) {
|
|
1105
|
+
// /spot/tradeFills
|
|
1106
|
+
price = this.safeString(trade, 'price');
|
|
1107
|
+
amount = this.safeString(trade, 'size');
|
|
1108
|
+
}
|
|
1104
1109
|
const order = this.safeString(trade, 'orderId');
|
|
1105
1110
|
const timestamp = this.safeIntegerProduct2(trade, 'ts', 'time', 0.000001);
|
|
1106
1111
|
const feeCurrency = market['quote'];
|
package/js/src/pro/woo.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export default class woo extends wooRest {
|
|
|
7
7
|
watchPublic(messageHash: any, message: any): Promise<any>;
|
|
8
8
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
9
9
|
handleOrderBook(client: Client, message: any): void;
|
|
10
|
+
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
11
|
+
fetchOrderBookSnapshot(client: any, message: any, subscription: any): Promise<void>;
|
|
12
|
+
handleOrderBookMessage(client: Client, message: any, orderbook: any): any;
|
|
13
|
+
handleDelta(bookside: any, delta: any): void;
|
|
14
|
+
handleDeltas(bookside: any, deltas: any): void;
|
|
10
15
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
11
16
|
parseWsTicker(ticker: any, market?: any): Ticker;
|
|
12
17
|
handleTicker(client: Client, message: any): any;
|
package/js/src/pro/woo.js
CHANGED
|
@@ -88,32 +88,49 @@ export default class woo extends wooRest {
|
|
|
88
88
|
/**
|
|
89
89
|
* @method
|
|
90
90
|
* @name woo#watchOrderBook
|
|
91
|
+
* @see https://docs.woo.org/#orderbookupdate
|
|
91
92
|
* @see https://docs.woo.org/#orderbook
|
|
92
93
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
93
94
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
94
95
|
* @param {int} [limit] the maximum amount of order book entries to return.
|
|
95
96
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
97
|
+
* @param {string} [params.method] either (default) 'orderbook' or 'orderbookupdate', default is 'orderbook'
|
|
96
98
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
97
99
|
*/
|
|
98
100
|
await this.loadMarkets();
|
|
99
|
-
|
|
101
|
+
let method = undefined;
|
|
102
|
+
[method, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'method', 'orderbook');
|
|
100
103
|
const market = this.market(symbol);
|
|
101
|
-
const topic = market['id'] + '@' +
|
|
104
|
+
const topic = market['id'] + '@' + method;
|
|
105
|
+
const urlUid = (this.uid) ? '/' + this.uid : '';
|
|
106
|
+
const url = this.urls['api']['ws']['public'] + urlUid;
|
|
107
|
+
const requestId = this.requestId(url);
|
|
102
108
|
const request = {
|
|
103
109
|
'event': 'subscribe',
|
|
104
110
|
'topic': topic,
|
|
111
|
+
'id': requestId,
|
|
105
112
|
};
|
|
106
|
-
const
|
|
107
|
-
|
|
113
|
+
const subscription = {
|
|
114
|
+
'id': requestId.toString(),
|
|
115
|
+
'name': method,
|
|
116
|
+
'symbol': symbol,
|
|
117
|
+
'limit': limit,
|
|
118
|
+
'params': params,
|
|
119
|
+
};
|
|
120
|
+
if (method === 'orderbookupdate') {
|
|
121
|
+
subscription['method'] = this.handleOrderBookSubscription;
|
|
122
|
+
}
|
|
123
|
+
const orderbook = await this.watch(url, topic, this.extend(request, params), topic, subscription);
|
|
108
124
|
return orderbook.limit();
|
|
109
125
|
}
|
|
110
126
|
handleOrderBook(client, message) {
|
|
111
127
|
//
|
|
112
128
|
// {
|
|
113
|
-
// "topic": "PERP_BTC_USDT@
|
|
114
|
-
// "ts":
|
|
129
|
+
// "topic": "PERP_BTC_USDT@orderbookupdate",
|
|
130
|
+
// "ts": 1722500373999,
|
|
115
131
|
// "data": {
|
|
116
132
|
// "symbol": "PERP_BTC_USDT",
|
|
133
|
+
// "prevTs": 1722500373799,
|
|
117
134
|
// "bids": [
|
|
118
135
|
// [
|
|
119
136
|
// 0.30891,
|
|
@@ -134,14 +151,106 @@ export default class woo extends wooRest {
|
|
|
134
151
|
const market = this.safeMarket(marketId);
|
|
135
152
|
const symbol = market['symbol'];
|
|
136
153
|
const topic = this.safeString(message, 'topic');
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
const method = this.safeString(topic.split('@'), 1);
|
|
155
|
+
if (method === 'orderbookupdate') {
|
|
156
|
+
if (!(symbol in this.orderbooks)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const orderbook = this.orderbooks[symbol];
|
|
160
|
+
const timestamp = this.safeInteger(orderbook, 'timestamp');
|
|
161
|
+
if (timestamp === undefined) {
|
|
162
|
+
orderbook.cache.push(message);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
try {
|
|
166
|
+
const ts = this.safeInteger(message, 'ts');
|
|
167
|
+
if (ts > timestamp) {
|
|
168
|
+
this.handleOrderBookMessage(client, message, orderbook);
|
|
169
|
+
client.resolve(orderbook, topic);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
delete this.orderbooks[symbol];
|
|
174
|
+
delete client.subscriptions[topic];
|
|
175
|
+
client.reject(e, topic);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
if (!(symbol in this.orderbooks)) {
|
|
181
|
+
const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
|
|
182
|
+
const subscription = client.subscriptions[topic];
|
|
183
|
+
const limit = this.safeInteger(subscription, 'limit', defaultLimit);
|
|
184
|
+
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
185
|
+
}
|
|
186
|
+
const orderbook = this.orderbooks[symbol];
|
|
187
|
+
const timestamp = this.safeInteger(message, 'ts');
|
|
188
|
+
const snapshot = this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks');
|
|
189
|
+
orderbook.reset(snapshot);
|
|
190
|
+
client.resolve(orderbook, topic);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
handleOrderBookSubscription(client, message, subscription) {
|
|
194
|
+
const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
|
|
195
|
+
const limit = this.safeInteger(subscription, 'limit', defaultLimit);
|
|
196
|
+
const symbol = this.safeString(subscription, 'symbol'); // watchOrderBook
|
|
197
|
+
if (symbol in this.orderbooks) {
|
|
198
|
+
delete this.orderbooks[symbol];
|
|
139
199
|
}
|
|
140
|
-
|
|
200
|
+
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
201
|
+
this.spawn(this.fetchOrderBookSnapshot, client, message, subscription);
|
|
202
|
+
}
|
|
203
|
+
async fetchOrderBookSnapshot(client, message, subscription) {
|
|
204
|
+
const symbol = this.safeString(subscription, 'symbol');
|
|
205
|
+
const messageHash = this.safeString(message, 'topic');
|
|
206
|
+
try {
|
|
207
|
+
const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
|
|
208
|
+
const limit = this.safeInteger(subscription, 'limit', defaultLimit);
|
|
209
|
+
const params = this.safeValue(subscription, 'params');
|
|
210
|
+
const snapshot = await this.fetchRestOrderBookSafe(symbol, limit, params);
|
|
211
|
+
if (this.safeValue(this.orderbooks, symbol) === undefined) {
|
|
212
|
+
// if the orderbook is dropped before the snapshot is received
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const orderbook = this.orderbooks[symbol];
|
|
216
|
+
orderbook.reset(snapshot);
|
|
217
|
+
const messages = orderbook.cache;
|
|
218
|
+
for (let i = 0; i < messages.length; i++) {
|
|
219
|
+
const messageItem = messages[i];
|
|
220
|
+
const ts = this.safeInteger(messageItem, 'ts');
|
|
221
|
+
if (ts < orderbook['timestamp']) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
this.handleOrderBookMessage(client, messageItem, orderbook);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
this.orderbooks[symbol] = orderbook;
|
|
229
|
+
client.resolve(orderbook, messageHash);
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
delete client.subscriptions[messageHash];
|
|
233
|
+
client.reject(e, messageHash);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
handleOrderBookMessage(client, message, orderbook) {
|
|
237
|
+
const data = this.safeDict(message, 'data');
|
|
238
|
+
this.handleDeltas(orderbook['asks'], this.safeValue(data, 'asks', []));
|
|
239
|
+
this.handleDeltas(orderbook['bids'], this.safeValue(data, 'bids', []));
|
|
141
240
|
const timestamp = this.safeInteger(message, 'ts');
|
|
142
|
-
|
|
143
|
-
orderbook.
|
|
144
|
-
|
|
241
|
+
orderbook['timestamp'] = timestamp;
|
|
242
|
+
orderbook['datetime'] = this.iso8601(timestamp);
|
|
243
|
+
return orderbook;
|
|
244
|
+
}
|
|
245
|
+
handleDelta(bookside, delta) {
|
|
246
|
+
const price = this.safeFloat2(delta, 'price', 0);
|
|
247
|
+
const amount = this.safeFloat2(delta, 'quantity', 1);
|
|
248
|
+
bookside.store(price, amount);
|
|
249
|
+
}
|
|
250
|
+
handleDeltas(bookside, deltas) {
|
|
251
|
+
for (let i = 0; i < deltas.length; i++) {
|
|
252
|
+
this.handleDelta(bookside, deltas[i]);
|
|
253
|
+
}
|
|
145
254
|
}
|
|
146
255
|
async watchTicker(symbol, params = {}) {
|
|
147
256
|
/**
|
|
@@ -1064,6 +1173,7 @@ export default class woo extends wooRest {
|
|
|
1064
1173
|
'pong': this.handlePong,
|
|
1065
1174
|
'subscribe': this.handleSubscribe,
|
|
1066
1175
|
'orderbook': this.handleOrderBook,
|
|
1176
|
+
'orderbookupdate': this.handleOrderBook,
|
|
1067
1177
|
'ticker': this.handleTicker,
|
|
1068
1178
|
'tickers': this.handleTickers,
|
|
1069
1179
|
'kline': this.handleOHLCV,
|
|
@@ -1129,6 +1239,13 @@ export default class woo extends wooRest {
|
|
|
1129
1239
|
// "ts": 1657117712212
|
|
1130
1240
|
// }
|
|
1131
1241
|
//
|
|
1242
|
+
const id = this.safeString(message, 'id');
|
|
1243
|
+
const subscriptionsById = this.indexBy(client.subscriptions, 'id');
|
|
1244
|
+
const subscription = this.safeValue(subscriptionsById, id, {});
|
|
1245
|
+
const method = this.safeValue(subscription, 'method');
|
|
1246
|
+
if (method !== undefined) {
|
|
1247
|
+
method.call(this, client, message, subscription);
|
|
1248
|
+
}
|
|
1132
1249
|
return message;
|
|
1133
1250
|
}
|
|
1134
1251
|
handleAuth(client, message) {
|
package/js/src/woo.js
CHANGED
|
@@ -147,7 +147,7 @@ export default class woo extends Exchange {
|
|
|
147
147
|
'https://support.woo.org/hc/en-001/articles/4404611795353--Trading-Fees',
|
|
148
148
|
],
|
|
149
149
|
'referral': {
|
|
150
|
-
'url': 'https://x.woo.org/register?ref=
|
|
150
|
+
'url': 'https://x.woo.org/register?ref=DIJT0CNL',
|
|
151
151
|
'discount': 0.35,
|
|
152
152
|
},
|
|
153
153
|
},
|
package/js/src/yobit.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export default class yobit extends Exchange {
|
|
|
12
12
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
13
13
|
fetchOrderBooks(symbols?: Strings, limit?: Int, params?: {}): Promise<Dictionary<OrderBook>>;
|
|
14
14
|
parseTicker(ticker: Dict, market?: Market): Ticker;
|
|
15
|
+
fetchTickersHelper(idsString: string, params?: {}): Promise<Tickers>;
|
|
15
16
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
16
17
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
17
18
|
parseTrade(trade: Dict, market?: Market): Trade;
|
package/js/src/yobit.js
CHANGED
|
@@ -550,6 +550,22 @@ export default class yobit extends Exchange {
|
|
|
550
550
|
'info': ticker,
|
|
551
551
|
}, market);
|
|
552
552
|
}
|
|
553
|
+
async fetchTickersHelper(idsString, params = {}) {
|
|
554
|
+
const request = {
|
|
555
|
+
'pair': idsString,
|
|
556
|
+
};
|
|
557
|
+
const tickers = await this.publicGetTickerPair(this.extend(request, params));
|
|
558
|
+
const result = {};
|
|
559
|
+
const keys = Object.keys(tickers);
|
|
560
|
+
for (let k = 0; k < keys.length; k++) {
|
|
561
|
+
const id = keys[k];
|
|
562
|
+
const ticker = tickers[id];
|
|
563
|
+
const market = this.safeMarket(id);
|
|
564
|
+
const symbol = market['symbol'];
|
|
565
|
+
result[symbol] = this.parseTicker(ticker, market);
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
553
569
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
554
570
|
/**
|
|
555
571
|
* @method
|
|
@@ -558,43 +574,53 @@ export default class yobit extends Exchange {
|
|
|
558
574
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
559
575
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
560
576
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
577
|
+
* @param {object} [params.all] you can set to `true` for convenience to fetch all tickers from this exchange by sending multiple requests
|
|
561
578
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
562
579
|
*/
|
|
563
|
-
|
|
564
|
-
|
|
580
|
+
let allSymbols = undefined;
|
|
581
|
+
[allSymbols, params] = this.handleParamBool(params, 'all', false);
|
|
582
|
+
if (symbols === undefined && !allSymbols) {
|
|
583
|
+
throw new ArgumentsRequired(this.id + ' fetchTickers() requires "symbols" argument or use `params["all"] = true` to send multiple requests for all markets');
|
|
565
584
|
}
|
|
566
585
|
await this.loadMarkets();
|
|
567
|
-
|
|
568
|
-
let ids = undefined;
|
|
569
|
-
if (symbols === undefined) {
|
|
570
|
-
ids = this.ids;
|
|
571
|
-
}
|
|
572
|
-
else {
|
|
573
|
-
ids = this.marketIds(symbols);
|
|
574
|
-
}
|
|
575
|
-
const idsLength = ids.length;
|
|
576
|
-
const idsString = ids.join('-');
|
|
586
|
+
const promises = [];
|
|
577
587
|
const maxLength = this.safeInteger(this.options, 'maxUrlLength', 2048);
|
|
578
588
|
// max URL length is 2048 symbols, including http schema, hostname, tld, etc...
|
|
579
|
-
const lenghtOfBaseUrl =
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
589
|
+
const lenghtOfBaseUrl = 40; // safe space for the url including api-base and endpoint dir is 30 chars
|
|
590
|
+
if (allSymbols) {
|
|
591
|
+
symbols = this.symbols;
|
|
592
|
+
let ids = '';
|
|
593
|
+
for (let i = 0; i < this.ids.length; i++) {
|
|
594
|
+
const id = this.ids[i];
|
|
595
|
+
const prefix = (ids === '') ? '' : '-';
|
|
596
|
+
ids += prefix + id;
|
|
597
|
+
if (ids.length > maxLength) {
|
|
598
|
+
promises.push(this.fetchTickersHelper(ids, params));
|
|
599
|
+
ids = '';
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (ids !== '') {
|
|
603
|
+
promises.push(this.fetchTickersHelper(ids, params));
|
|
604
|
+
}
|
|
583
605
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
606
|
+
else {
|
|
607
|
+
symbols = this.marketSymbols(symbols);
|
|
608
|
+
const ids = this.marketIds(symbols);
|
|
609
|
+
const idsLength = ids.length;
|
|
610
|
+
const idsString = ids.join('-');
|
|
611
|
+
const actualLength = idsString.length + lenghtOfBaseUrl;
|
|
612
|
+
if (actualLength > maxLength) {
|
|
613
|
+
throw new ArgumentsRequired(this.id + ' fetchTickers() is being requested for ' + idsLength.toString() + ' markets (which has an URL length of ' + actualLength.toString() + ' characters), but it exceedes max URL length (' + maxLength.toString() + '), please pass limisted symbols array to fetchTickers to fit in one request');
|
|
614
|
+
}
|
|
615
|
+
promises.push(this.fetchTickersHelper(idsString, params));
|
|
616
|
+
}
|
|
617
|
+
const resultAll = await Promise.all(promises);
|
|
618
|
+
let finalResult = {};
|
|
619
|
+
for (let i = 0; i < resultAll.length; i++) {
|
|
620
|
+
const result = this.filterByArrayTickers(resultAll[i], 'symbol', symbols);
|
|
621
|
+
finalResult = this.extend(finalResult, result);
|
|
596
622
|
}
|
|
597
|
-
return
|
|
623
|
+
return finalResult;
|
|
598
624
|
}
|
|
599
625
|
async fetchTicker(symbol, params = {}) {
|
|
600
626
|
/**
|
package/package.json
CHANGED