ccxt 4.3.73 → 4.3.75
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/binance.js +236 -87
- package/dist/cjs/src/bybit.js +42 -7
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/pro/alpaca.js +5 -0
- package/dist/cjs/src/pro/binance.js +15 -2
- package/dist/cjs/src/pro/bitfinex.js +5 -0
- package/dist/cjs/src/whitebit.js +17 -2
- 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/abstract/bybit.d.ts +1 -0
- package/js/src/ace.js +1 -1
- package/js/src/binance.js +236 -87
- package/js/src/bybit.js +42 -7
- package/js/src/mexc.js +1 -1
- package/js/src/pro/alpaca.js +5 -0
- package/js/src/pro/binance.js +15 -2
- package/js/src/pro/bitfinex.js +5 -0
- package/js/src/whitebit.js +17 -2
- 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/alpaca.js
CHANGED
|
@@ -52,6 +52,7 @@ export default class alpaca extends alpacaRest {
|
|
|
52
52
|
* @method
|
|
53
53
|
* @name alpaca#watchTicker
|
|
54
54
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
55
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#quotes
|
|
55
56
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
56
57
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
57
58
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -127,6 +128,7 @@ export default class alpaca extends alpacaRest {
|
|
|
127
128
|
* @method
|
|
128
129
|
* @name alpaca#watchOHLCV
|
|
129
130
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
131
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#bars
|
|
130
132
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
131
133
|
* @param {string} timeframe the length of time each candle represents
|
|
132
134
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -183,6 +185,7 @@ export default class alpaca extends alpacaRest {
|
|
|
183
185
|
* @method
|
|
184
186
|
* @name alpaca#watchOrderBook
|
|
185
187
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
188
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#orderbooks
|
|
186
189
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
187
190
|
* @param {int} [limit] the maximum amount of order book entries to return.
|
|
188
191
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -262,6 +265,7 @@ export default class alpaca extends alpacaRest {
|
|
|
262
265
|
* @method
|
|
263
266
|
* @name alpaca#watchTrades
|
|
264
267
|
* @description watches information on multiple trades made in a market
|
|
268
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#trades
|
|
265
269
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
266
270
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
267
271
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -314,6 +318,7 @@ export default class alpaca extends alpacaRest {
|
|
|
314
318
|
* @method
|
|
315
319
|
* @name alpaca#watchMyTrades
|
|
316
320
|
* @description watches information on multiple trades made by the user
|
|
321
|
+
* @see https://docs.alpaca.markets/docs/websocket-streaming#trade-updates
|
|
317
322
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
318
323
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
319
324
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
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) {
|
|
@@ -1258,6 +1270,7 @@ export default class binance extends binanceRest {
|
|
|
1258
1270
|
const subscribe = {
|
|
1259
1271
|
'id': requestId,
|
|
1260
1272
|
};
|
|
1273
|
+
params = this.omit(params, 'callerMethodName');
|
|
1261
1274
|
const [symbol, timeframe, candles] = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscribe);
|
|
1262
1275
|
if (this.newUpdates) {
|
|
1263
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/whitebit.js
CHANGED
|
@@ -807,8 +807,23 @@ export default class whitebit extends Exchange {
|
|
|
807
807
|
// "change": "2.12" // in percent
|
|
808
808
|
// }
|
|
809
809
|
//
|
|
810
|
+
// WS market_update
|
|
811
|
+
//
|
|
812
|
+
// {
|
|
813
|
+
// "open": "52853.04",
|
|
814
|
+
// "close": "55913.88",
|
|
815
|
+
// "high": "56272",
|
|
816
|
+
// "low": "49549.67",
|
|
817
|
+
// "volume": "57331.067185",
|
|
818
|
+
// "deal": "3063860382.42985338",
|
|
819
|
+
// "last": "55913.88",
|
|
820
|
+
// "period": 86400
|
|
821
|
+
// }
|
|
810
822
|
market = this.safeMarket(undefined, market);
|
|
811
|
-
|
|
823
|
+
// last price is provided as "last" or "last_price"
|
|
824
|
+
const last = this.safeString2(ticker, 'last', 'last_price');
|
|
825
|
+
// if "close" is provided, use it, otherwise use <last>
|
|
826
|
+
const close = this.safeString(ticker, 'close', last);
|
|
812
827
|
return this.safeTicker({
|
|
813
828
|
'symbol': market['symbol'],
|
|
814
829
|
'timestamp': undefined,
|
|
@@ -821,7 +836,7 @@ export default class whitebit extends Exchange {
|
|
|
821
836
|
'askVolume': undefined,
|
|
822
837
|
'vwap': undefined,
|
|
823
838
|
'open': this.safeString(ticker, 'open'),
|
|
824
|
-
'close':
|
|
839
|
+
'close': close,
|
|
825
840
|
'last': last,
|
|
826
841
|
'previousClose': undefined,
|
|
827
842
|
'change': undefined,
|
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