ccxt 4.1.68 → 4.1.69

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.
@@ -263,7 +263,7 @@ export default class ascendex extends Exchange {
263
263
  'account-category': 'cash',
264
264
  'account-group': undefined,
265
265
  'fetchClosedOrders': {
266
- 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountGroupGetAccountCategoryOrderHistCurrent'
266
+ 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountCategoryGetOrderHistCurrent'
267
267
  },
268
268
  'defaultType': 'spot',
269
269
  'accountsByType': {
@@ -803,6 +803,9 @@ export default class ascendex extends Exchange {
803
803
  * @method
804
804
  * @name ascendex#fetchBalance
805
805
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
806
+ * @see https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
807
+ * @see https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
808
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
806
809
  * @param {object} [params] extra parameters specific to the exchange API endpoint
807
810
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
808
811
  */
@@ -813,8 +816,7 @@ export default class ascendex extends Exchange {
813
816
  [marketType, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
814
817
  const isMargin = this.safeValue(params, 'margin', false);
815
818
  marketType = isMargin ? 'margin' : marketType;
816
- params = this.omit(params, 'margin');
817
- const options = this.safeValue(this.options, 'fetchBalance', {});
819
+ query = this.omit(query, 'margin');
818
820
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
819
821
  const accountCategory = this.safeString(accountsByType, marketType, 'cash');
820
822
  const account = this.safeValue(this.accounts, 0, {});
@@ -822,16 +824,19 @@ export default class ascendex extends Exchange {
822
824
  const request = {
823
825
  'account-group': accountGroup,
824
826
  };
825
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetBalance');
826
- const method = this.getSupportedMapping(marketType, {
827
- 'spot': defaultMethod,
828
- 'margin': defaultMethod,
829
- 'swap': 'v2PrivateAccountGroupGetFuturesPosition',
830
- });
831
827
  if ((accountCategory === 'cash') || (accountCategory === 'margin')) {
832
828
  request['account-category'] = accountCategory;
833
829
  }
834
- const response = await this[method](this.extend(request, query));
830
+ let response = undefined;
831
+ if ((marketType === 'spot') || (marketType === 'margin')) {
832
+ response = await this.v1PrivateAccountCategoryGetBalance(this.extend(request, query));
833
+ }
834
+ else if (marketType === 'swap') {
835
+ response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, query));
836
+ }
837
+ else {
838
+ throw new NotSupported(this.id + ' fetchBalance() is not currently supported for ' + marketType + ' markets');
839
+ }
835
840
  //
836
841
  // cash
837
842
  //
@@ -1756,6 +1761,8 @@ export default class ascendex extends Exchange {
1756
1761
  * @method
1757
1762
  * @name ascendex#fetchOrder
1758
1763
  * @description fetches information on an order made by the user
1764
+ * @see https://ascendex.github.io/ascendex-pro-api/#query-order
1765
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
1759
1766
  * @param {string} symbol unified symbol of the market the order was made in
1760
1767
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1761
1768
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1767,7 +1774,6 @@ export default class ascendex extends Exchange {
1767
1774
  market = this.market(symbol);
1768
1775
  }
1769
1776
  const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
1770
- const options = this.safeValue(this.options, 'fetchOrder', {});
1771
1777
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
1772
1778
  const accountCategory = this.safeString(accountsByType, type, 'cash');
1773
1779
  const account = this.safeValue(this.accounts, 0, {});
@@ -1777,21 +1783,17 @@ export default class ascendex extends Exchange {
1777
1783
  'account-category': accountCategory,
1778
1784
  'orderId': id,
1779
1785
  };
1780
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetOrderStatus');
1781
- const method = this.getSupportedMapping(type, {
1782
- 'spot': defaultMethod,
1783
- 'margin': defaultMethod,
1784
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderStatus',
1785
- });
1786
- if (method === 'v1PrivateAccountCategoryGetOrderStatus') {
1787
- if (accountCategory !== undefined) {
1788
- request['category'] = accountCategory;
1789
- }
1786
+ let response = undefined;
1787
+ if ((type === 'spot') || (type === 'margin')) {
1788
+ response = await this.v1PrivateAccountCategoryGetOrderStatus(this.extend(request, query));
1790
1789
  }
1791
- else {
1790
+ else if (type === 'swap') {
1792
1791
  request['account-category'] = accountCategory;
1792
+ response = await this.v2PrivateAccountGroupGetFuturesOrderStatus(this.extend(request, query));
1793
+ }
1794
+ else {
1795
+ throw new NotSupported(this.id + ' fetchOrder() is not currently supported for ' + type + ' markets');
1793
1796
  }
1794
- const response = await this[method](this.extend(request, query));
1795
1797
  //
1796
1798
  // AccountCategoryGetOrderStatus
1797
1799
  //
@@ -1867,6 +1869,8 @@ export default class ascendex extends Exchange {
1867
1869
  * @method
1868
1870
  * @name ascendex#fetchOpenOrders
1869
1871
  * @description fetch all unfilled currently open orders
1872
+ * @see https://ascendex.github.io/ascendex-pro-api/#list-open-orders
1873
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
1870
1874
  * @param {string} symbol unified market symbol
1871
1875
  * @param {int} [since] the earliest time in ms to fetch open orders for
1872
1876
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -1889,22 +1893,17 @@ export default class ascendex extends Exchange {
1889
1893
  'account-group': accountGroup,
1890
1894
  'account-category': accountCategory,
1891
1895
  };
1892
- const options = this.safeValue(this.options, 'fetchOpenOrders', {});
1893
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetOrderOpen');
1894
- const method = this.getSupportedMapping(type, {
1895
- 'spot': defaultMethod,
1896
- 'margin': defaultMethod,
1897
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderOpen',
1898
- });
1899
- if (method === 'v1PrivateAccountCategoryGetOrderOpen') {
1900
- if (accountCategory !== undefined) {
1901
- request['category'] = accountCategory;
1902
- }
1896
+ let response = undefined;
1897
+ if ((type === 'spot') || (type === 'margin')) {
1898
+ response = await this.v1PrivateAccountCategoryGetOrderOpen(this.extend(request, query));
1903
1899
  }
1904
- else {
1900
+ else if (type === 'swap') {
1905
1901
  request['account-category'] = accountCategory;
1902
+ response = await this.v2PrivateAccountGroupGetFuturesOrderOpen(this.extend(request, query));
1903
+ }
1904
+ else {
1905
+ throw new NotSupported(this.id + ' fetchOpenOrders() is not currently supported for ' + type + ' markets');
1906
1906
  }
1907
- const response = await this[method](this.extend(request, query));
1908
1907
  //
1909
1908
  // AccountCategoryGetOrderOpen
1910
1909
  //
@@ -1990,6 +1989,7 @@ export default class ascendex extends Exchange {
1990
1989
  * @name ascendex#fetchClosedOrders
1991
1990
  * @description fetches information on multiple closed orders made by the user
1992
1991
  * @see https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
1992
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
1993
1993
  * @param {string} symbol unified market symbol of the market orders were made in
1994
1994
  * @param {int} [since] the earliest time in ms to fetch orders for
1995
1995
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -2002,16 +2002,15 @@ export default class ascendex extends Exchange {
2002
2002
  const account = this.safeValue(this.accounts, 0, {});
2003
2003
  const accountGroup = this.safeValue(account, 'id');
2004
2004
  const request = {
2005
- 'account-group': accountGroup,
2006
- // 'category': accountCategory,
2007
- // 'symbol': market['id'],
2008
- // 'orderType': 'market', // optional, string
2009
- // 'side': 'buy', // or 'sell', optional, case insensitive.
2010
- // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
2011
- // 'startTime': exchange.milliseconds (),
2012
- // 'endTime': exchange.milliseconds (),
2013
- // 'page': 1,
2014
- // 'pageSize': 100,
2005
+ // 'category': accountCategory,
2006
+ // 'symbol': market['id'],
2007
+ // 'orderType': 'market', // optional, string
2008
+ // 'side': 'buy', // or 'sell', optional, case insensitive.
2009
+ // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
2010
+ // 'startTime': exchange.milliseconds (),
2011
+ // 'endTime': exchange.milliseconds (),
2012
+ // 'page': 1,
2013
+ // 'pageSize': 100,
2015
2014
  };
2016
2015
  let market = undefined;
2017
2016
  if (symbol !== undefined) {
@@ -2026,28 +2025,42 @@ export default class ascendex extends Exchange {
2026
2025
  'margin': defaultMethod,
2027
2026
  'swap': 'v2PrivateAccountGroupGetFuturesOrderHistCurrent',
2028
2027
  });
2028
+ if (since !== undefined) {
2029
+ request['startTime'] = since;
2030
+ }
2031
+ const until = this.safeString(params, 'until');
2032
+ if (until !== undefined) {
2033
+ request['endTime'] = until;
2034
+ }
2029
2035
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
2030
2036
  const accountCategory = this.safeString(accountsByType, type, 'cash'); // margin, futures
2031
- if (method === 'v2PrivateDataGetOrderHist') {
2037
+ let response = undefined;
2038
+ if (method === 'v1PrivateAccountCategoryGetOrderHistCurrent') {
2039
+ request['account-group'] = accountGroup;
2040
+ request['account-category'] = accountCategory;
2041
+ if (limit !== undefined) {
2042
+ request['limit'] = limit;
2043
+ }
2044
+ response = await this.v1PrivateAccountCategoryGetOrderHistCurrent(this.extend(request, query));
2045
+ }
2046
+ else if (method === 'v2PrivateDataGetOrderHist') {
2032
2047
  request['account'] = accountCategory;
2033
2048
  if (limit !== undefined) {
2034
2049
  request['limit'] = limit;
2035
2050
  }
2051
+ response = await this.v2PrivateDataGetOrderHist(this.extend(request, query));
2036
2052
  }
2037
- else {
2053
+ else if (method === 'v2PrivateAccountGroupGetFuturesOrderHistCurrent') {
2054
+ request['account-group'] = accountGroup;
2038
2055
  request['account-category'] = accountCategory;
2039
2056
  if (limit !== undefined) {
2040
2057
  request['pageSize'] = limit;
2041
2058
  }
2059
+ response = await this.v2PrivateAccountGroupGetFuturesOrderHistCurrent(this.extend(request, query));
2042
2060
  }
2043
- if (since !== undefined) {
2044
- request['startTime'] = since;
2045
- }
2046
- const until = this.safeString(params, 'until');
2047
- if (until !== undefined) {
2048
- request['endTime'] = until;
2061
+ else {
2062
+ throw new NotSupported(this.id + ' fetchClosedOrders() is not currently supported for ' + type + ' markets');
2049
2063
  }
2050
- const response = await this[method](this.extend(request, query));
2051
2064
  //
2052
2065
  // accountCategoryGetOrderHistCurrent
2053
2066
  //
@@ -2151,6 +2164,8 @@ export default class ascendex extends Exchange {
2151
2164
  * @method
2152
2165
  * @name ascendex#cancelOrder
2153
2166
  * @description cancels an open order
2167
+ * @see https://ascendex.github.io/ascendex-pro-api/#cancel-order
2168
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
2154
2169
  * @param {string} id order id
2155
2170
  * @param {string} symbol unified symbol of the market the order was made in
2156
2171
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2163,7 +2178,6 @@ export default class ascendex extends Exchange {
2163
2178
  await this.loadAccounts();
2164
2179
  const market = this.market(symbol);
2165
2180
  const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
2166
- const options = this.safeValue(this.options, 'cancelOrder', {});
2167
2181
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
2168
2182
  const accountCategory = this.safeString(accountsByType, type, 'cash');
2169
2183
  const account = this.safeValue(this.accounts, 0, {});
@@ -2175,20 +2189,6 @@ export default class ascendex extends Exchange {
2175
2189
  'time': this.milliseconds(),
2176
2190
  'id': 'foobar',
2177
2191
  };
2178
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryDeleteOrder');
2179
- const method = this.getSupportedMapping(type, {
2180
- 'spot': defaultMethod,
2181
- 'margin': defaultMethod,
2182
- 'swap': 'v2PrivateAccountGroupDeleteFuturesOrder',
2183
- });
2184
- if (method === 'v1PrivateAccountCategoryDeleteOrder') {
2185
- if (accountCategory !== undefined) {
2186
- request['category'] = accountCategory;
2187
- }
2188
- }
2189
- else {
2190
- request['account-category'] = accountCategory;
2191
- }
2192
2192
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'id');
2193
2193
  if (clientOrderId === undefined) {
2194
2194
  request['orderId'] = id;
@@ -2197,7 +2197,17 @@ export default class ascendex extends Exchange {
2197
2197
  request['id'] = clientOrderId;
2198
2198
  params = this.omit(params, ['clientOrderId', 'id']);
2199
2199
  }
2200
- const response = await this[method](this.extend(request, query));
2200
+ let response = undefined;
2201
+ if ((type === 'spot') || (type === 'margin')) {
2202
+ response = await this.v1PrivateAccountCategoryDeleteOrder(this.extend(request, query));
2203
+ }
2204
+ else if (type === 'swap') {
2205
+ request['account-category'] = accountCategory;
2206
+ response = await this.v2PrivateAccountGroupDeleteFuturesOrder(this.extend(request, query));
2207
+ }
2208
+ else {
2209
+ throw new NotSupported(this.id + ' cancelOrder() is not currently supported for ' + type + ' markets');
2210
+ }
2201
2211
  //
2202
2212
  // AccountCategoryDeleteOrder
2203
2213
  //
@@ -2270,6 +2280,8 @@ export default class ascendex extends Exchange {
2270
2280
  * @method
2271
2281
  * @name ascendex#cancelAllOrders
2272
2282
  * @description cancel all open orders
2283
+ * @see https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
2284
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
2273
2285
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2274
2286
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2275
2287
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -2281,7 +2293,6 @@ export default class ascendex extends Exchange {
2281
2293
  market = this.market(symbol);
2282
2294
  }
2283
2295
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
2284
- const options = this.safeValue(this.options, 'cancelAllOrders', {});
2285
2296
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
2286
2297
  const accountCategory = this.safeString(accountsByType, type, 'cash');
2287
2298
  const account = this.safeValue(this.accounts, 0, {});
@@ -2294,21 +2305,17 @@ export default class ascendex extends Exchange {
2294
2305
  if (symbol !== undefined) {
2295
2306
  request['symbol'] = market['id'];
2296
2307
  }
2297
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryDeleteOrderAll');
2298
- const method = this.getSupportedMapping(type, {
2299
- 'spot': defaultMethod,
2300
- 'margin': defaultMethod,
2301
- 'swap': 'v2PrivateAccountGroupDeleteFuturesOrderAll',
2302
- });
2303
- if (method === 'v1PrivateAccountCategoryDeleteOrderAll') {
2304
- if (accountCategory !== undefined) {
2305
- request['category'] = accountCategory;
2306
- }
2308
+ let response = undefined;
2309
+ if ((type === 'spot') || (type === 'margin')) {
2310
+ response = await this.v1PrivateAccountCategoryDeleteOrderAll(this.extend(request, query));
2307
2311
  }
2308
- else {
2312
+ else if (type === 'swap') {
2309
2313
  request['account-category'] = accountCategory;
2314
+ response = await this.v2PrivateAccountGroupDeleteFuturesOrderAll(this.extend(request, query));
2315
+ }
2316
+ else {
2317
+ throw new NotSupported(this.id + ' cancelAllOrders() is not currently supported for ' + type + ' markets');
2310
2318
  }
2311
- const response = await this[method](this.extend(request, query));
2312
2319
  //
2313
2320
  // AccountCategoryDeleteOrderAll
2314
2321
  //
package/js/src/phemex.js CHANGED
@@ -147,6 +147,7 @@ export default class phemex extends Exchange {
147
147
  },
148
148
  'v1': {
149
149
  'get': {
150
+ 'md/fullbook': 5,
150
151
  'md/orderbook': 5,
151
152
  'md/trade': 5,
152
153
  'md/ticker/24hr': 5,
@@ -200,6 +201,11 @@ export default class phemex extends Exchange {
200
201
  'phemex-user/users/children': 5,
201
202
  'phemex-user/wallets/v2/depositAddress': 5,
202
203
  'phemex-user/wallets/tradeAccountDetail': 5,
204
+ 'phemex-deposit/wallets/api/depositAddress': 5,
205
+ 'phemex-deposit/wallets/api/depositHist': 5,
206
+ 'phemex-deposit/wallets/api/chainCfg': 5,
207
+ 'phemex-withdraw/wallets/api/withdrawHist': 5,
208
+ 'phemex-withdraw/wallets/api/asset/info': 5,
203
209
  'phemex-user/order/closedPositionList': 5,
204
210
  'exchange/margins/transfer': 5,
205
211
  'exchange/wallets/confirm/withdraw': 5,
@@ -238,6 +244,9 @@ export default class phemex extends Exchange {
238
244
  'assets/futures/sub-accounts/transfer': 5,
239
245
  'assets/universal-transfer': 5,
240
246
  'assets/convert': 5,
247
+ // withdraw
248
+ 'phemex-withdraw/wallets/api/createWithdraw': 5,
249
+ 'phemex-withdraw/wallets/api/cancelWithdraw': 5, // ?id=<id>
241
250
  },
242
251
  'put': {
243
252
  // spot
@@ -994,7 +1003,12 @@ export default class phemex extends Exchange {
994
1003
  response = await this.v2GetMdV2Orderbook(this.extend(request, params));
995
1004
  }
996
1005
  else {
997
- response = await this.v1GetMdOrderbook(this.extend(request, params));
1006
+ if ((limit !== undefined) && (limit <= 30)) {
1007
+ response = await this.v1GetMdOrderbook(this.extend(request, params));
1008
+ }
1009
+ else {
1010
+ response = await this.v1GetMdFullbook(this.extend(request, params));
1011
+ }
998
1012
  }
999
1013
  //
1000
1014
  // {
package/js/src/pro/htx.js CHANGED
@@ -340,9 +340,11 @@ export default class htx extends htxRest {
340
340
  // which means whenever there is an order book change at that level, it pushes an update;
341
341
  // 150-levels/400-level incremental MBP feed is based on the gap
342
342
  // between two snapshots at 100ms interval.
343
- limit = (limit === undefined) ? 20 : limit;
343
+ if (limit === undefined) {
344
+ limit = market['spot'] ? 150 : 20;
345
+ }
344
346
  if (!this.inArray(limit, allowedLimits)) {
345
- throw new ExchangeError(this.id + ' watchOrderBook swap market accepts limits of 20 and 150 only');
347
+ throw new ExchangeError(this.id + ' watchOrderBook market accepts limits of 20 and 150 only');
346
348
  }
347
349
  let messageHash = undefined;
348
350
  if (market['spot']) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.68",
3
+ "version": "4.1.69",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",
package/skip-tests.json CHANGED
@@ -1086,6 +1086,7 @@
1086
1086
  }
1087
1087
  },
1088
1088
  "kuna": {
1089
+ "skip": "temporary glitches with this exchange: https://app.travis-ci.com/github/ccxt/ccxt/builds/267517440#L2304",
1089
1090
  "httpProxy": "http://5.75.153.75:8002",
1090
1091
  "skipPhpAsync": true,
1091
1092
  "skipMethods": {
@@ -1095,7 +1096,8 @@
1095
1096
  "fetchCurrencies": {
1096
1097
  "deposit":"is undefined",
1097
1098
  "withdraw":"is undefined",
1098
- "active":"is undefined"
1099
+ "active":"is undefined",
1100
+ "precision":"somewhat strange atm https://app.travis-ci.com/github/ccxt/ccxt/builds/267515280#L2337"
1099
1101
  }
1100
1102
  }
1101
1103
  },
@@ -1386,9 +1388,13 @@
1386
1388
  "skipWs": true,
1387
1389
  "skipPhpAsync": true,
1388
1390
  "skipMethods": {
1391
+ "loadMarkets": {
1392
+ "currencyIdAndCode": "https://app.travis-ci.com/github/ccxt/ccxt/builds/267515280#L2314"
1393
+ },
1389
1394
  "fetchCurrencies": {
1390
1395
  "withdraw": "undefined",
1391
- "deposit": "undefined"
1396
+ "deposit": "undefined",
1397
+ "currencyIdAndCode": "same as in loadMarkets"
1392
1398
  },
1393
1399
  "fetchTickers": {
1394
1400
  "quoteVolume": "quoteVolume <= baseVolume * high is failing",