ccxt 4.1.68 → 4.1.70

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.
@@ -3887,7 +3887,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
3887
3887
  'account-category': 'cash',
3888
3888
  'account-group': undefined,
3889
3889
  'fetchClosedOrders': {
3890
- 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountGroupGetAccountCategoryOrderHistCurrent'
3890
+ 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountCategoryGetOrderHistCurrent'
3891
3891
  },
3892
3892
  'defaultType': 'spot',
3893
3893
  'accountsByType': {
@@ -4427,6 +4427,9 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4427
4427
  * @method
4428
4428
  * @name ascendex#fetchBalance
4429
4429
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
4430
+ * @see https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
4431
+ * @see https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
4432
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
4430
4433
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4431
4434
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
4432
4435
  */
@@ -4437,8 +4440,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4437
4440
  [marketType, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
4438
4441
  const isMargin = this.safeValue(params, 'margin', false);
4439
4442
  marketType = isMargin ? 'margin' : marketType;
4440
- params = this.omit(params, 'margin');
4441
- const options = this.safeValue(this.options, 'fetchBalance', {});
4443
+ query = this.omit(query, 'margin');
4442
4444
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
4443
4445
  const accountCategory = this.safeString(accountsByType, marketType, 'cash');
4444
4446
  const account = this.safeValue(this.accounts, 0, {});
@@ -4446,16 +4448,19 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4446
4448
  const request = {
4447
4449
  'account-group': accountGroup,
4448
4450
  };
4449
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetBalance');
4450
- const method = this.getSupportedMapping(marketType, {
4451
- 'spot': defaultMethod,
4452
- 'margin': defaultMethod,
4453
- 'swap': 'v2PrivateAccountGroupGetFuturesPosition',
4454
- });
4455
4451
  if ((accountCategory === 'cash') || (accountCategory === 'margin')) {
4456
4452
  request['account-category'] = accountCategory;
4457
4453
  }
4458
- const response = await this[method](this.extend(request, query));
4454
+ let response = undefined;
4455
+ if ((marketType === 'spot') || (marketType === 'margin')) {
4456
+ response = await this.v1PrivateAccountCategoryGetBalance(this.extend(request, query));
4457
+ }
4458
+ else if (marketType === 'swap') {
4459
+ response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, query));
4460
+ }
4461
+ else {
4462
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchBalance() is not currently supported for ' + marketType + ' markets');
4463
+ }
4459
4464
  //
4460
4465
  // cash
4461
4466
  //
@@ -5380,6 +5385,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5380
5385
  * @method
5381
5386
  * @name ascendex#fetchOrder
5382
5387
  * @description fetches information on an order made by the user
5388
+ * @see https://ascendex.github.io/ascendex-pro-api/#query-order
5389
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
5383
5390
  * @param {string} symbol unified symbol of the market the order was made in
5384
5391
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5385
5392
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -5391,7 +5398,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5391
5398
  market = this.market(symbol);
5392
5399
  }
5393
5400
  const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
5394
- const options = this.safeValue(this.options, 'fetchOrder', {});
5395
5401
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5396
5402
  const accountCategory = this.safeString(accountsByType, type, 'cash');
5397
5403
  const account = this.safeValue(this.accounts, 0, {});
@@ -5401,21 +5407,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5401
5407
  'account-category': accountCategory,
5402
5408
  'orderId': id,
5403
5409
  };
5404
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetOrderStatus');
5405
- const method = this.getSupportedMapping(type, {
5406
- 'spot': defaultMethod,
5407
- 'margin': defaultMethod,
5408
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderStatus',
5409
- });
5410
- if (method === 'v1PrivateAccountCategoryGetOrderStatus') {
5411
- if (accountCategory !== undefined) {
5412
- request['category'] = accountCategory;
5413
- }
5410
+ let response = undefined;
5411
+ if ((type === 'spot') || (type === 'margin')) {
5412
+ response = await this.v1PrivateAccountCategoryGetOrderStatus(this.extend(request, query));
5414
5413
  }
5415
- else {
5414
+ else if (type === 'swap') {
5416
5415
  request['account-category'] = accountCategory;
5416
+ response = await this.v2PrivateAccountGroupGetFuturesOrderStatus(this.extend(request, query));
5417
+ }
5418
+ else {
5419
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrder() is not currently supported for ' + type + ' markets');
5417
5420
  }
5418
- const response = await this[method](this.extend(request, query));
5419
5421
  //
5420
5422
  // AccountCategoryGetOrderStatus
5421
5423
  //
@@ -5491,6 +5493,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5491
5493
  * @method
5492
5494
  * @name ascendex#fetchOpenOrders
5493
5495
  * @description fetch all unfilled currently open orders
5496
+ * @see https://ascendex.github.io/ascendex-pro-api/#list-open-orders
5497
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
5494
5498
  * @param {string} symbol unified market symbol
5495
5499
  * @param {int} [since] the earliest time in ms to fetch open orders for
5496
5500
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -5513,22 +5517,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5513
5517
  'account-group': accountGroup,
5514
5518
  'account-category': accountCategory,
5515
5519
  };
5516
- const options = this.safeValue(this.options, 'fetchOpenOrders', {});
5517
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetOrderOpen');
5518
- const method = this.getSupportedMapping(type, {
5519
- 'spot': defaultMethod,
5520
- 'margin': defaultMethod,
5521
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderOpen',
5522
- });
5523
- if (method === 'v1PrivateAccountCategoryGetOrderOpen') {
5524
- if (accountCategory !== undefined) {
5525
- request['category'] = accountCategory;
5526
- }
5520
+ let response = undefined;
5521
+ if ((type === 'spot') || (type === 'margin')) {
5522
+ response = await this.v1PrivateAccountCategoryGetOrderOpen(this.extend(request, query));
5527
5523
  }
5528
- else {
5524
+ else if (type === 'swap') {
5529
5525
  request['account-category'] = accountCategory;
5526
+ response = await this.v2PrivateAccountGroupGetFuturesOrderOpen(this.extend(request, query));
5527
+ }
5528
+ else {
5529
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOpenOrders() is not currently supported for ' + type + ' markets');
5530
5530
  }
5531
- const response = await this[method](this.extend(request, query));
5532
5531
  //
5533
5532
  // AccountCategoryGetOrderOpen
5534
5533
  //
@@ -5614,6 +5613,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5614
5613
  * @name ascendex#fetchClosedOrders
5615
5614
  * @description fetches information on multiple closed orders made by the user
5616
5615
  * @see https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
5616
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
5617
5617
  * @param {string} symbol unified market symbol of the market orders were made in
5618
5618
  * @param {int} [since] the earliest time in ms to fetch orders for
5619
5619
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -5626,16 +5626,15 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5626
5626
  const account = this.safeValue(this.accounts, 0, {});
5627
5627
  const accountGroup = this.safeValue(account, 'id');
5628
5628
  const request = {
5629
- 'account-group': accountGroup,
5630
- // 'category': accountCategory,
5631
- // 'symbol': market['id'],
5632
- // 'orderType': 'market', // optional, string
5633
- // 'side': 'buy', // or 'sell', optional, case insensitive.
5634
- // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
5635
- // 'startTime': exchange.milliseconds (),
5636
- // 'endTime': exchange.milliseconds (),
5637
- // 'page': 1,
5638
- // 'pageSize': 100,
5629
+ // 'category': accountCategory,
5630
+ // 'symbol': market['id'],
5631
+ // 'orderType': 'market', // optional, string
5632
+ // 'side': 'buy', // or 'sell', optional, case insensitive.
5633
+ // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
5634
+ // 'startTime': exchange.milliseconds (),
5635
+ // 'endTime': exchange.milliseconds (),
5636
+ // 'page': 1,
5637
+ // 'pageSize': 100,
5639
5638
  };
5640
5639
  let market = undefined;
5641
5640
  if (symbol !== undefined) {
@@ -5650,28 +5649,42 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5650
5649
  'margin': defaultMethod,
5651
5650
  'swap': 'v2PrivateAccountGroupGetFuturesOrderHistCurrent',
5652
5651
  });
5652
+ if (since !== undefined) {
5653
+ request['startTime'] = since;
5654
+ }
5655
+ const until = this.safeString(params, 'until');
5656
+ if (until !== undefined) {
5657
+ request['endTime'] = until;
5658
+ }
5653
5659
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5654
5660
  const accountCategory = this.safeString(accountsByType, type, 'cash'); // margin, futures
5655
- if (method === 'v2PrivateDataGetOrderHist') {
5661
+ let response = undefined;
5662
+ if (method === 'v1PrivateAccountCategoryGetOrderHistCurrent') {
5663
+ request['account-group'] = accountGroup;
5664
+ request['account-category'] = accountCategory;
5665
+ if (limit !== undefined) {
5666
+ request['limit'] = limit;
5667
+ }
5668
+ response = await this.v1PrivateAccountCategoryGetOrderHistCurrent(this.extend(request, query));
5669
+ }
5670
+ else if (method === 'v2PrivateDataGetOrderHist') {
5656
5671
  request['account'] = accountCategory;
5657
5672
  if (limit !== undefined) {
5658
5673
  request['limit'] = limit;
5659
5674
  }
5675
+ response = await this.v2PrivateDataGetOrderHist(this.extend(request, query));
5660
5676
  }
5661
- else {
5677
+ else if (method === 'v2PrivateAccountGroupGetFuturesOrderHistCurrent') {
5678
+ request['account-group'] = accountGroup;
5662
5679
  request['account-category'] = accountCategory;
5663
5680
  if (limit !== undefined) {
5664
5681
  request['pageSize'] = limit;
5665
5682
  }
5683
+ response = await this.v2PrivateAccountGroupGetFuturesOrderHistCurrent(this.extend(request, query));
5666
5684
  }
5667
- if (since !== undefined) {
5668
- request['startTime'] = since;
5669
- }
5670
- const until = this.safeString(params, 'until');
5671
- if (until !== undefined) {
5672
- request['endTime'] = until;
5685
+ else {
5686
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchClosedOrders() is not currently supported for ' + type + ' markets');
5673
5687
  }
5674
- const response = await this[method](this.extend(request, query));
5675
5688
  //
5676
5689
  // accountCategoryGetOrderHistCurrent
5677
5690
  //
@@ -5775,6 +5788,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5775
5788
  * @method
5776
5789
  * @name ascendex#cancelOrder
5777
5790
  * @description cancels an open order
5791
+ * @see https://ascendex.github.io/ascendex-pro-api/#cancel-order
5792
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
5778
5793
  * @param {string} id order id
5779
5794
  * @param {string} symbol unified symbol of the market the order was made in
5780
5795
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5787,7 +5802,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5787
5802
  await this.loadAccounts();
5788
5803
  const market = this.market(symbol);
5789
5804
  const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
5790
- const options = this.safeValue(this.options, 'cancelOrder', {});
5791
5805
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5792
5806
  const accountCategory = this.safeString(accountsByType, type, 'cash');
5793
5807
  const account = this.safeValue(this.accounts, 0, {});
@@ -5799,20 +5813,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5799
5813
  'time': this.milliseconds(),
5800
5814
  'id': 'foobar',
5801
5815
  };
5802
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryDeleteOrder');
5803
- const method = this.getSupportedMapping(type, {
5804
- 'spot': defaultMethod,
5805
- 'margin': defaultMethod,
5806
- 'swap': 'v2PrivateAccountGroupDeleteFuturesOrder',
5807
- });
5808
- if (method === 'v1PrivateAccountCategoryDeleteOrder') {
5809
- if (accountCategory !== undefined) {
5810
- request['category'] = accountCategory;
5811
- }
5812
- }
5813
- else {
5814
- request['account-category'] = accountCategory;
5815
- }
5816
5816
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'id');
5817
5817
  if (clientOrderId === undefined) {
5818
5818
  request['orderId'] = id;
@@ -5821,7 +5821,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5821
5821
  request['id'] = clientOrderId;
5822
5822
  params = this.omit(params, ['clientOrderId', 'id']);
5823
5823
  }
5824
- const response = await this[method](this.extend(request, query));
5824
+ let response = undefined;
5825
+ if ((type === 'spot') || (type === 'margin')) {
5826
+ response = await this.v1PrivateAccountCategoryDeleteOrder(this.extend(request, query));
5827
+ }
5828
+ else if (type === 'swap') {
5829
+ request['account-category'] = accountCategory;
5830
+ response = await this.v2PrivateAccountGroupDeleteFuturesOrder(this.extend(request, query));
5831
+ }
5832
+ else {
5833
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelOrder() is not currently supported for ' + type + ' markets');
5834
+ }
5825
5835
  //
5826
5836
  // AccountCategoryDeleteOrder
5827
5837
  //
@@ -5894,6 +5904,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5894
5904
  * @method
5895
5905
  * @name ascendex#cancelAllOrders
5896
5906
  * @description cancel all open orders
5907
+ * @see https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
5908
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
5897
5909
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
5898
5910
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5899
5911
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -5905,7 +5917,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5905
5917
  market = this.market(symbol);
5906
5918
  }
5907
5919
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
5908
- const options = this.safeValue(this.options, 'cancelAllOrders', {});
5909
5920
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5910
5921
  const accountCategory = this.safeString(accountsByType, type, 'cash');
5911
5922
  const account = this.safeValue(this.accounts, 0, {});
@@ -5918,21 +5929,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5918
5929
  if (symbol !== undefined) {
5919
5930
  request['symbol'] = market['id'];
5920
5931
  }
5921
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryDeleteOrderAll');
5922
- const method = this.getSupportedMapping(type, {
5923
- 'spot': defaultMethod,
5924
- 'margin': defaultMethod,
5925
- 'swap': 'v2PrivateAccountGroupDeleteFuturesOrderAll',
5926
- });
5927
- if (method === 'v1PrivateAccountCategoryDeleteOrderAll') {
5928
- if (accountCategory !== undefined) {
5929
- request['category'] = accountCategory;
5930
- }
5932
+ let response = undefined;
5933
+ if ((type === 'spot') || (type === 'margin')) {
5934
+ response = await this.v1PrivateAccountCategoryDeleteOrderAll(this.extend(request, query));
5931
5935
  }
5932
- else {
5936
+ else if (type === 'swap') {
5933
5937
  request['account-category'] = accountCategory;
5938
+ response = await this.v2PrivateAccountGroupDeleteFuturesOrderAll(this.extend(request, query));
5939
+ }
5940
+ else {
5941
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelAllOrders() is not currently supported for ' + type + ' markets');
5934
5942
  }
5935
- const response = await this[method](this.extend(request, query));
5936
5943
  //
5937
5944
  // AccountCategoryDeleteOrderAll
5938
5945
  //
@@ -91125,8 +91132,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91125
91132
  'borrowIsolatedMargin': true,
91126
91133
  'cancelAllOrders': true,
91127
91134
  'cancelOrder': true,
91135
+ 'cancelOrders': true,
91128
91136
  'createDepositAddress': true,
91129
91137
  'createOrder': true,
91138
+ 'createOrders': true,
91130
91139
  'createReduceOnlyOrder': true,
91131
91140
  'editOrder': true,
91132
91141
  'fetchBalance': true,
@@ -92617,6 +92626,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92617
92626
  }
92618
92627
  parseOrderStatus(status) {
92619
92628
  const statuses = {
92629
+ 'rejected': 'rejected',
92630
+ 'open': 'open',
92620
92631
  'not_deal': 'open',
92621
92632
  'part_deal': 'open',
92622
92633
  'done': 'closed',
@@ -92650,7 +92661,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92650
92661
  // "client_id": "",
92651
92662
  // }
92652
92663
  //
92653
- // Spot and Margin createOrder, cancelOrder, fetchOrder
92664
+ // Spot and Margin createOrder, createOrders, cancelOrder, cancelOrders, fetchOrder
92654
92665
  //
92655
92666
  // {
92656
92667
  // "amount":"1.5",
@@ -92849,13 +92860,50 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92849
92860
  // "user_id": 3620173
92850
92861
  // }
92851
92862
  //
92863
+ // swap: cancelOrders
92864
+ //
92865
+ // {
92866
+ // "amount": "0.0005",
92867
+ // "client_id": "x-167673045-b0cee0c584718b65",
92868
+ // "create_time": 1701233683.294231,
92869
+ // "deal_asset_fee": "0.00000000000000000000",
92870
+ // "deal_fee": "0.00000000000000000000",
92871
+ // "deal_profit": "0.00000000000000000000",
92872
+ // "deal_stock": "0.00000000000000000000",
92873
+ // "effect_type": 1,
92874
+ // "fee_asset": "",
92875
+ // "fee_discount": "0.00000000000000000000",
92876
+ // "last_deal_amount": "0.00000000000000000000",
92877
+ // "last_deal_id": 0,
92878
+ // "last_deal_price": "0.00000000000000000000",
92879
+ // "last_deal_role": 0,
92880
+ // "last_deal_time": 0,
92881
+ // "last_deal_type": 0,
92882
+ // "left": "0.0005",
92883
+ // "leverage": "3",
92884
+ // "maker_fee": "0.00030",
92885
+ // "market": "BTCUSDT",
92886
+ // "option": 0,
92887
+ // "order_id": 115940476323,
92888
+ // "position_id": 0,
92889
+ // "position_type": 2,
92890
+ // "price": "25000.00",
92891
+ // "side": 2,
92892
+ // "source": "api.v1",
92893
+ // "stop_id": 0,
92894
+ // "stop_loss_price": "0.00000000000000000000",
92895
+ // "stop_loss_type": 0,
92896
+ // "take_profit_price": "0.00000000000000000000",
92897
+ // "take_profit_type": 0,
92898
+ // "taker_fee": "0.00050",
92899
+ // "target": 0,
92900
+ // "type": 1,
92901
+ // "update_time": 1701233721.718884,
92902
+ // "user_id": 3620173
92903
+ // }
92904
+ //
92905
+ const rawStatus = this.safeString(order, 'status');
92852
92906
  const timestamp = this.safeTimestamp(order, 'create_time');
92853
- const priceString = this.safeString(order, 'price');
92854
- const costString = this.safeString(order, 'deal_money');
92855
- const amountString = this.safeString(order, 'amount');
92856
- const filledString = this.safeString(order, 'deal_amount');
92857
- const averageString = this.safeString(order, 'avg_price');
92858
- const remainingString = this.safeString(order, 'left');
92859
92907
  const marketId = this.safeString(order, 'market');
92860
92908
  const defaultType = this.safeString(this.options, 'defaultType');
92861
92909
  const orderType = ('source' in order) ? 'swap' : defaultType;
@@ -92865,7 +92913,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92865
92913
  if (feeCurrency === undefined) {
92866
92914
  feeCurrency = market['quote'];
92867
92915
  }
92868
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
92869
92916
  const rawSide = this.safeInteger(order, 'side');
92870
92917
  let side = undefined;
92871
92918
  if (rawSide === 1) {
@@ -92901,21 +92948,23 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92901
92948
  'datetime': this.iso8601(timestamp),
92902
92949
  'timestamp': timestamp,
92903
92950
  'lastTradeTimestamp': this.safeTimestamp(order, 'update_time'),
92904
- 'status': status,
92951
+ 'status': this.parseOrderStatus(rawStatus),
92905
92952
  'symbol': market['symbol'],
92906
92953
  'type': type,
92907
92954
  'timeInForce': undefined,
92908
92955
  'postOnly': undefined,
92909
92956
  'reduceOnly': undefined,
92910
92957
  'side': side,
92911
- 'price': priceString,
92958
+ 'price': this.safeString(order, 'price'),
92912
92959
  'stopPrice': this.safeString(order, 'stop_price'),
92913
92960
  'triggerPrice': this.safeString(order, 'stop_price'),
92914
- 'cost': costString,
92915
- 'average': averageString,
92916
- 'amount': amountString,
92917
- 'filled': filledString,
92918
- 'remaining': remainingString,
92961
+ 'takeProfitPrice': this.safeNumber(order, 'take_profit_price'),
92962
+ 'stopLossPrice': this.safeNumber(order, 'stop_loss_price'),
92963
+ 'cost': this.safeString(order, 'deal_money'),
92964
+ 'average': this.safeString(order, 'avg_price'),
92965
+ 'amount': this.safeString(order, 'amount'),
92966
+ 'filled': this.safeString(order, 'deal_amount'),
92967
+ 'remaining': this.safeString(order, 'left'),
92919
92968
  'trades': undefined,
92920
92969
  'fee': {
92921
92970
  'currency': feeCurrency,
@@ -92924,34 +92973,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92924
92973
  'info': order,
92925
92974
  }, market);
92926
92975
  }
92927
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
92928
- /**
92929
- * @method
92930
- * @name coinex#createOrder
92931
- * @description create a trade order
92932
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
92933
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
92934
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
92935
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
92936
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
92937
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
92938
- * @param {string} symbol unified symbol of the market to create an order in
92939
- * @param {string} type 'market' or 'limit'
92940
- * @param {string} side 'buy' or 'sell'
92941
- * @param {float} amount how much of currency you want to trade in units of base currency
92942
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
92943
- * @param {object} [params] extra parameters specific to the exchange API endpoint
92944
- * @param {float} triggerPrice price at which to triger stop orders
92945
- * @param {float} stopPrice price at which to triger stop orders
92946
- * @param {float} stopLossPrice price at which to trigger stop-loss orders
92947
- * @param {float} takeProfitPrice price at which to trigger take-profit orders
92948
- * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", "PO"
92949
- * @param {bool} params.postOnly
92950
- * @param {bool} params.reduceOnly
92951
- * @param {bool} [params.position_id] *required for reduce only orders* the position id to reduce
92952
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
92953
- */
92954
- await this.loadMarkets();
92976
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
92955
92977
  const market = this.market(symbol);
92956
92978
  const swap = market['swap'];
92957
92979
  const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
@@ -92965,14 +92987,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92965
92987
  const timeInForceRaw = this.safeString(params, 'timeInForce'); // Spot: IOC, FOK, PO, GTC, ... NORMAL (default), MAKER_ONLY
92966
92988
  const reduceOnly = this.safeValue(params, 'reduceOnly');
92967
92989
  if (reduceOnly) {
92968
- if (market['type'] !== 'swap') {
92990
+ if (!market['swap']) {
92969
92991
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only');
92970
92992
  }
92971
92993
  if (positionId === undefined) {
92972
92994
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders');
92973
92995
  }
92974
92996
  }
92975
- let method = undefined;
92976
92997
  const request = {
92977
92998
  'market': market['id'],
92978
92999
  };
@@ -92992,16 +93013,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92992
93013
  }
92993
93014
  request['position_id'] = positionId;
92994
93015
  if (stopLossPrice) {
92995
- method = 'perpetualPrivatePostPositionStopLoss';
92996
93016
  request['stop_loss_price'] = this.priceToPrecision(symbol, stopLossPrice);
92997
93017
  }
92998
93018
  else if (takeProfitPrice) {
92999
- method = 'perpetualPrivatePostPositionTakeProfit';
93000
93019
  request['take_profit_price'] = this.priceToPrecision(symbol, takeProfitPrice);
93001
93020
  }
93002
93021
  }
93003
93022
  else {
93004
- method = 'perpetualPrivatePostOrderPut' + this.capitalize(type);
93005
93023
  const requestSide = (side === 'buy') ? 2 : 1;
93006
93024
  if (stopPrice !== undefined) {
93007
93025
  request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
@@ -93009,12 +93027,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93009
93027
  request['amount'] = this.amountToPrecision(symbol, amount);
93010
93028
  request['side'] = requestSide;
93011
93029
  if (type === 'limit') {
93012
- method = 'perpetualPrivatePostOrderPutStopLimit';
93013
93030
  request['price'] = this.priceToPrecision(symbol, price);
93014
93031
  }
93015
- else if (type === 'market') {
93016
- method = 'perpetualPrivatePostOrderPutStopMarket';
93017
- }
93018
93032
  request['amount'] = this.amountToPrecision(symbol, amount);
93019
93033
  }
93020
93034
  let timeInForce = undefined;
@@ -93037,7 +93051,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93037
93051
  }
93038
93052
  if (type === 'limit' && stopPrice === undefined) {
93039
93053
  if (reduceOnly) {
93040
- method = 'perpetualPrivatePostOrderCloseLimit';
93041
93054
  request['position_id'] = positionId;
93042
93055
  }
93043
93056
  else {
@@ -93048,7 +93061,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93048
93061
  }
93049
93062
  else if (type === 'market' && stopPrice === undefined) {
93050
93063
  if (reduceOnly) {
93051
- method = 'perpetualPrivatePostOrderCloseMarket';
93052
93064
  request['position_id'] = positionId;
93053
93065
  }
93054
93066
  else {
@@ -93059,7 +93071,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93059
93071
  }
93060
93072
  }
93061
93073
  else {
93062
- method = 'privatePostOrder' + this.capitalize(type);
93063
93074
  request['type'] = side;
93064
93075
  if ((type === 'market') && (side === 'buy')) {
93065
93076
  if (this.options['createMarketBuyOrderRequiresPrice']) {
@@ -93086,12 +93097,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93086
93097
  }
93087
93098
  if (stopPrice !== undefined) {
93088
93099
  request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
93089
- if (type === 'limit') {
93090
- method = 'privatePostOrderStopLimit';
93091
- }
93092
- else if (type === 'market') {
93093
- method = 'privatePostOrderStopMarket';
93094
- }
93095
93100
  }
93096
93101
  if ((type !== 'market') || (stopPrice !== undefined)) {
93097
93102
  // following options cannot be applied to vanilla market orders (but can be applied to stop-market orders)
@@ -93119,7 +93124,100 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93119
93124
  request['account_id'] = accountId;
93120
93125
  }
93121
93126
  params = this.omit(params, ['reduceOnly', 'positionId', 'timeInForce', 'postOnly', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
93122
- const response = await this[method](this.extend(request, params));
93127
+ return this.extend(request, params);
93128
+ }
93129
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
93130
+ /**
93131
+ * @method
93132
+ * @name coinex#createOrder
93133
+ * @description create a trade order
93134
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
93135
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
93136
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
93137
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
93138
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
93139
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
93140
+ * @param {string} symbol unified symbol of the market to create an order in
93141
+ * @param {string} type 'market' or 'limit'
93142
+ * @param {string} side 'buy' or 'sell'
93143
+ * @param {float} amount how much you want to trade in units of the base currency
93144
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
93145
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
93146
+ * @param {float} [params.triggerPrice] price to trigger stop orders
93147
+ * @param {float} [params.stopLossPrice] price to trigger stop loss orders
93148
+ * @param {float} [params.takeProfitPrice] price to trigger take profit orders
93149
+ * @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK', 'PO'
93150
+ * @param {boolean} [params.postOnly] set to true if you wish to make a post only order
93151
+ * @param {boolean} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
93152
+ * @param {int} [params.position_id] *required for reduce only orders* the position id to reduce
93153
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
93154
+ */
93155
+ await this.loadMarkets();
93156
+ const market = this.market(symbol);
93157
+ const reduceOnly = this.safeValue(params, 'reduceOnly');
93158
+ const triggerPrice = this.safeNumber2(params, 'stopPrice', 'triggerPrice');
93159
+ const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice');
93160
+ const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
93161
+ const isTriggerOrder = triggerPrice !== undefined;
93162
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
93163
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
93164
+ const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
93165
+ const request = this.createOrderRequest(symbol, type, side, amount, price, params);
93166
+ let response = undefined;
93167
+ if (market['spot']) {
93168
+ if (isTriggerOrder) {
93169
+ if (type === 'limit') {
93170
+ response = await this.privatePostOrderStopLimit(request);
93171
+ }
93172
+ else {
93173
+ response = await this.privatePostOrderStopMarket(request);
93174
+ }
93175
+ }
93176
+ else {
93177
+ if (type === 'limit') {
93178
+ response = await this.privatePostOrderLimit(request);
93179
+ }
93180
+ else {
93181
+ response = await this.privatePostOrderMarket(request);
93182
+ }
93183
+ }
93184
+ }
93185
+ else {
93186
+ if (isTriggerOrder) {
93187
+ if (type === 'limit') {
93188
+ response = await this.perpetualPrivatePostOrderPutStopLimit(request);
93189
+ }
93190
+ else {
93191
+ response = await this.perpetualPrivatePostOrderPutStopMarket(request);
93192
+ }
93193
+ }
93194
+ else if (isStopLossOrTakeProfitTrigger) {
93195
+ if (isStopLossTriggerOrder) {
93196
+ response = await this.perpetualPrivatePostPositionStopLoss(request);
93197
+ }
93198
+ else if (isTakeProfitTriggerOrder) {
93199
+ response = await this.perpetualPrivatePostPositionTakeProfit(request);
93200
+ }
93201
+ }
93202
+ else {
93203
+ if (reduceOnly) {
93204
+ if (type === 'limit') {
93205
+ response = await this.perpetualPrivatePostOrderCloseLimit(request);
93206
+ }
93207
+ else {
93208
+ response = await this.perpetualPrivatePostOrderCloseMarket(request);
93209
+ }
93210
+ }
93211
+ else {
93212
+ if (type === 'limit') {
93213
+ response = await this.perpetualPrivatePostOrderPutLimit(request);
93214
+ }
93215
+ else {
93216
+ response = await this.perpetualPrivatePostOrderPutMarket(request);
93217
+ }
93218
+ }
93219
+ }
93220
+ }
93123
93221
  //
93124
93222
  // Spot and Margin
93125
93223
  //
@@ -93197,9 +93295,243 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93197
93295
  //
93198
93296
  // {"code":0,"data":{"status":"success"},"message":"OK"}
93199
93297
  //
93200
- const data = this.safeValue(response, 'data');
93298
+ const data = this.safeValue(response, 'data', {});
93201
93299
  return this.parseOrder(data, market);
93202
93300
  }
93301
+ async createOrders(orders, params = {}) {
93302
+ /**
93303
+ * @method
93304
+ * @name coinex#createOrders
93305
+ * @description create a list of trade orders (all orders should be of the same symbol)
93306
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade002_batch_limit_orders
93307
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
93308
+ * @param {object} [params] extra parameters specific to the api endpoint
93309
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
93310
+ */
93311
+ await this.loadMarkets();
93312
+ const ordersRequests = [];
93313
+ let symbol = undefined;
93314
+ for (let i = 0; i < orders.length; i++) {
93315
+ const rawOrder = orders[i];
93316
+ const marketId = this.safeString(rawOrder, 'symbol');
93317
+ if (symbol === undefined) {
93318
+ symbol = marketId;
93319
+ }
93320
+ else {
93321
+ if (symbol !== marketId) {
93322
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
93323
+ }
93324
+ }
93325
+ const type = this.safeString(rawOrder, 'type');
93326
+ const side = this.safeString(rawOrder, 'side');
93327
+ const amount = this.safeValue(rawOrder, 'amount');
93328
+ const price = this.safeValue(rawOrder, 'price');
93329
+ const orderParams = this.safeValue(rawOrder, 'params', {});
93330
+ if (type !== 'limit') {
93331
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support ' + type + ' orders, only limit orders are accepted');
93332
+ }
93333
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
93334
+ ordersRequests.push(orderRequest);
93335
+ }
93336
+ const market = this.market(symbol);
93337
+ if (!market['spot']) {
93338
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted');
93339
+ }
93340
+ const request = {
93341
+ 'market': market['id'],
93342
+ 'batch_orders': this.json(ordersRequests),
93343
+ };
93344
+ const response = await this.privatePostOrderLimitBatch(request);
93345
+ //
93346
+ // {
93347
+ // "code": 0,
93348
+ // "data": [
93349
+ // {
93350
+ // "code": 0,
93351
+ // "data": {
93352
+ // "amount": "0.0005",
93353
+ // "asset_fee": "0",
93354
+ // "avg_price": "0.00",
93355
+ // "client_id": "x-167673045-d34bfb41242d8fd1",
93356
+ // "create_time": 1701229157,
93357
+ // "deal_amount": "0",
93358
+ // "deal_fee": "0",
93359
+ // "deal_money": "0",
93360
+ // "fee_asset": null,
93361
+ // "fee_discount": "1",
93362
+ // "finished_time": null,
93363
+ // "id": 107745856676,
93364
+ // "left": "0.0005",
93365
+ // "maker_fee_rate": "0.002",
93366
+ // "market": "BTCUSDT",
93367
+ // "money_fee": "0",
93368
+ // "order_type": "limit",
93369
+ // "price": "23000",
93370
+ // "source_id": "",
93371
+ // "status": "not_deal",
93372
+ // "stock_fee": "0",
93373
+ // "taker_fee_rate": "0.002",
93374
+ // "type": "buy"
93375
+ // },
93376
+ // "message": "OK"
93377
+ // },
93378
+ // ],
93379
+ // "message": "Success"
93380
+ // }
93381
+ //
93382
+ const data = this.safeValue(response, 'data', []);
93383
+ const results = [];
93384
+ for (let i = 0; i < data.length; i++) {
93385
+ const entry = data[i];
93386
+ let status = undefined;
93387
+ const code = this.safeInteger(entry, 'code');
93388
+ if (code !== undefined) {
93389
+ if (code !== 0) {
93390
+ status = 'rejected';
93391
+ }
93392
+ else {
93393
+ status = 'open';
93394
+ }
93395
+ }
93396
+ const item = this.safeValue(entry, 'data', {});
93397
+ item['status'] = status;
93398
+ const order = this.parseOrder(item, market);
93399
+ results.push(order);
93400
+ }
93401
+ return results;
93402
+ }
93403
+ async cancelOrders(ids, symbol = undefined, params = {}) {
93404
+ /**
93405
+ * @method
93406
+ * @name coinex#cancelOrders
93407
+ * @description cancel multiple orders
93408
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade016_batch_cancel_order
93409
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021-0_cancel_order_batch
93410
+ * @param {string[]} ids order ids
93411
+ * @param {string} symbol unified market symbol
93412
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
93413
+ * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
93414
+ */
93415
+ if (symbol === undefined) {
93416
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
93417
+ }
93418
+ await this.loadMarkets();
93419
+ const market = this.market(symbol);
93420
+ const request = {
93421
+ 'market': market['id'],
93422
+ };
93423
+ const idsString = ids.join(',');
93424
+ let response = undefined;
93425
+ if (market['spot']) {
93426
+ request['batch_ids'] = idsString;
93427
+ response = await this.privateDeleteOrderPendingBatch(this.extend(request, params));
93428
+ }
93429
+ else {
93430
+ request['order_ids'] = idsString;
93431
+ response = await this.perpetualPrivatePostOrderCancelBatch(this.extend(request, params));
93432
+ }
93433
+ //
93434
+ // spot
93435
+ //
93436
+ // {
93437
+ // "code": 0,
93438
+ // "data": [
93439
+ // {
93440
+ // "code": 0,
93441
+ // "data": {
93442
+ // "account_id": 0,
93443
+ // "amount": "0.0005",
93444
+ // "asset_fee": "0",
93445
+ // "avg_price": "0.00",
93446
+ // "client_id": "x-167673045-d4e03c38f4d19b4e",
93447
+ // "create_time": 1701229157,
93448
+ // "deal_amount": "0",
93449
+ // "deal_fee": "0",
93450
+ // "deal_money": "0",
93451
+ // "fee_asset": null,
93452
+ // "fee_discount": "1",
93453
+ // "finished_time": 0,
93454
+ // "id": 107745856682,
93455
+ // "left": "0",
93456
+ // "maker_fee_rate": "0.002",
93457
+ // "market": "BTCUSDT",
93458
+ // "money_fee": "0",
93459
+ // "order_type": "limit",
93460
+ // "price": "22000",
93461
+ // "status": "not_deal",
93462
+ // "stock_fee": "0",
93463
+ // "taker_fee_rate": "0.002",
93464
+ // "type": "buy"
93465
+ // },
93466
+ // "message": ""
93467
+ // },
93468
+ // ],
93469
+ // "message": "Success"
93470
+ // }
93471
+ //
93472
+ // swap
93473
+ //
93474
+ // {
93475
+ // "code": 0,
93476
+ // "data": [
93477
+ // {
93478
+ // "code": 0,
93479
+ // "message": "",
93480
+ // "order": {
93481
+ // "amount": "0.0005",
93482
+ // "client_id": "x-167673045-b0cee0c584718b65",
93483
+ // "create_time": 1701233683.294231,
93484
+ // "deal_asset_fee": "0.00000000000000000000",
93485
+ // "deal_fee": "0.00000000000000000000",
93486
+ // "deal_profit": "0.00000000000000000000",
93487
+ // "deal_stock": "0.00000000000000000000",
93488
+ // "effect_type": 1,
93489
+ // "fee_asset": "",
93490
+ // "fee_discount": "0.00000000000000000000",
93491
+ // "last_deal_amount": "0.00000000000000000000",
93492
+ // "last_deal_id": 0,
93493
+ // "last_deal_price": "0.00000000000000000000",
93494
+ // "last_deal_role": 0,
93495
+ // "last_deal_time": 0,
93496
+ // "last_deal_type": 0,
93497
+ // "left": "0.0005",
93498
+ // "leverage": "3",
93499
+ // "maker_fee": "0.00030",
93500
+ // "market": "BTCUSDT",
93501
+ // "option": 0,
93502
+ // "order_id": 115940476323,
93503
+ // "position_id": 0,
93504
+ // "position_type": 2,
93505
+ // "price": "25000.00",
93506
+ // "side": 2,
93507
+ // "source": "api.v1",
93508
+ // "stop_id": 0,
93509
+ // "stop_loss_price": "0.00000000000000000000",
93510
+ // "stop_loss_type": 0,
93511
+ // "take_profit_price": "0.00000000000000000000",
93512
+ // "take_profit_type": 0,
93513
+ // "taker_fee": "0.00050",
93514
+ // "target": 0,
93515
+ // "type": 1,
93516
+ // "update_time": 1701233721.718884,
93517
+ // "user_id": 3620173
93518
+ // }
93519
+ // },
93520
+ // ],
93521
+ // "message": "OK"
93522
+ // }
93523
+ //
93524
+ const data = this.safeValue(response, 'data', []);
93525
+ const results = [];
93526
+ for (let i = 0; i < data.length; i++) {
93527
+ const entry = data[i];
93528
+ const dataRequest = market['spot'] ? 'data' : 'order';
93529
+ const item = this.safeValue(entry, dataRequest, {});
93530
+ const order = this.parseOrder(item, market);
93531
+ results.push(order);
93532
+ }
93533
+ return results;
93534
+ }
93203
93535
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
93204
93536
  /**
93205
93537
  * @method
@@ -193866,6 +194198,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
193866
194198
  },
193867
194199
  'v1': {
193868
194200
  'get': {
194201
+ 'md/fullbook': 5,
193869
194202
  'md/orderbook': 5,
193870
194203
  'md/trade': 5,
193871
194204
  'md/ticker/24hr': 5,
@@ -193919,6 +194252,11 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
193919
194252
  'phemex-user/users/children': 5,
193920
194253
  'phemex-user/wallets/v2/depositAddress': 5,
193921
194254
  'phemex-user/wallets/tradeAccountDetail': 5,
194255
+ 'phemex-deposit/wallets/api/depositAddress': 5,
194256
+ 'phemex-deposit/wallets/api/depositHist': 5,
194257
+ 'phemex-deposit/wallets/api/chainCfg': 5,
194258
+ 'phemex-withdraw/wallets/api/withdrawHist': 5,
194259
+ 'phemex-withdraw/wallets/api/asset/info': 5,
193922
194260
  'phemex-user/order/closedPositionList': 5,
193923
194261
  'exchange/margins/transfer': 5,
193924
194262
  'exchange/wallets/confirm/withdraw': 5,
@@ -193957,6 +194295,9 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
193957
194295
  'assets/futures/sub-accounts/transfer': 5,
193958
194296
  'assets/universal-transfer': 5,
193959
194297
  'assets/convert': 5,
194298
+ // withdraw
194299
+ 'phemex-withdraw/wallets/api/createWithdraw': 5,
194300
+ 'phemex-withdraw/wallets/api/cancelWithdraw': 5, // ?id=<id>
193960
194301
  },
193961
194302
  'put': {
193962
194303
  // spot
@@ -194713,7 +195054,12 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
194713
195054
  response = await this.v2GetMdV2Orderbook(this.extend(request, params));
194714
195055
  }
194715
195056
  else {
194716
- response = await this.v1GetMdOrderbook(this.extend(request, params));
195057
+ if ((limit !== undefined) && (limit <= 30)) {
195058
+ response = await this.v1GetMdOrderbook(this.extend(request, params));
195059
+ }
195060
+ else {
195061
+ response = await this.v1GetMdFullbook(this.extend(request, params));
195062
+ }
194717
195063
  }
194718
195064
  //
194719
195065
  // {
@@ -204133,8 +204479,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
204133
204479
  },
204134
204480
  'api': {
204135
204481
  'ws': {
204136
- 'spot': 'wss://stream.binance.com:9443/ws',
204137
- 'margin': 'wss://stream.binance.com:9443/ws',
204482
+ 'spot': 'wss://stream.binance.com/ws',
204483
+ 'margin': 'wss://stream.binance.com/ws',
204138
204484
  'future': 'wss://fstream.binance.com/ws',
204139
204485
  'delivery': 'wss://dstream.binance.com/ws',
204140
204486
  'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
@@ -231972,9 +232318,11 @@ class htx extends _htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
231972
232318
  // which means whenever there is an order book change at that level, it pushes an update;
231973
232319
  // 150-levels/400-level incremental MBP feed is based on the gap
231974
232320
  // between two snapshots at 100ms interval.
231975
- limit = (limit === undefined) ? 20 : limit;
232321
+ if (limit === undefined) {
232322
+ limit = market['spot'] ? 150 : 20;
232323
+ }
231976
232324
  if (!this.inArray(limit, allowedLimits)) {
231977
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook swap market accepts limits of 20 and 150 only');
232325
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook market accepts limits of 20 and 150 only');
231978
232326
  }
231979
232327
  let messageHash = undefined;
231980
232328
  if (market['spot']) {
@@ -287962,7 +288310,7 @@ SOFTWARE.
287962
288310
 
287963
288311
  //-----------------------------------------------------------------------------
287964
288312
  // this is updated by vss.js when building
287965
- const version = '4.1.68';
288313
+ const version = '4.1.70';
287966
288314
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
287967
288315
  //-----------------------------------------------------------------------------
287968
288316