ccxt 4.3.55 → 4.3.56

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/js/src/bingx.js CHANGED
@@ -104,6 +104,7 @@ export default class bingx extends Exchange {
104
104
  'subAccount': 'https://open-api.{hostname}/openApi',
105
105
  'account': 'https://open-api.{hostname}/openApi',
106
106
  'copyTrading': 'https://open-api.{hostname}/openApi',
107
+ 'cswap': 'https://open-api.{hostname}/openApi',
107
108
  },
108
109
  'test': {
109
110
  'swap': 'https://open-api-vst.{hostname}/openApi', // only swap is really "test" but since the API keys are the same, we want to keep all the functionalities when the user enables the sandboxmode
@@ -266,6 +267,36 @@ export default class bingx extends Exchange {
266
267
  },
267
268
  },
268
269
  },
270
+ 'cswap': {
271
+ 'v1': {
272
+ 'public': {
273
+ 'get': {
274
+ 'market/contracts': 1,
275
+ 'market/premiumIndex': 1,
276
+ 'market/openInterest': 1,
277
+ 'market/klines': 1,
278
+ 'market/depth': 1,
279
+ 'market/ticker': 1,
280
+ },
281
+ },
282
+ 'private': {
283
+ 'get': {
284
+ 'trade/leverage': 2,
285
+ 'trade/forceOrders': 2,
286
+ 'trade/allFillOrders': 2,
287
+ 'user/commissionRate': 2,
288
+ 'user/positions': 2,
289
+ 'user/balance': 2,
290
+ },
291
+ 'post': {
292
+ 'trade/order': 2,
293
+ 'trade/leverage': 2,
294
+ 'trade/allOpenOrders': 2,
295
+ 'trade/closeAllPositions': 2,
296
+ },
297
+ },
298
+ },
299
+ },
269
300
  'contract': {
270
301
  'v1': {
271
302
  'private': {
@@ -1526,7 +1557,10 @@ export default class bingx extends Exchange {
1526
1557
  percentage = percentage.replace('%', '');
1527
1558
  }
1528
1559
  const change = this.safeString(ticker, 'priceChange');
1529
- const ts = this.safeInteger(ticker, 'closeTime');
1560
+ let ts = this.safeInteger(ticker, 'closeTime');
1561
+ if (ts === 0) {
1562
+ ts = undefined;
1563
+ }
1530
1564
  const datetime = this.iso8601(ts);
1531
1565
  const bid = this.safeString(ticker, 'bidPrice');
1532
1566
  const bidVolume = this.safeString(ticker, 'bidQty');
@@ -18,7 +18,7 @@ export default class bitflyer extends Exchange {
18
18
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
19
19
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
20
20
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
21
- cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
21
+ cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
22
22
  parseOrderStatus(status: Str): string;
23
23
  parseOrder(order: Dict, market?: Market): Order;
24
24
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -596,7 +596,13 @@ export default class bitflyer extends Exchange {
596
596
  'product_code': this.marketId(symbol),
597
597
  'child_order_acceptance_id': id,
598
598
  };
599
- return await this.privatePostCancelchildorder(this.extend(request, params));
599
+ const response = await this.privatePostCancelchildorder(this.extend(request, params));
600
+ //
601
+ // 200 OK.
602
+ //
603
+ return this.safeOrder({
604
+ 'info': response,
605
+ });
600
606
  }
601
607
  parseOrderStatus(status) {
602
608
  const statuses = {
@@ -25,8 +25,9 @@ export default class bitopro extends Exchange {
25
25
  parseOrder(order: Dict, market?: Market): Order;
26
26
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
27
27
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
28
- cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any>;
29
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
28
+ parseCancelOrders(data: any): any[];
29
+ cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any[]>;
30
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<any[]>;
30
31
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
31
32
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
32
33
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/bitopro.js CHANGED
@@ -1088,6 +1088,22 @@ export default class bitopro extends Exchange {
1088
1088
  //
1089
1089
  return this.parseOrder(response, market);
1090
1090
  }
1091
+ parseCancelOrders(data) {
1092
+ const dataKeys = Object.keys(data);
1093
+ const orders = [];
1094
+ for (let i = 0; i < dataKeys.length; i++) {
1095
+ const marketId = dataKeys[i];
1096
+ const orderIds = data[marketId];
1097
+ for (let j = 0; j < orderIds.length; j++) {
1098
+ orders.push(this.safeOrder({
1099
+ 'info': orderIds[j],
1100
+ 'id': orderIds[j],
1101
+ 'symbol': this.safeSymbol(marketId),
1102
+ }));
1103
+ }
1104
+ }
1105
+ return orders;
1106
+ }
1091
1107
  async cancelOrders(ids, symbol = undefined, params = {}) {
1092
1108
  /**
1093
1109
  * @method
@@ -1118,7 +1134,8 @@ export default class bitopro extends Exchange {
1118
1134
  // }
1119
1135
  // }
1120
1136
  //
1121
- return response;
1137
+ const data = this.safeDict(response, 'data');
1138
+ return this.parseCancelOrders(data);
1122
1139
  }
1123
1140
  async cancelAllOrders(symbol = undefined, params = {}) {
1124
1141
  /**
@@ -1143,7 +1160,7 @@ export default class bitopro extends Exchange {
1143
1160
  else {
1144
1161
  response = await this.privateDeleteOrdersAll(this.extend(request, params));
1145
1162
  }
1146
- const result = this.safeValue(response, 'data', {});
1163
+ const data = this.safeValue(response, 'data', {});
1147
1164
  //
1148
1165
  // {
1149
1166
  // "data":{
@@ -1154,7 +1171,7 @@ export default class bitopro extends Exchange {
1154
1171
  // }
1155
1172
  // }
1156
1173
  //
1157
- return result;
1174
+ return this.parseCancelOrders(data);
1158
1175
  }
1159
1176
  async fetchOrder(id, symbol = undefined, params = {}) {
1160
1177
  /**
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/btcmarkets.js';
9
- import { ArgumentsRequired, ExchangeError, OrderNotFound, InvalidOrder, InsufficientFunds, DDoSProtection, BadRequest } from './base/errors.js';
9
+ import { ArgumentsRequired, ExchangeError, OrderNotFound, InvalidOrder, InsufficientFunds, BadRequest } from './base/errors.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { Precise } from './base/Precise.js';
12
12
  import { sha512 } from './static_dependencies/noble-hashes/sha512.js';
@@ -156,16 +156,17 @@ export default class btcmarkets extends Exchange {
156
156
  },
157
157
  'precisionMode': TICK_SIZE,
158
158
  'exceptions': {
159
- '3': InvalidOrder,
160
- '6': DDoSProtection,
161
- 'InsufficientFund': InsufficientFunds,
162
- 'InvalidPrice': InvalidOrder,
163
- 'InvalidAmount': InvalidOrder,
164
- 'MissingArgument': InvalidOrder,
165
- 'OrderAlreadyCancelled': InvalidOrder,
166
- 'OrderNotFound': OrderNotFound,
167
- 'OrderStatusIsFinal': InvalidOrder,
168
- 'InvalidPaginationParameter': BadRequest,
159
+ 'exact': {
160
+ 'InsufficientFund': InsufficientFunds,
161
+ 'InvalidPrice': InvalidOrder,
162
+ 'InvalidAmount': InvalidOrder,
163
+ 'MissingArgument': BadRequest,
164
+ 'OrderAlreadyCancelled': InvalidOrder,
165
+ 'OrderNotFound': OrderNotFound,
166
+ 'OrderStatusIsFinal': InvalidOrder,
167
+ 'InvalidPaginationParameter': BadRequest,
168
+ },
169
+ 'broad': {},
169
170
  },
170
171
  'fees': {
171
172
  'percentage': true,
@@ -380,7 +381,8 @@ export default class btcmarkets extends Exchange {
380
381
  // "minOrderAmount":"0.00007",
381
382
  // "maxOrderAmount":"1000000",
382
383
  // "amountDecimals":"8",
383
- // "priceDecimals":"2"
384
+ // "priceDecimals":"2",
385
+ // "status": "Online"
384
386
  // }
385
387
  // ]
386
388
  //
@@ -397,6 +399,7 @@ export default class btcmarkets extends Exchange {
397
399
  const pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'priceDecimals')));
398
400
  const minAmount = this.safeNumber(market, 'minOrderAmount');
399
401
  const maxAmount = this.safeNumber(market, 'maxOrderAmount');
402
+ const status = this.safeString(market, 'status');
400
403
  let minPrice = undefined;
401
404
  if (quote === 'AUD') {
402
405
  minPrice = pricePrecision;
@@ -416,7 +419,7 @@ export default class btcmarkets extends Exchange {
416
419
  'swap': false,
417
420
  'future': false,
418
421
  'option': false,
419
- 'active': undefined,
422
+ 'active': (status === 'Online'),
420
423
  'contract': false,
421
424
  'linear': undefined,
422
425
  'inverse': undefined,
@@ -1283,22 +1286,18 @@ export default class btcmarkets extends Exchange {
1283
1286
  if (response === undefined) {
1284
1287
  return undefined; // fallback to default error handler
1285
1288
  }
1286
- if ('success' in response) {
1287
- if (!response['success']) {
1288
- const error = this.safeString(response, 'errorCode');
1289
- const feedback = this.id + ' ' + body;
1290
- this.throwExactlyMatchedException(this.exceptions, error, feedback);
1291
- throw new ExchangeError(feedback);
1292
- }
1293
- }
1294
- // v3 api errors
1295
- if (code >= 400) {
1296
- const errorCode = this.safeString(response, 'code');
1297
- const message = this.safeString(response, 'message');
1289
+ //
1290
+ // {"code":"UnAuthorized","message":"invalid access token"}
1291
+ // {"code":"MarketNotFound","message":"invalid marketId"}
1292
+ //
1293
+ const errorCode = this.safeString(response, 'code');
1294
+ const message = this.safeString(response, 'message');
1295
+ if (errorCode !== undefined) {
1298
1296
  const feedback = this.id + ' ' + body;
1299
- this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
1300
- this.throwExactlyMatchedException(this.exceptions, message, feedback);
1301
- throw new ExchangeError(feedback);
1297
+ this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1298
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
1299
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1300
+ throw new ExchangeError(feedback); // unknown message
1302
1301
  }
1303
1302
  return undefined;
1304
1303
  }
package/js/src/bybit.js CHANGED
@@ -3061,16 +3061,20 @@ export default class bybit extends Exchange {
3061
3061
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
3062
3062
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
3063
3063
  let type = undefined;
3064
- [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
3064
+ [type, params] = this.getBybitType('fetchBalance', undefined, params);
3065
3065
  const isSpot = (type === 'spot');
3066
- const isSwap = (type === 'swap');
3066
+ const isLinear = (type === 'linear');
3067
+ const isInverse = (type === 'inverse');
3067
3068
  if (isUnifiedAccount) {
3068
- if (isSpot || isSwap) {
3069
+ if (isInverse) {
3070
+ type = 'contract';
3071
+ }
3072
+ else {
3069
3073
  type = 'unified';
3070
3074
  }
3071
3075
  }
3072
3076
  else {
3073
- if (isSwap) {
3077
+ if (isLinear || isInverse) {
3074
3078
  type = 'contract';
3075
3079
  }
3076
3080
  }
@@ -3390,7 +3394,7 @@ export default class bybit extends Exchange {
3390
3394
  feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
3391
3395
  }
3392
3396
  fee = {
3393
- 'cost': feeCostString,
3397
+ 'cost': this.parseNumber(feeCostString),
3394
3398
  'currency': feeCurrencyCode,
3395
3399
  };
3396
3400
  }
package/js/src/delta.d.ts CHANGED
@@ -38,7 +38,7 @@ export default class delta extends Exchange {
38
38
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
39
39
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
40
40
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
41
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
41
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
42
42
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
43
43
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
44
44
  fetchOrdersWithMethod(method: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/delta.js CHANGED
@@ -2015,7 +2015,11 @@ export default class delta extends Exchange {
2015
2015
  // "success":true
2016
2016
  // }
2017
2017
  //
2018
- return response;
2018
+ return [
2019
+ this.safeOrder({
2020
+ 'info': response,
2021
+ }),
2022
+ ];
2019
2023
  }
2020
2024
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2021
2025
  /**
package/js/src/gate.js CHANGED
@@ -625,6 +625,7 @@ export default class gate extends Exchange {
625
625
  'createOrder': {
626
626
  'expiration': 86400, // for conditional orders
627
627
  },
628
+ 'createMarketBuyOrderRequiresPrice': true,
628
629
  'networks': {
629
630
  'AVAXC': 'AVAX_C',
630
631
  'BEP20': 'BSC',
@@ -596,7 +596,7 @@ export default class hyperliquid extends Exchange {
596
596
  'limits': {
597
597
  'leverage': {
598
598
  'min': undefined,
599
- 'max': undefined,
599
+ 'max': this.safeInteger(market, 'maxLeverage'),
600
600
  },
601
601
  'amount': {
602
602
  'min': undefined,
package/js/src/lbank.d.ts CHANGED
@@ -33,8 +33,8 @@ export default class lbank extends Exchange {
33
33
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
34
34
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
35
35
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
36
- cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
37
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
36
+ cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
37
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
38
38
  getNetworkCodeForCurrency(currencyCode: any, params: any): string;
39
39
  fetchDepositAddress(code: string, params?: {}): Promise<any>;
40
40
  fetchDepositAddressDefault(code: string, params?: {}): Promise<{
package/js/src/lbank.js CHANGED
@@ -1489,6 +1489,27 @@ export default class lbank extends Exchange {
1489
1489
  // "status":-1
1490
1490
  // }
1491
1491
  //
1492
+ // cancelOrder
1493
+ //
1494
+ // {
1495
+ // "executedQty":0.0,
1496
+ // "price":0.05,
1497
+ // "origQty":100.0,
1498
+ // "tradeType":"buy",
1499
+ // "status":0
1500
+ // }
1501
+ //
1502
+ // cancelAllOrders
1503
+ //
1504
+ // {
1505
+ // "executedQty":0.00000000000000000000,
1506
+ // "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
1507
+ // "price":0.05000000000000000000,
1508
+ // "origQty":100.00000000000000000000,
1509
+ // "tradeType":"buy",
1510
+ // "status":0
1511
+ // }
1512
+ //
1492
1513
  const id = this.safeString2(order, 'orderId', 'order_id');
1493
1514
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'custom_id');
1494
1515
  const timestamp = this.safeInteger2(order, 'time', 'create_time');
@@ -1498,7 +1519,7 @@ export default class lbank extends Exchange {
1498
1519
  let timeInForce = undefined;
1499
1520
  let postOnly = false;
1500
1521
  let type = 'limit';
1501
- const rawType = this.safeString(order, 'type'); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1522
+ const rawType = this.safeString2(order, 'type', 'tradeType'); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1502
1523
  const parts = rawType.split('_');
1503
1524
  const side = this.safeString(parts, 0);
1504
1525
  const typePart = this.safeString(parts, 1); // market, maker, ioc, fok or undefined (limit)
@@ -1862,12 +1883,12 @@ export default class lbank extends Exchange {
1862
1883
  // "origQty":100.0,
1863
1884
  // "tradeType":"buy",
1864
1885
  // "status":0
1865
- // },
1886
+ // },
1866
1887
  // "error_code":0,
1867
1888
  // "ts":1648501286196
1868
1889
  // }
1869
- const result = this.safeValue(response, 'data', {});
1870
- return result;
1890
+ const data = this.safeDict(response, 'data', {});
1891
+ return this.parseOrder(data);
1871
1892
  }
1872
1893
  async cancelAllOrders(symbol = undefined, params = {}) {
1873
1894
  /**
@@ -1905,8 +1926,8 @@ export default class lbank extends Exchange {
1905
1926
  // "ts":1648506641469
1906
1927
  // }
1907
1928
  //
1908
- const result = this.safeValue(response, 'data', []);
1909
- return result;
1929
+ const data = this.safeList(response, 'data', []);
1930
+ return this.parseOrders(data);
1910
1931
  }
1911
1932
  getNetworkCodeForCurrency(currencyCode, params) {
1912
1933
  const defaultNetworks = this.safeValue(this.options, 'defaultNetworks');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.55",
3
+ "version": "4.3.56",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",
@@ -119,9 +119,13 @@
119
119
  "request-tests": "npm run request-js && npm run request-py && npm run request-php && npm run request-cs",
120
120
  "response-ts": "npm run ti-ts -- --responseTests",
121
121
  "response-js": "npm run ti-js -- --responseTests",
122
- "response-py": "npm run ti-py -- --responseTests",
122
+ "response-py-sync": "npm run ti-py -- --responseTests --sync",
123
+ "response-py-async": "npm run ti-py -- --responseTests",
124
+ "response-py": "npm run response-py-sync && npm run response-py-async",
123
125
  "response-cs": "npm run ti-cs -- --responseTests",
124
- "response-php": "npm run ti-php -- --responseTests",
126
+ "response-php-async": "npm run ti-php -- --responseTests",
127
+ "response-php-sync": "npm run ti-php -- --responseTests --sync",
128
+ "response-php": "npm run response-php-sync && npm run response-php-async",
125
129
  "response-tests": "npm run response-js && npm run response-py && npm run response-php && npm run response-cs",
126
130
  "id-tests-js": "npm run ti-js -- --idTests",
127
131
  "id-tests-py": "npm run ti-py -- --idTests",