ccxt 4.2.85 → 4.2.87
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.js +1132 -432
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +11 -1
- package/dist/cjs/src/binance.js +14 -1
- package/dist/cjs/src/bingx.js +71 -20
- package/dist/cjs/src/bitbank.js +19 -23
- package/dist/cjs/src/bitfinex.js +3 -0
- package/dist/cjs/src/bitfinex2.js +16 -1
- package/dist/cjs/src/bitflyer.js +19 -0
- package/dist/cjs/src/bitget.js +15 -1
- package/dist/cjs/src/bitopro.js +3 -0
- package/dist/cjs/src/bitrue.js +13 -7
- package/dist/cjs/src/bitvavo.js +3 -0
- package/dist/cjs/src/btcmarkets.js +1 -1
- package/dist/cjs/src/btcturk.js +2 -1
- package/dist/cjs/src/coinex.js +576 -302
- package/dist/cjs/src/currencycom.js +1 -1
- package/dist/cjs/src/delta.js +3 -1
- package/dist/cjs/src/digifinex.js +4 -2
- package/dist/cjs/src/exmo.js +11 -12
- package/dist/cjs/src/gate.js +5 -2
- package/dist/cjs/src/hitbtc.js +26 -2
- package/dist/cjs/src/htx.js +2 -2
- package/dist/cjs/src/huobijp.js +1 -1
- package/dist/cjs/src/hyperliquid.js +249 -12
- package/dist/cjs/src/idex.js +11 -12
- package/dist/cjs/src/krakenfutures.js +2 -6
- package/dist/cjs/src/lbank.js +3 -0
- package/dist/cjs/src/oceanex.js +1 -1
- package/dist/cjs/src/okcoin.js +3 -1
- package/dist/cjs/src/okx.js +24 -10
- package/dist/cjs/src/phemex.js +3 -1
- package/dist/cjs/src/pro/bitget.js +1 -0
- package/dist/cjs/src/pro/kucoin.js +11 -6
- package/dist/cjs/src/wazirx.js +1 -1
- package/dist/cjs/src/zonda.js +3 -0
- package/examples/js/benchmark.js +104 -0
- package/examples/ts/benchmark.ts +134 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/coinex.d.ts +232 -123
- package/js/src/ascendex.d.ts +5 -12
- package/js/src/ascendex.js +11 -1
- package/js/src/base/Exchange.d.ts +13 -13
- package/js/src/base/types.d.ts +11 -0
- package/js/src/binance.d.ts +4 -11
- package/js/src/binance.js +14 -1
- package/js/src/bingx.d.ts +5 -2
- package/js/src/bingx.js +71 -20
- package/js/src/bitbank.js +19 -23
- package/js/src/bitfinex.js +3 -0
- package/js/src/bitfinex2.d.ts +3 -17
- package/js/src/bitfinex2.js +16 -1
- package/js/src/bitflyer.d.ts +1 -0
- package/js/src/bitflyer.js +20 -1
- package/js/src/bitget.d.ts +5 -12
- package/js/src/bitget.js +15 -1
- package/js/src/bitopro.js +3 -0
- package/js/src/bitrue.d.ts +3 -17
- package/js/src/bitrue.js +13 -7
- package/js/src/bitvavo.js +3 -0
- package/js/src/btcmarkets.js +1 -1
- package/js/src/btcturk.js +2 -1
- package/js/src/coinex.d.ts +5 -12
- package/js/src/coinex.js +576 -302
- package/js/src/currencycom.js +1 -1
- package/js/src/delta.d.ts +5 -37
- package/js/src/delta.js +3 -1
- package/js/src/digifinex.d.ts +5 -13
- package/js/src/digifinex.js +4 -2
- package/js/src/exmo.d.ts +5 -37
- package/js/src/exmo.js +11 -12
- package/js/src/gate.d.ts +5 -33
- package/js/src/gate.js +5 -2
- package/js/src/hitbtc.d.ts +5 -12
- package/js/src/hitbtc.js +26 -2
- package/js/src/htx.js +2 -2
- package/js/src/huobijp.js +1 -1
- package/js/src/hyperliquid.d.ts +7 -4
- package/js/src/hyperliquid.js +249 -12
- package/js/src/idex.js +11 -12
- package/js/src/krakenfutures.js +2 -6
- package/js/src/kucoinfutures.d.ts +2 -2
- package/js/src/lbank.js +3 -0
- package/js/src/mexc.d.ts +3 -3
- package/js/src/oceanex.js +1 -1
- package/js/src/okcoin.js +3 -1
- package/js/src/okx.d.ts +5 -33
- package/js/src/okx.js +24 -10
- package/js/src/phemex.d.ts +3 -11
- package/js/src/phemex.js +3 -1
- package/js/src/pro/bitget.js +1 -0
- package/js/src/pro/kucoin.js +11 -6
- package/js/src/wazirx.js +1 -1
- package/js/src/zonda.js +3 -0
- package/package.json +3 -2
- package/skip-tests.json +7 -3
package/js/src/bingx.js
CHANGED
|
@@ -33,6 +33,7 @@ export default class bingx extends Exchange {
|
|
|
33
33
|
'swap': true,
|
|
34
34
|
'future': false,
|
|
35
35
|
'option': false,
|
|
36
|
+
'addMargin': true,
|
|
36
37
|
'cancelAllOrders': true,
|
|
37
38
|
'cancelOrder': true,
|
|
38
39
|
'cancelOrders': true,
|
|
@@ -79,6 +80,7 @@ export default class bingx extends Exchange {
|
|
|
79
80
|
'fetchTrades': true,
|
|
80
81
|
'fetchTransfers': true,
|
|
81
82
|
'fetchWithdrawals': true,
|
|
83
|
+
'reduceMargin': true,
|
|
82
84
|
'setLeverage': true,
|
|
83
85
|
'setMargin': true,
|
|
84
86
|
'setMarginMode': true,
|
|
@@ -632,7 +634,7 @@ export default class bingx extends Exchange {
|
|
|
632
634
|
symbol += ':' + settle;
|
|
633
635
|
}
|
|
634
636
|
const fees = this.safeDict(this.fees, type, {});
|
|
635
|
-
const contractSize = this.
|
|
637
|
+
const contractSize = (swap) ? this.parseNumber('1') : undefined;
|
|
636
638
|
const isActive = this.safeString(market, 'status') === '1';
|
|
637
639
|
const isInverse = (spot) ? undefined : false;
|
|
638
640
|
const isLinear = (spot) ? undefined : swap;
|
|
@@ -673,7 +675,7 @@ export default class bingx extends Exchange {
|
|
|
673
675
|
'max': this.safeInteger(market, 'maxLongLeverage'),
|
|
674
676
|
},
|
|
675
677
|
'amount': {
|
|
676
|
-
'min': this.
|
|
678
|
+
'min': this.safeNumber2(market, 'minQty', 'tradeMinQuantity'),
|
|
677
679
|
'max': this.safeNumber(market, 'maxQty'),
|
|
678
680
|
},
|
|
679
681
|
'price': {
|
|
@@ -681,7 +683,7 @@ export default class bingx extends Exchange {
|
|
|
681
683
|
'max': undefined,
|
|
682
684
|
},
|
|
683
685
|
'cost': {
|
|
684
|
-
'min': this.
|
|
686
|
+
'min': this.safeNumber2(market, 'minNotional', 'tradeMinUSDT'),
|
|
685
687
|
'max': this.safeNumber(market, 'maxNotional'),
|
|
686
688
|
},
|
|
687
689
|
},
|
|
@@ -1038,6 +1040,13 @@ export default class bingx extends Exchange {
|
|
|
1038
1040
|
if (isMaker !== undefined) {
|
|
1039
1041
|
takeOrMaker = isMaker ? 'maker' : 'taker';
|
|
1040
1042
|
}
|
|
1043
|
+
let amount = this.safeStringN(trade, ['qty', 'amount', 'q']);
|
|
1044
|
+
if ((market !== undefined) && market['swap'] && ('volume' in trade)) {
|
|
1045
|
+
// private trade returns num of contracts instead of base currency (as the order-related methods do)
|
|
1046
|
+
const contractSize = this.safeString(market['info'], 'tradeMinQuantity');
|
|
1047
|
+
const volume = this.safeString(trade, 'volume');
|
|
1048
|
+
amount = Precise.stringMul(volume, contractSize);
|
|
1049
|
+
}
|
|
1041
1050
|
return this.safeTrade({
|
|
1042
1051
|
'id': this.safeStringN(trade, ['id', 't']),
|
|
1043
1052
|
'info': trade,
|
|
@@ -1049,7 +1058,7 @@ export default class bingx extends Exchange {
|
|
|
1049
1058
|
'side': this.parseOrderSide(side),
|
|
1050
1059
|
'takerOrMaker': takeOrMaker,
|
|
1051
1060
|
'price': this.safeString2(trade, 'price', 'p'),
|
|
1052
|
-
'amount':
|
|
1061
|
+
'amount': amount,
|
|
1053
1062
|
'cost': cost,
|
|
1054
1063
|
'fee': {
|
|
1055
1064
|
'cost': this.parseNumber(Precise.stringAbs(this.safeString2(trade, 'commission', 'n'))),
|
|
@@ -1681,19 +1690,27 @@ export default class bingx extends Exchange {
|
|
|
1681
1690
|
}
|
|
1682
1691
|
parsePosition(position, market = undefined) {
|
|
1683
1692
|
//
|
|
1684
|
-
//
|
|
1685
|
-
//
|
|
1686
|
-
//
|
|
1687
|
-
//
|
|
1688
|
-
//
|
|
1689
|
-
//
|
|
1690
|
-
//
|
|
1691
|
-
//
|
|
1692
|
-
//
|
|
1693
|
-
//
|
|
1694
|
-
//
|
|
1695
|
-
//
|
|
1696
|
-
//
|
|
1693
|
+
// {
|
|
1694
|
+
// "positionId":"1773122376147623936",
|
|
1695
|
+
// "symbol":"XRP-USDT",
|
|
1696
|
+
// "currency":"USDT",
|
|
1697
|
+
// "positionAmt":"3",
|
|
1698
|
+
// "availableAmt":"3",
|
|
1699
|
+
// "positionSide":"LONG",
|
|
1700
|
+
// "isolated":false,
|
|
1701
|
+
// "avgPrice":"0.6139",
|
|
1702
|
+
// "initialMargin":"0.0897",
|
|
1703
|
+
// "leverage":20,
|
|
1704
|
+
// "unrealizedProfit":"-0.0023",
|
|
1705
|
+
// "realisedProfit":"-0.0009",
|
|
1706
|
+
// "liquidationPrice":0,
|
|
1707
|
+
// "pnlRatio":"-0.0260",
|
|
1708
|
+
// "maxMarginReduction":"",
|
|
1709
|
+
// "riskRate":"",
|
|
1710
|
+
// "markPrice":"",
|
|
1711
|
+
// "positionValue":"",
|
|
1712
|
+
// "onlyOnePosition":false
|
|
1713
|
+
// }
|
|
1697
1714
|
//
|
|
1698
1715
|
// standard position
|
|
1699
1716
|
//
|
|
@@ -1720,7 +1737,7 @@ export default class bingx extends Exchange {
|
|
|
1720
1737
|
'info': position,
|
|
1721
1738
|
'id': this.safeString(position, 'positionId'),
|
|
1722
1739
|
'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
|
|
1723
|
-
'notional': this.safeNumber(position, '
|
|
1740
|
+
'notional': this.safeNumber(position, 'positionValue'),
|
|
1724
1741
|
'marginMode': marginMode,
|
|
1725
1742
|
'liquidationPrice': undefined,
|
|
1726
1743
|
'entryPrice': this.safeNumber2(position, 'avgPrice', 'entryPrice'),
|
|
@@ -1738,7 +1755,7 @@ export default class bingx extends Exchange {
|
|
|
1738
1755
|
'lastUpdateTimestamp': undefined,
|
|
1739
1756
|
'maintenanceMargin': undefined,
|
|
1740
1757
|
'maintenanceMarginPercentage': undefined,
|
|
1741
|
-
'collateral':
|
|
1758
|
+
'collateral': undefined,
|
|
1742
1759
|
'initialMargin': this.safeNumber(position, 'initialMargin'),
|
|
1743
1760
|
'initialMarginPercentage': undefined,
|
|
1744
1761
|
'leverage': this.safeNumber(position, 'leverage'),
|
|
@@ -3452,6 +3469,18 @@ export default class bingx extends Exchange {
|
|
|
3452
3469
|
};
|
|
3453
3470
|
return await this.swapV2PrivatePostTradeMarginType(this.extend(request, params));
|
|
3454
3471
|
}
|
|
3472
|
+
async addMargin(symbol, amount, params = {}) {
|
|
3473
|
+
const request = {
|
|
3474
|
+
'type': 1,
|
|
3475
|
+
};
|
|
3476
|
+
return await this.setMargin(symbol, amount, this.extend(request, params));
|
|
3477
|
+
}
|
|
3478
|
+
async reduceMargin(symbol, amount, params = {}) {
|
|
3479
|
+
const request = {
|
|
3480
|
+
'type': 2,
|
|
3481
|
+
};
|
|
3482
|
+
return await this.setMargin(symbol, amount, this.extend(request, params));
|
|
3483
|
+
}
|
|
3455
3484
|
async setMargin(symbol, amount, params = {}) {
|
|
3456
3485
|
/**
|
|
3457
3486
|
* @method
|
|
@@ -3486,7 +3515,29 @@ export default class bingx extends Exchange {
|
|
|
3486
3515
|
// "type": 1
|
|
3487
3516
|
// }
|
|
3488
3517
|
//
|
|
3489
|
-
return response;
|
|
3518
|
+
return this.parseMarginModification(response, market);
|
|
3519
|
+
}
|
|
3520
|
+
parseMarginModification(data, market = undefined) {
|
|
3521
|
+
//
|
|
3522
|
+
// {
|
|
3523
|
+
// "code": 0,
|
|
3524
|
+
// "msg": "",
|
|
3525
|
+
// "amount": 1,
|
|
3526
|
+
// "type": 1
|
|
3527
|
+
// }
|
|
3528
|
+
//
|
|
3529
|
+
const type = this.safeString(data, 'type');
|
|
3530
|
+
return {
|
|
3531
|
+
'info': data,
|
|
3532
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
3533
|
+
'type': (type === '1') ? 'add' : 'reduce',
|
|
3534
|
+
'amount': this.safeNumber(data, 'amount'),
|
|
3535
|
+
'total': this.safeNumber(data, 'margin'),
|
|
3536
|
+
'code': this.safeString(market, 'settle'),
|
|
3537
|
+
'status': undefined,
|
|
3538
|
+
'timestamp': undefined,
|
|
3539
|
+
'datetime': undefined,
|
|
3540
|
+
};
|
|
3490
3541
|
}
|
|
3491
3542
|
async fetchLeverage(symbol, params = {}) {
|
|
3492
3543
|
/**
|
package/js/src/bitbank.js
CHANGED
|
@@ -141,21 +141,23 @@ export default class bitbank extends Exchange {
|
|
|
141
141
|
},
|
|
142
142
|
'precisionMode': TICK_SIZE,
|
|
143
143
|
'exceptions': {
|
|
144
|
-
'
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
144
|
+
'exact': {
|
|
145
|
+
'20001': AuthenticationError,
|
|
146
|
+
'20002': AuthenticationError,
|
|
147
|
+
'20003': AuthenticationError,
|
|
148
|
+
'20005': AuthenticationError,
|
|
149
|
+
'20004': InvalidNonce,
|
|
150
|
+
'40020': InvalidOrder,
|
|
151
|
+
'40021': InvalidOrder,
|
|
152
|
+
'40025': ExchangeError,
|
|
153
|
+
'40013': OrderNotFound,
|
|
154
|
+
'40014': OrderNotFound,
|
|
155
|
+
'50008': PermissionDenied,
|
|
156
|
+
'50009': OrderNotFound,
|
|
157
|
+
'50010': OrderNotFound,
|
|
158
|
+
'60001': InsufficientFunds,
|
|
159
|
+
'60005': InvalidOrder,
|
|
160
|
+
},
|
|
159
161
|
},
|
|
160
162
|
});
|
|
161
163
|
}
|
|
@@ -986,16 +988,10 @@ export default class bitbank extends Exchange {
|
|
|
986
988
|
'70009': 'We are currently temporarily restricting orders to be carried out. Please use the limit order.',
|
|
987
989
|
'70010': 'We are temporarily raising the minimum order quantity as the system load is now rising.',
|
|
988
990
|
};
|
|
989
|
-
const errorClasses = this.exceptions;
|
|
990
991
|
const code = this.safeString(data, 'code');
|
|
991
992
|
const message = this.safeString(errorMessages, code, 'Error');
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
throw new errorClasses[code](message);
|
|
995
|
-
}
|
|
996
|
-
else {
|
|
997
|
-
throw new ExchangeError(this.id + ' ' + this.json(response));
|
|
998
|
-
}
|
|
993
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], code, message);
|
|
994
|
+
throw new ExchangeError(this.id + ' ' + this.json(response));
|
|
999
995
|
}
|
|
1000
996
|
return undefined;
|
|
1001
997
|
}
|
package/js/src/bitfinex.js
CHANGED
|
@@ -1326,6 +1326,9 @@ export default class bitfinex extends Exchange {
|
|
|
1326
1326
|
if (limit === undefined) {
|
|
1327
1327
|
limit = 100;
|
|
1328
1328
|
}
|
|
1329
|
+
else {
|
|
1330
|
+
limit = Math.min(limit, 10000);
|
|
1331
|
+
}
|
|
1329
1332
|
const market = this.market(symbol);
|
|
1330
1333
|
const v2id = 't' + market['id'];
|
|
1331
1334
|
const request = {
|
package/js/src/bitfinex2.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bitfinex2.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bitfinex2
|
|
5
5
|
* @augments Exchange
|
|
@@ -154,22 +154,8 @@ export default class bitfinex2 extends Exchange {
|
|
|
154
154
|
parseOpenInterest(interest: any, market?: Market): OpenInterest;
|
|
155
155
|
fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
|
|
156
156
|
parseLiquidation(liquidation: any, market?: Market): Liquidation;
|
|
157
|
-
setMargin(symbol: string, amount: number, params?: {}): Promise<
|
|
158
|
-
|
|
159
|
-
type: any;
|
|
160
|
-
amount: any;
|
|
161
|
-
code: any;
|
|
162
|
-
symbol: any;
|
|
163
|
-
status: string;
|
|
164
|
-
}>;
|
|
165
|
-
parseMarginModification(data: any, market?: any): {
|
|
166
|
-
info: any;
|
|
167
|
-
type: any;
|
|
168
|
-
amount: any;
|
|
169
|
-
code: any;
|
|
170
|
-
symbol: any;
|
|
171
|
-
status: string;
|
|
172
|
-
};
|
|
157
|
+
setMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
158
|
+
parseMarginModification(data: any, market?: any): MarginModification;
|
|
173
159
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
174
160
|
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
175
161
|
}
|
package/js/src/bitfinex2.js
CHANGED
|
@@ -1383,6 +1383,9 @@ export default class bitfinex2 extends Exchange {
|
|
|
1383
1383
|
if (limit === undefined) {
|
|
1384
1384
|
limit = 10000;
|
|
1385
1385
|
}
|
|
1386
|
+
else {
|
|
1387
|
+
limit = Math.min(limit, 10000);
|
|
1388
|
+
}
|
|
1386
1389
|
let request = {
|
|
1387
1390
|
'symbol': market['id'],
|
|
1388
1391
|
'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
|
|
@@ -3504,15 +3507,27 @@ export default class bitfinex2 extends Exchange {
|
|
|
3504
3507
|
return this.parseMarginModification(data, market);
|
|
3505
3508
|
}
|
|
3506
3509
|
parseMarginModification(data, market = undefined) {
|
|
3510
|
+
//
|
|
3511
|
+
// setMargin
|
|
3512
|
+
//
|
|
3513
|
+
// [
|
|
3514
|
+
// [
|
|
3515
|
+
// 1
|
|
3516
|
+
// ]
|
|
3517
|
+
// ]
|
|
3518
|
+
//
|
|
3507
3519
|
const marginStatusRaw = data[0];
|
|
3508
3520
|
const marginStatus = (marginStatusRaw === 1) ? 'ok' : 'failed';
|
|
3509
3521
|
return {
|
|
3510
3522
|
'info': data,
|
|
3523
|
+
'symbol': market['symbol'],
|
|
3511
3524
|
'type': undefined,
|
|
3512
3525
|
'amount': undefined,
|
|
3526
|
+
'total': undefined,
|
|
3513
3527
|
'code': undefined,
|
|
3514
|
-
'symbol': market['symbol'],
|
|
3515
3528
|
'status': marginStatus,
|
|
3529
|
+
'timestamp': undefined,
|
|
3530
|
+
'datetime': undefined,
|
|
3516
3531
|
};
|
|
3517
3532
|
}
|
|
3518
3533
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
package/js/src/bitflyer.d.ts
CHANGED
package/js/src/bitflyer.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/bitflyer.js';
|
|
9
|
-
import { ExchangeError, ArgumentsRequired, OrderNotFound } from './base/errors.js';
|
|
9
|
+
import { ExchangeError, ArgumentsRequired, OrderNotFound, OnMaintenance } from './base/errors.js';
|
|
10
10
|
import { TICK_SIZE } from './base/functions/number.js';
|
|
11
11
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
import { Precise } from './base/Precise.js';
|
|
@@ -117,6 +117,11 @@ export default class bitflyer extends Exchange {
|
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
119
|
'precisionMode': TICK_SIZE,
|
|
120
|
+
'exceptions': {
|
|
121
|
+
'exact': {
|
|
122
|
+
'-2': OnMaintenance, // {"status":-2,"error_message":"Under maintenance","data":null}
|
|
123
|
+
},
|
|
124
|
+
},
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
127
|
parseExpiryDate(expiry) {
|
|
@@ -1044,4 +1049,18 @@ export default class bitflyer extends Exchange {
|
|
|
1044
1049
|
}
|
|
1045
1050
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1046
1051
|
}
|
|
1052
|
+
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1053
|
+
if (response === undefined) {
|
|
1054
|
+
return undefined; // fallback to the default error handler
|
|
1055
|
+
}
|
|
1056
|
+
const feedback = this.id + ' ' + body;
|
|
1057
|
+
// i.e. {"status":-2,"error_message":"Under maintenance","data":null}
|
|
1058
|
+
const errorMessage = this.safeString(response, 'error_message');
|
|
1059
|
+
const statusCode = this.safeNumber(response, 'status');
|
|
1060
|
+
if (errorMessage !== undefined) {
|
|
1061
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], statusCode, feedback);
|
|
1062
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
|
|
1063
|
+
}
|
|
1064
|
+
return undefined;
|
|
1065
|
+
}
|
|
1047
1066
|
}
|
package/js/src/bitget.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bitget.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bitget
|
|
5
5
|
* @augments Exchange
|
|
@@ -146,17 +146,10 @@ export default class bitget extends Exchange {
|
|
|
146
146
|
id: string;
|
|
147
147
|
};
|
|
148
148
|
parseFundingHistories(contracts: any, market?: any, since?: Int, limit?: Int): FundingHistory[];
|
|
149
|
-
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<
|
|
150
|
-
parseMarginModification(data: any, market?: Market):
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
amount: any;
|
|
154
|
-
code: string;
|
|
155
|
-
symbol: string;
|
|
156
|
-
status: string;
|
|
157
|
-
};
|
|
158
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
159
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
149
|
+
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
150
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
151
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
152
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
160
153
|
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
161
154
|
parseLeverage(leverage: any, market?: any): Leverage;
|
|
162
155
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
package/js/src/bitget.js
CHANGED
|
@@ -1222,6 +1222,7 @@ export default class bitget extends Exchange {
|
|
|
1222
1222
|
'40768': OrderNotFound,
|
|
1223
1223
|
'41114': OnMaintenance,
|
|
1224
1224
|
'43011': InvalidOrder,
|
|
1225
|
+
'43012': InsufficientFunds,
|
|
1225
1226
|
'43025': InvalidOrder,
|
|
1226
1227
|
'43115': OnMaintenance,
|
|
1227
1228
|
'45110': InvalidOrder,
|
|
@@ -6963,15 +6964,28 @@ export default class bitget extends Exchange {
|
|
|
6963
6964
|
});
|
|
6964
6965
|
}
|
|
6965
6966
|
parseMarginModification(data, market = undefined) {
|
|
6967
|
+
//
|
|
6968
|
+
// addMargin/reduceMargin
|
|
6969
|
+
//
|
|
6970
|
+
// {
|
|
6971
|
+
// "code": "00000",
|
|
6972
|
+
// "msg": "success",
|
|
6973
|
+
// "requestTime": 1700813444618,
|
|
6974
|
+
// "data": ""
|
|
6975
|
+
// }
|
|
6976
|
+
//
|
|
6966
6977
|
const errorCode = this.safeString(data, 'code');
|
|
6967
6978
|
const status = (errorCode === '00000') ? 'ok' : 'failed';
|
|
6968
6979
|
return {
|
|
6969
6980
|
'info': data,
|
|
6981
|
+
'symbol': market['symbol'],
|
|
6970
6982
|
'type': undefined,
|
|
6971
6983
|
'amount': undefined,
|
|
6984
|
+
'total': undefined,
|
|
6972
6985
|
'code': market['settle'],
|
|
6973
|
-
'symbol': market['symbol'],
|
|
6974
6986
|
'status': status,
|
|
6987
|
+
'timestamp': undefined,
|
|
6988
|
+
'datetime': undefined,
|
|
6975
6989
|
};
|
|
6976
6990
|
}
|
|
6977
6991
|
async reduceMargin(symbol, amount, params = {}) {
|
package/js/src/bitopro.js
CHANGED
|
@@ -759,6 +759,9 @@ export default class bitopro extends Exchange {
|
|
|
759
759
|
if (limit === undefined) {
|
|
760
760
|
limit = 500;
|
|
761
761
|
}
|
|
762
|
+
else {
|
|
763
|
+
limit = Math.min(limit, 75000); // supports slightly more than 75k candles atm, but limit here to avoid errors
|
|
764
|
+
}
|
|
762
765
|
const timeframeInSeconds = this.parseTimeframe(timeframe);
|
|
763
766
|
let alignedSince = undefined;
|
|
764
767
|
if (since === undefined) {
|
package/js/src/bitrue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bitrue.js';
|
|
2
|
-
import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry } from './base/types.js';
|
|
2
|
+
import type { Balances, Currency, Int, MarginModification, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bitrue
|
|
5
5
|
* @augments Exchange
|
|
@@ -73,22 +73,8 @@ export default class bitrue extends Exchange {
|
|
|
73
73
|
fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
74
74
|
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
|
|
75
75
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
76
|
-
parseMarginModification(data: any, market?: any):
|
|
77
|
-
|
|
78
|
-
type: any;
|
|
79
|
-
amount: any;
|
|
80
|
-
code: any;
|
|
81
|
-
symbol: any;
|
|
82
|
-
status: any;
|
|
83
|
-
};
|
|
84
|
-
setMargin(symbol: string, amount: number, params?: {}): Promise<{
|
|
85
|
-
info: any;
|
|
86
|
-
type: any;
|
|
87
|
-
amount: any;
|
|
88
|
-
code: any;
|
|
89
|
-
symbol: any;
|
|
90
|
-
status: any;
|
|
91
|
-
}>;
|
|
76
|
+
parseMarginModification(data: any, market?: any): MarginModification;
|
|
77
|
+
setMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
92
78
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
93
79
|
url: any;
|
|
94
80
|
method: string;
|
package/js/src/bitrue.js
CHANGED
|
@@ -1351,9 +1351,6 @@ export default class bitrue extends Exchange {
|
|
|
1351
1351
|
'interval': this.safeString(timeframesFuture, timeframe, '1min'),
|
|
1352
1352
|
};
|
|
1353
1353
|
if (limit !== undefined) {
|
|
1354
|
-
if (limit > 300) {
|
|
1355
|
-
limit = 300;
|
|
1356
|
-
}
|
|
1357
1354
|
request['limit'] = limit;
|
|
1358
1355
|
}
|
|
1359
1356
|
if (market['linear']) {
|
|
@@ -1372,9 +1369,6 @@ export default class bitrue extends Exchange {
|
|
|
1372
1369
|
'scale': this.safeString(timeframesSpot, timeframe, '1m'),
|
|
1373
1370
|
};
|
|
1374
1371
|
if (limit !== undefined) {
|
|
1375
|
-
if (limit > 1440) {
|
|
1376
|
-
limit = 1440;
|
|
1377
|
-
}
|
|
1378
1372
|
request['limit'] = limit;
|
|
1379
1373
|
}
|
|
1380
1374
|
if (since !== undefined) {
|
|
@@ -3046,13 +3040,25 @@ export default class bitrue extends Exchange {
|
|
|
3046
3040
|
return response;
|
|
3047
3041
|
}
|
|
3048
3042
|
parseMarginModification(data, market = undefined) {
|
|
3043
|
+
//
|
|
3044
|
+
// setMargin
|
|
3045
|
+
//
|
|
3046
|
+
// {
|
|
3047
|
+
// "code": 0,
|
|
3048
|
+
// "msg": "success"
|
|
3049
|
+
// "data": null
|
|
3050
|
+
// }
|
|
3051
|
+
//
|
|
3049
3052
|
return {
|
|
3050
3053
|
'info': data,
|
|
3054
|
+
'symbol': market['symbol'],
|
|
3051
3055
|
'type': undefined,
|
|
3052
3056
|
'amount': undefined,
|
|
3057
|
+
'total': undefined,
|
|
3053
3058
|
'code': undefined,
|
|
3054
|
-
'symbol': market['symbol'],
|
|
3055
3059
|
'status': undefined,
|
|
3060
|
+
'timestamp': undefined,
|
|
3061
|
+
'datetime': undefined,
|
|
3056
3062
|
};
|
|
3057
3063
|
}
|
|
3058
3064
|
async setMargin(symbol, amount, params = {}) {
|
package/js/src/bitvavo.js
CHANGED
|
@@ -935,6 +935,9 @@ export default class bitvavo extends Exchange {
|
|
|
935
935
|
if (limit === undefined) {
|
|
936
936
|
limit = 1440;
|
|
937
937
|
}
|
|
938
|
+
else {
|
|
939
|
+
limit = Math.min(limit, 1440);
|
|
940
|
+
}
|
|
938
941
|
request['end'] = this.sum(since, limit * duration * 1000);
|
|
939
942
|
}
|
|
940
943
|
[request, params] = this.handleUntilOption('end', request, params);
|
package/js/src/btcmarkets.js
CHANGED
|
@@ -541,7 +541,7 @@ export default class btcmarkets extends Exchange {
|
|
|
541
541
|
request['from'] = this.iso8601(since);
|
|
542
542
|
}
|
|
543
543
|
if (limit !== undefined) {
|
|
544
|
-
request['limit'] = limit; // default is 10, max 200
|
|
544
|
+
request['limit'] = Math.min(limit, 200); // default is 10, max 200
|
|
545
545
|
}
|
|
546
546
|
const response = await this.publicGetMarketsMarketIdCandles(this.extend(request, params));
|
|
547
547
|
//
|
package/js/src/btcturk.js
CHANGED
|
@@ -588,6 +588,7 @@ export default class btcturk extends Exchange {
|
|
|
588
588
|
limit = 100; // default value
|
|
589
589
|
}
|
|
590
590
|
if (limit !== undefined) {
|
|
591
|
+
limit = Math.min(limit, 11000); // max 11000 candles diapason can be covered
|
|
591
592
|
if (timeframe === '1y') { // difficult with leap years
|
|
592
593
|
throw new BadRequest(this.id + ' fetchOHLCV () does not accept a limit parameter when timeframe == "1y"');
|
|
593
594
|
}
|
|
@@ -598,7 +599,7 @@ export default class btcturk extends Exchange {
|
|
|
598
599
|
request['to'] = Math.min(request['to'], to);
|
|
599
600
|
}
|
|
600
601
|
else {
|
|
601
|
-
request['from'] = this.parseToInt(
|
|
602
|
+
request['from'] = this.parseToInt(0 / 1000) - limitSeconds;
|
|
602
603
|
}
|
|
603
604
|
}
|
|
604
605
|
const response = await this.graphGetKlinesHistory(this.extend(request, params));
|
package/js/src/coinex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/coinex.js';
|
|
2
|
-
import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Market, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, OrderRequest, TransferEntry, Leverage, Leverages, Num } from './base/types.js';
|
|
2
|
+
import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Market, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, OrderRequest, TransferEntry, Leverage, Leverages, Num, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class coinex
|
|
5
5
|
* @augments Exchange
|
|
@@ -88,16 +88,9 @@ export default class coinex extends Exchange {
|
|
|
88
88
|
parseLeverageTiers(response: any, symbols?: Strings, marketIdKey?: any): {};
|
|
89
89
|
parseMarketLeverageTiers(item: any, market?: Market): any[];
|
|
90
90
|
modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
|
|
91
|
-
parseMarginModification(data: any, market?: Market):
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
amount: any;
|
|
95
|
-
code: string;
|
|
96
|
-
symbol: string;
|
|
97
|
-
status: any;
|
|
98
|
-
};
|
|
99
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
100
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
91
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
92
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
93
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
101
94
|
fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
|
|
102
95
|
fetchFundingRate(symbol: string, params?: {}): Promise<{
|
|
103
96
|
info: any;
|
|
@@ -211,7 +204,7 @@ export default class coinex extends Exchange {
|
|
|
211
204
|
parseLeverage(leverage: any, market?: any): Leverage;
|
|
212
205
|
handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
|
|
213
206
|
nonce(): number;
|
|
214
|
-
sign(path: any, api?:
|
|
207
|
+
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
215
208
|
url: string;
|
|
216
209
|
method: string;
|
|
217
210
|
body: any;
|