ccxt 4.2.51 → 4.2.52
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/CHANGELOG.md +76 -16
- package/README.md +5 -6
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +688 -1360
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -4
- package/dist/cjs/src/base/Exchange.js +65 -26
- package/dist/cjs/src/binance.js +45 -2
- package/dist/cjs/src/pro/binance.js +156 -1
- package/dist/cjs/src/pro/bitfinex2.js +3 -1
- package/dist/cjs/src/pro/gate.js +2 -1
- package/dist/cjs/src/woo.js +3 -1
- package/js/ccxt.d.ts +2 -5
- package/js/ccxt.js +2 -4
- package/js/src/base/Exchange.d.ts +65 -26
- package/js/src/base/Exchange.js +65 -26
- package/js/src/binance.d.ts +4 -0
- package/js/src/binance.js +45 -2
- package/js/src/deribit.js +1 -1
- package/js/src/ndax.js +1 -1
- package/js/src/pro/binance.d.ts +3 -0
- package/js/src/pro/binance.js +156 -1
- package/js/src/pro/bingx.js +1 -1
- package/js/src/pro/bitfinex2.js +3 -1
- package/js/src/pro/gate.js +2 -1
- package/js/src/woo.js +4 -2
- package/package.json +1 -1
- package/skip-tests.json +4 -5
- package/dist/cjs/src/abstract/bitforex.js +0 -9
- package/dist/cjs/src/bitforex.js +0 -884
- package/js/src/abstract/bitforex.d.ts +0 -27
- package/js/src/abstract/bitforex.js +0 -11
- package/js/src/bitforex.d.ts +0 -39
- package/js/src/bitforex.js +0 -885
package/js/src/pro/binance.js
CHANGED
|
@@ -41,9 +41,11 @@ export default class binance extends binanceRest {
|
|
|
41
41
|
'fetchDepositsWs': false,
|
|
42
42
|
'fetchMarketsWs': false,
|
|
43
43
|
'fetchMyTradesWs': true,
|
|
44
|
+
'fetchOHLCVWs': true,
|
|
44
45
|
'fetchOpenOrdersWs': true,
|
|
45
46
|
'fetchOrderWs': true,
|
|
46
47
|
'fetchOrdersWs': true,
|
|
48
|
+
'fetchTradesWs': true,
|
|
47
49
|
'fetchTradingFeesWs': false,
|
|
48
50
|
'fetchWithdrawalsWs': false,
|
|
49
51
|
},
|
|
@@ -840,6 +842,94 @@ export default class binance extends binanceRest {
|
|
|
840
842
|
stored.append(parsed);
|
|
841
843
|
client.resolve(stored, messageHash);
|
|
842
844
|
}
|
|
845
|
+
async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
846
|
+
/**
|
|
847
|
+
* @method
|
|
848
|
+
* @name binance#fetchOHLCVWs
|
|
849
|
+
* @see https://binance-docs.github.io/apidocs/websocket_api/en/#klines
|
|
850
|
+
* @description query historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
851
|
+
* @param {string} symbol unified symbol of the market to query OHLCV data for
|
|
852
|
+
* @param {string} timeframe the length of time each candle represents
|
|
853
|
+
* @param {int} since timestamp in ms of the earliest candle to fetch
|
|
854
|
+
* @param {int} limit the maximum amount of candles to fetch
|
|
855
|
+
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
856
|
+
* @param {int} params.until timestamp in ms of the earliest candle to fetch
|
|
857
|
+
*
|
|
858
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
859
|
+
* @param {string} params.timeZone default=0 (UTC)
|
|
860
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
861
|
+
*/
|
|
862
|
+
await this.loadMarkets();
|
|
863
|
+
this.checkIsSpot('fetchOHLCVWs', symbol, params);
|
|
864
|
+
const url = this.urls['api']['ws']['ws'];
|
|
865
|
+
const requestId = this.requestId(url);
|
|
866
|
+
const messageHash = requestId.toString();
|
|
867
|
+
let returnRateLimits = false;
|
|
868
|
+
[returnRateLimits, params] = this.handleOptionAndParams(params, 'fetchOHLCVWs', 'returnRateLimits', false);
|
|
869
|
+
const payload = {
|
|
870
|
+
'symbol': this.marketId(symbol),
|
|
871
|
+
'returnRateLimits': returnRateLimits,
|
|
872
|
+
'interval': this.timeframes[timeframe],
|
|
873
|
+
};
|
|
874
|
+
const until = this.safeInteger(params, 'until');
|
|
875
|
+
params = this.omit(params, 'until');
|
|
876
|
+
if (since !== undefined) {
|
|
877
|
+
payload['startTime'] = since;
|
|
878
|
+
}
|
|
879
|
+
if (limit !== undefined) {
|
|
880
|
+
payload['limit'] = limit;
|
|
881
|
+
}
|
|
882
|
+
if (until !== undefined) {
|
|
883
|
+
payload['endTime'] = until;
|
|
884
|
+
}
|
|
885
|
+
const message = {
|
|
886
|
+
'id': messageHash,
|
|
887
|
+
'method': 'klines',
|
|
888
|
+
'params': this.extend(payload, params),
|
|
889
|
+
};
|
|
890
|
+
const subscription = {
|
|
891
|
+
'method': this.handleFetchOHLCV,
|
|
892
|
+
};
|
|
893
|
+
return await this.watch(url, messageHash, message, messageHash, subscription);
|
|
894
|
+
}
|
|
895
|
+
handleFetchOHLCV(client, message) {
|
|
896
|
+
//
|
|
897
|
+
// {
|
|
898
|
+
// "id": "1dbbeb56-8eea-466a-8f6e-86bdcfa2fc0b",
|
|
899
|
+
// "status": 200,
|
|
900
|
+
// "result": [
|
|
901
|
+
// [
|
|
902
|
+
// 1655971200000, // Kline open time
|
|
903
|
+
// "0.01086000", // Open price
|
|
904
|
+
// "0.01086600", // High price
|
|
905
|
+
// "0.01083600", // Low price
|
|
906
|
+
// "0.01083800", // Close price
|
|
907
|
+
// "2290.53800000", // Volume
|
|
908
|
+
// 1655974799999, // Kline close time
|
|
909
|
+
// "24.85074442", // Quote asset volume
|
|
910
|
+
// 2283, // Number of trades
|
|
911
|
+
// "1171.64000000", // Taker buy base asset volume
|
|
912
|
+
// "12.71225884", // Taker buy quote asset volume
|
|
913
|
+
// "0" // Unused field, ignore
|
|
914
|
+
// ]
|
|
915
|
+
// ],
|
|
916
|
+
// "rateLimits": [
|
|
917
|
+
// {
|
|
918
|
+
// "rateLimitType": "REQUEST_WEIGHT",
|
|
919
|
+
// "interval": "MINUTE",
|
|
920
|
+
// "intervalNum": 1,
|
|
921
|
+
// "limit": 6000,
|
|
922
|
+
// "count": 2
|
|
923
|
+
// }
|
|
924
|
+
// ]
|
|
925
|
+
// }
|
|
926
|
+
//
|
|
927
|
+
const result = this.safeList(message, 'result');
|
|
928
|
+
const parsed = this.parseOHLCVs(result);
|
|
929
|
+
// use a reverse lookup in a static map instead
|
|
930
|
+
const messageHash = this.safeString(message, 'id');
|
|
931
|
+
client.resolve(parsed, messageHash);
|
|
932
|
+
}
|
|
843
933
|
async watchTicker(symbol, params = {}) {
|
|
844
934
|
/**
|
|
845
935
|
* @method
|
|
@@ -2541,12 +2631,58 @@ export default class binance extends binanceRest {
|
|
|
2541
2631
|
const trades = await this.watch(url, messageHash, message, messageHash, subscription);
|
|
2542
2632
|
return this.filterBySymbolSinceLimit(trades, symbol, since, limit);
|
|
2543
2633
|
}
|
|
2634
|
+
async fetchTradesWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2635
|
+
/**
|
|
2636
|
+
* @method
|
|
2637
|
+
* @name binance#fetchTradesWs
|
|
2638
|
+
* @see https://binance-docs.github.io/apidocs/websocket_api/en/#recent-trades
|
|
2639
|
+
* @description fetch all trades made by the user
|
|
2640
|
+
* @param {string} symbol unified market symbol
|
|
2641
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
2642
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve, default=500, max=1000
|
|
2643
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2644
|
+
*
|
|
2645
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
2646
|
+
* @param {int} [params.fromId] trade ID to begin at
|
|
2647
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2648
|
+
*/
|
|
2649
|
+
await this.loadMarkets();
|
|
2650
|
+
if (symbol === undefined) {
|
|
2651
|
+
throw new BadRequest(this.id + ' fetchTradesWs () requires a symbol argument');
|
|
2652
|
+
}
|
|
2653
|
+
this.checkIsSpot('fetchTradesWs', symbol, params);
|
|
2654
|
+
const url = this.urls['api']['ws']['ws'];
|
|
2655
|
+
const requestId = this.requestId(url);
|
|
2656
|
+
const messageHash = requestId.toString();
|
|
2657
|
+
let returnRateLimits = false;
|
|
2658
|
+
[returnRateLimits, params] = this.handleOptionAndParams(params, 'fetchTradesWs', 'returnRateLimits', false);
|
|
2659
|
+
const payload = {
|
|
2660
|
+
'symbol': this.marketId(symbol),
|
|
2661
|
+
'returnRateLimits': returnRateLimits,
|
|
2662
|
+
};
|
|
2663
|
+
if (limit !== undefined) {
|
|
2664
|
+
payload['limit'] = limit;
|
|
2665
|
+
}
|
|
2666
|
+
const message = {
|
|
2667
|
+
'id': messageHash,
|
|
2668
|
+
'method': 'trades.historical',
|
|
2669
|
+
'params': this.extend(payload, params),
|
|
2670
|
+
};
|
|
2671
|
+
const subscription = {
|
|
2672
|
+
'method': this.handleTradesWs,
|
|
2673
|
+
};
|
|
2674
|
+
const trades = await this.watch(url, messageHash, message, messageHash, subscription);
|
|
2675
|
+
return this.filterBySinceLimit(trades, since, limit);
|
|
2676
|
+
}
|
|
2544
2677
|
handleTradesWs(client, message) {
|
|
2678
|
+
//
|
|
2679
|
+
// fetchMyTradesWs
|
|
2545
2680
|
//
|
|
2546
2681
|
// {
|
|
2547
2682
|
// "id": "f4ce6a53-a29d-4f70-823b-4ab59391d6e8",
|
|
2548
2683
|
// "status": 200,
|
|
2549
|
-
// "result": [
|
|
2684
|
+
// "result": [
|
|
2685
|
+
// {
|
|
2550
2686
|
// "symbol": "BTCUSDT",
|
|
2551
2687
|
// "id": 1650422481,
|
|
2552
2688
|
// "orderId": 12569099453,
|
|
@@ -2565,6 +2701,25 @@ export default class binance extends binanceRest {
|
|
|
2565
2701
|
// ],
|
|
2566
2702
|
// }
|
|
2567
2703
|
//
|
|
2704
|
+
// fetchTradesWs
|
|
2705
|
+
//
|
|
2706
|
+
// {
|
|
2707
|
+
// "id": "f4ce6a53-a29d-4f70-823b-4ab59391d6e8",
|
|
2708
|
+
// "status": 200,
|
|
2709
|
+
// "result": [
|
|
2710
|
+
// {
|
|
2711
|
+
// "id": 0,
|
|
2712
|
+
// "price": "0.00005000",
|
|
2713
|
+
// "qty": "40.00000000",
|
|
2714
|
+
// "quoteQty": "0.00200000",
|
|
2715
|
+
// "time": 1500004800376,
|
|
2716
|
+
// "isBuyerMaker": true,
|
|
2717
|
+
// "isBestMatch": true
|
|
2718
|
+
// }
|
|
2719
|
+
// ...
|
|
2720
|
+
// ],
|
|
2721
|
+
// }
|
|
2722
|
+
//
|
|
2568
2723
|
const messageHash = this.safeString(message, 'id');
|
|
2569
2724
|
const result = this.safeValue(message, 'result', []);
|
|
2570
2725
|
const trades = this.parseTrades(result);
|
package/js/src/pro/bingx.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import bingxRest from '../bingx.js';
|
|
9
9
|
import { BadRequest, NetworkError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
|
|
11
|
-
import Precise from '../base/Precise.js';
|
|
11
|
+
import { Precise } from '../base/Precise.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
export default class bingx extends bingxRest {
|
|
14
14
|
describe() {
|
package/js/src/pro/bitfinex2.js
CHANGED
|
@@ -323,7 +323,9 @@ export default class bitfinex2 extends bitfinex2Rest {
|
|
|
323
323
|
const messageLength = message.length;
|
|
324
324
|
if (messageLength === 2) {
|
|
325
325
|
// initial snapshot
|
|
326
|
-
|
|
326
|
+
let trades = this.safeList(message, 1, []);
|
|
327
|
+
// needs to be reversed to make chronological order
|
|
328
|
+
trades = trades.reverse();
|
|
327
329
|
for (let i = 0; i < trades.length; i++) {
|
|
328
330
|
const parsed = this.parseWsTrade(trades[i], market);
|
|
329
331
|
stored.append(parsed);
|
package/js/src/pro/gate.js
CHANGED
|
@@ -386,8 +386,9 @@ export default class gate extends gateRest {
|
|
|
386
386
|
const parts = channel.split('.');
|
|
387
387
|
const rawMarketType = this.safeString(parts, 0);
|
|
388
388
|
const marketType = (rawMarketType === 'futures') ? 'contract' : 'spot';
|
|
389
|
+
const result = this.safeValue(message, 'result');
|
|
389
390
|
let results = [];
|
|
390
|
-
if (
|
|
391
|
+
if (Array.isArray(result)) {
|
|
391
392
|
results = this.safeList(message, 'result', []);
|
|
392
393
|
}
|
|
393
394
|
else {
|
package/js/src/woo.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/woo.js';
|
|
9
|
-
import { AuthenticationError, RateLimitExceeded, BadRequest, ExchangeError, InvalidOrder, ArgumentsRequired, NotSupported } from './base/errors.js';
|
|
9
|
+
import { AuthenticationError, RateLimitExceeded, BadRequest, ExchangeError, InvalidOrder, ArgumentsRequired, NotSupported, OnMaintenance } from './base/errors.js';
|
|
10
10
|
import { Precise } from './base/Precise.js';
|
|
11
11
|
import { TICK_SIZE } from './base/functions/number.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
@@ -298,7 +298,6 @@ export default class woo extends Exchange {
|
|
|
298
298
|
'-1007': BadRequest,
|
|
299
299
|
'-1008': InvalidOrder,
|
|
300
300
|
'-1009': BadRequest,
|
|
301
|
-
'-1011': ExchangeError,
|
|
302
301
|
'-1012': BadRequest,
|
|
303
302
|
'-1101': InvalidOrder,
|
|
304
303
|
'-1102': InvalidOrder,
|
|
@@ -307,6 +306,8 @@ export default class woo extends Exchange {
|
|
|
307
306
|
'-1105': InvalidOrder, // { "code": -1105, "message": "Price is X% too high or X% too low from the mid price." }
|
|
308
307
|
},
|
|
309
308
|
'broad': {
|
|
309
|
+
'Can not place': ExchangeError,
|
|
310
|
+
'maintenance': OnMaintenance,
|
|
310
311
|
'symbol must not be blank': BadRequest,
|
|
311
312
|
'The token is not supported': BadRequest,
|
|
312
313
|
'Your order and symbol are not valid or already canceled': BadRequest,
|
|
@@ -2383,6 +2384,7 @@ export default class woo extends Exchange {
|
|
|
2383
2384
|
}
|
|
2384
2385
|
//
|
|
2385
2386
|
// 400 Bad Request {"success":false,"code":-1012,"message":"Amount is required for buy market orders when margin disabled."}
|
|
2387
|
+
// {"code":"-1011","message":"The system is under maintenance.","success":false}
|
|
2386
2388
|
//
|
|
2387
2389
|
const success = this.safeValue(response, 'success');
|
|
2388
2390
|
const errorCode = this.safeString(response, 'code');
|
package/package.json
CHANGED
package/skip-tests.json
CHANGED
|
@@ -199,7 +199,6 @@
|
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
201
|
"bitfinex2": {
|
|
202
|
-
"skipWs": true,
|
|
203
202
|
"skipMethods": {
|
|
204
203
|
"loadMarkets": {
|
|
205
204
|
"currencyIdAndCode": "broken currencies"
|
|
@@ -371,7 +370,6 @@
|
|
|
371
370
|
}
|
|
372
371
|
},
|
|
373
372
|
"bitrue": {
|
|
374
|
-
"skipWs": true,
|
|
375
373
|
"skipMethods": {
|
|
376
374
|
"loadMarkets": {
|
|
377
375
|
"currencyIdAndCode": "broken currencies",
|
|
@@ -391,6 +389,7 @@
|
|
|
391
389
|
}
|
|
392
390
|
},
|
|
393
391
|
"bitso": {
|
|
392
|
+
"skipWs": true,
|
|
394
393
|
"skipMethods": {
|
|
395
394
|
"loadMarkets": {
|
|
396
395
|
"active": "not provided"
|
|
@@ -398,8 +397,10 @@
|
|
|
398
397
|
"fetchOHLCV": "randomly failing with 404 not found"
|
|
399
398
|
}
|
|
400
399
|
},
|
|
400
|
+
"bitforex": {
|
|
401
|
+
"skipWs": true
|
|
402
|
+
},
|
|
401
403
|
"bitstamp": {
|
|
402
|
-
"skipWs": true,
|
|
403
404
|
"skipMethods": {
|
|
404
405
|
"fetchOrderBook": "bid/ask might be 0",
|
|
405
406
|
"fetchL2OrderBook": "same",
|
|
@@ -450,8 +451,6 @@
|
|
|
450
451
|
}
|
|
451
452
|
},
|
|
452
453
|
"bitvavo": {
|
|
453
|
-
"skip": "temp",
|
|
454
|
-
"skipWs": "temp",
|
|
455
454
|
"httpsProxy": "http://51.83.140.52:11230",
|
|
456
455
|
"skipMethods": {
|
|
457
456
|
"fetchCurrencies": {
|