ccxt 4.2.25 → 4.2.26
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/ccxt.browser.js +208 -13
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +2 -4
- package/dist/cjs/src/base/ws/Client.js +4 -1
- package/dist/cjs/src/bingx.js +46 -6
- package/dist/cjs/src/pro/bingx.js +155 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/base/Exchange.js +2 -4
- package/js/src/base/ws/Client.js +4 -1
- package/js/src/bingx.js +46 -6
- package/js/src/pro/bingx.d.ts +4 -1
- package/js/src/pro/bingx.js +155 -1
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -174,7 +174,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
174
174
|
|
|
175
175
|
//-----------------------------------------------------------------------------
|
|
176
176
|
// this is updated by vss.js when building
|
|
177
|
-
const version = '4.2.
|
|
177
|
+
const version = '4.2.26';
|
|
178
178
|
Exchange["default"].ccxtVersion = version;
|
|
179
179
|
const exchanges = {
|
|
180
180
|
'ace': ace,
|
|
@@ -1252,15 +1252,13 @@ class Exchange {
|
|
|
1252
1252
|
client.throttle(cost).then(() => {
|
|
1253
1253
|
client.send(message);
|
|
1254
1254
|
}).catch((e) => {
|
|
1255
|
-
|
|
1256
|
-
future.reject(e);
|
|
1255
|
+
client.onError(e);
|
|
1257
1256
|
});
|
|
1258
1257
|
}
|
|
1259
1258
|
else {
|
|
1260
1259
|
client.send(message)
|
|
1261
1260
|
.catch((e) => {
|
|
1262
|
-
|
|
1263
|
-
future.reject(e);
|
|
1261
|
+
client.onError(e);
|
|
1264
1262
|
});
|
|
1265
1263
|
}
|
|
1266
1264
|
}
|
|
@@ -145,7 +145,10 @@ class Client {
|
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
147
|
if (this.ping) {
|
|
148
|
-
this.send(this.ping(this))
|
|
148
|
+
this.send(this.ping(this))
|
|
149
|
+
.catch((error) => {
|
|
150
|
+
this.onError(error);
|
|
151
|
+
});
|
|
149
152
|
}
|
|
150
153
|
else if (platform.isNode) {
|
|
151
154
|
// can't do this inside browser
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -55,6 +55,7 @@ class bingx extends bingx$1 {
|
|
|
55
55
|
'fetchLeverage': true,
|
|
56
56
|
'fetchLiquidations': false,
|
|
57
57
|
'fetchMarkets': true,
|
|
58
|
+
'fetchMarkOHLCV': true,
|
|
58
59
|
'fetchMyLiquidations': true,
|
|
59
60
|
'fetchOHLCV': true,
|
|
60
61
|
'fetchOpenInterest': true,
|
|
@@ -159,6 +160,7 @@ class bingx extends bingx$1 {
|
|
|
159
160
|
'private': {
|
|
160
161
|
'get': {
|
|
161
162
|
'positionSide/dual': 1,
|
|
163
|
+
'market/markPriceKlines': 1,
|
|
162
164
|
},
|
|
163
165
|
'post': {
|
|
164
166
|
'positionSide/dual': 1,
|
|
@@ -684,6 +686,7 @@ class bingx extends bingx$1 {
|
|
|
684
686
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
|
|
685
687
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
|
|
686
688
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
|
|
689
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
|
|
687
690
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
688
691
|
* @param {string} timeframe the length of time each candle represents
|
|
689
692
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -720,7 +723,14 @@ class bingx extends bingx$1 {
|
|
|
720
723
|
response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
|
|
721
724
|
}
|
|
722
725
|
else {
|
|
723
|
-
|
|
726
|
+
const price = this.safeString(params, 'price');
|
|
727
|
+
params = this.omit(params, 'price');
|
|
728
|
+
if (price === 'mark') {
|
|
729
|
+
response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
|
|
733
|
+
}
|
|
724
734
|
}
|
|
725
735
|
//
|
|
726
736
|
// {
|
|
@@ -739,6 +749,24 @@ class bingx extends bingx$1 {
|
|
|
739
749
|
// ]
|
|
740
750
|
// }
|
|
741
751
|
//
|
|
752
|
+
// fetchMarkOHLCV
|
|
753
|
+
//
|
|
754
|
+
// {
|
|
755
|
+
// "code": 0,
|
|
756
|
+
// "msg": "",
|
|
757
|
+
// "data": [
|
|
758
|
+
// {
|
|
759
|
+
// "open": "42191.7",
|
|
760
|
+
// "close": "42189.5",
|
|
761
|
+
// "high": "42196.5",
|
|
762
|
+
// "low": "42189.5",
|
|
763
|
+
// "volume": "0.00",
|
|
764
|
+
// "openTime": 1706508840000,
|
|
765
|
+
// "closeTime": 1706508840000
|
|
766
|
+
// }
|
|
767
|
+
// ]
|
|
768
|
+
// }
|
|
769
|
+
//
|
|
742
770
|
let ohlcvs = this.safeValue(response, 'data', []);
|
|
743
771
|
if (!Array.isArray(ohlcvs)) {
|
|
744
772
|
ohlcvs = [ohlcvs];
|
|
@@ -755,6 +783,18 @@ class bingx extends bingx$1 {
|
|
|
755
783
|
// "volume": "167.44",
|
|
756
784
|
// "time": 1666584000000
|
|
757
785
|
// }
|
|
786
|
+
//
|
|
787
|
+
// fetchMarkOHLCV
|
|
788
|
+
//
|
|
789
|
+
// {
|
|
790
|
+
// "open": "42191.7",
|
|
791
|
+
// "close": "42189.5",
|
|
792
|
+
// "high": "42196.5",
|
|
793
|
+
// "low": "42189.5",
|
|
794
|
+
// "volume": "0.00",
|
|
795
|
+
// "openTime": 1706508840000,
|
|
796
|
+
// "closeTime": 1706508840000
|
|
797
|
+
// }
|
|
758
798
|
// spot
|
|
759
799
|
// [
|
|
760
800
|
// 1691402580000,
|
|
@@ -778,7 +818,7 @@ class bingx extends bingx$1 {
|
|
|
778
818
|
];
|
|
779
819
|
}
|
|
780
820
|
return [
|
|
781
|
-
this.
|
|
821
|
+
this.safeInteger2(ohlcv, 'time', 'closeTime'),
|
|
782
822
|
this.safeNumber(ohlcv, 'open'),
|
|
783
823
|
this.safeNumber(ohlcv, 'high'),
|
|
784
824
|
this.safeNumber(ohlcv, 'low'),
|
|
@@ -2235,10 +2275,10 @@ class bingx extends bingx$1 {
|
|
|
2235
2275
|
const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
|
|
2236
2276
|
let stopLoss = this.safeValue(order, 'stopLoss');
|
|
2237
2277
|
let stopLossPrice = undefined;
|
|
2238
|
-
if (stopLoss !== undefined) {
|
|
2278
|
+
if ((stopLoss !== undefined) && (stopLoss !== '')) {
|
|
2239
2279
|
stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
|
|
2240
2280
|
}
|
|
2241
|
-
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
|
|
2281
|
+
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number') && (stopLoss !== '')) {
|
|
2242
2282
|
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
|
2243
2283
|
if (typeof stopLoss === 'string') {
|
|
2244
2284
|
stopLoss = this.parseJson(stopLoss);
|
|
@@ -2247,10 +2287,10 @@ class bingx extends bingx$1 {
|
|
|
2247
2287
|
}
|
|
2248
2288
|
let takeProfit = this.safeValue(order, 'takeProfit');
|
|
2249
2289
|
let takeProfitPrice = undefined;
|
|
2250
|
-
if (takeProfit !== undefined) {
|
|
2290
|
+
if (takeProfit !== undefined && (takeProfit !== '')) {
|
|
2251
2291
|
takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
|
|
2252
2292
|
}
|
|
2253
|
-
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
|
|
2293
|
+
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number') && (takeProfit !== '')) {
|
|
2254
2294
|
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
|
2255
2295
|
if (typeof takeProfit === 'string') {
|
|
2256
2296
|
takeProfit = this.parseJson(takeProfit);
|
|
@@ -17,7 +17,7 @@ class bingx extends bingx$1 {
|
|
|
17
17
|
'watchOHLCV': true,
|
|
18
18
|
'watchOrders': true,
|
|
19
19
|
'watchMyTrades': true,
|
|
20
|
-
'watchTicker':
|
|
20
|
+
'watchTicker': true,
|
|
21
21
|
'watchTickers': false,
|
|
22
22
|
'watchBalance': true,
|
|
23
23
|
},
|
|
@@ -72,6 +72,151 @@ class bingx extends bingx$1 {
|
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
+
async watchTicker(symbol, params = {}) {
|
|
76
|
+
/**
|
|
77
|
+
* @method
|
|
78
|
+
* @name bingx#watchTicker
|
|
79
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
80
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/socket/market.html#Subscribe%20to%2024-hour%20price%20changes
|
|
81
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
82
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
83
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
84
|
+
*/
|
|
85
|
+
await this.loadMarkets();
|
|
86
|
+
const market = this.market(symbol);
|
|
87
|
+
const [marketType, query] = this.handleMarketTypeAndParams('watchTrades', market, params);
|
|
88
|
+
const url = this.safeValue(this.urls['api']['ws'], marketType);
|
|
89
|
+
if (url === undefined) {
|
|
90
|
+
throw new errors.BadRequest(this.id + ' watchTrades is not supported for ' + marketType + ' markets.');
|
|
91
|
+
}
|
|
92
|
+
const messageHash = market['id'] + '@ticker';
|
|
93
|
+
const uuid = this.uuid();
|
|
94
|
+
const request = {
|
|
95
|
+
'id': uuid,
|
|
96
|
+
'dataType': messageHash,
|
|
97
|
+
};
|
|
98
|
+
if (marketType === 'swap') {
|
|
99
|
+
request['reqType'] = 'sub';
|
|
100
|
+
}
|
|
101
|
+
return await this.watch(url, messageHash, this.extend(request, query), messageHash);
|
|
102
|
+
}
|
|
103
|
+
handleTicker(client, message) {
|
|
104
|
+
//
|
|
105
|
+
// swap
|
|
106
|
+
//
|
|
107
|
+
// {
|
|
108
|
+
// "code": 0,
|
|
109
|
+
// "dataType": "BTC-USDT@ticker",
|
|
110
|
+
// "data": {
|
|
111
|
+
// "e": "24hTicker",
|
|
112
|
+
// "E": 1706498923556,
|
|
113
|
+
// "s": "BTC-USDT",
|
|
114
|
+
// "p": "346.4",
|
|
115
|
+
// "P": "0.82",
|
|
116
|
+
// "c": "42432.5",
|
|
117
|
+
// "L": "0.0529",
|
|
118
|
+
// "h": "42855.4",
|
|
119
|
+
// "l": "41578.3",
|
|
120
|
+
// "v": "64310.9754",
|
|
121
|
+
// "q": "2728360284.15",
|
|
122
|
+
// "o": "42086.1",
|
|
123
|
+
// "O": 1706498922655,
|
|
124
|
+
// "C": 1706498883023,
|
|
125
|
+
// "A": "42437.8",
|
|
126
|
+
// "a": "1.4160",
|
|
127
|
+
// "B": "42437.1",
|
|
128
|
+
// "b": "2.5747"
|
|
129
|
+
// }
|
|
130
|
+
// }
|
|
131
|
+
//
|
|
132
|
+
// spot
|
|
133
|
+
//
|
|
134
|
+
// {
|
|
135
|
+
// "code": 0,
|
|
136
|
+
// "timestamp": 1706506795473,
|
|
137
|
+
// "data": {
|
|
138
|
+
// "e": "24hTicker",
|
|
139
|
+
// "E": 1706506795472,
|
|
140
|
+
// "s": "BTC-USDT",
|
|
141
|
+
// "p": -372.12,
|
|
142
|
+
// "P": "-0.87%",
|
|
143
|
+
// "o": 42548.95,
|
|
144
|
+
// "h": 42696.1,
|
|
145
|
+
// "l": 41621.29,
|
|
146
|
+
// "c": 42176.83,
|
|
147
|
+
// "v": 4943.33,
|
|
148
|
+
// "q": 208842236.5,
|
|
149
|
+
// "O": 1706420395472,
|
|
150
|
+
// "C": 1706506795472,
|
|
151
|
+
// "A": 42177.23,
|
|
152
|
+
// "a": 5.14484,
|
|
153
|
+
// "B": 42176.38,
|
|
154
|
+
// "b": 5.36117
|
|
155
|
+
// }
|
|
156
|
+
// }
|
|
157
|
+
//
|
|
158
|
+
const data = this.safeValue(message, 'data', {});
|
|
159
|
+
const marketId = this.safeString(data, 's');
|
|
160
|
+
// const marketId = messageHash.split('@')[0];
|
|
161
|
+
const isSwap = client.url.indexOf('swap') >= 0;
|
|
162
|
+
const marketType = isSwap ? 'swap' : 'spot';
|
|
163
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
164
|
+
const symbol = market['symbol'];
|
|
165
|
+
const ticker = this.parseWsTicker(data, market);
|
|
166
|
+
this.tickers[symbol] = ticker;
|
|
167
|
+
const messageHash = market['id'] + '@ticker';
|
|
168
|
+
client.resolve(ticker, messageHash);
|
|
169
|
+
}
|
|
170
|
+
parseWsTicker(message, market = undefined) {
|
|
171
|
+
//
|
|
172
|
+
// {
|
|
173
|
+
// "e": "24hTicker",
|
|
174
|
+
// "E": 1706498923556,
|
|
175
|
+
// "s": "BTC-USDT",
|
|
176
|
+
// "p": "346.4",
|
|
177
|
+
// "P": "0.82",
|
|
178
|
+
// "c": "42432.5",
|
|
179
|
+
// "L": "0.0529",
|
|
180
|
+
// "h": "42855.4",
|
|
181
|
+
// "l": "41578.3",
|
|
182
|
+
// "v": "64310.9754",
|
|
183
|
+
// "q": "2728360284.15",
|
|
184
|
+
// "o": "42086.1",
|
|
185
|
+
// "O": 1706498922655,
|
|
186
|
+
// "C": 1706498883023,
|
|
187
|
+
// "A": "42437.8",
|
|
188
|
+
// "a": "1.4160",
|
|
189
|
+
// "B": "42437.1",
|
|
190
|
+
// "b": "2.5747"
|
|
191
|
+
// }
|
|
192
|
+
//
|
|
193
|
+
const timestamp = this.safeInteger(message, 'ts');
|
|
194
|
+
const marketId = this.safeString(message, 's');
|
|
195
|
+
market = this.safeMarket(marketId, market);
|
|
196
|
+
const close = this.safeString(message, 'c');
|
|
197
|
+
return this.safeTicker({
|
|
198
|
+
'symbol': market['symbol'],
|
|
199
|
+
'timestamp': timestamp,
|
|
200
|
+
'datetime': this.iso8601(timestamp),
|
|
201
|
+
'high': this.safeString(message, 'h'),
|
|
202
|
+
'low': this.safeString(message, 'l'),
|
|
203
|
+
'bid': this.safeString(message, 'B'),
|
|
204
|
+
'bidVolume': this.safeString(message, 'b'),
|
|
205
|
+
'ask': this.safeString(message, 'A'),
|
|
206
|
+
'askVolume': this.safeString(message, 'a'),
|
|
207
|
+
'vwap': undefined,
|
|
208
|
+
'open': this.safeString(message, 'o'),
|
|
209
|
+
'close': close,
|
|
210
|
+
'last': close,
|
|
211
|
+
'previousClose': undefined,
|
|
212
|
+
'change': this.safeString(message, 'p'),
|
|
213
|
+
'percentage': undefined,
|
|
214
|
+
'average': undefined,
|
|
215
|
+
'baseVolume': this.safeString(message, 'v'),
|
|
216
|
+
'quoteVolume': this.safeString(message, 'q'),
|
|
217
|
+
'info': message,
|
|
218
|
+
}, market);
|
|
219
|
+
}
|
|
75
220
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
76
221
|
/**
|
|
77
222
|
* @method
|
|
@@ -908,6 +1053,10 @@ class bingx extends bingx$1 {
|
|
|
908
1053
|
this.handleOrderBook(client, message);
|
|
909
1054
|
return;
|
|
910
1055
|
}
|
|
1056
|
+
if (dataType.indexOf('@ticker') >= 0) {
|
|
1057
|
+
this.handleTicker(client, message);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
911
1060
|
if (dataType.indexOf('@trade') >= 0) {
|
|
912
1061
|
this.handleTrades(client, message);
|
|
913
1062
|
return;
|
|
@@ -938,6 +1087,11 @@ class bingx extends bingx$1 {
|
|
|
938
1087
|
this.handleMyTrades(client, message);
|
|
939
1088
|
}
|
|
940
1089
|
}
|
|
1090
|
+
const msgData = this.safeValue(message, 'data');
|
|
1091
|
+
const msgEvent = this.safeString(msgData, 'e');
|
|
1092
|
+
if (msgEvent === '24hTicker') {
|
|
1093
|
+
this.handleTicker(client, message);
|
|
1094
|
+
}
|
|
941
1095
|
}
|
|
942
1096
|
}
|
|
943
1097
|
|
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 } from './src/base/types.js';
|
|
6
6
|
import { 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, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.25";
|
|
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, 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, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.26';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -23,6 +23,7 @@ interface Exchange {
|
|
|
23
23
|
spotV3PrivateGetCapitalWithdrawHistory(params?: {}): Promise<implicitReturnType>;
|
|
24
24
|
spotV3PrivatePostPostAssetTransfer(params?: {}): Promise<implicitReturnType>;
|
|
25
25
|
swapV1PrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
|
|
26
|
+
swapV1PrivateGetMarketMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
|
|
26
27
|
swapV1PrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
|
|
27
28
|
swapV2PublicGetServerTime(params?: {}): Promise<implicitReturnType>;
|
|
28
29
|
swapV2PublicGetQuoteContracts(params?: {}): Promise<implicitReturnType>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -1246,15 +1246,13 @@ export default class Exchange {
|
|
|
1246
1246
|
client.throttle(cost).then(() => {
|
|
1247
1247
|
client.send(message);
|
|
1248
1248
|
}).catch((e) => {
|
|
1249
|
-
|
|
1250
|
-
future.reject(e);
|
|
1249
|
+
client.onError(e);
|
|
1251
1250
|
});
|
|
1252
1251
|
}
|
|
1253
1252
|
else {
|
|
1254
1253
|
client.send(message)
|
|
1255
1254
|
.catch((e) => {
|
|
1256
|
-
|
|
1257
|
-
future.reject(e);
|
|
1255
|
+
client.onError(e);
|
|
1258
1256
|
});
|
|
1259
1257
|
}
|
|
1260
1258
|
}
|
package/js/src/base/ws/Client.js
CHANGED
|
@@ -144,7 +144,10 @@ export default class Client {
|
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
146
|
if (this.ping) {
|
|
147
|
-
this.send(this.ping(this))
|
|
147
|
+
this.send(this.ping(this))
|
|
148
|
+
.catch((error) => {
|
|
149
|
+
this.onError(error);
|
|
150
|
+
});
|
|
148
151
|
}
|
|
149
152
|
else if (isNode) {
|
|
150
153
|
// can't do this inside browser
|
package/js/src/bingx.js
CHANGED
|
@@ -58,6 +58,7 @@ export default class bingx extends Exchange {
|
|
|
58
58
|
'fetchLeverage': true,
|
|
59
59
|
'fetchLiquidations': false,
|
|
60
60
|
'fetchMarkets': true,
|
|
61
|
+
'fetchMarkOHLCV': true,
|
|
61
62
|
'fetchMyLiquidations': true,
|
|
62
63
|
'fetchOHLCV': true,
|
|
63
64
|
'fetchOpenInterest': true,
|
|
@@ -162,6 +163,7 @@ export default class bingx extends Exchange {
|
|
|
162
163
|
'private': {
|
|
163
164
|
'get': {
|
|
164
165
|
'positionSide/dual': 1,
|
|
166
|
+
'market/markPriceKlines': 1,
|
|
165
167
|
},
|
|
166
168
|
'post': {
|
|
167
169
|
'positionSide/dual': 1,
|
|
@@ -687,6 +689,7 @@ export default class bingx extends Exchange {
|
|
|
687
689
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
|
|
688
690
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
|
|
689
691
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
|
|
692
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
|
|
690
693
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
691
694
|
* @param {string} timeframe the length of time each candle represents
|
|
692
695
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -723,7 +726,14 @@ export default class bingx extends Exchange {
|
|
|
723
726
|
response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
|
|
724
727
|
}
|
|
725
728
|
else {
|
|
726
|
-
|
|
729
|
+
const price = this.safeString(params, 'price');
|
|
730
|
+
params = this.omit(params, 'price');
|
|
731
|
+
if (price === 'mark') {
|
|
732
|
+
response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
|
|
736
|
+
}
|
|
727
737
|
}
|
|
728
738
|
//
|
|
729
739
|
// {
|
|
@@ -742,6 +752,24 @@ export default class bingx extends Exchange {
|
|
|
742
752
|
// ]
|
|
743
753
|
// }
|
|
744
754
|
//
|
|
755
|
+
// fetchMarkOHLCV
|
|
756
|
+
//
|
|
757
|
+
// {
|
|
758
|
+
// "code": 0,
|
|
759
|
+
// "msg": "",
|
|
760
|
+
// "data": [
|
|
761
|
+
// {
|
|
762
|
+
// "open": "42191.7",
|
|
763
|
+
// "close": "42189.5",
|
|
764
|
+
// "high": "42196.5",
|
|
765
|
+
// "low": "42189.5",
|
|
766
|
+
// "volume": "0.00",
|
|
767
|
+
// "openTime": 1706508840000,
|
|
768
|
+
// "closeTime": 1706508840000
|
|
769
|
+
// }
|
|
770
|
+
// ]
|
|
771
|
+
// }
|
|
772
|
+
//
|
|
745
773
|
let ohlcvs = this.safeValue(response, 'data', []);
|
|
746
774
|
if (!Array.isArray(ohlcvs)) {
|
|
747
775
|
ohlcvs = [ohlcvs];
|
|
@@ -758,6 +786,18 @@ export default class bingx extends Exchange {
|
|
|
758
786
|
// "volume": "167.44",
|
|
759
787
|
// "time": 1666584000000
|
|
760
788
|
// }
|
|
789
|
+
//
|
|
790
|
+
// fetchMarkOHLCV
|
|
791
|
+
//
|
|
792
|
+
// {
|
|
793
|
+
// "open": "42191.7",
|
|
794
|
+
// "close": "42189.5",
|
|
795
|
+
// "high": "42196.5",
|
|
796
|
+
// "low": "42189.5",
|
|
797
|
+
// "volume": "0.00",
|
|
798
|
+
// "openTime": 1706508840000,
|
|
799
|
+
// "closeTime": 1706508840000
|
|
800
|
+
// }
|
|
761
801
|
// spot
|
|
762
802
|
// [
|
|
763
803
|
// 1691402580000,
|
|
@@ -781,7 +821,7 @@ export default class bingx extends Exchange {
|
|
|
781
821
|
];
|
|
782
822
|
}
|
|
783
823
|
return [
|
|
784
|
-
this.
|
|
824
|
+
this.safeInteger2(ohlcv, 'time', 'closeTime'),
|
|
785
825
|
this.safeNumber(ohlcv, 'open'),
|
|
786
826
|
this.safeNumber(ohlcv, 'high'),
|
|
787
827
|
this.safeNumber(ohlcv, 'low'),
|
|
@@ -2238,10 +2278,10 @@ export default class bingx extends Exchange {
|
|
|
2238
2278
|
const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
|
|
2239
2279
|
let stopLoss = this.safeValue(order, 'stopLoss');
|
|
2240
2280
|
let stopLossPrice = undefined;
|
|
2241
|
-
if (stopLoss !== undefined) {
|
|
2281
|
+
if ((stopLoss !== undefined) && (stopLoss !== '')) {
|
|
2242
2282
|
stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
|
|
2243
2283
|
}
|
|
2244
|
-
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
|
|
2284
|
+
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number') && (stopLoss !== '')) {
|
|
2245
2285
|
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
|
2246
2286
|
if (typeof stopLoss === 'string') {
|
|
2247
2287
|
stopLoss = this.parseJson(stopLoss);
|
|
@@ -2250,10 +2290,10 @@ export default class bingx extends Exchange {
|
|
|
2250
2290
|
}
|
|
2251
2291
|
let takeProfit = this.safeValue(order, 'takeProfit');
|
|
2252
2292
|
let takeProfitPrice = undefined;
|
|
2253
|
-
if (takeProfit !== undefined) {
|
|
2293
|
+
if (takeProfit !== undefined && (takeProfit !== '')) {
|
|
2254
2294
|
takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
|
|
2255
2295
|
}
|
|
2256
|
-
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
|
|
2296
|
+
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number') && (takeProfit !== '')) {
|
|
2257
2297
|
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
|
2258
2298
|
if (typeof takeProfit === 'string') {
|
|
2259
2299
|
takeProfit = this.parseJson(takeProfit);
|
package/js/src/pro/bingx.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import bingxRest from '../bingx.js';
|
|
2
|
-
import type { Int, OHLCV, Str, OrderBook, Order, Trade, Balances } from '../base/types.js';
|
|
2
|
+
import type { Int, OHLCV, Str, OrderBook, Order, Trade, Balances, Ticker } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class bingx extends bingxRest {
|
|
5
5
|
describe(): any;
|
|
6
|
+
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
7
|
+
handleTicker(client: Client, message: any): void;
|
|
8
|
+
parseWsTicker(message: any, market?: any): Ticker;
|
|
6
9
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
7
10
|
handleTrades(client: Client, message: any): void;
|
|
8
11
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|