ccxt 4.1.100 → 4.2.2

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.
@@ -1189,9 +1189,15 @@ class poloniexfutures extends poloniexfutures$1 {
1189
1189
  if (symbol !== undefined) {
1190
1190
  request['symbol'] = this.marketId(symbol);
1191
1191
  }
1192
- const stop = this.safeValue(params, 'stop');
1193
- const method = stop ? 'privateDeleteStopOrders' : 'privateDeleteOrders';
1194
- const response = await this[method](this.extend(request, params));
1192
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1193
+ params = this.omit(params, ['stop', 'trigger']);
1194
+ let response = undefined;
1195
+ if (stop) {
1196
+ response = await this.privateDeleteStopOrders(this.extend(request, params));
1197
+ }
1198
+ else {
1199
+ response = await this.privateDeleteOrders(this.extend(request, params));
1200
+ }
1195
1201
  //
1196
1202
  // {
1197
1203
  // "code": "200000",
@@ -1253,9 +1259,9 @@ class poloniexfutures extends poloniexfutures$1 {
1253
1259
  * @returns An [array of order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1254
1260
  */
1255
1261
  await this.loadMarkets();
1256
- const stop = this.safeValue(params, 'stop');
1262
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1257
1263
  const until = this.safeInteger2(params, 'until', 'till');
1258
- params = this.omit(params, ['stop', 'until', 'till']);
1264
+ params = this.omit(params, ['triger', 'stop', 'until', 'till']);
1259
1265
  if (status === 'closed') {
1260
1266
  status = 'done';
1261
1267
  }
@@ -1277,8 +1283,13 @@ class poloniexfutures extends poloniexfutures$1 {
1277
1283
  if (until !== undefined) {
1278
1284
  request['endAt'] = until;
1279
1285
  }
1280
- const method = stop ? 'privateGetStopOrders' : 'privateGetOrders';
1281
- const response = await this[method](this.extend(request, params));
1286
+ let response = undefined;
1287
+ if (stop) {
1288
+ response = await this.privateGetStopOrders(this.extend(request, params));
1289
+ }
1290
+ else {
1291
+ response = await this.privateGetOrders(this.extend(request, params));
1292
+ }
1282
1293
  //
1283
1294
  // {
1284
1295
  // "code": "200000",
@@ -1388,20 +1399,20 @@ class poloniexfutures extends poloniexfutures$1 {
1388
1399
  */
1389
1400
  await this.loadMarkets();
1390
1401
  const request = {};
1391
- let method = 'privateGetOrdersOrderId';
1402
+ let response = undefined;
1392
1403
  if (id === undefined) {
1393
1404
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
1394
1405
  if (clientOrderId === undefined) {
1395
1406
  throw new errors.InvalidOrder(this.id + ' fetchOrder() requires parameter id or params.clientOid');
1396
1407
  }
1397
1408
  request['clientOid'] = clientOrderId;
1398
- method = 'privateGetOrdersByClientOid';
1399
1409
  params = this.omit(params, ['clientOid', 'clientOrderId']);
1410
+ response = await this.privateGetClientOrderIdClientOid(this.extend(request, params));
1400
1411
  }
1401
1412
  else {
1402
1413
  request['order-id'] = id;
1414
+ response = await this.privateGetOrdersOrderId(this.extend(request, params));
1403
1415
  }
1404
- const response = await this[method](this.extend(request, params));
1405
1416
  //
1406
1417
  // {
1407
1418
  // "code": "200000",
@@ -1721,7 +1732,7 @@ class poloniexfutures extends poloniexfutures$1 {
1721
1732
  const version = this.safeString(params, 'version', defaultVersion);
1722
1733
  const tail = '/api/' + version + '/' + this.implodeParams(path, params);
1723
1734
  url += tail;
1724
- const query = this.omit(params, path);
1735
+ const query = this.omit(params, this.extractParams(path));
1725
1736
  const queryLength = Object.keys(query).length;
1726
1737
  if (api === 'public') {
1727
1738
  if (queryLength) {
@@ -1114,25 +1114,27 @@ class binance extends binance$1 {
1114
1114
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
1115
1115
  const delay = this.sum(listenKeyRefreshRate, 10000);
1116
1116
  if (time - lastAuthenticatedTime > delay) {
1117
- let method = 'publicPostUserDataStream';
1117
+ let response = undefined;
1118
1118
  if (type === 'future') {
1119
- method = 'fapiPrivatePostListenKey';
1119
+ response = await this.fapiPrivatePostListenKey(query);
1120
1120
  }
1121
1121
  else if (type === 'delivery') {
1122
- method = 'dapiPrivatePostListenKey';
1122
+ response = await this.dapiPrivatePostListenKey(query);
1123
1123
  }
1124
1124
  else if (type === 'margin' && isCrossMargin) {
1125
- method = 'sapiPostUserDataStream';
1125
+ response = await this.sapiPostUserDataStream(query);
1126
1126
  }
1127
1127
  else if (isIsolatedMargin) {
1128
- method = 'sapiPostUserDataStreamIsolated';
1129
1128
  if (symbol === undefined) {
1130
1129
  throw new errors.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
1131
1130
  }
1132
1131
  const marketId = this.marketId(symbol);
1133
1132
  query = this.extend(query, { 'symbol': marketId });
1133
+ response = await this.sapiPostUserDataStreamIsolated(query);
1134
+ }
1135
+ else {
1136
+ response = await this.publicPostUserDataStream(query);
1134
1137
  }
1135
- const response = await this[method](query);
1136
1138
  this.options[type] = this.extend(options, {
1137
1139
  'listenKey': this.safeString(response, 'listenKey'),
1138
1140
  'lastAuthenticatedTime': time,
@@ -1158,26 +1160,27 @@ class binance extends binance$1 {
1158
1160
  // A network error happened: we can't renew a listen key that does not exist.
1159
1161
  return;
1160
1162
  }
1161
- let method = 'publicPutUserDataStream';
1162
1163
  const request = {};
1163
1164
  const symbol = this.safeString(params, 'symbol');
1164
1165
  const sendParams = this.omit(params, ['type', 'symbol']);
1165
- if (type === 'future') {
1166
- method = 'fapiPrivatePutListenKey';
1167
- }
1168
- else if (type === 'delivery') {
1169
- method = 'dapiPrivatePutListenKey';
1170
- }
1171
- else {
1172
- request['listenKey'] = listenKey;
1173
- if (type === 'margin') {
1174
- request['symbol'] = symbol;
1175
- method = 'sapiPutUserDataStream';
1176
- }
1177
- }
1178
1166
  const time = this.milliseconds();
1179
1167
  try {
1180
- await this[method](this.extend(request, sendParams));
1168
+ if (type === 'future') {
1169
+ await this.fapiPrivatePutListenKey(this.extend(request, sendParams));
1170
+ }
1171
+ else if (type === 'delivery') {
1172
+ await this.dapiPrivatePutListenKey(this.extend(request, sendParams));
1173
+ }
1174
+ else {
1175
+ request['listenKey'] = listenKey;
1176
+ if (type === 'margin') {
1177
+ request['symbol'] = symbol;
1178
+ await this.sapiPutUserDataStream(this.extend(request, sendParams));
1179
+ }
1180
+ else {
1181
+ await this.publicPutUserDataStream(this.extend(request, sendParams));
1182
+ }
1183
+ }
1181
1184
  }
1182
1185
  catch (error) {
1183
1186
  const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
@@ -51,7 +51,7 @@ class bitmart extends bitmart$1 {
51
51
  'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
52
52
  },
53
53
  'watchOrderBook': {
54
- 'depth': 'depth50', // depth5, depth20, depth50
54
+ 'depth': 'depth/increase100', // depth/increase100, depth5, depth20, depth50
55
55
  },
56
56
  'ws': {
57
57
  'inflate': true,
@@ -1069,6 +1069,7 @@ class bitmart extends bitmart$1 {
1069
1069
  * @method
1070
1070
  * @name bitmart#watchOrderBook
1071
1071
  * @see https://developer-pro.bitmart.com/en/spot/#public-depth-all-channel
1072
+ * @see https://developer-pro.bitmart.com/en/spot/#public-depth-increase-channel
1072
1073
  * @see https://developer-pro.bitmart.com/en/futures/#public-depth-channel
1073
1074
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1074
1075
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -1078,11 +1079,14 @@ class bitmart extends bitmart$1 {
1078
1079
  */
1079
1080
  await this.loadMarkets();
1080
1081
  const options = this.safeValue(this.options, 'watchOrderBook', {});
1081
- const depth = this.safeString(options, 'depth', 'depth50');
1082
+ let depth = this.safeString(options, 'depth', 'depth/increase100');
1082
1083
  symbol = this.symbol(symbol);
1083
1084
  const market = this.market(symbol);
1084
1085
  let type = 'spot';
1085
1086
  [type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
1087
+ if (type === 'swap' && depth === 'depth/increase100') {
1088
+ depth = 'depth50';
1089
+ }
1086
1090
  const orderbook = await this.subscribe(depth, symbol, type, params);
1087
1091
  return orderbook.limit();
1088
1092
  }
@@ -1131,46 +1135,72 @@ class bitmart extends bitmart$1 {
1131
1135
  }
1132
1136
  handleOrderBook(client, message) {
1133
1137
  //
1134
- // spot
1135
- // {
1136
- // "data": [
1137
- // {
1138
- // "asks": [
1139
- // [ '46828.38', "0.21847" ],
1140
- // [ '46830.68', "0.08232" ],
1141
- // ...
1142
- // ],
1143
- // "bids": [
1144
- // [ '46820.78', "0.00444" ],
1145
- // [ '46814.33', "0.00234" ],
1146
- // ...
1138
+ // spot depth-all
1139
+ // {
1140
+ // "data": [
1141
+ // {
1142
+ // "asks": [
1143
+ // [ '46828.38', "0.21847" ],
1144
+ // [ '46830.68', "0.08232" ],
1145
+ // ...
1146
+ // ],
1147
+ // "bids": [
1148
+ // [ '46820.78', "0.00444" ],
1149
+ // [ '46814.33', "0.00234" ],
1150
+ // ...
1151
+ // ],
1152
+ // "ms_t": 1631044962431,
1153
+ // "symbol": "BTC_USDT"
1154
+ // }
1155
+ // ],
1156
+ // "table": "spot/depth5"
1157
+ // }
1158
+ // spot increse depth snapshot
1159
+ // {
1160
+ // "data":[
1161
+ // {
1162
+ // "asks":[
1163
+ // [
1164
+ // "43652.52",
1165
+ // "0.02039"
1147
1166
  // ],
1148
- // "ms_t": 1631044962431,
1149
- // "symbol": "BTC_USDT"
1150
- // }
1151
- // ],
1152
- // "table": "spot/depth5"
1153
- // }
1167
+ // ...
1168
+ // ],
1169
+ // "bids":[
1170
+ // [
1171
+ // "43652.51",
1172
+ // "0.00500"
1173
+ // ],
1174
+ // ...
1175
+ // ],
1176
+ // "ms_t":1703376836487,
1177
+ // "symbol":"BTC_USDT",
1178
+ // "type":"snapshot", // or update
1179
+ // "version":2141731
1180
+ // }
1181
+ // ],
1182
+ // "table":"spot/depth/increase100"
1183
+ // }
1154
1184
  // swap
1155
- // {
1156
- // "group":"futures/depth50:BTCUSDT",
1157
- // "data":{
1158
- // "symbol":"BTCUSDT",
1159
- // "way":1,
1160
- // "depths":[
1161
- // {
1162
- // "price":"39509.8",
1163
- // "vol":"2379"
1164
- // },
1165
- // {
1166
- // "price":"39509.6",
1167
- // "vol":"6815"
1168
- // },
1169
- // ...
1170
- // ],
1171
- // "ms_t":1701566021194
1172
- // }
1173
- // }
1185
+ // {
1186
+ // "group":"futures/depth50:BTCUSDT",
1187
+ // "data":{
1188
+ // "symbol":"BTCUSDT",
1189
+ // "way":1,
1190
+ // "depths":[
1191
+ // {
1192
+ // "price":"39509.8",
1193
+ // "vol":"2379"
1194
+ // },
1195
+ // {
1196
+ // "price":"39509.6",
1197
+ // "vol":"6815"
1198
+ // },
1199
+ // ...
1200
+ // ],
1201
+ // "ms_t":1701566021194
1202
+ // }
1203
+ // }
1174
1204
  //
1175
1205
  const data = this.safeValue(message, 'data');
1176
1206
  if (data === undefined) {
@@ -1179,12 +1209,16 @@ class bitmart extends bitmart$1 {
1179
1209
  const depths = this.safeValue(data, 'depths');
1180
1210
  const isSpot = (depths === undefined);
1181
1211
  const table = this.safeString2(message, 'table', 'group');
1182
- const parts = table.split('/');
1183
- const lastPart = this.safeString(parts, 1);
1184
- let limitString = lastPart.replace('depth', '');
1185
- const dotsIndex = limitString.indexOf(':');
1186
- limitString = limitString.slice(0, dotsIndex);
1187
- const limit = this.parseToInt(limitString);
1212
+ // find limit subscribed to
1213
+ const limitsToCheck = ['100', '50', '20', '10', '5'];
1214
+ let limit = 0;
1215
+ for (let i = 0; i < limitsToCheck.length; i++) {
1216
+ const limitString = limitsToCheck[i];
1217
+ if (table.indexOf(limitString) >= 0) {
1218
+ limit = this.parseToInt(limitString);
1219
+ break;
1220
+ }
1221
+ }
1188
1222
  if (isSpot) {
1189
1223
  for (let i = 0; i < data.length; i++) {
1190
1224
  const update = data[i];
@@ -1196,7 +1230,10 @@ class bitmart extends bitmart$1 {
1196
1230
  orderbook['symbol'] = symbol;
1197
1231
  this.orderbooks[symbol] = orderbook;
1198
1232
  }
1199
- orderbook.reset({});
1233
+ const type = this.safeValue(update, 'type');
1234
+ if ((type === 'snapshot') || (!(table.indexOf('increase') >= 0))) {
1235
+ orderbook.reset({});
1236
+ }
1200
1237
  this.handleOrderBookMessage(client, update, orderbook);
1201
1238
  const timestamp = this.safeInteger(update, 'ms_t');
1202
1239
  orderbook['timestamp'] = timestamp;
@@ -1388,9 +1425,7 @@ class bitmart extends bitmart$1 {
1388
1425
  }
1389
1426
  else {
1390
1427
  const methods = {
1391
- 'depth5': this.handleOrderBook,
1392
- 'depth20': this.handleOrderBook,
1393
- 'depth50': this.handleOrderBook,
1428
+ 'depth': this.handleOrderBook,
1394
1429
  'ticker': this.handleTicker,
1395
1430
  'trade': this.handleTrade,
1396
1431
  'kline': this.handleOHLCV,
@@ -886,10 +886,15 @@ class bybit extends bybit$1 {
886
886
  }
887
887
  const trades = this.myTrades;
888
888
  const symbols = {};
889
- const method = spot ? 'parseWsTrade' : 'parseTrade';
890
889
  for (let i = 0; i < data.length; i++) {
891
890
  const rawTrade = data[i];
892
- const parsed = this[method](rawTrade);
891
+ let parsed = undefined;
892
+ if (spot) {
893
+ parsed = this.parseWsTrade(rawTrade);
894
+ }
895
+ else {
896
+ parsed = this.parseTrade(rawTrade);
897
+ }
893
898
  const symbol = parsed['symbol'];
894
899
  symbols[symbol] = true;
895
900
  trades.append(parsed);
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.1.99";
7
+ declare const version = "4.2.1";
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.1.100';
41
+ const version = '4.2.2';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -9,11 +9,13 @@ interface Exchange {
9
9
  spotV1PrivateGetTradeQuery(params?: {}): Promise<implicitReturnType>;
10
10
  spotV1PrivateGetTradeOpenOrders(params?: {}): Promise<implicitReturnType>;
11
11
  spotV1PrivateGetTradeHistoryOrders(params?: {}): Promise<implicitReturnType>;
12
+ spotV1PrivateGetUserCommissionRate(params?: {}): Promise<implicitReturnType>;
12
13
  spotV1PrivateGetAccountBalance(params?: {}): Promise<implicitReturnType>;
13
14
  spotV1PrivatePostTradeOrder(params?: {}): Promise<implicitReturnType>;
14
15
  spotV1PrivatePostTradeCancel(params?: {}): Promise<implicitReturnType>;
15
16
  spotV1PrivatePostTradeBatchOrders(params?: {}): Promise<implicitReturnType>;
16
17
  spotV1PrivatePostTradeCancelOrders(params?: {}): Promise<implicitReturnType>;
18
+ spotV1PrivatePostTradeCancelOpenOrders(params?: {}): Promise<implicitReturnType>;
17
19
  spotV3PrivateGetGetAssetTransfer(params?: {}): Promise<implicitReturnType>;
18
20
  spotV3PrivateGetAssetTransfer(params?: {}): Promise<implicitReturnType>;
19
21
  spotV3PrivateGetCapitalDepositHisrec(params?: {}): Promise<implicitReturnType>;
package/js/src/binance.js CHANGED
@@ -1595,6 +1595,7 @@ export default class binance extends Exchange {
1595
1595
  '-4046': AuthenticationError,
1596
1596
  '-4047': BadRequest,
1597
1597
  '-4054': BadRequest,
1598
+ '-4164': InvalidOrder,
1598
1599
  '-5001': BadRequest,
1599
1600
  '-5002': InsufficientFunds,
1600
1601
  '-5003': InsufficientFunds,
package/js/src/bingx.js CHANGED
@@ -120,6 +120,7 @@ export default class bingx extends Exchange {
120
120
  'trade/query': 3,
121
121
  'trade/openOrders': 3,
122
122
  'trade/historyOrders': 3,
123
+ 'user/commissionRate': 3,
123
124
  'account/balance': 3,
124
125
  },
125
126
  'post': {
@@ -127,6 +128,7 @@ export default class bingx extends Exchange {
127
128
  'trade/cancel': 3,
128
129
  'trade/batchOrders': 3,
129
130
  'trade/cancelOrders': 3,
131
+ 'trade/cancelOpenOrders': 3,
130
132
  },
131
133
  },
132
134
  },
@@ -1317,22 +1319,30 @@ export default class bingx extends Exchange {
1317
1319
  // }
1318
1320
  //
1319
1321
  const marketId = this.safeString(ticker, 'symbol');
1320
- // const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
1321
1322
  const lastQty = this.safeString(ticker, 'lastQty');
1322
1323
  // in spot markets, lastQty is not present
1323
1324
  // it's (bad, but) the only way we can check the tickers origin
1324
1325
  const type = (lastQty === undefined) ? 'spot' : 'swap';
1325
- const symbol = this.safeSymbol(marketId, market, undefined, type);
1326
+ market = this.safeMarket(marketId, market, undefined, type);
1327
+ const symbol = market['symbol'];
1326
1328
  const open = this.safeString(ticker, 'openPrice');
1327
1329
  const high = this.safeString(ticker, 'highPrice');
1328
1330
  const low = this.safeString(ticker, 'lowPrice');
1329
1331
  const close = this.safeString(ticker, 'lastPrice');
1330
1332
  const quoteVolume = this.safeString(ticker, 'quoteVolume');
1331
1333
  const baseVolume = this.safeString(ticker, 'volume');
1334
+ let percentage = undefined;
1335
+ let change = undefined;
1336
+ if (market['swap']) {
1337
+ // right now only swap uses the 24h change, spot will be added soon
1338
+ percentage = this.safeString(ticker, 'priceChangePercent');
1339
+ change = this.safeString(ticker, 'priceChange');
1340
+ }
1332
1341
  // let percentage = this.safeString (ticker, 'priceChangePercent');
1333
1342
  // if (percentage !== undefined) {
1334
1343
  // percentage = percentage.replace ('%', '');
1335
1344
  // } similarly to change, it's not ccxt's percentage because it does priceChange/open, and priceChange is high-low
1345
+ // const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
1336
1346
  const ts = this.safeInteger(ticker, 'closeTime');
1337
1347
  const datetime = this.iso8601(ts);
1338
1348
  const bid = this.safeString(ticker, 'bidPrice');
@@ -1354,8 +1364,8 @@ export default class bingx extends Exchange {
1354
1364
  'close': close,
1355
1365
  'last': undefined,
1356
1366
  'previousClose': undefined,
1357
- 'change': undefined,
1358
- 'percentage': undefined,
1367
+ 'change': change,
1368
+ 'percentage': percentage,
1359
1369
  'average': undefined,
1360
1370
  'baseVolume': baseVolume,
1361
1371
  'quoteVolume': quoteVolume,
@@ -2206,6 +2216,7 @@ export default class bingx extends Exchange {
2206
2216
  * @method
2207
2217
  * @name bingx#cancelAllOrders
2208
2218
  * @description cancel all open orders
2219
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
2209
2220
  * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
2210
2221
  * @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2211
2222
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2216,42 +2227,70 @@ export default class bingx extends Exchange {
2216
2227
  }
2217
2228
  await this.loadMarkets();
2218
2229
  const market = this.market(symbol);
2219
- if (market['type'] !== 'swap') {
2220
- throw new BadRequest(this.id + ' cancelAllOrders is only supported for swap markets.');
2221
- }
2222
2230
  const request = {
2223
2231
  'symbol': market['id'],
2224
2232
  };
2225
- const response = await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
2226
- //
2227
- // {
2228
- // "code": 0,
2229
- // "msg": "",
2230
- // "data": {
2231
- // "success": [
2232
- // {
2233
- // "symbol": "LINK-USDT",
2234
- // "orderId": 1597783835095859200,
2235
- // "side": "BUY",
2236
- // "positionSide": "LONG",
2237
- // "type": "TRIGGER_LIMIT",
2238
- // "origQty": "5.0",
2239
- // "price": "9.0000",
2240
- // "executedQty": "0.0",
2241
- // "avgPrice": "0.0000",
2242
- // "cumQuote": "0",
2243
- // "stopPrice": "9.5000",
2244
- // "profit": "",
2245
- // "commission": "",
2246
- // "status": "NEW",
2247
- // "time": 1669776326000,
2248
- // "updateTime": 1669776326000
2249
- // }
2250
- // ],
2251
- // "failed": null
2252
- // }
2253
- // }
2254
- //
2233
+ let response = undefined;
2234
+ if (market['spot']) {
2235
+ response = await this.spotV1PrivatePostTradeCancelOpenOrders(this.extend(request, params));
2236
+ //
2237
+ // {
2238
+ // "code": 0,
2239
+ // "msg": "",
2240
+ // "debugMsg": "",
2241
+ // "data": {
2242
+ // "orders": [{
2243
+ // "symbol": "ADA-USDT",
2244
+ // "orderId": 1740659971369992192,
2245
+ // "transactTime": 1703840651730,
2246
+ // "price": 5,
2247
+ // "stopPrice": 0,
2248
+ // "origQty": 10,
2249
+ // "executedQty": 0,
2250
+ // "cummulativeQuoteQty": 0,
2251
+ // "status": "CANCELED",
2252
+ // "type": "LIMIT",
2253
+ // "side": "SELL"
2254
+ // }]
2255
+ // }
2256
+ // }
2257
+ //
2258
+ }
2259
+ else if (market['swap']) {
2260
+ response = await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
2261
+ //
2262
+ // {
2263
+ // "code": 0,
2264
+ // "msg": "",
2265
+ // "data": {
2266
+ // "success": [
2267
+ // {
2268
+ // "symbol": "LINK-USDT",
2269
+ // "orderId": 1597783835095859200,
2270
+ // "side": "BUY",
2271
+ // "positionSide": "LONG",
2272
+ // "type": "TRIGGER_LIMIT",
2273
+ // "origQty": "5.0",
2274
+ // "price": "9.0000",
2275
+ // "executedQty": "0.0",
2276
+ // "avgPrice": "0.0000",
2277
+ // "cumQuote": "0",
2278
+ // "stopPrice": "9.5000",
2279
+ // "profit": "",
2280
+ // "commission": "",
2281
+ // "status": "NEW",
2282
+ // "time": 1669776326000,
2283
+ // "updateTime": 1669776326000
2284
+ // }
2285
+ // ],
2286
+ // "failed": null
2287
+ // }
2288
+ // }
2289
+ //
2290
+ }
2291
+ else {
2292
+ throw new BadRequest(this.id + ' cancelAllOrders is only supported for spot and swap markets.');
2293
+ }
2255
2294
  return response;
2256
2295
  }
2257
2296
  async cancelOrders(ids, symbol = undefined, params = {}) {
package/js/src/bitget.js CHANGED
@@ -3224,14 +3224,13 @@ export default class bitget extends Exchange {
3224
3224
  // "1399132.341"
3225
3225
  // ]
3226
3226
  //
3227
- const volumeIndex = (market['inverse']) ? 6 : 5;
3228
3227
  return [
3229
3228
  this.safeInteger(ohlcv, 0),
3230
3229
  this.safeNumber(ohlcv, 1),
3231
3230
  this.safeNumber(ohlcv, 2),
3232
3231
  this.safeNumber(ohlcv, 3),
3233
3232
  this.safeNumber(ohlcv, 4),
3234
- this.safeNumber(ohlcv, volumeIndex),
3233
+ this.safeNumber(ohlcv, 5),
3235
3234
  ];
3236
3235
  }
3237
3236
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -3539,10 +3538,16 @@ export default class bitget extends Exchange {
3539
3538
  // Use transferable instead of available for swap and margin https://github.com/ccxt/ccxt/pull/19127
3540
3539
  const spotAccountFree = this.safeString(entry, 'available');
3541
3540
  const contractAccountFree = this.safeString(entry, 'maxTransferOut');
3542
- account['free'] = (contractAccountFree !== undefined) ? contractAccountFree : spotAccountFree;
3543
- const frozen = this.safeString(entry, 'frozen');
3544
- const locked = this.safeString(entry, 'locked');
3545
- account['used'] = Precise.stringAdd(frozen, locked);
3541
+ if (contractAccountFree !== undefined) {
3542
+ account['free'] = contractAccountFree;
3543
+ account['total'] = this.safeString(entry, 'accountEquity');
3544
+ }
3545
+ else {
3546
+ account['free'] = spotAccountFree;
3547
+ const frozen = this.safeString(entry, 'frozen');
3548
+ const locked = this.safeString(entry, 'locked');
3549
+ account['used'] = Precise.stringAdd(frozen, locked);
3550
+ }
3546
3551
  }
3547
3552
  result[code] = account;
3548
3553
  }