ccxt 4.3.9 → 4.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -213,13 +213,13 @@ console.log(version, Object.keys(exchanges));
213
213
 
214
214
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
215
215
 
216
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.9/dist/ccxt.browser.js
217
- * unpkg: https://unpkg.com/ccxt@4.3.9/dist/ccxt.browser.js
216
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.10/dist/ccxt.browser.js
217
+ * unpkg: https://unpkg.com/ccxt@4.3.10/dist/ccxt.browser.js
218
218
 
219
219
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
220
220
 
221
221
  ```HTML
222
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.9/dist/ccxt.browser.js"></script>
222
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.10/dist/ccxt.browser.js"></script>
223
223
  ```
224
224
 
225
225
  Creates a global `ccxt` object:
package/dist/cjs/ccxt.js CHANGED
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.3.9';
185
+ const version = '4.3.10';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -6114,10 +6114,10 @@ class Exchange {
6114
6114
  const fromId = this.safeString(entry, fromCurrencyKey);
6115
6115
  const toId = this.safeString(entry, toCurrencyKey);
6116
6116
  if (fromId !== undefined) {
6117
- fromCurrency = this.currency(fromId);
6117
+ fromCurrency = this.safeCurrency(fromId);
6118
6118
  }
6119
6119
  if (toId !== undefined) {
6120
- toCurrency = this.currency(toId);
6120
+ toCurrency = this.safeCurrency(toId);
6121
6121
  }
6122
6122
  const conversion = this.extend(this.parseConversion(entry, fromCurrency, toCurrency), params);
6123
6123
  result.push(conversion);
@@ -6125,7 +6125,7 @@ class Exchange {
6125
6125
  const sorted = this.sortBy(result, 'timestamp');
6126
6126
  let currency = undefined;
6127
6127
  if (code !== undefined) {
6128
- currency = this.currency(code);
6128
+ currency = this.safeCurrency(code);
6129
6129
  code = currency['code'];
6130
6130
  }
6131
6131
  if (code === undefined) {
@@ -8455,7 +8455,7 @@ class bitget extends bitget$1 {
8455
8455
  * @name bitget#fetchPositionsHistory
8456
8456
  * @description fetches historical positions
8457
8457
  * @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
8458
- * @param {string} [symbol] unified contract symbols
8458
+ * @param {string[]} [symbols] unified contract symbols
8459
8459
  * @param {int} [since] timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
8460
8460
  * @param {int} [limit] the maximum amount of records to fetch, default=20, max=100
8461
8461
  * @param {object} params extra parameters specific to the exchange api endpoint
@@ -1740,7 +1740,7 @@ class coinex extends coinex$1 {
1740
1740
  // "client_id": "",
1741
1741
  // }
1742
1742
  //
1743
- // Spot and Margin cancelOrder, cancelOrders, fetchOrder
1743
+ // Spot and Margin cancelOrder, fetchOrder
1744
1744
  //
1745
1745
  // {
1746
1746
  // "amount":"1.5",
@@ -1935,49 +1935,7 @@ class coinex extends coinex$1 {
1935
1935
  // "user_id": 3620173
1936
1936
  // }
1937
1937
  //
1938
- // swap: cancelOrders
1939
- //
1940
- // {
1941
- // "amount": "0.0005",
1942
- // "client_id": "x-167673045-b0cee0c584718b65",
1943
- // "create_time": 1701233683.294231,
1944
- // "deal_asset_fee": "0.00000000000000000000",
1945
- // "deal_fee": "0.00000000000000000000",
1946
- // "deal_profit": "0.00000000000000000000",
1947
- // "deal_stock": "0.00000000000000000000",
1948
- // "effect_type": 1,
1949
- // "fee_asset": "",
1950
- // "fee_discount": "0.00000000000000000000",
1951
- // "last_deal_amount": "0.00000000000000000000",
1952
- // "last_deal_id": 0,
1953
- // "last_deal_price": "0.00000000000000000000",
1954
- // "last_deal_role": 0,
1955
- // "last_deal_time": 0,
1956
- // "last_deal_type": 0,
1957
- // "left": "0.0005",
1958
- // "leverage": "3",
1959
- // "maker_fee": "0.00030",
1960
- // "market": "BTCUSDT",
1961
- // "option": 0,
1962
- // "order_id": 115940476323,
1963
- // "position_id": 0,
1964
- // "position_type": 2,
1965
- // "price": "25000.00",
1966
- // "side": 2,
1967
- // "source": "api.v1",
1968
- // "stop_id": 0,
1969
- // "stop_loss_price": "0.00000000000000000000",
1970
- // "stop_loss_type": 0,
1971
- // "take_profit_price": "0.00000000000000000000",
1972
- // "take_profit_type": 0,
1973
- // "taker_fee": "0.00050",
1974
- // "target": 0,
1975
- // "type": 1,
1976
- // "update_time": 1701233721.718884,
1977
- // "user_id": 3620173
1978
- // }
1979
- //
1980
- // Spot and Margin createOrder, createOrders v2
1938
+ // Spot and Margin createOrder, createOrders, cancelOrders v2
1981
1939
  //
1982
1940
  // {
1983
1941
  // "amount": "0.0001",
@@ -2009,7 +1967,7 @@ class coinex extends coinex$1 {
2009
1967
  // "stop_id": 117180138153
2010
1968
  // }
2011
1969
  //
2012
- // Swap createOrder, createOrders v2
1970
+ // Swap createOrder, createOrders, cancelOrders v2
2013
1971
  //
2014
1972
  // {
2015
1973
  // "amount": "0.0001",
@@ -2069,6 +2027,24 @@ class coinex extends coinex$1 {
2069
2027
  // "updated_at": 1714119054559
2070
2028
  // }
2071
2029
  //
2030
+ // Swap and Spot stop cancelOrders v2
2031
+ //
2032
+ // {
2033
+ // "amount": "0.0001",
2034
+ // "client_id": "x-167673045-a7d7714c6478acf6",
2035
+ // "created_at": 1714187923820,
2036
+ // "market": "BTCUSDT",
2037
+ // "market_type": "FUTURES",
2038
+ // "price": "61000",
2039
+ // "side": "buy",
2040
+ // "stop_id": 136984426097,
2041
+ // "trigger_direction": "higher",
2042
+ // "trigger_price": "62000",
2043
+ // "trigger_price_type": "latest_price",
2044
+ // "type": "limit",
2045
+ // "updated_at": 1714187974363
2046
+ // }
2047
+ //
2072
2048
  const rawStatus = this.safeString(order, 'status');
2073
2049
  let timestamp = this.safeTimestamp(order, 'create_time');
2074
2050
  if (timestamp === undefined) {
@@ -2141,8 +2117,8 @@ class coinex extends coinex$1 {
2141
2117
  'reduceOnly': undefined,
2142
2118
  'side': side,
2143
2119
  'price': this.safeString(order, 'price'),
2144
- 'stopPrice': this.safeString(order, 'stop_price'),
2145
- 'triggerPrice': this.safeString(order, 'stop_price'),
2120
+ 'stopPrice': this.safeString2(order, 'stop_price', 'trigger_price'),
2121
+ 'triggerPrice': this.safeString2(order, 'stop_price', 'trigger_price'),
2146
2122
  'takeProfitPrice': this.safeNumber(order, 'take_profit_price'),
2147
2123
  'stopLossPrice': this.safeNumber(order, 'stop_loss_price'),
2148
2124
  'cost': this.safeString2(order, 'deal_money', 'filled_value'),
@@ -2748,11 +2724,14 @@ class coinex extends coinex$1 {
2748
2724
  * @method
2749
2725
  * @name coinex#cancelOrders
2750
2726
  * @description cancel multiple orders
2751
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade016_batch_cancel_order
2752
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021-0_cancel_order_batch
2727
+ * @see https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
2728
+ * @see https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
2729
+ * @see https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
2730
+ * @see https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
2753
2731
  * @param {string[]} ids order ids
2754
2732
  * @param {string} symbol unified market symbol
2755
2733
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2734
+ * @param {boolean} [params.stop] set to true for canceling stop orders
2756
2735
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2757
2736
  */
2758
2737
  if (symbol === undefined) {
@@ -2763,113 +2742,161 @@ class coinex extends coinex$1 {
2763
2742
  const request = {
2764
2743
  'market': market['id'],
2765
2744
  };
2766
- const idsString = ids.join(',');
2745
+ const stop = this.safeBool2(params, 'stop', 'trigger');
2746
+ params = this.omit(params, ['stop', 'trigger']);
2767
2747
  let response = undefined;
2748
+ if (stop) {
2749
+ request['stop_ids'] = ids;
2750
+ }
2751
+ else {
2752
+ request['order_ids'] = ids;
2753
+ }
2768
2754
  if (market['spot']) {
2769
- request['batch_ids'] = idsString;
2770
- response = await this.v1PrivateDeleteOrderPendingBatch(this.extend(request, params));
2755
+ if (stop) {
2756
+ response = await this.v2PrivatePostSpotCancelBatchStopOrder(this.extend(request, params));
2757
+ //
2758
+ // {
2759
+ // "code": 0,
2760
+ // "data": [
2761
+ // {
2762
+ // "code": 0,
2763
+ // "data": {
2764
+ // "amount": "0.0001",
2765
+ // "ccy": "BTC",
2766
+ // "client_id": "x-167673045-8e33d6f4a4bcb022",
2767
+ // "created_at": 1714188827291,
2768
+ // "market": "BTCUSDT",
2769
+ // "market_type": "SPOT",
2770
+ // "price": "61000",
2771
+ // "side": "buy",
2772
+ // "stop_id": 117248845854,
2773
+ // "trigger_direction": "higher",
2774
+ // "trigger_price": "62000",
2775
+ // "trigger_price_type": "mark_price",
2776
+ // "type": "limit",
2777
+ // "updated_at": 1714188827291
2778
+ // },
2779
+ // "message": "OK"
2780
+ // },
2781
+ // ],
2782
+ // "message": "OK"
2783
+ // }
2784
+ //
2785
+ }
2786
+ else {
2787
+ response = await this.v2PrivatePostSpotCancelBatchOrder(this.extend(request, params));
2788
+ //
2789
+ // {
2790
+ // "code": 0,
2791
+ // "data": [
2792
+ // {
2793
+ // "code": 0,
2794
+ // "data": {
2795
+ // "amount": "0.0001",
2796
+ // "base_fee": "0",
2797
+ // "ccy": "BTC",
2798
+ // "client_id": "x-167673045-c1cc78e5b42d8c4e",
2799
+ // "created_at": 1714188449497,
2800
+ // "discount_fee": "0",
2801
+ // "filled_amount": "0",
2802
+ // "filled_value": "0",
2803
+ // "last_fill_amount": "0",
2804
+ // "last_fill_price": "0",
2805
+ // "maker_fee_rate": "0.002",
2806
+ // "market": "BTCUSDT",
2807
+ // "market_type": "SPOT",
2808
+ // "order_id": 117248494358,
2809
+ // "price": "60000",
2810
+ // "quote_fee": "0",
2811
+ // "side": "buy",
2812
+ // "taker_fee_rate": "0.002",
2813
+ // "type": "limit",
2814
+ // "unfilled_amount": "0.0001",
2815
+ // "updated_at": 1714188449497
2816
+ // },
2817
+ // "message": ""
2818
+ // },
2819
+ // ],
2820
+ // "message": "OK"
2821
+ // }
2822
+ //
2823
+ }
2771
2824
  }
2772
2825
  else {
2773
- request['order_ids'] = idsString;
2774
- response = await this.v1PerpetualPrivatePostOrderCancelBatch(this.extend(request, params));
2826
+ request['market_type'] = 'FUTURES';
2827
+ if (stop) {
2828
+ response = await this.v2PrivatePostFuturesCancelBatchStopOrder(this.extend(request, params));
2829
+ //
2830
+ // {
2831
+ // "code": 0,
2832
+ // "data": [
2833
+ // {
2834
+ // "code": 0,
2835
+ // "data": {
2836
+ // "amount": "0.0001",
2837
+ // "client_id": "x-167673045-a7d7714c6478acf6",
2838
+ // "created_at": 1714187923820,
2839
+ // "market": "BTCUSDT",
2840
+ // "market_type": "FUTURES",
2841
+ // "price": "61000",
2842
+ // "side": "buy",
2843
+ // "stop_id": 136984426097,
2844
+ // "trigger_direction": "higher",
2845
+ // "trigger_price": "62000",
2846
+ // "trigger_price_type": "latest_price",
2847
+ // "type": "limit",
2848
+ // "updated_at": 1714187974363
2849
+ // },
2850
+ // "message": ""
2851
+ // },
2852
+ // ],
2853
+ // "message": "OK"
2854
+ // }
2855
+ //
2856
+ }
2857
+ else {
2858
+ response = await this.v2PrivatePostFuturesCancelBatchOrder(this.extend(request, params));
2859
+ //
2860
+ // {
2861
+ // "code": 0,
2862
+ // "data": [
2863
+ // {
2864
+ // "code": 0,
2865
+ // "data": {
2866
+ // "amount": "0.0001",
2867
+ // "client_id": "x-167673045-9f80fde284339a72",
2868
+ // "created_at": 1714187491784,
2869
+ // "fee": "0",
2870
+ // "fee_ccy": "USDT",
2871
+ // "filled_amount": "0",
2872
+ // "filled_value": "0",
2873
+ // "last_filled_amount": "0",
2874
+ // "last_filled_price": "0",
2875
+ // "maker_fee_rate": "0.0003",
2876
+ // "market": "BTCUSDT",
2877
+ // "market_type": "FUTURES",
2878
+ // "order_id": 136983851788,
2879
+ // "price": "61000",
2880
+ // "realized_pnl": "0",
2881
+ // "side": "buy",
2882
+ // "taker_fee_rate": "0.0005",
2883
+ // "type": "limit",
2884
+ // "unfilled_amount": "0.0001",
2885
+ // "updated_at": 1714187567079
2886
+ // },
2887
+ // "message": ""
2888
+ // },
2889
+ // ],
2890
+ // "message": "OK"
2891
+ // }
2892
+ //
2893
+ }
2775
2894
  }
2776
- //
2777
- // spot
2778
- //
2779
- // {
2780
- // "code": 0,
2781
- // "data": [
2782
- // {
2783
- // "code": 0,
2784
- // "data": {
2785
- // "account_id": 0,
2786
- // "amount": "0.0005",
2787
- // "asset_fee": "0",
2788
- // "avg_price": "0.00",
2789
- // "client_id": "x-167673045-d4e03c38f4d19b4e",
2790
- // "create_time": 1701229157,
2791
- // "deal_amount": "0",
2792
- // "deal_fee": "0",
2793
- // "deal_money": "0",
2794
- // "fee_asset": null,
2795
- // "fee_discount": "1",
2796
- // "finished_time": 0,
2797
- // "id": 107745856682,
2798
- // "left": "0",
2799
- // "maker_fee_rate": "0.002",
2800
- // "market": "BTCUSDT",
2801
- // "money_fee": "0",
2802
- // "order_type": "limit",
2803
- // "price": "22000",
2804
- // "status": "not_deal",
2805
- // "stock_fee": "0",
2806
- // "taker_fee_rate": "0.002",
2807
- // "type": "buy"
2808
- // },
2809
- // "message": ""
2810
- // },
2811
- // ],
2812
- // "message": "Success"
2813
- // }
2814
- //
2815
- // swap
2816
- //
2817
- // {
2818
- // "code": 0,
2819
- // "data": [
2820
- // {
2821
- // "code": 0,
2822
- // "message": "",
2823
- // "order": {
2824
- // "amount": "0.0005",
2825
- // "client_id": "x-167673045-b0cee0c584718b65",
2826
- // "create_time": 1701233683.294231,
2827
- // "deal_asset_fee": "0.00000000000000000000",
2828
- // "deal_fee": "0.00000000000000000000",
2829
- // "deal_profit": "0.00000000000000000000",
2830
- // "deal_stock": "0.00000000000000000000",
2831
- // "effect_type": 1,
2832
- // "fee_asset": "",
2833
- // "fee_discount": "0.00000000000000000000",
2834
- // "last_deal_amount": "0.00000000000000000000",
2835
- // "last_deal_id": 0,
2836
- // "last_deal_price": "0.00000000000000000000",
2837
- // "last_deal_role": 0,
2838
- // "last_deal_time": 0,
2839
- // "last_deal_type": 0,
2840
- // "left": "0.0005",
2841
- // "leverage": "3",
2842
- // "maker_fee": "0.00030",
2843
- // "market": "BTCUSDT",
2844
- // "option": 0,
2845
- // "order_id": 115940476323,
2846
- // "position_id": 0,
2847
- // "position_type": 2,
2848
- // "price": "25000.00",
2849
- // "side": 2,
2850
- // "source": "api.v1",
2851
- // "stop_id": 0,
2852
- // "stop_loss_price": "0.00000000000000000000",
2853
- // "stop_loss_type": 0,
2854
- // "take_profit_price": "0.00000000000000000000",
2855
- // "take_profit_type": 0,
2856
- // "taker_fee": "0.00050",
2857
- // "target": 0,
2858
- // "type": 1,
2859
- // "update_time": 1701233721.718884,
2860
- // "user_id": 3620173
2861
- // }
2862
- // },
2863
- // ],
2864
- // "message": "OK"
2865
- // }
2866
- //
2867
- const data = this.safeValue(response, 'data', []);
2895
+ const data = this.safeList(response, 'data', []);
2868
2896
  const results = [];
2869
2897
  for (let i = 0; i < data.length; i++) {
2870
2898
  const entry = data[i];
2871
- const dataRequest = market['spot'] ? 'data' : 'order';
2872
- const item = this.safeValue(entry, dataRequest, {});
2899
+ const item = this.safeDict(entry, 'data', {});
2873
2900
  const order = this.parseOrder(item, market);
2874
2901
  results.push(order);
2875
2902
  }