ccxt 4.1.34 → 4.1.35
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 +8 -3
- package/dist/ccxt.browser.js +596 -326
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/errors.js +15 -1
- package/dist/cjs/src/bingx.js +16 -16
- package/dist/cjs/src/digifinex.js +109 -3
- package/dist/cjs/src/huobi.js +206 -39
- package/dist/cjs/src/kraken.js +15 -8
- package/dist/cjs/src/kucoin.js +233 -257
- package/dist/cjs/src/pro/okx.js +1 -1
- package/examples2md.js +79 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoin.d.ts +81 -83
- package/js/src/abstract/kucoinfutures.d.ts +90 -86
- package/js/src/base/errorHierarchy.d.ts +1 -1
- package/js/src/base/errorHierarchy.js +1 -1
- package/js/src/base/errors.d.ts +9 -1
- package/js/src/base/errors.js +14 -2
- package/js/src/bingx.js +16 -16
- package/js/src/digifinex.d.ts +13 -0
- package/js/src/digifinex.js +109 -3
- package/js/src/huobi.js +206 -39
- package/js/src/kraken.js +15 -8
- package/js/src/kucoin.d.ts +0 -1
- package/js/src/kucoin.js +233 -257
- package/js/src/pro/okx.js +1 -1
- package/package.json +2 -2
package/dist/cjs/ccxt.js
CHANGED
|
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
180
180
|
|
|
181
181
|
//-----------------------------------------------------------------------------
|
|
182
182
|
// this is updated by vss.js when building
|
|
183
|
-
const version = '4.1.
|
|
183
|
+
const version = '4.1.35';
|
|
184
184
|
Exchange["default"].ccxtVersion = version;
|
|
185
185
|
const exchanges = {
|
|
186
186
|
'ace': ace,
|
|
@@ -46,6 +46,12 @@ class ExchangeError extends Error {
|
|
|
46
46
|
this.name = 'ExchangeError';
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
class OperationFailed extends ExchangeError {
|
|
50
|
+
constructor(message) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = 'OperationFailed';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
49
55
|
class AuthenticationError extends ExchangeError {
|
|
50
56
|
constructor(message) {
|
|
51
57
|
super(message);
|
|
@@ -82,6 +88,12 @@ class BadRequest extends ExchangeError {
|
|
|
82
88
|
this.name = 'BadRequest';
|
|
83
89
|
}
|
|
84
90
|
}
|
|
91
|
+
class OperationRejected extends BadRequest {
|
|
92
|
+
constructor(message) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.name = 'OperationRejected';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
85
97
|
class BadSymbol extends BadRequest {
|
|
86
98
|
constructor(message) {
|
|
87
99
|
super(message);
|
|
@@ -234,7 +246,7 @@ class RequestTimeout extends NetworkError {
|
|
|
234
246
|
// // Derived class hierarchy
|
|
235
247
|
// errorHierarchy
|
|
236
248
|
// )
|
|
237
|
-
const errors = { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange };
|
|
249
|
+
const errors = { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange, OperationRejected, OperationFailed };
|
|
238
250
|
|
|
239
251
|
exports.AccountNotEnabled = AccountNotEnabled;
|
|
240
252
|
exports.AccountSuspended = AccountSuspended;
|
|
@@ -261,6 +273,8 @@ exports.NoChange = NoChange;
|
|
|
261
273
|
exports.NotSupported = NotSupported;
|
|
262
274
|
exports.NullResponse = NullResponse;
|
|
263
275
|
exports.OnMaintenance = OnMaintenance;
|
|
276
|
+
exports.OperationFailed = OperationFailed;
|
|
277
|
+
exports.OperationRejected = OperationRejected;
|
|
264
278
|
exports.OrderImmediatelyFillable = OrderImmediatelyFillable;
|
|
265
279
|
exports.OrderNotCached = OrderNotCached;
|
|
266
280
|
exports.OrderNotFillable = OrderNotFillable;
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -623,7 +623,7 @@ class bingx extends bingx$1 {
|
|
|
623
623
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20Symbols
|
|
624
624
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Contract%20Information
|
|
625
625
|
* @param {object} [params] extra parameters specific to the exchange api endpoint
|
|
626
|
-
* @returns {[
|
|
626
|
+
* @returns {object[]} an array of objects representing market data
|
|
627
627
|
*/
|
|
628
628
|
const requests = [this.fetchSpotMarkets(params), this.fetchSwapMarkets(params)];
|
|
629
629
|
const promises = await Promise.all(requests);
|
|
@@ -646,7 +646,7 @@ class bingx extends bingx$1 {
|
|
|
646
646
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
647
647
|
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
648
648
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
649
|
-
* @returns {[[
|
|
649
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
650
650
|
*/
|
|
651
651
|
await this.loadMarkets();
|
|
652
652
|
let paginate = false;
|
|
@@ -752,7 +752,7 @@ class bingx extends bingx$1 {
|
|
|
752
752
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
753
753
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
754
754
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
755
|
-
* @returns {[
|
|
755
|
+
* @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
|
|
756
756
|
*/
|
|
757
757
|
await this.loadMarkets();
|
|
758
758
|
const market = this.market(symbol);
|
|
@@ -1082,7 +1082,7 @@ class bingx extends bingx$1 {
|
|
|
1082
1082
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
1083
1083
|
* @param {int} [params.until] timestamp in ms of the latest funding rate to fetch
|
|
1084
1084
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1085
|
-
* @returns {[
|
|
1085
|
+
* @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
|
|
1086
1086
|
*/
|
|
1087
1087
|
this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
|
|
1088
1088
|
await this.loadMarkets();
|
|
@@ -1245,7 +1245,7 @@ class bingx extends bingx$1 {
|
|
|
1245
1245
|
* @name bingx#fetchTickers
|
|
1246
1246
|
* @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
|
1247
1247
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
|
|
1248
|
-
* @param {[
|
|
1248
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1249
1249
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
1250
1250
|
* @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
|
|
1251
1251
|
*/
|
|
@@ -1482,10 +1482,10 @@ class bingx extends bingx$1 {
|
|
|
1482
1482
|
* @description fetch all open positions
|
|
1483
1483
|
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Perpetual%20Swap%20Positions
|
|
1484
1484
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
|
|
1485
|
-
* @param {[
|
|
1485
|
+
* @param {string[]|undefined} symbols list of unified market symbols
|
|
1486
1486
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
1487
1487
|
* @param {boolean} [params.standard] whether to fetch standard contract positions
|
|
1488
|
-
* @returns {[
|
|
1488
|
+
* @returns {object[]} a list of [position structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
|
|
1489
1489
|
*/
|
|
1490
1490
|
await this.loadMarkets();
|
|
1491
1491
|
symbols = this.marketSymbols(symbols);
|
|
@@ -2009,7 +2009,7 @@ class bingx extends bingx$1 {
|
|
|
2009
2009
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
|
|
2010
2010
|
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
2011
2011
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2012
|
-
* @returns {[
|
|
2012
|
+
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2013
2013
|
*/
|
|
2014
2014
|
this.checkRequiredSymbol('cancelAllOrders', symbol);
|
|
2015
2015
|
await this.loadMarkets();
|
|
@@ -2059,7 +2059,7 @@ class bingx extends bingx$1 {
|
|
|
2059
2059
|
* @description cancel multiple orders
|
|
2060
2060
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20a%20Batch%20of%20Orders
|
|
2061
2061
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Cancel%20a%20Batch%20of%20Orders
|
|
2062
|
-
* @param {[
|
|
2062
|
+
* @param {string[]} ids order ids
|
|
2063
2063
|
* @param {string} symbol unified market symbol, default is undefined
|
|
2064
2064
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2065
2065
|
* @returns {object} an list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
@@ -2208,7 +2208,7 @@ class bingx extends bingx$1 {
|
|
|
2208
2208
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
2209
2209
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
2210
2210
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2211
|
-
* @returns {[
|
|
2211
|
+
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2212
2212
|
*/
|
|
2213
2213
|
this.checkRequiredSymbol('fetchOrders', symbol);
|
|
2214
2214
|
await this.loadMarkets();
|
|
@@ -2297,7 +2297,7 @@ class bingx extends bingx$1 {
|
|
|
2297
2297
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2298
2298
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
2299
2299
|
* @param {boolean} [params.standard] whether to fetch standard contract orders
|
|
2300
|
-
* @returns {[
|
|
2300
|
+
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2301
2301
|
*/
|
|
2302
2302
|
this.checkRequiredSymbol('fetchClosedOrders', symbol);
|
|
2303
2303
|
await this.loadMarkets();
|
|
@@ -2428,7 +2428,7 @@ class bingx extends bingx$1 {
|
|
|
2428
2428
|
* @param {int} [since] the earliest time in ms to fetch transfers for
|
|
2429
2429
|
* @param {int} [limit] the maximum number of transfers structures to retrieve
|
|
2430
2430
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2431
|
-
* @returns {[
|
|
2431
|
+
* @returns {object[]} a list of [transfer structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure}
|
|
2432
2432
|
*/
|
|
2433
2433
|
await this.loadMarkets();
|
|
2434
2434
|
let currency = undefined;
|
|
@@ -2573,7 +2573,7 @@ class bingx extends bingx$1 {
|
|
|
2573
2573
|
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
2574
2574
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
2575
2575
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2576
|
-
* @returns {[
|
|
2576
|
+
* @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
|
|
2577
2577
|
*/
|
|
2578
2578
|
await this.loadMarkets();
|
|
2579
2579
|
const request = {};
|
|
@@ -2618,7 +2618,7 @@ class bingx extends bingx$1 {
|
|
|
2618
2618
|
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
2619
2619
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
2620
2620
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2621
|
-
* @returns {[
|
|
2621
|
+
* @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
|
|
2622
2622
|
*/
|
|
2623
2623
|
await this.loadMarkets();
|
|
2624
2624
|
const request = {};
|
|
@@ -2891,7 +2891,7 @@ class bingx extends bingx$1 {
|
|
|
2891
2891
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
2892
2892
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
2893
2893
|
* @param {string} params.trandingUnit COIN (directly represent assets such as BTC and ETH) or CONT (represents the number of contract sheets)
|
|
2894
|
-
* @returns {[
|
|
2894
|
+
* @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
|
|
2895
2895
|
*/
|
|
2896
2896
|
this.checkRequiredArgument('fetchMyTrades', symbol, 'symbol');
|
|
2897
2897
|
this.checkRequiredArgument('fetchMyTrades', since, 'since');
|
|
@@ -3001,7 +3001,7 @@ class bingx extends bingx$1 {
|
|
|
3001
3001
|
* @name bingx#fetchDepositWithdrawFees
|
|
3002
3002
|
* @description fetch deposit and withdraw fees
|
|
3003
3003
|
* @see https://bingx-api.github.io/docs/#/common/account-api.html#All%20Coins'%20Information
|
|
3004
|
-
* @param {[
|
|
3004
|
+
* @param {string[]|undefined} codes list of unified currency codes
|
|
3005
3005
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
3006
3006
|
* @returns {object} a list of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
|
|
3007
3007
|
*/
|
|
@@ -27,7 +27,7 @@ class digifinex extends digifinex$1 {
|
|
|
27
27
|
'swap': true,
|
|
28
28
|
'future': false,
|
|
29
29
|
'option': false,
|
|
30
|
-
'addMargin':
|
|
30
|
+
'addMargin': true,
|
|
31
31
|
'cancelOrder': true,
|
|
32
32
|
'cancelOrders': true,
|
|
33
33
|
'createOrder': true,
|
|
@@ -79,10 +79,10 @@ class digifinex extends digifinex$1 {
|
|
|
79
79
|
'fetchTradingFees': false,
|
|
80
80
|
'fetchTransfers': true,
|
|
81
81
|
'fetchWithdrawals': true,
|
|
82
|
-
'reduceMargin':
|
|
82
|
+
'reduceMargin': true,
|
|
83
83
|
'setLeverage': true,
|
|
84
84
|
'setMargin': false,
|
|
85
|
-
'setMarginMode':
|
|
85
|
+
'setMarginMode': true,
|
|
86
86
|
'setPositionMode': false,
|
|
87
87
|
'transfer': true,
|
|
88
88
|
'withdraw': true,
|
|
@@ -3797,6 +3797,88 @@ class digifinex extends digifinex$1 {
|
|
|
3797
3797
|
}
|
|
3798
3798
|
return depositWithdrawFees;
|
|
3799
3799
|
}
|
|
3800
|
+
async addMargin(symbol, amount, params = {}) {
|
|
3801
|
+
/**
|
|
3802
|
+
* @method
|
|
3803
|
+
* @name digifinex#addMargin
|
|
3804
|
+
* @description add margin to a position
|
|
3805
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
|
|
3806
|
+
* @param {string} symbol unified market symbol
|
|
3807
|
+
* @param {float} amount amount of margin to add
|
|
3808
|
+
* @param {object} [params] extra parameters specific to the digifinex api endpoint
|
|
3809
|
+
* @param {string} params.side the position side: 'long' or 'short'
|
|
3810
|
+
* @returns {object} a [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#margin-structure}
|
|
3811
|
+
*/
|
|
3812
|
+
const side = this.safeString(params, 'side');
|
|
3813
|
+
this.checkRequiredArgument('addMargin', side, 'side', ['long', 'short']);
|
|
3814
|
+
return await this.modifyMarginHelper(symbol, amount, 1, params);
|
|
3815
|
+
}
|
|
3816
|
+
async reduceMargin(symbol, amount, params = {}) {
|
|
3817
|
+
/**
|
|
3818
|
+
* @method
|
|
3819
|
+
* @name digifinex#reduceMargin
|
|
3820
|
+
* @description remove margin from a position
|
|
3821
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
|
|
3822
|
+
* @param {string} symbol unified market symbol
|
|
3823
|
+
* @param {float} amount the amount of margin to remove
|
|
3824
|
+
* @param {object} [params] extra parameters specific to the digifinex api endpoint
|
|
3825
|
+
* @param {string} params.side the position side: 'long' or 'short'
|
|
3826
|
+
* @returns {object} a [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#margin-structure}
|
|
3827
|
+
*/
|
|
3828
|
+
const side = this.safeString(params, 'side');
|
|
3829
|
+
this.checkRequiredArgument('reduceMargin', side, 'side', ['long', 'short']);
|
|
3830
|
+
return await this.modifyMarginHelper(symbol, amount, 2, params);
|
|
3831
|
+
}
|
|
3832
|
+
async modifyMarginHelper(symbol, amount, type, params = {}) {
|
|
3833
|
+
await this.loadMarkets();
|
|
3834
|
+
const side = this.safeString(params, 'side');
|
|
3835
|
+
const market = this.market(symbol);
|
|
3836
|
+
const request = {
|
|
3837
|
+
'instrument_id': market['id'],
|
|
3838
|
+
'amount': this.numberToString(amount),
|
|
3839
|
+
'type': type,
|
|
3840
|
+
'side': side,
|
|
3841
|
+
};
|
|
3842
|
+
const response = await this.privateSwapPostAccountPositionMargin(this.extend(request, params));
|
|
3843
|
+
//
|
|
3844
|
+
// {
|
|
3845
|
+
// "code": 0,
|
|
3846
|
+
// "data": {
|
|
3847
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3848
|
+
// "side": "long",
|
|
3849
|
+
// "type": 1,
|
|
3850
|
+
// "amount": "3.6834"
|
|
3851
|
+
// }
|
|
3852
|
+
// }
|
|
3853
|
+
//
|
|
3854
|
+
const code = this.safeInteger(response, 'code');
|
|
3855
|
+
const status = (code === 0) ? 'ok' : 'failed';
|
|
3856
|
+
const data = this.safeValue(response, 'data', {});
|
|
3857
|
+
return this.extend(this.parseMarginModification(data, market), {
|
|
3858
|
+
'status': status,
|
|
3859
|
+
});
|
|
3860
|
+
}
|
|
3861
|
+
parseMarginModification(data, market = undefined) {
|
|
3862
|
+
//
|
|
3863
|
+
// {
|
|
3864
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3865
|
+
// "side": "long",
|
|
3866
|
+
// "type": 1,
|
|
3867
|
+
// "amount": "3.6834"
|
|
3868
|
+
// }
|
|
3869
|
+
//
|
|
3870
|
+
const marketId = this.safeString(data, 'instrument_id');
|
|
3871
|
+
const rawType = this.safeInteger(data, 'type');
|
|
3872
|
+
return {
|
|
3873
|
+
'info': data,
|
|
3874
|
+
'type': (rawType === 1) ? 'add' : 'reduce',
|
|
3875
|
+
'amount': this.safeNumber(data, 'amount'),
|
|
3876
|
+
'total': undefined,
|
|
3877
|
+
'code': market['settle'],
|
|
3878
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3879
|
+
'status': undefined,
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3800
3882
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3801
3883
|
/**
|
|
3802
3884
|
* @method
|
|
@@ -3863,6 +3945,30 @@ class digifinex extends digifinex$1 {
|
|
|
3863
3945
|
'amount': this.safeNumber(income, 'amount'),
|
|
3864
3946
|
};
|
|
3865
3947
|
}
|
|
3948
|
+
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
3949
|
+
/**
|
|
3950
|
+
* @method
|
|
3951
|
+
* @name digifinex#setMarginMode
|
|
3952
|
+
* @description set margin mode to 'cross' or 'isolated'
|
|
3953
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
|
|
3954
|
+
* @param {string} marginMode 'cross' or 'isolated'
|
|
3955
|
+
* @param {string} symbol unified market symbol
|
|
3956
|
+
* @param {object} [params] extra parameters specific to the digifinex api endpoint
|
|
3957
|
+
* @returns {object} response from the exchange
|
|
3958
|
+
*/
|
|
3959
|
+
this.checkRequiredSymbol('setMarginMode', symbol);
|
|
3960
|
+
await this.loadMarkets();
|
|
3961
|
+
const market = this.market(symbol);
|
|
3962
|
+
marginMode = marginMode.toLowerCase();
|
|
3963
|
+
if (marginMode === 'cross') {
|
|
3964
|
+
marginMode = 'crossed';
|
|
3965
|
+
}
|
|
3966
|
+
const request = {
|
|
3967
|
+
'instrument_id': market['id'],
|
|
3968
|
+
'margin_mode': marginMode,
|
|
3969
|
+
};
|
|
3970
|
+
return await this.privateSwapPostAccountPositionMode(this.extend(request, params));
|
|
3971
|
+
}
|
|
3866
3972
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3867
3973
|
const signed = api[0] === 'private';
|
|
3868
3974
|
const endpoint = api[1];
|
package/dist/cjs/src/huobi.js
CHANGED
|
@@ -943,41 +943,195 @@ class huobi extends huobi$1 {
|
|
|
943
943
|
},
|
|
944
944
|
'networks': {
|
|
945
945
|
// by displaynames
|
|
946
|
-
'
|
|
947
|
-
'ALGORAND': 'ALGO',
|
|
948
|
-
'BEP20': 'BEP20',
|
|
949
|
-
'BSC': 'BEP20',
|
|
950
|
-
'ERC20': 'ERC20',
|
|
951
|
-
'ETH': 'ERC20',
|
|
952
|
-
'AVALANCHE': 'AVAXCCHAIN',
|
|
953
|
-
'AVAX': 'AVAXCCHAIN',
|
|
954
|
-
'HRC20': 'HECO',
|
|
955
|
-
'HECO': 'HECO',
|
|
956
|
-
// 'HT': 'HECO', // HT is not acceptable networkcode for unification
|
|
957
|
-
'TRC20': 'TRC20',
|
|
958
|
-
'TRX': 'TRC20',
|
|
959
|
-
'BTC': 'BTC',
|
|
960
|
-
'BITCOIN': 'BTC',
|
|
961
|
-
'ARBITRUM': 'ARB',
|
|
962
|
-
'ARB': 'ARB',
|
|
963
|
-
'SOLANA': 'SOL',
|
|
964
|
-
'SOL': 'SOL',
|
|
965
|
-
'SPL': 'SOL',
|
|
966
|
-
'PRC20': 'PRC20',
|
|
967
|
-
'POLYGON': 'PRC20',
|
|
968
|
-
'MATIC': 'PRC20',
|
|
969
|
-
},
|
|
970
|
-
'networksById': {
|
|
971
|
-
'ALGO': 'ALGO',
|
|
972
|
-
'BEP20': 'BEP20',
|
|
973
|
-
'ERC20': 'ERC20',
|
|
974
|
-
'AVAXCCHAIN': 'AVALANCHE',
|
|
975
|
-
'HECO': 'HRC20',
|
|
976
|
-
'TRC20': 'TRC20',
|
|
946
|
+
'TRC20': 'TRX',
|
|
977
947
|
'BTC': 'BTC',
|
|
978
|
-
'
|
|
948
|
+
'ERC20': 'ETH',
|
|
979
949
|
'SOL': 'SOLANA',
|
|
980
|
-
'
|
|
950
|
+
'HRC20': 'HECO',
|
|
951
|
+
'BEP20': 'BSC',
|
|
952
|
+
'XMR': 'XMR',
|
|
953
|
+
'LTC': 'LTC',
|
|
954
|
+
'XRP': 'XRP',
|
|
955
|
+
'XLM': 'XLM',
|
|
956
|
+
'CRONOS': 'CRO',
|
|
957
|
+
'CRO': 'CRO',
|
|
958
|
+
'GLMR': 'GLMR',
|
|
959
|
+
'POLYGON': 'MATIC',
|
|
960
|
+
'MATIC': 'MATIC',
|
|
961
|
+
'BTT': 'BTT',
|
|
962
|
+
'CUBE': 'CUBE',
|
|
963
|
+
'IOST': 'IOST',
|
|
964
|
+
'NEO': 'NEO',
|
|
965
|
+
'KLAY': 'KLAY',
|
|
966
|
+
'EOS': 'EOS',
|
|
967
|
+
'THETA': 'THETA',
|
|
968
|
+
'NAS': 'NAS',
|
|
969
|
+
'NULS': 'NULS',
|
|
970
|
+
'QTUM': 'QTUM',
|
|
971
|
+
'FTM': 'FTM',
|
|
972
|
+
'CELO': 'CELO',
|
|
973
|
+
'DOGE': 'DOGE',
|
|
974
|
+
'DOGECHAIN': 'DOGECHAIN',
|
|
975
|
+
'NEAR': 'NEAR',
|
|
976
|
+
'STEP': 'STEP',
|
|
977
|
+
'BITCI': 'BITCI',
|
|
978
|
+
'CARDANO': 'ADA',
|
|
979
|
+
'ADA': 'ADA',
|
|
980
|
+
'ETC': 'ETC',
|
|
981
|
+
'LUK': 'LUK',
|
|
982
|
+
'MINEPLEX': 'MINEPLEX',
|
|
983
|
+
'DASH': 'DASH',
|
|
984
|
+
'ZEC': 'ZEC',
|
|
985
|
+
'IOTA': 'IOTA',
|
|
986
|
+
'NEON3': 'NEON3',
|
|
987
|
+
'XEM': 'XEM',
|
|
988
|
+
'HC': 'HC',
|
|
989
|
+
'LSK': 'LSK',
|
|
990
|
+
'DCR': 'DCR',
|
|
991
|
+
'BTG': 'BTG',
|
|
992
|
+
'STEEM': 'STEEM',
|
|
993
|
+
'BTS': 'BTS',
|
|
994
|
+
'ICX': 'ICX',
|
|
995
|
+
'WAVES': 'WAVES',
|
|
996
|
+
'CMT': 'CMT',
|
|
997
|
+
'BTM': 'BTM',
|
|
998
|
+
'VET': 'VET',
|
|
999
|
+
'XZC': 'XZC',
|
|
1000
|
+
'ACT': 'ACT',
|
|
1001
|
+
'SMT': 'SMT',
|
|
1002
|
+
'BCD': 'BCD',
|
|
1003
|
+
'WAX': 'WAX1',
|
|
1004
|
+
'WICC': 'WICC',
|
|
1005
|
+
'ELF': 'ELF',
|
|
1006
|
+
'ZIL': 'ZIL',
|
|
1007
|
+
'ELA': 'ELA',
|
|
1008
|
+
'BCX': 'BCX',
|
|
1009
|
+
'SBTC': 'SBTC',
|
|
1010
|
+
'BIFI': 'BIFI',
|
|
1011
|
+
'CTXC': 'CTXC',
|
|
1012
|
+
'WAN': 'WAN',
|
|
1013
|
+
'POLYX': 'POLYX',
|
|
1014
|
+
'PAI': 'PAI',
|
|
1015
|
+
'WTC': 'WTC',
|
|
1016
|
+
'DGB': 'DGB',
|
|
1017
|
+
'XVG': 'XVG',
|
|
1018
|
+
'AAC': 'AAC',
|
|
1019
|
+
'AE': 'AE',
|
|
1020
|
+
'SEELE': 'SEELE',
|
|
1021
|
+
'BCV': 'BCV',
|
|
1022
|
+
'GRS': 'GRS',
|
|
1023
|
+
'ARDR': 'ARDR',
|
|
1024
|
+
'NANO': 'NANO',
|
|
1025
|
+
'ZEN': 'ZEN',
|
|
1026
|
+
'RBTC': 'RBTC',
|
|
1027
|
+
'BSV': 'BSV',
|
|
1028
|
+
'GAS': 'GAS',
|
|
1029
|
+
'XTZ': 'XTZ',
|
|
1030
|
+
'LAMB': 'LAMB',
|
|
1031
|
+
'CVNT1': 'CVNT1',
|
|
1032
|
+
'DOCK': 'DOCK',
|
|
1033
|
+
'SC': 'SC',
|
|
1034
|
+
'KMD': 'KMD',
|
|
1035
|
+
'ETN': 'ETN',
|
|
1036
|
+
'TOP': 'TOP',
|
|
1037
|
+
'IRIS': 'IRIS',
|
|
1038
|
+
'UGAS': 'UGAS',
|
|
1039
|
+
'TT': 'TT',
|
|
1040
|
+
'NEWTON': 'NEWTON',
|
|
1041
|
+
'VSYS': 'VSYS',
|
|
1042
|
+
'FSN': 'FSN',
|
|
1043
|
+
'BHD': 'BHD',
|
|
1044
|
+
'ONE': 'ONE',
|
|
1045
|
+
'EM': 'EM',
|
|
1046
|
+
'CKB': 'CKB',
|
|
1047
|
+
'EOSS': 'EOSS',
|
|
1048
|
+
'HIVE': 'HIVE',
|
|
1049
|
+
'RVN': 'RVN',
|
|
1050
|
+
'DOT': 'DOT',
|
|
1051
|
+
'KSM': 'KSM',
|
|
1052
|
+
'BAND': 'BAND',
|
|
1053
|
+
'OEP4': 'OEP4',
|
|
1054
|
+
'NBS': 'NBS',
|
|
1055
|
+
'FIS': 'FIS',
|
|
1056
|
+
'AR': 'AR',
|
|
1057
|
+
'HBAR': 'HBAR',
|
|
1058
|
+
'FIL': 'FIL',
|
|
1059
|
+
'MASS': 'MASS',
|
|
1060
|
+
'KAVA': 'KAVA',
|
|
1061
|
+
'XYM': 'XYM',
|
|
1062
|
+
'ENJ': 'ENJ',
|
|
1063
|
+
'CRUST': 'CRUST',
|
|
1064
|
+
'ICP': 'ICP',
|
|
1065
|
+
'CSPR': 'CSPR',
|
|
1066
|
+
'FLOW': 'FLOW',
|
|
1067
|
+
'IOTX': 'IOTX',
|
|
1068
|
+
'LAT': 'LAT',
|
|
1069
|
+
'APT': 'APT',
|
|
1070
|
+
'XCH': 'XCH',
|
|
1071
|
+
'MINA': 'MINA',
|
|
1072
|
+
'XEC': 'ECASH',
|
|
1073
|
+
'XPRT': 'XPRT',
|
|
1074
|
+
'CCA': 'ACA',
|
|
1075
|
+
'AOTI': 'COTI',
|
|
1076
|
+
'AKT': 'AKT',
|
|
1077
|
+
'ARS': 'ARS',
|
|
1078
|
+
'ASTR': 'ASTR',
|
|
1079
|
+
'AZERO': 'AZERO',
|
|
1080
|
+
'BLD': 'BLD',
|
|
1081
|
+
'BRISE': 'BRISE',
|
|
1082
|
+
'CORE': 'CORE',
|
|
1083
|
+
'DESO': 'DESO',
|
|
1084
|
+
'DFI': 'DFI',
|
|
1085
|
+
'EGLD': 'EGLD',
|
|
1086
|
+
'ERG': 'ERG',
|
|
1087
|
+
'ETHF': 'ETHFAIR',
|
|
1088
|
+
'ETHW': 'ETHW',
|
|
1089
|
+
'EVMOS': 'EVMOS',
|
|
1090
|
+
'FIO': 'FIO',
|
|
1091
|
+
'FLR': 'FLR',
|
|
1092
|
+
'FINSCHIA': 'FINSCHIA',
|
|
1093
|
+
'KMA': 'KMA',
|
|
1094
|
+
'KYVE': 'KYVE',
|
|
1095
|
+
'MEV': 'MEV',
|
|
1096
|
+
'MOVR': 'MOVR',
|
|
1097
|
+
'NODL': 'NODL',
|
|
1098
|
+
'OAS': 'OAS',
|
|
1099
|
+
'OSMO': 'OSMO',
|
|
1100
|
+
'PAYCOIN': 'PAYCOIN',
|
|
1101
|
+
'POKT': 'POKT',
|
|
1102
|
+
'PYG': 'PYG',
|
|
1103
|
+
'REI': 'REI',
|
|
1104
|
+
'SCRT': 'SCRT',
|
|
1105
|
+
'SDN': 'SDN',
|
|
1106
|
+
'SEI': 'SEI',
|
|
1107
|
+
'SGB': 'SGB',
|
|
1108
|
+
'SUI': 'SUI',
|
|
1109
|
+
'SXP': 'SOLAR',
|
|
1110
|
+
'SYS': 'SYS',
|
|
1111
|
+
'TENET': 'TENET',
|
|
1112
|
+
'TON': 'TON',
|
|
1113
|
+
'UNQ': 'UNQ',
|
|
1114
|
+
'UYU': 'UYU',
|
|
1115
|
+
'WEMIX': 'WEMIX',
|
|
1116
|
+
'XDC': 'XDC',
|
|
1117
|
+
'XPLA': 'XPLA',
|
|
1118
|
+
// todo: below
|
|
1119
|
+
// 'LUNC': 'LUNC',
|
|
1120
|
+
// 'TERRA': 'TERRA', // tbd
|
|
1121
|
+
// 'LUNA': 'LUNA', tbd
|
|
1122
|
+
// 'FCT2': 'FCT2',
|
|
1123
|
+
// FIL-0X ?
|
|
1124
|
+
// 'COSMOS': 'ATOM1',
|
|
1125
|
+
// 'ATOM': 'ATOM1',
|
|
1126
|
+
// 'CRO': 'CRO',
|
|
1127
|
+
// 'OP': [ 'OPTIMISM', 'OPTIMISMETH' ]
|
|
1128
|
+
// 'ARB': ['ARB', 'ARBITRUMETH']
|
|
1129
|
+
// 'CHZ': [ 'CHZ', 'CZH' ],
|
|
1130
|
+
// todo: AVAXCCHAIN CCHAIN AVAX
|
|
1131
|
+
// 'ALGO': ['ALGO', 'ALGOUSDT']
|
|
1132
|
+
// 'ONT': [ 'ONT', 'ONTOLOGY' ],
|
|
1133
|
+
// 'BCC': 'BCC', BCH's somewhat chain
|
|
1134
|
+
// 'DBC1': 'DBC1',
|
|
981
1135
|
},
|
|
982
1136
|
// https://github.com/ccxt/ccxt/issues/5376
|
|
983
1137
|
'fetchOrdersByStatesMethod': 'spot_private_get_v1_order_orders',
|
|
@@ -2928,10 +3082,10 @@ class huobi extends huobi$1 {
|
|
|
2928
3082
|
for (let j = 0; j < chains.length; j++) {
|
|
2929
3083
|
const chainEntry = chains[j];
|
|
2930
3084
|
const uniqueChainId = this.safeString(chainEntry, 'chain'); // i.e. usdterc20, trc20usdt ...
|
|
2931
|
-
const title = this.
|
|
3085
|
+
const title = this.safeString2(chainEntry, 'baseChain', 'displayName'); // baseChain and baseChainProtocol are together existent or inexistent in entries, but baseChain is preferred. when they are both inexistent, then we use generic displayName
|
|
2932
3086
|
this.options['networkChainIdsByNames'][code][title] = uniqueChainId;
|
|
2933
3087
|
this.options['networkNamesByChainIds'][uniqueChainId] = title;
|
|
2934
|
-
const networkCode = this.networkIdToCode(
|
|
3088
|
+
const networkCode = this.networkIdToCode(uniqueChainId);
|
|
2935
3089
|
minWithdraw = this.safeNumber(chainEntry, 'minWithdrawAmt');
|
|
2936
3090
|
maxWithdraw = this.safeNumber(chainEntry, 'maxWithdrawAmt');
|
|
2937
3091
|
const withdrawStatus = this.safeString(chainEntry, 'withdrawStatus');
|
|
@@ -2951,6 +3105,10 @@ class huobi extends huobi$1 {
|
|
|
2951
3105
|
'id': uniqueChainId,
|
|
2952
3106
|
'network': networkCode,
|
|
2953
3107
|
'limits': {
|
|
3108
|
+
'deposit': {
|
|
3109
|
+
'min': undefined,
|
|
3110
|
+
'max': undefined,
|
|
3111
|
+
},
|
|
2954
3112
|
'withdraw': {
|
|
2955
3113
|
'min': minWithdraw,
|
|
2956
3114
|
'max': maxWithdraw,
|
|
@@ -2981,6 +3139,10 @@ class huobi extends huobi$1 {
|
|
|
2981
3139
|
'min': minWithdraw,
|
|
2982
3140
|
'max': maxWithdraw,
|
|
2983
3141
|
},
|
|
3142
|
+
'deposit': {
|
|
3143
|
+
'min': undefined,
|
|
3144
|
+
'max': undefined,
|
|
3145
|
+
},
|
|
2984
3146
|
},
|
|
2985
3147
|
'precision': this.parseNumber(minPrecision),
|
|
2986
3148
|
'networks': networks,
|
|
@@ -3008,8 +3170,13 @@ class huobi extends huobi$1 {
|
|
|
3008
3170
|
throw new errors.ExchangeError(this.id + ' networkCodeToId() - markets need to be loaded at first');
|
|
3009
3171
|
}
|
|
3010
3172
|
const uniqueNetworkIds = this.safeValue(this.options['networkChainIdsByNames'], currencyCode, {});
|
|
3011
|
-
|
|
3012
|
-
|
|
3173
|
+
if (networkCode in uniqueNetworkIds) {
|
|
3174
|
+
return uniqueNetworkIds[networkCode];
|
|
3175
|
+
}
|
|
3176
|
+
else {
|
|
3177
|
+
const networkTitle = super.networkCodeToId(networkCode);
|
|
3178
|
+
return this.safeValue(uniqueNetworkIds, networkTitle, networkTitle);
|
|
3179
|
+
}
|
|
3013
3180
|
}
|
|
3014
3181
|
async fetchBalance(params = {}) {
|
|
3015
3182
|
/**
|
|
@@ -5448,7 +5615,7 @@ class huobi extends huobi$1 {
|
|
|
5448
5615
|
'currency': code,
|
|
5449
5616
|
'address': address,
|
|
5450
5617
|
'tag': tag,
|
|
5451
|
-
'network': this.networkIdToCode(networkId
|
|
5618
|
+
'network': this.networkIdToCode(networkId),
|
|
5452
5619
|
'note': note,
|
|
5453
5620
|
'info': depositAddress,
|
|
5454
5621
|
};
|
|
@@ -5723,7 +5890,7 @@ class huobi extends huobi$1 {
|
|
|
5723
5890
|
'txid': txHash,
|
|
5724
5891
|
'timestamp': timestamp,
|
|
5725
5892
|
'datetime': this.iso8601(timestamp),
|
|
5726
|
-
'network': this.networkIdToCode(networkId
|
|
5893
|
+
'network': this.networkIdToCode(networkId),
|
|
5727
5894
|
'address': this.safeString(transaction, 'address'),
|
|
5728
5895
|
'addressTo': undefined,
|
|
5729
5896
|
'addressFrom': undefined,
|