ccxt 4.3.56 → 4.3.57

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/htx.d.ts CHANGED
@@ -90,8 +90,9 @@ export default class htx extends Exchange {
90
90
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
91
91
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
92
92
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
93
- cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any>;
94
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
93
+ cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any[]>;
94
+ parseCancelOrders(orders: any): any[];
95
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<any[]>;
95
96
  cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<any>;
96
97
  parseDepositAddress(depositAddress: any, currency?: Currency): {
97
98
  currency: string;
package/js/src/htx.js CHANGED
@@ -6029,7 +6029,66 @@ export default class htx extends Exchange {
6029
6029
  // "ts": 1604367997451
6030
6030
  // }
6031
6031
  //
6032
- return response;
6032
+ const data = this.safeDict(response, 'data');
6033
+ return this.parseCancelOrders(data);
6034
+ }
6035
+ parseCancelOrders(orders) {
6036
+ //
6037
+ // {
6038
+ // "success": [
6039
+ // "5983466"
6040
+ // ],
6041
+ // "failed": [
6042
+ // {
6043
+ // "err-msg": "Incorrect order state",
6044
+ // "order-state": 7,
6045
+ // "order-id": "",
6046
+ // "err-code": "order-orderstate-error",
6047
+ // "client-order-id": "first"
6048
+ // },
6049
+ // ...
6050
+ // ]
6051
+ // }
6052
+ //
6053
+ // {
6054
+ // "errors": [
6055
+ // {
6056
+ // "order_id": "769206471845261312",
6057
+ // "err_code": 1061,
6058
+ // "err_msg": "This order doesnt exist."
6059
+ // }
6060
+ // ],
6061
+ // "successes": "1258075374411399168,1258075393254871040"
6062
+ // }
6063
+ //
6064
+ const successes = this.safeString(orders, 'successes');
6065
+ let success = undefined;
6066
+ if (successes !== undefined) {
6067
+ success = successes.split(',');
6068
+ }
6069
+ else {
6070
+ success = this.safeList(orders, 'success', []);
6071
+ }
6072
+ const failed = this.safeList2(orders, 'errors', 'failed', []);
6073
+ const result = [];
6074
+ for (let i = 0; i < success.length; i++) {
6075
+ const order = success[i];
6076
+ result.push(this.safeOrder({
6077
+ 'info': order,
6078
+ 'id': order,
6079
+ 'status': 'canceled',
6080
+ }));
6081
+ }
6082
+ for (let i = 0; i < failed.length; i++) {
6083
+ const order = failed[i];
6084
+ result.push(this.safeOrder({
6085
+ 'info': order,
6086
+ 'id': this.safeString2(order, 'order-id', 'order_id'),
6087
+ 'status': 'failed',
6088
+ 'clientOrderId': this.safeString(order, 'client-order-id'),
6089
+ }));
6090
+ }
6091
+ return result;
6033
6092
  }
6034
6093
  async cancelAllOrders(symbol = undefined, params = {}) {
6035
6094
  /**
@@ -6070,6 +6129,22 @@ export default class htx extends Exchange {
6070
6129
  request['symbol'] = market['id'];
6071
6130
  }
6072
6131
  response = await this.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(this.extend(request, params));
6132
+ //
6133
+ // {
6134
+ // "code": 200,
6135
+ // "data": {
6136
+ // "success-count": 2,
6137
+ // "failed-count": 0,
6138
+ // "next-id": 5454600
6139
+ // }
6140
+ // }
6141
+ //
6142
+ const data = this.safeDict(response, 'data');
6143
+ return [
6144
+ this.safeOrder({
6145
+ 'info': data,
6146
+ }),
6147
+ ];
6073
6148
  }
6074
6149
  else {
6075
6150
  if (symbol === undefined) {
@@ -6149,31 +6224,19 @@ export default class htx extends Exchange {
6149
6224
  else {
6150
6225
  throw new NotSupported(this.id + ' cancelAllOrders() does not support ' + marketType + ' markets');
6151
6226
  }
6227
+ //
6228
+ // {
6229
+ // "status": "ok",
6230
+ // "data": {
6231
+ // "errors": [],
6232
+ // "successes": "1104754904426696704"
6233
+ // },
6234
+ // "ts": "1683435723755"
6235
+ // }
6236
+ //
6237
+ const data = this.safeDict(response, 'data');
6238
+ return this.parseCancelOrders(data);
6152
6239
  }
6153
- //
6154
- // spot
6155
- //
6156
- // {
6157
- // "code": 200,
6158
- // "data": {
6159
- // "success-count": 2,
6160
- // "failed-count": 0,
6161
- // "next-id": 5454600
6162
- // }
6163
- // }
6164
- //
6165
- // future and swap
6166
- //
6167
- // {
6168
- // "status": "ok",
6169
- // "data": {
6170
- // "errors": [],
6171
- // "successes": "1104754904426696704"
6172
- // },
6173
- // "ts": "1683435723755"
6174
- // }
6175
- //
6176
- return response;
6177
6240
  }
6178
6241
  async cancelAllOrdersAfter(timeout, params = {}) {
6179
6242
  /**
@@ -54,8 +54,9 @@ export default class huobijp extends Exchange {
54
54
  createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
55
55
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
56
56
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
57
- cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any>;
58
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
57
+ cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any[]>;
58
+ parseCancelOrders(orders: any): any[];
59
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
59
60
  currencyToPrecision(code: any, fee: any, networkCode?: any): string;
60
61
  safeNetwork(networkId: any): string;
61
62
  parseDepositAddress(depositAddress: any, currency?: Currency): {
package/js/src/huobijp.js CHANGED
@@ -1548,7 +1548,65 @@ export default class huobijp extends Exchange {
1548
1548
  // }
1549
1549
  // }
1550
1550
  //
1551
- return response;
1551
+ return this.parseCancelOrders(response);
1552
+ }
1553
+ parseCancelOrders(orders) {
1554
+ //
1555
+ // {
1556
+ // "success": [
1557
+ // "5983466"
1558
+ // ],
1559
+ // "failed": [
1560
+ // {
1561
+ // "err-msg": "Incorrect order state",
1562
+ // "order-state": 7,
1563
+ // "order-id": "",
1564
+ // "err-code": "order-orderstate-error",
1565
+ // "client-order-id": "first"
1566
+ // },
1567
+ // ...
1568
+ // ]
1569
+ // }
1570
+ //
1571
+ // {
1572
+ // "errors": [
1573
+ // {
1574
+ // "order_id": "769206471845261312",
1575
+ // "err_code": 1061,
1576
+ // "err_msg": "This order doesnt exist."
1577
+ // }
1578
+ // ],
1579
+ // "successes": "1258075374411399168,1258075393254871040"
1580
+ // }
1581
+ //
1582
+ const successes = this.safeString(orders, 'successes');
1583
+ let success = undefined;
1584
+ if (successes !== undefined) {
1585
+ success = successes.split(',');
1586
+ }
1587
+ else {
1588
+ success = this.safeList(orders, 'success', []);
1589
+ }
1590
+ const failed = this.safeList2(orders, 'errors', 'failed', []);
1591
+ const result = [];
1592
+ for (let i = 0; i < success.length; i++) {
1593
+ const order = success[i];
1594
+ result.push(this.safeOrder({
1595
+ 'info': order,
1596
+ 'id': order,
1597
+ 'status': 'canceled',
1598
+ }));
1599
+ }
1600
+ for (let i = 0; i < failed.length; i++) {
1601
+ const order = failed[i];
1602
+ result.push(this.safeOrder({
1603
+ 'info': order,
1604
+ 'id': this.safeString2(order, 'order-id', 'order_id'),
1605
+ 'status': 'failed',
1606
+ 'clientOrderId': this.safeString(order, 'client-order-id'),
1607
+ }));
1608
+ }
1609
+ return result;
1552
1610
  }
1553
1611
  async cancelAllOrders(symbol = undefined, params = {}) {
1554
1612
  /**
@@ -1583,7 +1641,12 @@ export default class huobijp extends Exchange {
1583
1641
  // }
1584
1642
  // }
1585
1643
  //
1586
- return response;
1644
+ const data = this.safeDict(response, 'data', {});
1645
+ return [
1646
+ this.safeOrder({
1647
+ 'info': data,
1648
+ }),
1649
+ ];
1587
1650
  }
1588
1651
  currencyToPrecision(code, fee, networkCode = undefined) {
1589
1652
  return this.decimalToPrecision(fee, 0, this.currencies[code]['precision'], this.precisionMode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.56",
3
+ "version": "4.3.57",
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",