ccxt 4.3.15 → 4.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +1 -0
- package/dist/cjs/src/ascendex.js +1 -0
- package/dist/cjs/src/base/Exchange.js +24 -15
- package/dist/cjs/src/base/Precise.js +3 -2
- package/dist/cjs/src/base/ws/WsClient.js +4 -0
- package/dist/cjs/src/binance.js +10 -9
- package/dist/cjs/src/bingx.js +1 -0
- package/dist/cjs/src/bitmex.js +1 -0
- package/dist/cjs/src/bybit.js +11 -7
- package/dist/cjs/src/coinbaseinternational.js +1 -0
- package/dist/cjs/src/coinmetro.js +1 -0
- package/dist/cjs/src/cryptocom.js +1 -0
- package/dist/cjs/src/currencycom.js +1 -0
- package/dist/cjs/src/deribit.js +1 -0
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/gemini.js +1 -0
- package/dist/cjs/src/hitbtc.js +1 -0
- package/dist/cjs/src/hollaex.js +1 -0
- package/dist/cjs/src/hyperliquid.js +5 -0
- package/dist/cjs/src/idex.js +1 -0
- package/dist/cjs/src/krakenfutures.js +1 -0
- package/dist/cjs/src/ndax.js +1 -0
- package/dist/cjs/src/okx.js +18 -0
- package/dist/cjs/src/phemex.js +1 -0
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/bitfinex2.js +2 -0
- package/dist/cjs/src/pro/bitget.js +3 -0
- package/dist/cjs/src/pro/bybit.js +3 -3
- package/dist/cjs/src/pro/htx.js +2 -0
- package/dist/cjs/src/pro/independentreserve.js +2 -0
- package/dist/cjs/src/pro/kraken.js +2 -0
- package/dist/cjs/src/pro/okx.js +22 -22
- package/dist/cjs/src/probit.js +1 -0
- package/dist/cjs/src/wavesexchange.js +1 -0
- package/dist/cjs/src/woo.js +1 -0
- package/dist/cjs/src/zaif.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/alpaca.js +1 -0
- package/js/src/ascendex.js +1 -0
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +24 -15
- package/js/src/base/Precise.d.ts +19 -19
- package/js/src/base/Precise.js +3 -2
- package/js/src/base/errors.d.ts +37 -37
- package/js/src/base/ws/WsClient.d.ts +1 -1
- package/js/src/base/ws/WsClient.js +4 -0
- package/js/src/binance.js +10 -9
- package/js/src/bingx.js +1 -0
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +11 -7
- package/js/src/coinbaseinternational.js +1 -0
- package/js/src/coinmetro.js +1 -0
- package/js/src/cryptocom.js +1 -0
- package/js/src/currencycom.js +1 -0
- package/js/src/deribit.js +1 -0
- package/js/src/gate.js +1 -0
- package/js/src/gemini.js +1 -0
- package/js/src/hitbtc.js +1 -0
- package/js/src/hollaex.js +1 -0
- package/js/src/hyperliquid.js +5 -0
- package/js/src/idex.js +1 -0
- package/js/src/krakenfutures.js +1 -0
- package/js/src/kuna.d.ts +1 -1
- package/js/src/ndax.js +1 -0
- package/js/src/okx.js +19 -1
- package/js/src/phemex.js +1 -0
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/bitfinex2.js +2 -0
- package/js/src/pro/bitget.js +3 -0
- package/js/src/pro/bybit.js +3 -3
- package/js/src/pro/htx.js +2 -0
- package/js/src/pro/independentreserve.js +2 -0
- package/js/src/pro/kraken.js +2 -0
- package/js/src/pro/okx.js +23 -23
- package/js/src/probit.js +1 -0
- package/js/src/wavesexchange.js +1 -0
- package/js/src/woo.js +1 -0
- package/js/src/zaif.js +1 -1
- package/package.json +1 -1
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -450,10 +450,12 @@ class okx extends okx$1 {
|
|
|
450
450
|
/**
|
|
451
451
|
* @method
|
|
452
452
|
* @name okx#watchOrderBook
|
|
453
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel
|
|
453
454
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
454
455
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
455
456
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
456
457
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
458
|
+
* @param {string} [params.depth] okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
|
|
457
459
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
458
460
|
*/
|
|
459
461
|
//
|
|
@@ -485,16 +487,18 @@ class okx extends okx$1 {
|
|
|
485
487
|
/**
|
|
486
488
|
* @method
|
|
487
489
|
* @name okx#watchOrderBookForSymbols
|
|
490
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel
|
|
488
491
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
489
492
|
* @param {string[]} symbols unified array of symbols
|
|
490
493
|
* @param {int} [limit] 1,5, 400, 50 (l2-tbt, vip4+) or 40000 (vip5+) the maximum amount of order book entries to return
|
|
491
494
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
495
|
+
* @param {string} [params.depth] okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
|
|
492
496
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
493
497
|
*/
|
|
494
498
|
await this.loadMarkets();
|
|
495
499
|
symbols = this.marketSymbols(symbols);
|
|
496
|
-
|
|
497
|
-
|
|
500
|
+
let depth = undefined;
|
|
501
|
+
[depth, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'depth', 'books');
|
|
498
502
|
if (limit !== undefined) {
|
|
499
503
|
if (limit === 1) {
|
|
500
504
|
depth = 'bbo-tbt';
|
|
@@ -502,17 +506,17 @@ class okx extends okx$1 {
|
|
|
502
506
|
else if (limit > 1 && limit <= 5) {
|
|
503
507
|
depth = 'books5';
|
|
504
508
|
}
|
|
505
|
-
else if (limit === 400) {
|
|
506
|
-
depth = 'books';
|
|
507
|
-
}
|
|
508
509
|
else if (limit === 50) {
|
|
509
510
|
depth = 'books50-l2-tbt'; // Make sure you have VIP4 and above
|
|
510
511
|
}
|
|
511
|
-
else if (limit ===
|
|
512
|
-
depth = 'books
|
|
512
|
+
else if (limit === 400) {
|
|
513
|
+
depth = 'books';
|
|
513
514
|
}
|
|
514
515
|
}
|
|
515
516
|
if ((depth === 'books-l2-tbt') || (depth === 'books50-l2-tbt')) {
|
|
517
|
+
if (!this.checkRequiredCredentials(false)) {
|
|
518
|
+
throw new errors.AuthenticationError(this.id + ' watchOrderBook/watchOrderBookForSymbols requires authentication for this depth. Add credentials or change the depth option to books or books5');
|
|
519
|
+
}
|
|
516
520
|
await this.authenticate({ 'access': 'public' });
|
|
517
521
|
}
|
|
518
522
|
const topics = [];
|
|
@@ -576,6 +580,8 @@ class okx extends okx$1 {
|
|
|
576
580
|
const storedBids = orderbook['bids'];
|
|
577
581
|
this.handleDeltas(storedAsks, asks);
|
|
578
582
|
this.handleDeltas(storedBids, bids);
|
|
583
|
+
const marketId = this.safeString(message, 'instId');
|
|
584
|
+
const symbol = this.safeSymbol(marketId);
|
|
579
585
|
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
580
586
|
if (checksum) {
|
|
581
587
|
const asksLength = storedAsks.length;
|
|
@@ -596,6 +602,8 @@ class okx extends okx$1 {
|
|
|
596
602
|
const localChecksum = this.crc32(payload, true);
|
|
597
603
|
if (responseChecksum !== localChecksum) {
|
|
598
604
|
const error = new errors.InvalidNonce(this.id + ' invalid checksum');
|
|
605
|
+
delete client.subscriptions[messageHash];
|
|
606
|
+
delete this.orderbooks[symbol];
|
|
599
607
|
client.reject(error, messageHash);
|
|
600
608
|
}
|
|
601
609
|
}
|
|
@@ -690,10 +698,10 @@ class okx extends okx$1 {
|
|
|
690
698
|
// ]
|
|
691
699
|
// }
|
|
692
700
|
//
|
|
693
|
-
const arg = this.
|
|
701
|
+
const arg = this.safeDict(message, 'arg', {});
|
|
694
702
|
const channel = this.safeString(arg, 'channel');
|
|
695
703
|
const action = this.safeString(message, 'action');
|
|
696
|
-
const data = this.
|
|
704
|
+
const data = this.safeList(message, 'data', []);
|
|
697
705
|
const marketId = this.safeString(arg, 'instId');
|
|
698
706
|
const market = this.safeMarket(marketId);
|
|
699
707
|
const symbol = market['symbol'];
|
|
@@ -1523,29 +1531,21 @@ class okx extends okx$1 {
|
|
|
1523
1531
|
// { event: 'error', msg: "Illegal request: {"op":"subscribe","args":["spot/ticker:BTC-USDT"]}", code: "60012" }
|
|
1524
1532
|
// { event: 'error", msg: "channel:ticker,instId:BTC-USDT doesn"t exist", code: "60018" }
|
|
1525
1533
|
//
|
|
1526
|
-
const errorCode = this.
|
|
1534
|
+
const errorCode = this.safeString(message, 'code');
|
|
1527
1535
|
try {
|
|
1528
|
-
if (errorCode) {
|
|
1536
|
+
if (errorCode && errorCode !== '0') {
|
|
1529
1537
|
const feedback = this.id + ' ' + this.json(message);
|
|
1530
1538
|
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
1531
1539
|
const messageString = this.safeValue(message, 'msg');
|
|
1532
1540
|
if (messageString !== undefined) {
|
|
1533
1541
|
this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
|
|
1534
1542
|
}
|
|
1543
|
+
throw new errors.ExchangeError(feedback);
|
|
1535
1544
|
}
|
|
1536
1545
|
}
|
|
1537
1546
|
catch (e) {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
client.reject(e, messageHash);
|
|
1541
|
-
if (messageHash in client.subscriptions) {
|
|
1542
|
-
delete client.subscriptions[messageHash];
|
|
1543
|
-
}
|
|
1544
|
-
return false;
|
|
1545
|
-
}
|
|
1546
|
-
else {
|
|
1547
|
-
client.reject(e);
|
|
1548
|
-
}
|
|
1547
|
+
client.reject(e);
|
|
1548
|
+
return false;
|
|
1549
1549
|
}
|
|
1550
1550
|
return message;
|
|
1551
1551
|
}
|
package/dist/cjs/src/probit.js
CHANGED
package/dist/cjs/src/woo.js
CHANGED
package/dist/cjs/src/zaif.js
CHANGED
|
@@ -675,7 +675,7 @@ class zaif extends zaif$1 {
|
|
|
675
675
|
};
|
|
676
676
|
}
|
|
677
677
|
customNonce() {
|
|
678
|
-
const num = (this.milliseconds() / 1000)
|
|
678
|
+
const num = this.numberToString(this.milliseconds() / 1000);
|
|
679
679
|
const nonce = parseFloat(num);
|
|
680
680
|
return nonce.toFixed(8);
|
|
681
681
|
}
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.3.
|
|
7
|
+
declare const version = "4.3.16";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.3.
|
|
41
|
+
const version = '4.3.17';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/alpaca.js
CHANGED
package/js/src/ascendex.js
CHANGED
package/js/src/base/Exchange.js
CHANGED
|
@@ -351,6 +351,7 @@ export default class Exchange {
|
|
|
351
351
|
'publicAPI': true,
|
|
352
352
|
'privateAPI': true,
|
|
353
353
|
'CORS': undefined,
|
|
354
|
+
'sandbox': undefined,
|
|
354
355
|
'spot': undefined,
|
|
355
356
|
'margin': undefined,
|
|
356
357
|
'swap': undefined,
|
|
@@ -5835,24 +5836,26 @@ export default class Exchange {
|
|
|
5835
5836
|
let maxRetries = undefined;
|
|
5836
5837
|
[maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
|
|
5837
5838
|
let errors = 0;
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
catch (e) {
|
|
5847
|
-
if (e instanceof RateLimitExceeded) {
|
|
5848
|
-
throw e; // if we are rate limited, we should not retry and fail fast
|
|
5839
|
+
while (errors <= maxRetries) {
|
|
5840
|
+
try {
|
|
5841
|
+
if (timeframe && method !== 'fetchFundingRateHistory') {
|
|
5842
|
+
return await this[method](symbol, timeframe, since, limit, params);
|
|
5843
|
+
}
|
|
5844
|
+
else {
|
|
5845
|
+
return await this[method](symbol, since, limit, params);
|
|
5846
|
+
}
|
|
5849
5847
|
}
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5848
|
+
catch (e) {
|
|
5849
|
+
if (e instanceof RateLimitExceeded) {
|
|
5850
|
+
throw e; // if we are rate limited, we should not retry and fail fast
|
|
5851
|
+
}
|
|
5852
|
+
errors += 1;
|
|
5853
|
+
if (errors > maxRetries) {
|
|
5854
|
+
throw e;
|
|
5855
|
+
}
|
|
5853
5856
|
}
|
|
5854
5857
|
}
|
|
5855
|
-
return
|
|
5858
|
+
return [];
|
|
5856
5859
|
}
|
|
5857
5860
|
async fetchPaginatedCallDeterministic(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}, maxEntriesPerRequest = undefined) {
|
|
5858
5861
|
let maxCalls = undefined;
|
|
@@ -5866,6 +5869,9 @@ export default class Exchange {
|
|
|
5866
5869
|
if (since !== undefined) {
|
|
5867
5870
|
currentSince = Math.max(currentSince, since);
|
|
5868
5871
|
}
|
|
5872
|
+
else {
|
|
5873
|
+
currentSince = Math.max(currentSince, 1241440531000); // avoid timestamps older than 2009
|
|
5874
|
+
}
|
|
5869
5875
|
const until = this.safeInteger2(params, 'until', 'till'); // do not omit it here
|
|
5870
5876
|
if (until !== undefined) {
|
|
5871
5877
|
const requiredCalls = Math.ceil((until - since) / step);
|
|
@@ -5877,6 +5883,9 @@ export default class Exchange {
|
|
|
5877
5883
|
if ((until !== undefined) && (currentSince >= until)) {
|
|
5878
5884
|
break;
|
|
5879
5885
|
}
|
|
5886
|
+
if (currentSince >= current) {
|
|
5887
|
+
break;
|
|
5888
|
+
}
|
|
5880
5889
|
tasks.push(this.safeDeterministicCall(method, symbol, currentSince, maxEntriesPerRequest, timeframe, params));
|
|
5881
5890
|
currentSince = this.sum(currentSince, step) - 1;
|
|
5882
5891
|
}
|
package/js/src/base/Precise.d.ts
CHANGED
|
@@ -3,38 +3,38 @@ declare class Precise {
|
|
|
3
3
|
decimals: number;
|
|
4
4
|
integer: bigint;
|
|
5
5
|
base: any;
|
|
6
|
-
constructor(number:
|
|
7
|
-
mul(other:
|
|
8
|
-
div(other:
|
|
9
|
-
add(other:
|
|
10
|
-
mod(other:
|
|
11
|
-
sub(other:
|
|
6
|
+
constructor(number: bigint | string, decimals?: Int);
|
|
7
|
+
mul(other: Precise): Precise;
|
|
8
|
+
div(other: Precise, precision?: number): Precise;
|
|
9
|
+
add(other: Precise): Precise;
|
|
10
|
+
mod(other: Precise): Precise;
|
|
11
|
+
sub(other: Precise): Precise;
|
|
12
12
|
abs(): Precise;
|
|
13
13
|
neg(): Precise;
|
|
14
|
-
min(other:
|
|
15
|
-
max(other:
|
|
16
|
-
gt(other:
|
|
17
|
-
ge(other:
|
|
18
|
-
lt(other:
|
|
19
|
-
le(other:
|
|
14
|
+
min(other: Precise): Precise;
|
|
15
|
+
max(other: Precise): Precise;
|
|
16
|
+
gt(other: Precise): boolean;
|
|
17
|
+
ge(other: Precise): boolean;
|
|
18
|
+
lt(other: Precise): boolean;
|
|
19
|
+
le(other: Precise): boolean;
|
|
20
20
|
reduce(): this;
|
|
21
21
|
equals(other: any): boolean;
|
|
22
22
|
toString(): string;
|
|
23
23
|
static stringMul(string1: Str, string2: Str): string;
|
|
24
|
-
static stringDiv(string1:
|
|
24
|
+
static stringDiv(string1: Str, string2: Str, precision?: number): string;
|
|
25
25
|
static stringAdd(string1: Str, string2: Str): string;
|
|
26
26
|
static stringSub(string1: Str, string2: Str): string;
|
|
27
|
-
static stringAbs(string:
|
|
28
|
-
static stringNeg(string:
|
|
27
|
+
static stringAbs(string: Str): string;
|
|
28
|
+
static stringNeg(string: Str): string;
|
|
29
29
|
static stringMod(string1: Str, string2: Str): string;
|
|
30
30
|
static stringEquals(string1: Str, string2: Str): boolean;
|
|
31
31
|
static stringEq(string1: Str, string2: Str): boolean;
|
|
32
|
-
static stringMin(string1: Str, string2: Str):
|
|
33
|
-
static stringMax(string1: Str, string2: Str):
|
|
32
|
+
static stringMin(string1: Str, string2: Str): string;
|
|
33
|
+
static stringMax(string1: Str, string2: Str): string;
|
|
34
34
|
static stringGt(string1: Str, string2: Str): boolean;
|
|
35
35
|
static stringGe(string1: Str, string2: Str): boolean;
|
|
36
|
-
static stringLt(string1: Str, string2: Str):
|
|
37
|
-
static stringLe(string1: Str, string2: Str):
|
|
36
|
+
static stringLt(string1: Str, string2: Str): boolean;
|
|
37
|
+
static stringLe(string1: Str, string2: Str): boolean;
|
|
38
38
|
}
|
|
39
39
|
export default Precise;
|
|
40
40
|
export { Precise };
|
package/js/src/base/Precise.js
CHANGED
|
@@ -14,8 +14,9 @@ class Precise {
|
|
|
14
14
|
let modifier = 0;
|
|
15
15
|
number = number.toLowerCase();
|
|
16
16
|
if (number.indexOf('e') > -1) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
let modifierString = '0';
|
|
18
|
+
[number, modifierString] = number.split('e');
|
|
19
|
+
modifier = parseInt(modifierString);
|
|
19
20
|
}
|
|
20
21
|
const decimalIndex = number.indexOf('.');
|
|
21
22
|
this.decimals = (decimalIndex > -1) ? number.length - decimalIndex - 1 : 0;
|
package/js/src/base/errors.d.ts
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
1
|
declare class BaseError extends Error {
|
|
2
|
-
constructor(message:
|
|
2
|
+
constructor(message: string);
|
|
3
3
|
}
|
|
4
4
|
declare class ExchangeError extends BaseError {
|
|
5
|
-
constructor(message:
|
|
5
|
+
constructor(message: string);
|
|
6
6
|
}
|
|
7
7
|
declare class AuthenticationError extends ExchangeError {
|
|
8
|
-
constructor(message:
|
|
8
|
+
constructor(message: string);
|
|
9
9
|
}
|
|
10
10
|
declare class PermissionDenied extends AuthenticationError {
|
|
11
|
-
constructor(message:
|
|
11
|
+
constructor(message: string);
|
|
12
12
|
}
|
|
13
13
|
declare class AccountNotEnabled extends PermissionDenied {
|
|
14
|
-
constructor(message:
|
|
14
|
+
constructor(message: string);
|
|
15
15
|
}
|
|
16
16
|
declare class AccountSuspended extends AuthenticationError {
|
|
17
|
-
constructor(message:
|
|
17
|
+
constructor(message: string);
|
|
18
18
|
}
|
|
19
19
|
declare class ArgumentsRequired extends ExchangeError {
|
|
20
|
-
constructor(message:
|
|
20
|
+
constructor(message: string);
|
|
21
21
|
}
|
|
22
22
|
declare class BadRequest extends ExchangeError {
|
|
23
|
-
constructor(message:
|
|
23
|
+
constructor(message: string);
|
|
24
24
|
}
|
|
25
25
|
declare class BadSymbol extends BadRequest {
|
|
26
|
-
constructor(message:
|
|
26
|
+
constructor(message: string);
|
|
27
27
|
}
|
|
28
28
|
declare class OperationRejected extends ExchangeError {
|
|
29
|
-
constructor(message:
|
|
29
|
+
constructor(message: string);
|
|
30
30
|
}
|
|
31
31
|
declare class NoChange extends OperationRejected {
|
|
32
|
-
constructor(message:
|
|
32
|
+
constructor(message: string);
|
|
33
33
|
}
|
|
34
34
|
declare class MarginModeAlreadySet extends NoChange {
|
|
35
|
-
constructor(message:
|
|
35
|
+
constructor(message: string);
|
|
36
36
|
}
|
|
37
37
|
declare class MarketClosed extends OperationRejected {
|
|
38
|
-
constructor(message:
|
|
38
|
+
constructor(message: string);
|
|
39
39
|
}
|
|
40
40
|
declare class BadResponse extends ExchangeError {
|
|
41
|
-
constructor(message:
|
|
41
|
+
constructor(message: string);
|
|
42
42
|
}
|
|
43
43
|
declare class NullResponse extends BadResponse {
|
|
44
|
-
constructor(message:
|
|
44
|
+
constructor(message: string);
|
|
45
45
|
}
|
|
46
46
|
declare class InsufficientFunds extends ExchangeError {
|
|
47
|
-
constructor(message:
|
|
47
|
+
constructor(message: string);
|
|
48
48
|
}
|
|
49
49
|
declare class InvalidAddress extends ExchangeError {
|
|
50
|
-
constructor(message:
|
|
50
|
+
constructor(message: string);
|
|
51
51
|
}
|
|
52
52
|
declare class AddressPending extends InvalidAddress {
|
|
53
|
-
constructor(message:
|
|
53
|
+
constructor(message: string);
|
|
54
54
|
}
|
|
55
55
|
declare class InvalidOrder extends ExchangeError {
|
|
56
|
-
constructor(message:
|
|
56
|
+
constructor(message: string);
|
|
57
57
|
}
|
|
58
58
|
declare class OrderNotFound extends InvalidOrder {
|
|
59
|
-
constructor(message:
|
|
59
|
+
constructor(message: string);
|
|
60
60
|
}
|
|
61
61
|
declare class OrderNotCached extends InvalidOrder {
|
|
62
|
-
constructor(message:
|
|
62
|
+
constructor(message: string);
|
|
63
63
|
}
|
|
64
64
|
declare class CancelPending extends InvalidOrder {
|
|
65
|
-
constructor(message:
|
|
65
|
+
constructor(message: string);
|
|
66
66
|
}
|
|
67
67
|
declare class OrderImmediatelyFillable extends InvalidOrder {
|
|
68
|
-
constructor(message:
|
|
68
|
+
constructor(message: string);
|
|
69
69
|
}
|
|
70
70
|
declare class OrderNotFillable extends InvalidOrder {
|
|
71
|
-
constructor(message:
|
|
71
|
+
constructor(message: string);
|
|
72
72
|
}
|
|
73
73
|
declare class DuplicateOrderId extends InvalidOrder {
|
|
74
|
-
constructor(message:
|
|
74
|
+
constructor(message: string);
|
|
75
75
|
}
|
|
76
76
|
declare class ContractUnavailable extends InvalidOrder {
|
|
77
|
-
constructor(message:
|
|
77
|
+
constructor(message: string);
|
|
78
78
|
}
|
|
79
79
|
declare class NotSupported extends ExchangeError {
|
|
80
|
-
constructor(message:
|
|
80
|
+
constructor(message: string);
|
|
81
81
|
}
|
|
82
82
|
declare class ProxyError extends ExchangeError {
|
|
83
|
-
constructor(message:
|
|
83
|
+
constructor(message: string);
|
|
84
84
|
}
|
|
85
85
|
declare class ExchangeClosedByUser extends ExchangeError {
|
|
86
|
-
constructor(message:
|
|
86
|
+
constructor(message: string);
|
|
87
87
|
}
|
|
88
88
|
declare class OperationFailed extends BaseError {
|
|
89
|
-
constructor(message:
|
|
89
|
+
constructor(message: string);
|
|
90
90
|
}
|
|
91
91
|
declare class NetworkError extends OperationFailed {
|
|
92
|
-
constructor(message:
|
|
92
|
+
constructor(message: string);
|
|
93
93
|
}
|
|
94
94
|
declare class DDoSProtection extends NetworkError {
|
|
95
|
-
constructor(message:
|
|
95
|
+
constructor(message: string);
|
|
96
96
|
}
|
|
97
97
|
declare class RateLimitExceeded extends NetworkError {
|
|
98
|
-
constructor(message:
|
|
98
|
+
constructor(message: string);
|
|
99
99
|
}
|
|
100
100
|
declare class ExchangeNotAvailable extends NetworkError {
|
|
101
|
-
constructor(message:
|
|
101
|
+
constructor(message: string);
|
|
102
102
|
}
|
|
103
103
|
declare class OnMaintenance extends ExchangeNotAvailable {
|
|
104
|
-
constructor(message:
|
|
104
|
+
constructor(message: string);
|
|
105
105
|
}
|
|
106
106
|
declare class InvalidNonce extends NetworkError {
|
|
107
|
-
constructor(message:
|
|
107
|
+
constructor(message: string);
|
|
108
108
|
}
|
|
109
109
|
declare class RequestTimeout extends NetworkError {
|
|
110
|
-
constructor(message:
|
|
110
|
+
constructor(message: string);
|
|
111
111
|
}
|
|
112
112
|
export { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
|
|
113
113
|
declare const _default: {
|
|
@@ -12,6 +12,10 @@ import { Future } from './Future.js';
|
|
|
12
12
|
// eslint-disable-next-line no-restricted-globals
|
|
13
13
|
const WebSocketPlatform = isNode ? WebSocket : self.WebSocket;
|
|
14
14
|
export default class WsClient extends Client {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.startedConnecting = false;
|
|
18
|
+
}
|
|
15
19
|
createConnection() {
|
|
16
20
|
if (this.verbose) {
|
|
17
21
|
this.log(new Date(), 'connecting to', this.url);
|
package/js/src/binance.js
CHANGED
|
@@ -157,6 +157,7 @@ export default class binance extends Exchange {
|
|
|
157
157
|
'reduceMargin': true,
|
|
158
158
|
'repayCrossMargin': true,
|
|
159
159
|
'repayIsolatedMargin': true,
|
|
160
|
+
'sandbox': true,
|
|
160
161
|
'setLeverage': true,
|
|
161
162
|
'setMargin': false,
|
|
162
163
|
'setMarginMode': true,
|
|
@@ -2621,7 +2622,7 @@ export default class binance extends Exchange {
|
|
|
2621
2622
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2622
2623
|
* @returns {object} an associative dictionary of currencies
|
|
2623
2624
|
*/
|
|
2624
|
-
const fetchCurrenciesEnabled = this.
|
|
2625
|
+
const fetchCurrenciesEnabled = this.safeBool(this.options, 'fetchCurrencies');
|
|
2625
2626
|
if (!fetchCurrenciesEnabled) {
|
|
2626
2627
|
return undefined;
|
|
2627
2628
|
}
|
|
@@ -4545,7 +4546,7 @@ export default class binance extends Exchange {
|
|
|
4545
4546
|
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
4546
4547
|
const symbol = market['symbol'];
|
|
4547
4548
|
let side = undefined;
|
|
4548
|
-
const buyerMaker = this.
|
|
4549
|
+
const buyerMaker = this.safeBool2(trade, 'm', 'isBuyerMaker');
|
|
4549
4550
|
let takerOrMaker = undefined;
|
|
4550
4551
|
if (buyerMaker !== undefined) {
|
|
4551
4552
|
side = buyerMaker ? 'sell' : 'buy'; // this is reversed intentionally
|
|
@@ -4853,7 +4854,7 @@ export default class binance extends Exchange {
|
|
|
4853
4854
|
uppercaseType = 'STOP_LOSS_LIMIT';
|
|
4854
4855
|
}
|
|
4855
4856
|
}
|
|
4856
|
-
const validOrderTypes = this.
|
|
4857
|
+
const validOrderTypes = this.safeList(market['info'], 'orderTypes');
|
|
4857
4858
|
if (!this.inArray(uppercaseType, validOrderTypes)) {
|
|
4858
4859
|
if (initialUppercaseType !== uppercaseType) {
|
|
4859
4860
|
throw new InvalidOrder(this.id + ' stopPrice parameter is not allowed for ' + symbol + ' ' + type + ' orders');
|
|
@@ -4863,7 +4864,7 @@ export default class binance extends Exchange {
|
|
|
4863
4864
|
}
|
|
4864
4865
|
}
|
|
4865
4866
|
if (clientOrderId === undefined) {
|
|
4866
|
-
const broker = this.
|
|
4867
|
+
const broker = this.safeDict(this.options, 'broker');
|
|
4867
4868
|
if (broker !== undefined) {
|
|
4868
4869
|
const brokerId = this.safeString(broker, 'spot');
|
|
4869
4870
|
if (brokerId !== undefined) {
|
|
@@ -7662,7 +7663,7 @@ export default class binance extends Exchange {
|
|
|
7662
7663
|
request['endTime'] = until;
|
|
7663
7664
|
}
|
|
7664
7665
|
const raw = await this.sapiGetFiatOrders(this.extend(request, params));
|
|
7665
|
-
response = this.
|
|
7666
|
+
response = this.safeList(raw, 'data', []);
|
|
7666
7667
|
// {
|
|
7667
7668
|
// "code": "000000",
|
|
7668
7669
|
// "message": "success",
|
|
@@ -7777,7 +7778,7 @@ export default class binance extends Exchange {
|
|
|
7777
7778
|
request['beginTime'] = since;
|
|
7778
7779
|
}
|
|
7779
7780
|
const raw = await this.sapiGetFiatOrders(this.extend(request, params));
|
|
7780
|
-
response = this.
|
|
7781
|
+
response = this.safeList(raw, 'data', []);
|
|
7781
7782
|
// {
|
|
7782
7783
|
// "code": "000000",
|
|
7783
7784
|
// "message": "success",
|
|
@@ -7995,7 +7996,7 @@ export default class binance extends Exchange {
|
|
|
7995
7996
|
if (txType !== undefined) {
|
|
7996
7997
|
type = (txType === '0') ? 'deposit' : 'withdrawal';
|
|
7997
7998
|
}
|
|
7998
|
-
const legalMoneyCurrenciesById = this.
|
|
7999
|
+
const legalMoneyCurrenciesById = this.safeDict(this.options, 'legalMoneyCurrenciesById');
|
|
7999
8000
|
code = this.safeString(legalMoneyCurrenciesById, code, code);
|
|
8000
8001
|
}
|
|
8001
8002
|
const status = this.parseTransactionStatusByType(this.safeString(transaction, 'status'), type);
|
|
@@ -8349,7 +8350,7 @@ export default class binance extends Exchange {
|
|
|
8349
8350
|
}
|
|
8350
8351
|
}
|
|
8351
8352
|
impliedNetwork = this.safeString(reverseNetworks, topLevel);
|
|
8352
|
-
const impliedNetworks = this.
|
|
8353
|
+
const impliedNetworks = this.safeDict(this.options, 'impliedNetworks', {
|
|
8353
8354
|
'ETH': { 'ERC20': 'ETH' },
|
|
8354
8355
|
'TRX': { 'TRC20': 'TRX' },
|
|
8355
8356
|
});
|
|
@@ -9658,7 +9659,7 @@ export default class binance extends Exchange {
|
|
|
9658
9659
|
await this.loadMarkets();
|
|
9659
9660
|
// by default cache the leverage bracket
|
|
9660
9661
|
// it contains useful stuff like the maintenance margin and initial margin for positions
|
|
9661
|
-
const leverageBrackets = this.
|
|
9662
|
+
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
|
|
9662
9663
|
if ((leverageBrackets === undefined) || (reload)) {
|
|
9663
9664
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
9664
9665
|
const type = this.safeString(params, 'type', defaultType);
|
package/js/src/bingx.js
CHANGED