ccxt 4.3.57 → 4.3.59
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 +4 -4
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +4 -2
- package/dist/cjs/src/alpaca.js +5 -1
- package/dist/cjs/src/base/Exchange.js +4 -4
- package/dist/cjs/src/base/errors.js +22 -22
- package/dist/cjs/src/bigone.js +21 -1
- package/dist/cjs/src/bingx.js +131 -26
- package/dist/cjs/src/bitmart.js +1 -0
- package/dist/cjs/src/btcbox.js +149 -7
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/coinmate.js +28 -35
- package/dist/cjs/src/coinone.js +1 -1
- package/dist/cjs/src/deribit.js +15 -1
- package/dist/cjs/src/digifinex.js +32 -7
- package/dist/cjs/src/gate.js +24 -18
- package/dist/cjs/src/htx.js +10 -8
- package/dist/cjs/src/hyperliquid.js +107 -1
- package/dist/cjs/src/kucoin.js +3 -0
- package/dist/cjs/src/latoken.js +5 -1
- package/dist/cjs/src/mexc.js +11 -11
- package/dist/cjs/src/okx.js +3 -0
- package/dist/cjs/src/pro/binance.js +11 -13
- package/dist/cjs/src/pro/bingx.js +11 -8
- package/dist/cjs/src/pro/okx.js +3 -3
- package/dist/cjs/src/pro/xt.js +1108 -0
- package/dist/cjs/src/upbit.js +148 -49
- package/dist/cjs/src/woo.js +1 -1
- package/dist/cjs/src/xt.js +72 -7
- package/js/ccxt.d.ts +6 -3
- package/js/ccxt.js +5 -3
- package/js/src/abstract/bitmart.d.ts +1 -0
- package/js/src/abstract/btcbox.d.ts +1 -0
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/abstract/upbit.d.ts +3 -0
- package/js/src/abstract/xt.d.ts +1 -0
- package/js/src/alpaca.d.ts +1 -1
- package/js/src/alpaca.js +5 -1
- package/js/src/base/Exchange.d.ts +3 -3
- package/js/src/base/Exchange.js +5 -5
- package/js/src/base/errorHierarchy.d.ts +5 -5
- package/js/src/base/errorHierarchy.js +5 -5
- package/js/src/base/errors.d.ts +15 -15
- package/js/src/base/errors.js +22 -22
- package/js/src/bigone.d.ts +1 -1
- package/js/src/bigone.js +21 -1
- package/js/src/bingx.js +131 -26
- package/js/src/bitmart.js +1 -0
- package/js/src/btcbox.d.ts +4 -1
- package/js/src/btcbox.js +149 -7
- package/js/src/bybit.js +2 -2
- package/js/src/coinmate.js +28 -35
- package/js/src/coinone.js +1 -1
- package/js/src/deribit.d.ts +1 -1
- package/js/src/deribit.js +15 -1
- package/js/src/digifinex.d.ts +3 -2
- package/js/src/digifinex.js +32 -7
- package/js/src/gate.js +24 -18
- package/js/src/htx.js +10 -8
- package/js/src/hyperliquid.d.ts +3 -1
- package/js/src/hyperliquid.js +107 -1
- package/js/src/kucoin.js +3 -0
- package/js/src/latoken.d.ts +1 -1
- package/js/src/latoken.js +5 -1
- package/js/src/mexc.js +11 -11
- package/js/src/okx.js +3 -0
- package/js/src/pro/binance.js +11 -13
- package/js/src/pro/bingx.js +11 -8
- package/js/src/pro/bitmart.d.ts +3 -3
- package/js/src/pro/bitopro.d.ts +2 -2
- package/js/src/pro/coincheck.d.ts +2 -2
- package/js/src/pro/coinone.d.ts +2 -2
- package/js/src/pro/hyperliquid.d.ts +2 -2
- package/js/src/pro/okx.js +3 -3
- package/js/src/pro/xt.d.ts +31 -0
- package/js/src/pro/xt.js +1109 -0
- package/js/src/upbit.d.ts +0 -1
- package/js/src/upbit.js +148 -49
- package/js/src/woo.js +2 -2
- package/js/src/xt.js +72 -7
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -187,10 +187,11 @@ var wazirx$1 = require('./src/pro/wazirx.js');
|
|
|
187
187
|
var whitebit$1 = require('./src/pro/whitebit.js');
|
|
188
188
|
var woo$1 = require('./src/pro/woo.js');
|
|
189
189
|
var woofipro$1 = require('./src/pro/woofipro.js');
|
|
190
|
+
var xt$1 = require('./src/pro/xt.js');
|
|
190
191
|
|
|
191
192
|
//-----------------------------------------------------------------------------
|
|
192
193
|
// this is updated by vss.js when building
|
|
193
|
-
const version = '4.3.
|
|
194
|
+
const version = '4.3.59';
|
|
194
195
|
Exchange["default"].ccxtVersion = version;
|
|
195
196
|
const exchanges = {
|
|
196
197
|
'ace': ace,
|
|
@@ -370,6 +371,7 @@ const pro = {
|
|
|
370
371
|
'whitebit': whitebit$1,
|
|
371
372
|
'woo': woo$1,
|
|
372
373
|
'woofipro': woofipro$1,
|
|
374
|
+
'xt': xt$1,
|
|
373
375
|
};
|
|
374
376
|
pro.exchanges = Object.keys(pro);
|
|
375
377
|
pro['Exchange'] = Exchange["default"]; // now the same for rest and ts
|
|
@@ -400,6 +402,7 @@ exports.InsufficientFunds = errors.InsufficientFunds;
|
|
|
400
402
|
exports.InvalidAddress = errors.InvalidAddress;
|
|
401
403
|
exports.InvalidNonce = errors.InvalidNonce;
|
|
402
404
|
exports.InvalidOrder = errors.InvalidOrder;
|
|
405
|
+
exports.InvalidProxySettings = errors.InvalidProxySettings;
|
|
403
406
|
exports.MarginModeAlreadySet = errors.MarginModeAlreadySet;
|
|
404
407
|
exports.MarketClosed = errors.MarketClosed;
|
|
405
408
|
exports.NetworkError = errors.NetworkError;
|
|
@@ -414,7 +417,6 @@ exports.OrderNotCached = errors.OrderNotCached;
|
|
|
414
417
|
exports.OrderNotFillable = errors.OrderNotFillable;
|
|
415
418
|
exports.OrderNotFound = errors.OrderNotFound;
|
|
416
419
|
exports.PermissionDenied = errors.PermissionDenied;
|
|
417
|
-
exports.ProxyError = errors.ProxyError;
|
|
418
420
|
exports.RateLimitExceeded = errors.RateLimitExceeded;
|
|
419
421
|
exports.RequestTimeout = errors.RequestTimeout;
|
|
420
422
|
exports.errors = errors;
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -809,7 +809,11 @@ class alpaca extends alpaca$1 {
|
|
|
809
809
|
return this.parseOrders(response, undefined);
|
|
810
810
|
}
|
|
811
811
|
else {
|
|
812
|
-
return
|
|
812
|
+
return [
|
|
813
|
+
this.safeOrder({
|
|
814
|
+
'info': response,
|
|
815
|
+
}),
|
|
816
|
+
];
|
|
813
817
|
}
|
|
814
818
|
}
|
|
815
819
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
@@ -1702,7 +1702,7 @@ class Exchange {
|
|
|
1702
1702
|
const length = usedProxies.length;
|
|
1703
1703
|
if (length > 1) {
|
|
1704
1704
|
const joinedProxyNames = usedProxies.join(',');
|
|
1705
|
-
throw new errors.
|
|
1705
|
+
throw new errors.InvalidProxySettings(this.id + ' you have multiple conflicting proxy settings (' + joinedProxyNames + '), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback');
|
|
1706
1706
|
}
|
|
1707
1707
|
return proxyUrl;
|
|
1708
1708
|
}
|
|
@@ -1766,7 +1766,7 @@ class Exchange {
|
|
|
1766
1766
|
const length = usedProxies.length;
|
|
1767
1767
|
if (length > 1) {
|
|
1768
1768
|
const joinedProxyNames = usedProxies.join(',');
|
|
1769
|
-
throw new errors.
|
|
1769
|
+
throw new errors.InvalidProxySettings(this.id + ' you have multiple conflicting proxy settings (' + joinedProxyNames + '), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback');
|
|
1770
1770
|
}
|
|
1771
1771
|
return [httpProxy, httpsProxy, socksProxy];
|
|
1772
1772
|
}
|
|
@@ -1806,13 +1806,13 @@ class Exchange {
|
|
|
1806
1806
|
const length = usedProxies.length;
|
|
1807
1807
|
if (length > 1) {
|
|
1808
1808
|
const joinedProxyNames = usedProxies.join(',');
|
|
1809
|
-
throw new errors.
|
|
1809
|
+
throw new errors.InvalidProxySettings(this.id + ' you have multiple conflicting proxy settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, wsSocksProxy');
|
|
1810
1810
|
}
|
|
1811
1811
|
return [wsProxy, wssProxy, wsSocksProxy];
|
|
1812
1812
|
}
|
|
1813
1813
|
checkConflictingProxies(proxyAgentSet, proxyUrlSet) {
|
|
1814
1814
|
if (proxyAgentSet && proxyUrlSet) {
|
|
1815
|
-
throw new errors.
|
|
1815
|
+
throw new errors.InvalidProxySettings(this.id + ' you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy');
|
|
1816
1816
|
}
|
|
1817
1817
|
}
|
|
1818
1818
|
findMessageHashes(client, element) {
|
|
@@ -81,18 +81,6 @@ class MarketClosed extends OperationRejected {
|
|
|
81
81
|
this.name = 'MarketClosed';
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
class BadResponse extends ExchangeError {
|
|
85
|
-
constructor(message) {
|
|
86
|
-
super(message);
|
|
87
|
-
this.name = 'BadResponse';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
class NullResponse extends BadResponse {
|
|
91
|
-
constructor(message) {
|
|
92
|
-
super(message);
|
|
93
|
-
this.name = 'NullResponse';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
84
|
class InsufficientFunds extends ExchangeError {
|
|
97
85
|
constructor(message) {
|
|
98
86
|
super(message);
|
|
@@ -129,12 +117,6 @@ class OrderNotCached extends InvalidOrder {
|
|
|
129
117
|
this.name = 'OrderNotCached';
|
|
130
118
|
}
|
|
131
119
|
}
|
|
132
|
-
class CancelPending extends InvalidOrder {
|
|
133
|
-
constructor(message) {
|
|
134
|
-
super(message);
|
|
135
|
-
this.name = 'CancelPending';
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
120
|
class OrderImmediatelyFillable extends InvalidOrder {
|
|
139
121
|
constructor(message) {
|
|
140
122
|
super(message);
|
|
@@ -165,10 +147,10 @@ class NotSupported extends ExchangeError {
|
|
|
165
147
|
this.name = 'NotSupported';
|
|
166
148
|
}
|
|
167
149
|
}
|
|
168
|
-
class
|
|
150
|
+
class InvalidProxySettings extends ExchangeError {
|
|
169
151
|
constructor(message) {
|
|
170
152
|
super(message);
|
|
171
|
-
this.name = '
|
|
153
|
+
this.name = 'InvalidProxySettings';
|
|
172
154
|
}
|
|
173
155
|
}
|
|
174
156
|
class ExchangeClosedByUser extends ExchangeError {
|
|
@@ -225,7 +207,25 @@ class RequestTimeout extends NetworkError {
|
|
|
225
207
|
this.name = 'RequestTimeout';
|
|
226
208
|
}
|
|
227
209
|
}
|
|
228
|
-
|
|
210
|
+
class BadResponse extends OperationFailed {
|
|
211
|
+
constructor(message) {
|
|
212
|
+
super(message);
|
|
213
|
+
this.name = 'BadResponse';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
class NullResponse extends BadResponse {
|
|
217
|
+
constructor(message) {
|
|
218
|
+
super(message);
|
|
219
|
+
this.name = 'NullResponse';
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
class CancelPending extends OperationFailed {
|
|
223
|
+
constructor(message) {
|
|
224
|
+
super(message);
|
|
225
|
+
this.name = 'CancelPending';
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, BadResponse, NullResponse, CancelPending };
|
|
229
229
|
|
|
230
230
|
exports.AccountNotEnabled = AccountNotEnabled;
|
|
231
231
|
exports.AccountSuspended = AccountSuspended;
|
|
@@ -247,6 +247,7 @@ exports.InsufficientFunds = InsufficientFunds;
|
|
|
247
247
|
exports.InvalidAddress = InvalidAddress;
|
|
248
248
|
exports.InvalidNonce = InvalidNonce;
|
|
249
249
|
exports.InvalidOrder = InvalidOrder;
|
|
250
|
+
exports.InvalidProxySettings = InvalidProxySettings;
|
|
250
251
|
exports.MarginModeAlreadySet = MarginModeAlreadySet;
|
|
251
252
|
exports.MarketClosed = MarketClosed;
|
|
252
253
|
exports.NetworkError = NetworkError;
|
|
@@ -261,7 +262,6 @@ exports.OrderNotCached = OrderNotCached;
|
|
|
261
262
|
exports.OrderNotFillable = OrderNotFillable;
|
|
262
263
|
exports.OrderNotFound = OrderNotFound;
|
|
263
264
|
exports.PermissionDenied = PermissionDenied;
|
|
264
|
-
exports.ProxyError = ProxyError;
|
|
265
265
|
exports.RateLimitExceeded = RateLimitExceeded;
|
|
266
266
|
exports.RequestTimeout = RequestTimeout;
|
|
267
267
|
exports["default"] = errors;
|
package/dist/cjs/src/bigone.js
CHANGED
|
@@ -1621,7 +1621,27 @@ class bigone extends bigone$1 {
|
|
|
1621
1621
|
// }
|
|
1622
1622
|
// }
|
|
1623
1623
|
//
|
|
1624
|
-
|
|
1624
|
+
const data = this.safeDict(response, 'data', {});
|
|
1625
|
+
const cancelled = this.safeList(data, 'cancelled', []);
|
|
1626
|
+
const failed = this.safeList(data, 'failed', []);
|
|
1627
|
+
const result = [];
|
|
1628
|
+
for (let i = 0; i < cancelled.length; i++) {
|
|
1629
|
+
const orderId = cancelled[i];
|
|
1630
|
+
result.push(this.safeOrder({
|
|
1631
|
+
'info': orderId,
|
|
1632
|
+
'id': orderId,
|
|
1633
|
+
'status': 'canceled',
|
|
1634
|
+
}));
|
|
1635
|
+
}
|
|
1636
|
+
for (let i = 0; i < failed.length; i++) {
|
|
1637
|
+
const orderId = failed[i];
|
|
1638
|
+
result.push(this.safeOrder({
|
|
1639
|
+
'info': orderId,
|
|
1640
|
+
'id': orderId,
|
|
1641
|
+
'status': 'failed',
|
|
1642
|
+
}));
|
|
1643
|
+
}
|
|
1644
|
+
return result;
|
|
1625
1645
|
}
|
|
1626
1646
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1627
1647
|
/**
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -820,13 +820,14 @@ class bingx extends bingx$1 {
|
|
|
820
820
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
|
|
821
821
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
|
|
822
822
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
|
|
823
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20K-line%20Data
|
|
823
824
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
824
825
|
* @param {string} timeframe the length of time each candle represents
|
|
825
826
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
826
827
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
827
828
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
828
829
|
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
829
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
830
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
830
831
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
831
832
|
*/
|
|
832
833
|
await this.loadMarkets();
|
|
@@ -856,13 +857,18 @@ class bingx extends bingx$1 {
|
|
|
856
857
|
response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
|
|
857
858
|
}
|
|
858
859
|
else {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (price === 'mark') {
|
|
862
|
-
response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
|
|
860
|
+
if (market['inverse']) {
|
|
861
|
+
response = await this.cswapV1PublicGetMarketKlines(this.extend(request, params));
|
|
863
862
|
}
|
|
864
863
|
else {
|
|
865
|
-
|
|
864
|
+
const price = this.safeString(params, 'price');
|
|
865
|
+
params = this.omit(params, 'price');
|
|
866
|
+
if (price === 'mark') {
|
|
867
|
+
response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
|
|
868
|
+
}
|
|
869
|
+
else {
|
|
870
|
+
response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
|
|
871
|
+
}
|
|
866
872
|
}
|
|
867
873
|
}
|
|
868
874
|
//
|
|
@@ -1174,6 +1180,7 @@ class bingx extends bingx$1 {
|
|
|
1174
1180
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1175
1181
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20depth%20information
|
|
1176
1182
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Market%20Depth
|
|
1183
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%20Depth%20Data
|
|
1177
1184
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1178
1185
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1179
1186
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1194,7 +1201,12 @@ class bingx extends bingx$1 {
|
|
|
1194
1201
|
response = await this.spotV1PublicGetMarketDepth(this.extend(request, params));
|
|
1195
1202
|
}
|
|
1196
1203
|
else {
|
|
1197
|
-
|
|
1204
|
+
if (market['inverse']) {
|
|
1205
|
+
response = await this.cswapV1PublicGetMarketDepth(this.extend(request, params));
|
|
1206
|
+
}
|
|
1207
|
+
else {
|
|
1208
|
+
response = await this.swapV2PublicGetQuoteDepth(this.extend(request, params));
|
|
1209
|
+
}
|
|
1198
1210
|
}
|
|
1199
1211
|
//
|
|
1200
1212
|
// spot
|
|
@@ -1263,6 +1275,7 @@ class bingx extends bingx$1 {
|
|
|
1263
1275
|
* @name bingx#fetchFundingRate
|
|
1264
1276
|
* @description fetch the current funding rate
|
|
1265
1277
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
|
|
1278
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Price%20&%20Current%20Funding%20Rate
|
|
1266
1279
|
* @param {string} symbol unified market symbol
|
|
1267
1280
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1268
1281
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
@@ -1272,7 +1285,13 @@ class bingx extends bingx$1 {
|
|
|
1272
1285
|
const request = {
|
|
1273
1286
|
'symbol': market['id'],
|
|
1274
1287
|
};
|
|
1275
|
-
|
|
1288
|
+
let response = undefined;
|
|
1289
|
+
if (market['inverse']) {
|
|
1290
|
+
response = await this.cswapV1PublicGetMarketPremiumIndex(this.extend(request, params));
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(request, params));
|
|
1294
|
+
}
|
|
1276
1295
|
//
|
|
1277
1296
|
// {
|
|
1278
1297
|
// "code":0,
|
|
@@ -1424,9 +1443,10 @@ class bingx extends bingx$1 {
|
|
|
1424
1443
|
/**
|
|
1425
1444
|
* @method
|
|
1426
1445
|
* @name bingx#fetchOpenInterest
|
|
1427
|
-
* @description
|
|
1446
|
+
* @description retrieves the open interest of a trading pair
|
|
1428
1447
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Swap%20Open%20Positions
|
|
1429
|
-
* @
|
|
1448
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20Swap%20Open%20Positions
|
|
1449
|
+
* @param {string} symbol unified CCXT market symbol
|
|
1430
1450
|
* @param {object} [params] exchange specific parameters
|
|
1431
1451
|
* @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
1432
1452
|
*/
|
|
@@ -1435,7 +1455,15 @@ class bingx extends bingx$1 {
|
|
|
1435
1455
|
const request = {
|
|
1436
1456
|
'symbol': market['id'],
|
|
1437
1457
|
};
|
|
1438
|
-
|
|
1458
|
+
let response = undefined;
|
|
1459
|
+
if (market['inverse']) {
|
|
1460
|
+
response = await this.cswapV1PublicGetMarketOpenInterest(this.extend(request, params));
|
|
1461
|
+
}
|
|
1462
|
+
else {
|
|
1463
|
+
response = await this.swapV2PublicGetQuoteOpenInterest(this.extend(request, params));
|
|
1464
|
+
}
|
|
1465
|
+
//
|
|
1466
|
+
// linear swap
|
|
1439
1467
|
//
|
|
1440
1468
|
// {
|
|
1441
1469
|
// "code": 0,
|
|
@@ -1447,18 +1475,50 @@ class bingx extends bingx$1 {
|
|
|
1447
1475
|
// }
|
|
1448
1476
|
// }
|
|
1449
1477
|
//
|
|
1450
|
-
|
|
1451
|
-
|
|
1478
|
+
// inverse swap
|
|
1479
|
+
//
|
|
1480
|
+
// {
|
|
1481
|
+
// "code": 0,
|
|
1482
|
+
// "msg": "",
|
|
1483
|
+
// "timestamp": 1720328247986,
|
|
1484
|
+
// "data": [
|
|
1485
|
+
// {
|
|
1486
|
+
// "symbol": "BTC-USD",
|
|
1487
|
+
// "openInterest": "749.1160",
|
|
1488
|
+
// "timestamp": 1720310400000
|
|
1489
|
+
// }
|
|
1490
|
+
// ]
|
|
1491
|
+
// }
|
|
1492
|
+
//
|
|
1493
|
+
let result = {};
|
|
1494
|
+
if (market['inverse']) {
|
|
1495
|
+
const data = this.safeList(response, 'data', []);
|
|
1496
|
+
result = this.safeDict(data, 0, {});
|
|
1497
|
+
}
|
|
1498
|
+
else {
|
|
1499
|
+
result = this.safeDict(response, 'data', {});
|
|
1500
|
+
}
|
|
1501
|
+
return this.parseOpenInterest(result, market);
|
|
1452
1502
|
}
|
|
1453
1503
|
parseOpenInterest(interest, market = undefined) {
|
|
1454
1504
|
//
|
|
1455
|
-
//
|
|
1456
|
-
//
|
|
1457
|
-
//
|
|
1458
|
-
//
|
|
1459
|
-
//
|
|
1505
|
+
// linear swap
|
|
1506
|
+
//
|
|
1507
|
+
// {
|
|
1508
|
+
// "openInterest": "3289641547.10",
|
|
1509
|
+
// "symbol": "BTC-USDT",
|
|
1510
|
+
// "time": 1672026617364
|
|
1511
|
+
// }
|
|
1512
|
+
//
|
|
1513
|
+
// inverse swap
|
|
1514
|
+
//
|
|
1515
|
+
// {
|
|
1516
|
+
// "symbol": "BTC-USD",
|
|
1517
|
+
// "openInterest": "749.1160",
|
|
1518
|
+
// "timestamp": 1720310400000
|
|
1519
|
+
// }
|
|
1460
1520
|
//
|
|
1461
|
-
const timestamp = this.
|
|
1521
|
+
const timestamp = this.safeInteger2(interest, 'time', 'timestamp');
|
|
1462
1522
|
const id = this.safeString(interest, 'symbol');
|
|
1463
1523
|
const symbol = this.safeSymbol(id, market, '-', 'swap');
|
|
1464
1524
|
const openInterest = this.safeNumber(interest, 'openInterest');
|
|
@@ -1956,7 +2016,7 @@ class bingx extends bingx$1 {
|
|
|
1956
2016
|
request['timeInForce'] = 'GTC';
|
|
1957
2017
|
}
|
|
1958
2018
|
if (isSpot) {
|
|
1959
|
-
const cost = this.
|
|
2019
|
+
const cost = this.safeString2(params, 'cost', 'quoteOrderQty');
|
|
1960
2020
|
params = this.omit(params, 'cost');
|
|
1961
2021
|
if (cost !== undefined) {
|
|
1962
2022
|
request['quoteOrderQty'] = this.parseToNumeric(this.costToPrecision(symbol, cost));
|
|
@@ -2101,7 +2161,7 @@ class bingx extends bingx$1 {
|
|
|
2101
2161
|
positionSide = (side === 'buy') ? 'LONG' : 'SHORT';
|
|
2102
2162
|
}
|
|
2103
2163
|
request['positionSide'] = positionSide;
|
|
2104
|
-
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
2164
|
+
request['quantity'] = (market['inverse']) ? amount : this.parseToNumeric(this.amountToPrecision(symbol, amount)); // precision not available for inverse contracts
|
|
2105
2165
|
}
|
|
2106
2166
|
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
2107
2167
|
return this.extend(request, params);
|
|
@@ -2113,6 +2173,7 @@ class bingx extends bingx$1 {
|
|
|
2113
2173
|
* @description create a trade order
|
|
2114
2174
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
|
2115
2175
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
|
2176
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade%20order
|
|
2116
2177
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2117
2178
|
* @param {string} type 'market' or 'limit'
|
|
2118
2179
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2146,6 +2207,9 @@ class bingx extends bingx$1 {
|
|
|
2146
2207
|
if (test) {
|
|
2147
2208
|
response = await this.swapV2PrivatePostTradeOrderTest(request);
|
|
2148
2209
|
}
|
|
2210
|
+
else if (market['inverse']) {
|
|
2211
|
+
response = await this.cswapV1PrivatePostTradeOrder(request);
|
|
2212
|
+
}
|
|
2149
2213
|
else {
|
|
2150
2214
|
response = await this.swapV2PrivatePostTradeOrder(request);
|
|
2151
2215
|
}
|
|
@@ -2173,7 +2237,7 @@ class bingx extends bingx$1 {
|
|
|
2173
2237
|
// }
|
|
2174
2238
|
// }
|
|
2175
2239
|
//
|
|
2176
|
-
// swap
|
|
2240
|
+
// linear swap
|
|
2177
2241
|
//
|
|
2178
2242
|
// {
|
|
2179
2243
|
// "code": 0,
|
|
@@ -2191,6 +2255,21 @@ class bingx extends bingx$1 {
|
|
|
2191
2255
|
// }
|
|
2192
2256
|
// }
|
|
2193
2257
|
//
|
|
2258
|
+
// inverse swap
|
|
2259
|
+
//
|
|
2260
|
+
// {
|
|
2261
|
+
// "orderId": 1809841379603398656,
|
|
2262
|
+
// "symbol": "SOL-USD",
|
|
2263
|
+
// "positionSide": "LONG",
|
|
2264
|
+
// "side": "BUY",
|
|
2265
|
+
// "type": "LIMIT",
|
|
2266
|
+
// "price": 100,
|
|
2267
|
+
// "quantity": 1,
|
|
2268
|
+
// "stopPrice": 0,
|
|
2269
|
+
// "workingType": "",
|
|
2270
|
+
// "timeInForce": ""
|
|
2271
|
+
// }
|
|
2272
|
+
//
|
|
2194
2273
|
if (typeof response === 'string') {
|
|
2195
2274
|
// broken api engine : order-ids are too long numbers (i.e. 1742930526912864656)
|
|
2196
2275
|
// and JSON.parse can not handle them in JS, so we have to use .parseJson
|
|
@@ -2198,9 +2277,20 @@ class bingx extends bingx$1 {
|
|
|
2198
2277
|
response = this.fixStringifiedJsonMembers(response);
|
|
2199
2278
|
response = this.parseJson(response);
|
|
2200
2279
|
}
|
|
2201
|
-
const data = this.
|
|
2202
|
-
|
|
2203
|
-
|
|
2280
|
+
const data = this.safeDict(response, 'data', {});
|
|
2281
|
+
let result = {};
|
|
2282
|
+
if (market['swap']) {
|
|
2283
|
+
if (market['inverse']) {
|
|
2284
|
+
result = response;
|
|
2285
|
+
}
|
|
2286
|
+
else {
|
|
2287
|
+
result = this.safeDict(data, 'order', {});
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
else {
|
|
2291
|
+
result = data;
|
|
2292
|
+
}
|
|
2293
|
+
return this.parseOrder(result, market);
|
|
2204
2294
|
}
|
|
2205
2295
|
async createOrders(orders, params = {}) {
|
|
2206
2296
|
/**
|
|
@@ -2374,7 +2464,7 @@ class bingx extends bingx$1 {
|
|
|
2374
2464
|
// }
|
|
2375
2465
|
//
|
|
2376
2466
|
//
|
|
2377
|
-
// swap
|
|
2467
|
+
// linear swap
|
|
2378
2468
|
// createOrder, createOrders
|
|
2379
2469
|
//
|
|
2380
2470
|
// {
|
|
@@ -2385,6 +2475,21 @@ class bingx extends bingx$1 {
|
|
|
2385
2475
|
// "type": "LIMIT"
|
|
2386
2476
|
// }
|
|
2387
2477
|
//
|
|
2478
|
+
// inverse swap createOrder
|
|
2479
|
+
//
|
|
2480
|
+
// {
|
|
2481
|
+
// "orderId": 1809841379603398656,
|
|
2482
|
+
// "symbol": "SOL-USD",
|
|
2483
|
+
// "positionSide": "LONG",
|
|
2484
|
+
// "side": "BUY",
|
|
2485
|
+
// "type": "LIMIT",
|
|
2486
|
+
// "price": 100,
|
|
2487
|
+
// "quantity": 1,
|
|
2488
|
+
// "stopPrice": 0,
|
|
2489
|
+
// "workingType": "",
|
|
2490
|
+
// "timeInForce": ""
|
|
2491
|
+
// }
|
|
2492
|
+
//
|
|
2388
2493
|
// fetchOrder, fetchOpenOrders, fetchClosedOrders
|
|
2389
2494
|
//
|
|
2390
2495
|
// {
|
package/dist/cjs/src/bitmart.js
CHANGED