ccxt 4.4.37 → 4.4.39

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.
Files changed (52) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +73 -2
  5. package/dist/cjs/src/base/Exchange.js +31 -10
  6. package/dist/cjs/src/binance.js +0 -2
  7. package/dist/cjs/src/bingx.js +93 -8
  8. package/dist/cjs/src/bitget.js +0 -2
  9. package/dist/cjs/src/bithumb.js +1 -1
  10. package/dist/cjs/src/bitmart.js +163 -15
  11. package/dist/cjs/src/bybit.js +3 -2
  12. package/dist/cjs/src/digifinex.js +58 -18
  13. package/dist/cjs/src/htx.js +154 -32
  14. package/dist/cjs/src/kucoin.js +77 -2
  15. package/dist/cjs/src/kucoinfutures.js +93 -5
  16. package/dist/cjs/src/mexc.js +36 -25
  17. package/dist/cjs/src/ndax.js +7 -2
  18. package/dist/cjs/src/okx.js +1 -1
  19. package/dist/cjs/src/pro/woo.js +1 -1
  20. package/dist/cjs/src/probit.js +3 -1
  21. package/dist/cjs/src/woo.js +4 -4
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/bingx.d.ts +0 -1
  25. package/js/src/abstract/digifinex.d.ts +1 -0
  26. package/js/src/abstract/mexc.d.ts +1 -0
  27. package/js/src/alpaca.d.ts +11 -1
  28. package/js/src/alpaca.js +73 -2
  29. package/js/src/base/Exchange.js +31 -10
  30. package/js/src/binance.js +0 -2
  31. package/js/src/bingx.d.ts +14 -1
  32. package/js/src/bingx.js +93 -8
  33. package/js/src/bitget.js +0 -2
  34. package/js/src/bithumb.js +1 -1
  35. package/js/src/bitmart.js +163 -15
  36. package/js/src/bybit.js +3 -2
  37. package/js/src/digifinex.d.ts +4 -2
  38. package/js/src/digifinex.js +58 -18
  39. package/js/src/htx.d.ts +5 -5
  40. package/js/src/htx.js +154 -32
  41. package/js/src/kucoin.js +77 -2
  42. package/js/src/kucoinfutures.js +93 -5
  43. package/js/src/mexc.d.ts +7 -7
  44. package/js/src/mexc.js +36 -25
  45. package/js/src/ndax.d.ts +2 -0
  46. package/js/src/ndax.js +7 -2
  47. package/js/src/okx.d.ts +1 -0
  48. package/js/src/okx.js +1 -1
  49. package/js/src/pro/woo.js +1 -1
  50. package/js/src/probit.js +3 -1
  51. package/js/src/woo.js +4 -4
  52. package/package.json +1 -1
@@ -557,6 +557,7 @@ class kucoin extends kucoin$1 {
557
557
  '400008': errors.NotSupported,
558
558
  '400100': errors.InsufficientFunds,
559
559
  '400200': errors.InvalidOrder,
560
+ '400330': errors.InvalidOrder,
560
561
  '400350': errors.InvalidOrder,
561
562
  '400370': errors.InvalidOrder,
562
563
  '400400': errors.BadRequest,
@@ -908,6 +909,7 @@ class kucoin extends kucoin$1 {
908
909
  'TRUE': 'true',
909
910
  'CS': 'cs',
910
911
  'ORAI': 'orai',
912
+ 'BASE': 'base',
911
913
  // below will be uncommented after consensus
912
914
  // 'BITCOINDIAMON': 'bcd',
913
915
  // 'BITCOINGOLD': 'btg',
@@ -983,6 +985,74 @@ class kucoin extends kucoin$1 {
983
985
  'spot': 'TRADE',
984
986
  },
985
987
  },
988
+ 'features': {
989
+ 'spot': {
990
+ 'sandbox': false,
991
+ 'createOrder': {
992
+ 'marginMode': true,
993
+ 'triggerPrice': true,
994
+ 'triggerPriceType': undefined,
995
+ 'triggerDirection': false,
996
+ 'stopLossPrice': true,
997
+ 'takeProfitPrice': true,
998
+ 'attachedStopLossTakeProfit': undefined,
999
+ 'timeInForce': {
1000
+ 'IOC': true,
1001
+ 'FOK': true,
1002
+ 'PO': true,
1003
+ 'GTD': true,
1004
+ },
1005
+ 'hedged': false,
1006
+ 'trailing': false,
1007
+ // exchange-supported features
1008
+ // 'iceberg': true,
1009
+ // 'selfTradePrevention': true,
1010
+ // 'twap': false,
1011
+ // 'oco': false,
1012
+ },
1013
+ 'createOrders': {
1014
+ 'max': 5,
1015
+ },
1016
+ 'fetchMyTrades': {
1017
+ 'marginMode': true,
1018
+ 'limit': undefined,
1019
+ 'daysBack': undefined,
1020
+ 'untilDays': 7, // per implementation comments
1021
+ },
1022
+ 'fetchOrder': {
1023
+ 'marginMode': false,
1024
+ 'trigger': true,
1025
+ 'trailing': false,
1026
+ },
1027
+ 'fetchOpenOrders': {
1028
+ 'marginMode': true,
1029
+ 'limit': 500,
1030
+ 'trigger': true,
1031
+ 'trailing': false,
1032
+ },
1033
+ 'fetchOrders': undefined,
1034
+ 'fetchClosedOrders': {
1035
+ 'marginMode': true,
1036
+ 'limit': 500,
1037
+ 'daysBackClosed': undefined,
1038
+ 'daysBackCanceled': undefined,
1039
+ 'untilDays': 7,
1040
+ 'trigger': true,
1041
+ 'trailing': false,
1042
+ },
1043
+ 'fetchOHLCV': {
1044
+ 'limit': 1500,
1045
+ },
1046
+ },
1047
+ 'swap': {
1048
+ 'linear': undefined,
1049
+ 'inverse': undefined,
1050
+ },
1051
+ 'future': {
1052
+ 'linear': undefined,
1053
+ 'inverse': undefined,
1054
+ },
1055
+ },
986
1056
  });
987
1057
  }
988
1058
  nonce() {
@@ -2691,7 +2761,7 @@ class kucoin extends kucoin$1 {
2691
2761
  await this.loadMarkets();
2692
2762
  let lowercaseStatus = status.toLowerCase();
2693
2763
  const until = this.safeInteger(params, 'until');
2694
- const stop = this.safeBool2(params, 'stop', 'trigger', false);
2764
+ const trigger = this.safeBool2(params, 'stop', 'trigger', false);
2695
2765
  let hf = undefined;
2696
2766
  [hf, params] = this.handleHfAndParams(params);
2697
2767
  if (hf && (symbol === undefined)) {
@@ -2724,7 +2794,7 @@ class kucoin extends kucoin$1 {
2724
2794
  }
2725
2795
  request['tradeType'] = this.safeString(this.options['marginModes'], marginMode, 'TRADE');
2726
2796
  let response = undefined;
2727
- if (stop) {
2797
+ if (trigger) {
2728
2798
  response = await this.privateGetStopOrder(this.extend(request, query));
2729
2799
  }
2730
2800
  else if (hf) {
@@ -3170,6 +3240,11 @@ class kucoin extends kucoin$1 {
3170
3240
  let response = undefined;
3171
3241
  [request, params] = this.handleUntilOption('endAt', request, params);
3172
3242
  if (hf) {
3243
+ // does not return trades earlier than 2019-02-18T00:00:00Z
3244
+ if (since !== undefined) {
3245
+ // only returns trades up to one week after the since param
3246
+ request['startAt'] = since;
3247
+ }
3173
3248
  response = await this.privateGetHfFills(this.extend(request, params));
3174
3249
  }
3175
3250
  else if (method === 'private_get_fills') {
@@ -357,6 +357,91 @@ class kucoinfutures extends kucoinfutures$1 {
357
357
  // 'code': 'BTC',
358
358
  // },
359
359
  },
360
+ 'features': {
361
+ 'spot': undefined,
362
+ 'forDerivs': {
363
+ 'sandbox': false,
364
+ 'createOrder': {
365
+ 'marginMode': true,
366
+ 'triggerPrice': true,
367
+ 'triggerPriceType': {
368
+ 'last': true,
369
+ 'mark': true,
370
+ 'index': true,
371
+ },
372
+ 'triggerDirection': true,
373
+ 'stopLossPrice': true,
374
+ 'takeProfitPrice': true,
375
+ 'attachedStopLossTakeProfit': {
376
+ 'triggerPrice': undefined,
377
+ 'triggerPriceType': undefined,
378
+ 'limitPrice': true,
379
+ },
380
+ 'timeInForce': {
381
+ 'IOC': true,
382
+ 'FOK': false,
383
+ 'PO': true,
384
+ 'GTD': false,
385
+ },
386
+ 'hedged': false,
387
+ 'trailing': false,
388
+ // exchange-supported features
389
+ // 'iceberg': true,
390
+ // 'selfTradePrevention': true,
391
+ // 'twap': false,
392
+ // 'oco': false,
393
+ },
394
+ 'createOrders': {
395
+ 'max': 20,
396
+ },
397
+ 'fetchMyTrades': {
398
+ 'marginMode': true,
399
+ 'limit': 1000,
400
+ 'daysBack': undefined,
401
+ 'untilDays': 7,
402
+ },
403
+ 'fetchOrder': {
404
+ 'marginMode': false,
405
+ 'trigger': false,
406
+ 'trailing': false,
407
+ },
408
+ 'fetchOpenOrders': {
409
+ 'marginMode': false,
410
+ 'limit': 1000,
411
+ 'trigger': true,
412
+ 'trailing': false,
413
+ },
414
+ 'fetchOrders': undefined,
415
+ 'fetchClosedOrders': {
416
+ 'marginMode': false,
417
+ 'limit': 1000,
418
+ 'daysBackClosed': undefined,
419
+ 'daysBackCanceled': undefined,
420
+ 'untilDays': undefined,
421
+ 'trigger': true,
422
+ 'trailing': false,
423
+ },
424
+ 'fetchOHLCV': {
425
+ 'limit': 500,
426
+ },
427
+ },
428
+ 'swap': {
429
+ 'linear': {
430
+ 'extends': 'forDerivs',
431
+ },
432
+ 'inverse': {
433
+ 'extends': 'forDerivs',
434
+ },
435
+ },
436
+ 'future': {
437
+ 'linear': {
438
+ 'extends': 'forDerivs',
439
+ },
440
+ 'inverse': {
441
+ 'extends': 'forDerivs',
442
+ },
443
+ },
444
+ },
360
445
  });
361
446
  }
362
447
  /**
@@ -1751,10 +1836,10 @@ class kucoinfutures extends kucoinfutures$1 {
1751
1836
  if (symbol !== undefined) {
1752
1837
  request['symbol'] = this.marketId(symbol);
1753
1838
  }
1754
- const stop = this.safeValue2(params, 'stop', 'trigger');
1839
+ const trigger = this.safeValue2(params, 'stop', 'trigger');
1755
1840
  params = this.omit(params, ['stop', 'trigger']);
1756
1841
  let response = undefined;
1757
- if (stop) {
1842
+ if (trigger) {
1758
1843
  response = await this.futuresPrivateDeleteStopOrders(this.extend(request, params));
1759
1844
  }
1760
1845
  else {
@@ -1938,7 +2023,7 @@ class kucoinfutures extends kucoinfutures$1 {
1938
2023
  if (paginate) {
1939
2024
  return await this.fetchPaginatedCallDynamic('fetchOrdersByStatus', symbol, since, limit, params);
1940
2025
  }
1941
- const stop = this.safeBool2(params, 'stop', 'trigger');
2026
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
1942
2027
  const until = this.safeInteger(params, 'until');
1943
2028
  params = this.omit(params, ['stop', 'until', 'trigger']);
1944
2029
  if (status === 'closed') {
@@ -1948,7 +2033,7 @@ class kucoinfutures extends kucoinfutures$1 {
1948
2033
  status = 'active';
1949
2034
  }
1950
2035
  const request = {};
1951
- if (!stop) {
2036
+ if (!trigger) {
1952
2037
  request['status'] = status;
1953
2038
  }
1954
2039
  else if (status !== 'active') {
@@ -1966,7 +2051,7 @@ class kucoinfutures extends kucoinfutures$1 {
1966
2051
  request['endAt'] = until;
1967
2052
  }
1968
2053
  let response = undefined;
1969
- if (stop) {
2054
+ if (trigger) {
1970
2055
  response = await this.futuresPrivateGetStopOrders(this.extend(request, params));
1971
2056
  }
1972
2057
  else {
@@ -2591,6 +2676,9 @@ class kucoinfutures extends kucoinfutures$1 {
2591
2676
  if (since !== undefined) {
2592
2677
  request['startAt'] = since;
2593
2678
  }
2679
+ if (limit !== undefined) {
2680
+ request['pageSize'] = Math.min(1000, limit);
2681
+ }
2594
2682
  [request, params] = this.handleUntilOption('endAt', request, params);
2595
2683
  const response = await this.futuresPrivateGetFills(this.extend(request, params));
2596
2684
  //
@@ -118,8 +118,8 @@ class mexc extends mexc$1 {
118
118
  'fetchTickers': true,
119
119
  'fetchTime': true,
120
120
  'fetchTrades': true,
121
- 'fetchTradingFee': undefined,
122
- 'fetchTradingFees': true,
121
+ 'fetchTradingFee': true,
122
+ 'fetchTradingFees': false,
123
123
  'fetchTradingLimits': undefined,
124
124
  'fetchTransactionFee': 'emulated',
125
125
  'fetchTransactionFees': true,
@@ -192,6 +192,7 @@ class mexc extends mexc$1 {
192
192
  'allOrders': 10,
193
193
  'account': 10,
194
194
  'myTrades': 10,
195
+ 'tradeFee': 10,
195
196
  'sub-account/list': 1,
196
197
  'sub-account/apiKey': 1,
197
198
  'capital/config/getall': 10,
@@ -3603,33 +3604,43 @@ class mexc extends mexc$1 {
3603
3604
  }
3604
3605
  /**
3605
3606
  * @method
3606
- * @name mexc#fetchTradingFees
3607
- * @description fetch the trading fees for multiple markets
3608
- * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3609
- * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3607
+ * @name mexc#fetchTradingFee
3608
+ * @description fetch the trading fees for a market
3609
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-mx-deduct-status
3610
+ * @param {string} symbol unified market symbol
3610
3611
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3611
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
3612
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
3612
3613
  */
3613
- async fetchTradingFees(params = {}) {
3614
+ async fetchTradingFee(symbol, params = {}) {
3614
3615
  await this.loadMarkets();
3615
- const response = await this.fetchAccountHelper('spot', params);
3616
- let makerFee = this.safeString(response, 'makerCommission');
3617
- let takerFee = this.safeString(response, 'takerCommission');
3618
- makerFee = Precise["default"].stringDiv(makerFee, '1000');
3619
- takerFee = Precise["default"].stringDiv(takerFee, '1000');
3620
- const result = {};
3621
- for (let i = 0; i < this.symbols.length; i++) {
3622
- const symbol = this.symbols[i];
3623
- result[symbol] = {
3624
- 'symbol': symbol,
3625
- 'maker': this.parseNumber(makerFee),
3626
- 'taker': this.parseNumber(takerFee),
3627
- 'percentage': true,
3628
- 'tierBased': false,
3629
- 'info': response,
3630
- };
3616
+ const market = this.market(symbol);
3617
+ if (!market['spot']) {
3618
+ throw new errors.BadRequest(this.id + ' fetchTradingFee() supports spot markets only');
3631
3619
  }
3632
- return result;
3620
+ const request = {
3621
+ 'symbol': market['id'],
3622
+ };
3623
+ const response = await this.spotPrivateGetTradeFee(this.extend(request, params));
3624
+ //
3625
+ // {
3626
+ // "data":{
3627
+ // "makerCommission":0.003000000000000000,
3628
+ // "takerCommission":0.003000000000000000
3629
+ // },
3630
+ // "code":0,
3631
+ // "msg":"success",
3632
+ // "timestamp":1669109672717
3633
+ // }
3634
+ //
3635
+ const data = this.safeDict(response, 'data', {});
3636
+ return {
3637
+ 'info': data,
3638
+ 'symbol': symbol,
3639
+ 'maker': this.safeNumber(data, 'makerCommission'),
3640
+ 'taker': this.safeNumber(data, 'takerCommission'),
3641
+ 'percentage': undefined,
3642
+ 'tierBased': undefined,
3643
+ };
3633
3644
  }
3634
3645
  customParseBalance(response, marketType) {
3635
3646
  //
@@ -1089,8 +1089,11 @@ class ndax extends ndax$1 {
1089
1089
  const omsId = this.safeInteger(this.options, 'omsId', 1);
1090
1090
  await this.loadMarkets();
1091
1091
  await this.loadAccounts();
1092
- const defaultAccountId = this.safeInteger2(this.options, 'accountId', 'AccountId', parseInt(this.accounts[0]['id']));
1093
- const accountId = this.safeInteger2(params, 'accountId', 'AccountId', defaultAccountId);
1092
+ const defaultAccountId = this.safeInteger2(this.options, 'accountId', 'AccountId');
1093
+ let accountId = this.safeInteger2(params, 'accountId', 'AccountId', defaultAccountId);
1094
+ if (accountId === undefined) {
1095
+ accountId = parseInt(this.accounts[0]['id']);
1096
+ }
1094
1097
  params = this.omit(params, ['accountId', 'AccountId']);
1095
1098
  const request = {
1096
1099
  'omsId': omsId,
@@ -1373,6 +1376,7 @@ class ndax extends ndax$1 {
1373
1376
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1374
1377
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1375
1378
  * @param {float} [params.triggerPrice] the price at which a trigger order would be triggered
1379
+ * @param {string} [params.clientOrderId] a unique id for the order
1376
1380
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1377
1381
  */
1378
1382
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1615,6 +1619,7 @@ class ndax extends ndax$1 {
1615
1619
  * @param {string} id order id
1616
1620
  * @param {string} symbol unified symbol of the market the order was made in
1617
1621
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1622
+ * @param {string} [params.clientOrderId] a unique id for the order
1618
1623
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1619
1624
  */
1620
1625
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -1198,7 +1198,6 @@ class okx extends okx$1 {
1198
1198
  'limitPrice': true,
1199
1199
  },
1200
1200
  'timeInForce': {
1201
- 'GTC': true,
1202
1201
  'IOC': true,
1203
1202
  'FOK': true,
1204
1203
  'PO': true,
@@ -2255,6 +2254,7 @@ class okx extends okx$1 {
2255
2254
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
2256
2255
  * @param {int} [limit] the maximum amount of trades to fetch
2257
2256
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2257
+ * @param {string} [params.method] 'publicGetMarketTrades' or 'publicGetMarketHistoryTrades' default is 'publicGetMarketTrades'
2258
2258
  * @param {boolean} [params.paginate] *only applies to publicGetMarketHistoryTrades* default false, when true will automatically paginate by calling this endpoint multiple times
2259
2259
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
2260
2260
  */
@@ -881,7 +881,7 @@ class woo extends woo$1 {
881
881
  'triggerPrice': undefined,
882
882
  'amount': amount,
883
883
  'cost': undefined,
884
- 'average': undefined,
884
+ 'average': avgPrice,
885
885
  'filled': filled,
886
886
  'remaining': remaining,
887
887
  'status': status,
@@ -271,6 +271,8 @@ class probit extends probit$1 {
271
271
  const base = this.safeCurrencyCode(baseId);
272
272
  const quote = this.safeCurrencyCode(quoteId);
273
273
  const closed = this.safeBool(market, 'closed', false);
274
+ const showInUI = this.safeBool(market, 'show_in_ui', true);
275
+ const active = !closed && showInUI;
274
276
  const takerFeeRate = this.safeString(market, 'taker_fee_rate');
275
277
  const taker = Precise["default"].stringDiv(takerFeeRate, '100');
276
278
  const makerFeeRate = this.safeString(market, 'maker_fee_rate');
@@ -290,7 +292,7 @@ class probit extends probit$1 {
290
292
  'swap': false,
291
293
  'future': false,
292
294
  'option': false,
293
- 'active': !closed,
295
+ 'active': active,
294
296
  'contract': false,
295
297
  'linear': undefined,
296
298
  'inverse': undefined,
@@ -113,7 +113,7 @@ class woo extends woo$1 {
113
113
  'setMargin': false,
114
114
  'setPositionMode': true,
115
115
  'transfer': true,
116
- 'withdraw': true, // exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://kronosresearch.github.io/wootrade-documents/#token-withdraw
116
+ 'withdraw': true, // exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://docx.woo.io/wootrade-documents/#token-withdraw
117
117
  },
118
118
  'timeframes': {
119
119
  '1m': '1m',
@@ -157,7 +157,7 @@ class woo extends woo$1 {
157
157
  'pub': {
158
158
  'get': {
159
159
  'hist/kline': 10,
160
- 'hist/trades': 1,
160
+ 'hist/trades': 10,
161
161
  },
162
162
  },
163
163
  'public': {
@@ -207,7 +207,7 @@ class woo extends woo$1 {
207
207
  'client/futures_leverage': 60,
208
208
  },
209
209
  'post': {
210
- 'order': 5,
210
+ 'order': 1,
211
211
  'order/cancel_all_after': 1,
212
212
  'asset/main_sub_transfer': 30,
213
213
  'asset/ltv': 30,
@@ -224,7 +224,7 @@ class woo extends woo$1 {
224
224
  'order': 1,
225
225
  'client/order': 1,
226
226
  'orders': 1,
227
- 'asset/withdraw': 120, // implemented in ccxt, disabled on the exchange side https://kronosresearch.github.io/wootrade-documents/#cancel-withdraw-request
227
+ 'asset/withdraw': 120, // implemented in ccxt, disabled on the exchange side https://docx.woo.io/wootrade-documents/#cancel-withdraw-request
228
228
  },
229
229
  },
230
230
  },
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.36";
7
+ declare const version = "4.4.38";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.4.37';
41
+ const version = '4.4.39';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -34,7 +34,6 @@ interface Exchange {
34
34
  swapV1PublicGetMarketMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
35
35
  swapV1PublicGetTradeMultiAssetsRules(params?: {}): Promise<implicitReturnType>;
36
36
  swapV1PrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
37
- swapV1PrivateGetMarketMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
38
37
  swapV1PrivateGetTradeBatchCancelReplace(params?: {}): Promise<implicitReturnType>;
39
38
  swapV1PrivateGetTradeFullOrder(params?: {}): Promise<implicitReturnType>;
40
39
  swapV1PrivateGetMaintMarginRatio(params?: {}): Promise<implicitReturnType>;
@@ -70,6 +70,7 @@ interface Exchange {
70
70
  privateSwapGetTradeHistoryTrades(params?: {}): Promise<implicitReturnType>;
71
71
  privateSwapGetTradeOpenOrders(params?: {}): Promise<implicitReturnType>;
72
72
  privateSwapGetTradeOrderInfo(params?: {}): Promise<implicitReturnType>;
73
+ privateSwapPostAccountTransfer(params?: {}): Promise<implicitReturnType>;
73
74
  privateSwapPostAccountLeverage(params?: {}): Promise<implicitReturnType>;
74
75
  privateSwapPostAccountPositionMode(params?: {}): Promise<implicitReturnType>;
75
76
  privateSwapPostAccountPositionMargin(params?: {}): Promise<implicitReturnType>;
@@ -19,6 +19,7 @@ interface Exchange {
19
19
  spotPrivateGetAllOrders(params?: {}): Promise<implicitReturnType>;
20
20
  spotPrivateGetAccount(params?: {}): Promise<implicitReturnType>;
21
21
  spotPrivateGetMyTrades(params?: {}): Promise<implicitReturnType>;
22
+ spotPrivateGetTradeFee(params?: {}): Promise<implicitReturnType>;
22
23
  spotPrivateGetSubAccountList(params?: {}): Promise<implicitReturnType>;
23
24
  spotPrivateGetSubAccountApiKey(params?: {}): Promise<implicitReturnType>;
24
25
  spotPrivateGetCapitalConfigGetall(params?: {}): Promise<implicitReturnType>;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/alpaca.js';
2
- import type { Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Trade, int, Strings, Ticker, Tickers, Currency, DepositAddress, Transaction } from './base/types.js';
2
+ import type { Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Trade, int, Strings, Ticker, Tickers, Currency, DepositAddress, Transaction, Balances } from './base/types.js';
3
3
  /**
4
4
  * @class alpaca
5
5
  * @augments Exchange
@@ -276,6 +276,16 @@ export default class alpaca extends Exchange {
276
276
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
277
277
  parseTransactionStatus(status: Str): string;
278
278
  parseTransactionType(type: any): string;
279
+ /**
280
+ * @method
281
+ * @name alpaca#fetchBalance
282
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
283
+ * @see https://docs.alpaca.markets/reference/getaccount-1
284
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
285
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
286
+ */
287
+ fetchBalance(params?: {}): Promise<Balances>;
288
+ parseBalance(response: any): Balances;
279
289
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
280
290
  url: string;
281
291
  method: string;
package/js/src/alpaca.js CHANGED
@@ -37,7 +37,7 @@ export default class alpaca extends Exchange {
37
37
  'test': {
38
38
  'broker': 'https://broker-api.sandbox.{hostname}',
39
39
  'trader': 'https://paper-api.{hostname}',
40
- 'market': 'https://data.sandbox.{hostname}',
40
+ 'market': 'https://data.{hostname}',
41
41
  },
42
42
  'doc': 'https://alpaca.markets/docs/',
43
43
  'fees': 'https://docs.alpaca.markets/docs/crypto-fees',
@@ -57,7 +57,7 @@ export default class alpaca extends Exchange {
57
57
  'createStopOrder': true,
58
58
  'createTriggerOrder': true,
59
59
  'editOrder': true,
60
- 'fetchBalance': false,
60
+ 'fetchBalance': true,
61
61
  'fetchBidsAsks': false,
62
62
  'fetchClosedOrders': true,
63
63
  'fetchCurrencies': false,
@@ -1589,6 +1589,77 @@ export default class alpaca extends Exchange {
1589
1589
  };
1590
1590
  return this.safeString(types, type, type);
1591
1591
  }
1592
+ /**
1593
+ * @method
1594
+ * @name alpaca#fetchBalance
1595
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1596
+ * @see https://docs.alpaca.markets/reference/getaccount-1
1597
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1598
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1599
+ */
1600
+ async fetchBalance(params = {}) {
1601
+ await this.loadMarkets();
1602
+ const response = await this.traderPrivateGetV2Account(params);
1603
+ //
1604
+ // {
1605
+ // "id": "43a01bde-4eb1-64fssc26adb5",
1606
+ // "admin_configurations": {
1607
+ // "allow_instant_ach": true,
1608
+ // "max_margin_multiplier": "4"
1609
+ // },
1610
+ // "user_configurations": {
1611
+ // "fractional_trading": true,
1612
+ // "max_margin_multiplier": "4"
1613
+ // },
1614
+ // "account_number": "744873727",
1615
+ // "status": "ACTIVE",
1616
+ // "crypto_status": "ACTIVE",
1617
+ // "currency": "USD",
1618
+ // "buying_power": "5.92",
1619
+ // "regt_buying_power": "5.92",
1620
+ // "daytrading_buying_power": "0",
1621
+ // "effective_buying_power": "5.92",
1622
+ // "non_marginable_buying_power": "5.92",
1623
+ // "bod_dtbp": "0",
1624
+ // "cash": "5.92",
1625
+ // "accrued_fees": "0",
1626
+ // "portfolio_value": "48.6",
1627
+ // "pattern_day_trader": false,
1628
+ // "trading_blocked": false,
1629
+ // "transfers_blocked": false,
1630
+ // "account_blocked": false,
1631
+ // "created_at": "2022-06-13T14:59:18.318096Z",
1632
+ // "trade_suspended_by_user": false,
1633
+ // "multiplier": "1",
1634
+ // "shorting_enabled": false,
1635
+ // "equity": "48.6",
1636
+ // "last_equity": "48.8014266",
1637
+ // "long_market_value": "42.68",
1638
+ // "short_market_value": "0",
1639
+ // "position_market_value": "42.68",
1640
+ // "initial_margin": "0",
1641
+ // "maintenance_margin": "0",
1642
+ // "last_maintenance_margin": "0",
1643
+ // "sma": "5.92",
1644
+ // "daytrade_count": 0,
1645
+ // "balance_asof": "2024-12-10",
1646
+ // "crypto_tier": 1,
1647
+ // "intraday_adjustments": "0",
1648
+ // "pending_reg_taf_fees": "0"
1649
+ // }
1650
+ //
1651
+ return this.parseBalance(response);
1652
+ }
1653
+ parseBalance(response) {
1654
+ const result = { 'info': response };
1655
+ const account = this.account();
1656
+ const currencyId = this.safeString(response, 'currency');
1657
+ const code = this.safeCurrencyCode(currencyId);
1658
+ account['free'] = this.safeString(response, 'cash');
1659
+ account['total'] = this.safeString(response, 'equity');
1660
+ result[code] = account;
1661
+ return this.safeBalance(result);
1662
+ }
1592
1663
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1593
1664
  let endpoint = '/' + this.implodeParams(path, params);
1594
1665
  let url = this.implodeHostname(this.urls['api'][api[0]]);