ccxt 4.4.49 → 4.4.50

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 (122) 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 +64 -1
  5. package/dist/cjs/src/base/Exchange.js +75 -0
  6. package/dist/cjs/src/binance.js +8 -4
  7. package/dist/cjs/src/bitfinex1.js +22 -22
  8. package/dist/cjs/src/blofin.js +2 -2
  9. package/dist/cjs/src/bybit.js +2 -2
  10. package/dist/cjs/src/coinex.js +4 -4
  11. package/dist/cjs/src/coinmetro.js +1 -1
  12. package/dist/cjs/src/defx.js +1 -1
  13. package/dist/cjs/src/ellipx.js +1 -0
  14. package/dist/cjs/src/gate.js +1 -1
  15. package/dist/cjs/src/hollaex.js +13 -19
  16. package/dist/cjs/src/hyperliquid.js +4 -4
  17. package/dist/cjs/src/krakenfutures.js +1 -1
  18. package/dist/cjs/src/kucoin.js +49 -71
  19. package/dist/cjs/src/kuna.js +1 -1
  20. package/dist/cjs/src/mexc.js +3 -2
  21. package/dist/cjs/src/okcoin.js +13 -5
  22. package/dist/cjs/src/okx.js +1 -1
  23. package/dist/cjs/src/paradex.js +1 -1
  24. package/dist/cjs/src/paymium.js +42 -0
  25. package/dist/cjs/src/pro/bitfinex1.js +4 -4
  26. package/dist/cjs/src/pro/bitvavo.js +1 -1
  27. package/dist/cjs/src/pro/blofin.js +1 -1
  28. package/dist/cjs/src/pro/bybit.js +1 -1
  29. package/dist/cjs/src/pro/coincatch.js +2 -2
  30. package/dist/cjs/src/pro/cryptocom.js +2 -2
  31. package/dist/cjs/src/pro/defx.js +1 -1
  32. package/dist/cjs/src/pro/exmo.js +1 -1
  33. package/dist/cjs/src/pro/gemini.js +1 -1
  34. package/dist/cjs/src/pro/hashkey.js +2 -2
  35. package/dist/cjs/src/pro/hyperliquid.js +2 -2
  36. package/dist/cjs/src/pro/kucoin.js +1 -1
  37. package/dist/cjs/src/pro/okx.js +1 -1
  38. package/dist/cjs/src/pro/oxfun.js +1 -1
  39. package/dist/cjs/src/probit.js +68 -1
  40. package/dist/cjs/src/timex.js +67 -0
  41. package/dist/cjs/src/tokocrypto.js +82 -5
  42. package/dist/cjs/src/tradeogre.js +55 -2
  43. package/dist/cjs/src/whitebit.js +11 -4
  44. package/examples/README.md +6 -0
  45. package/js/ccxt.d.ts +1 -1
  46. package/js/ccxt.js +1 -1
  47. package/js/src/abstract/binance.d.ts +1 -0
  48. package/js/src/abstract/binancecoinm.d.ts +1 -0
  49. package/js/src/abstract/binanceus.d.ts +1 -0
  50. package/js/src/abstract/binanceusdm.d.ts +1 -0
  51. package/js/src/alpaca.d.ts +35 -0
  52. package/js/src/alpaca.js +64 -1
  53. package/js/src/base/Exchange.js +75 -0
  54. package/js/src/binance.d.ts +1 -0
  55. package/js/src/binance.js +8 -4
  56. package/js/src/bitfinex1.d.ts +22 -22
  57. package/js/src/bitfinex1.js +22 -22
  58. package/js/src/blofin.d.ts +1 -1
  59. package/js/src/blofin.js +2 -2
  60. package/js/src/bybit.d.ts +2 -2
  61. package/js/src/bybit.js +2 -2
  62. package/js/src/coinex.js +4 -4
  63. package/js/src/coinmetro.d.ts +1 -1
  64. package/js/src/coinmetro.js +1 -1
  65. package/js/src/defx.d.ts +1 -1
  66. package/js/src/defx.js +1 -1
  67. package/js/src/ellipx.d.ts +1 -0
  68. package/js/src/ellipx.js +1 -0
  69. package/js/src/gate.d.ts +1 -1
  70. package/js/src/gate.js +1 -1
  71. package/js/src/hollaex.d.ts +2 -1
  72. package/js/src/hollaex.js +13 -19
  73. package/js/src/hyperliquid.d.ts +3 -3
  74. package/js/src/hyperliquid.js +4 -4
  75. package/js/src/krakenfutures.d.ts +1 -1
  76. package/js/src/krakenfutures.js +1 -1
  77. package/js/src/kucoin.js +49 -71
  78. package/js/src/kuna.d.ts +1 -1
  79. package/js/src/kuna.js +1 -1
  80. package/js/src/mexc.js +3 -2
  81. package/js/src/okcoin.js +13 -5
  82. package/js/src/okx.d.ts +1 -1
  83. package/js/src/okx.js +1 -1
  84. package/js/src/paradex.d.ts +1 -1
  85. package/js/src/paradex.js +1 -1
  86. package/js/src/paymium.js +42 -0
  87. package/js/src/pro/bitfinex1.d.ts +4 -4
  88. package/js/src/pro/bitfinex1.js +4 -4
  89. package/js/src/pro/bitvavo.d.ts +1 -1
  90. package/js/src/pro/bitvavo.js +1 -1
  91. package/js/src/pro/blofin.d.ts +1 -1
  92. package/js/src/pro/blofin.js +1 -1
  93. package/js/src/pro/bybit.d.ts +1 -1
  94. package/js/src/pro/bybit.js +1 -1
  95. package/js/src/pro/coincatch.d.ts +2 -2
  96. package/js/src/pro/coincatch.js +2 -2
  97. package/js/src/pro/cryptocom.d.ts +2 -2
  98. package/js/src/pro/cryptocom.js +2 -2
  99. package/js/src/pro/defx.d.ts +1 -1
  100. package/js/src/pro/defx.js +1 -1
  101. package/js/src/pro/exmo.d.ts +1 -1
  102. package/js/src/pro/exmo.js +1 -1
  103. package/js/src/pro/gemini.d.ts +1 -1
  104. package/js/src/pro/gemini.js +1 -1
  105. package/js/src/pro/hashkey.d.ts +2 -2
  106. package/js/src/pro/hashkey.js +2 -2
  107. package/js/src/pro/hyperliquid.d.ts +2 -2
  108. package/js/src/pro/hyperliquid.js +2 -2
  109. package/js/src/pro/kucoin.d.ts +1 -1
  110. package/js/src/pro/kucoin.js +1 -1
  111. package/js/src/pro/okx.d.ts +1 -1
  112. package/js/src/pro/okx.js +1 -1
  113. package/js/src/pro/oxfun.d.ts +1 -1
  114. package/js/src/pro/oxfun.js +1 -1
  115. package/js/src/probit.js +68 -1
  116. package/js/src/timex.js +67 -0
  117. package/js/src/tokocrypto.d.ts +2 -3
  118. package/js/src/tokocrypto.js +82 -5
  119. package/js/src/tradeogre.d.ts +4 -2
  120. package/js/src/tradeogre.js +55 -2
  121. package/js/src/whitebit.js +11 -4
  122. package/package.json +1 -1
@@ -268,6 +268,73 @@ class timex extends timex$1 {
268
268
  'defaultSort': 'timestamp,asc',
269
269
  'defaultSortOrders': 'createdAt,asc',
270
270
  },
271
+ 'features': {
272
+ 'spot': {
273
+ 'sandbox': false,
274
+ 'createOrder': {
275
+ 'marginMode': false,
276
+ 'triggerPrice': false,
277
+ 'triggerDirection': false,
278
+ 'triggerPriceType': undefined,
279
+ 'stopLossPrice': false,
280
+ 'takeProfitPrice': false,
281
+ 'attachedStopLossTakeProfit': undefined,
282
+ // todo
283
+ 'timeInForce': {
284
+ 'IOC': true,
285
+ 'FOK': true,
286
+ 'PO': false,
287
+ 'GTD': true,
288
+ },
289
+ 'hedged': false,
290
+ 'trailing': false,
291
+ 'leverage': false,
292
+ 'marketBuyByCost': false,
293
+ 'marketBuyRequiresPrice': false,
294
+ 'selfTradePrevention': false,
295
+ 'iceberg': false,
296
+ },
297
+ 'createOrders': undefined,
298
+ 'fetchMyTrades': {
299
+ 'marginMode': false,
300
+ 'limit': 100,
301
+ 'daysBack': 100000,
302
+ 'untilDays': 100000, // todo
303
+ },
304
+ 'fetchOrder': {
305
+ 'marginMode': false,
306
+ 'trigger': false,
307
+ 'trailing': false,
308
+ },
309
+ 'fetchOpenOrders': {
310
+ 'marginMode': false,
311
+ 'limit': 100,
312
+ 'trigger': false,
313
+ 'trailing': false,
314
+ },
315
+ 'fetchOrders': undefined,
316
+ 'fetchClosedOrders': {
317
+ 'marginMode': false,
318
+ 'limit': 100,
319
+ 'daysBack': 100000,
320
+ 'daysBackCanceled': 1,
321
+ 'untilDays': 100000,
322
+ 'trigger': false,
323
+ 'trailing': false,
324
+ },
325
+ 'fetchOHLCV': {
326
+ 'limit': undefined,
327
+ },
328
+ },
329
+ 'swap': {
330
+ 'linear': undefined,
331
+ 'inverse': undefined,
332
+ },
333
+ 'future': {
334
+ 'linear': undefined,
335
+ 'inverse': undefined,
336
+ },
337
+ },
271
338
  });
272
339
  }
273
340
  /**
@@ -595,6 +595,79 @@ class tokocrypto extends tokocrypto$1 {
595
595
  'MAX_POSITION': errors.InvalidOrder, // {"code":-2010,"msg":"Filter failure: MAX_POSITION"}
596
596
  },
597
597
  },
598
+ 'features': {
599
+ 'spot': {
600
+ 'sandbox': false,
601
+ 'createOrder': {
602
+ 'marginMode': false,
603
+ 'triggerPrice': true,
604
+ 'triggerDirection': false,
605
+ 'triggerPriceType': undefined,
606
+ 'stopLossPrice': false,
607
+ 'takeProfitPrice': false,
608
+ 'attachedStopLossTakeProfit': undefined,
609
+ 'timeInForce': {
610
+ 'IOC': true,
611
+ 'FOK': true,
612
+ 'PO': true,
613
+ 'GTD': false,
614
+ },
615
+ 'hedged': false,
616
+ 'trailing': false,
617
+ 'leverage': false,
618
+ 'marketBuyByCost': true,
619
+ 'marketBuyRequiresPrice': true,
620
+ 'selfTradePrevention': true,
621
+ 'iceberg': true, // todo
622
+ },
623
+ 'createOrders': undefined,
624
+ 'fetchMyTrades': {
625
+ 'marginMode': false,
626
+ 'limit': 1000,
627
+ 'daysBack': 100000,
628
+ 'untilDays': 100000, // todo
629
+ },
630
+ 'fetchOrder': {
631
+ 'marginMode': false,
632
+ 'trigger': false,
633
+ 'trailing': false,
634
+ },
635
+ 'fetchOpenOrders': {
636
+ 'marginMode': false,
637
+ 'limit': 1000,
638
+ 'trigger': false,
639
+ 'trailing': false,
640
+ },
641
+ 'fetchOrders': {
642
+ 'marginMode': false,
643
+ 'limit': 1000,
644
+ 'daysBack': 100000,
645
+ 'untilDays': 100000,
646
+ 'trigger': false,
647
+ 'trailing': false,
648
+ },
649
+ 'fetchClosedOrders': {
650
+ 'marginMode': false,
651
+ 'limit': 1000,
652
+ 'daysBack': 100000,
653
+ 'daysBackCanceled': 1,
654
+ 'untilDays': 100000,
655
+ 'trigger': false,
656
+ 'trailing': false,
657
+ },
658
+ 'fetchOHLCV': {
659
+ 'limit': 1000,
660
+ },
661
+ },
662
+ 'swap': {
663
+ 'linear': undefined,
664
+ 'inverse': undefined,
665
+ },
666
+ 'future': {
667
+ 'linear': undefined,
668
+ 'inverse': undefined,
669
+ },
670
+ },
598
671
  });
599
672
  }
600
673
  nonce() {
@@ -611,9 +684,14 @@ class tokocrypto extends tokocrypto$1 {
611
684
  async fetchTime(params = {}) {
612
685
  const response = await this.publicGetOpenV1CommonTime(params);
613
686
  //
687
+ // {
688
+ // "code": 0,
689
+ // "msg": "Success",
690
+ // "data": null,
691
+ // "timestamp": 1737378074159
692
+ // }
614
693
  //
615
- //
616
- return this.safeInteger(response, 'serverTime');
694
+ return this.safeInteger(response, 'timestamp');
617
695
  }
618
696
  /**
619
697
  * @method
@@ -1588,7 +1666,6 @@ class tokocrypto extends tokocrypto$1 {
1588
1666
  * @name tokocrypto#createOrder
1589
1667
  * @description create a trade order
1590
1668
  * @see https://www.tokocrypto.com/apidocs/#new-order--signed
1591
- * @see https://www.tokocrypto.com/apidocs/#account-trade-list-signed
1592
1669
  * @param {string} symbol unified symbol of the market to create an order in
1593
1670
  * @param {string} type 'market' or 'limit'
1594
1671
  * @param {string} side 'buy' or 'sell'
@@ -1778,7 +1855,7 @@ class tokocrypto extends tokocrypto$1 {
1778
1855
  /**
1779
1856
  * @method
1780
1857
  * @name tokocrypto#fetchOrder
1781
- * @see https://www.tokocrypto.com/apidocs/#all-orders-signed
1858
+ * @see https://www.tokocrypto.com/apidocs/#query-order-signed
1782
1859
  * @description fetches information on an order made by the user
1783
1860
  * @param {string} id order id
1784
1861
  * @param {string} symbol unified symbol of the market the order was made in
@@ -2343,7 +2420,7 @@ class tokocrypto extends tokocrypto$1 {
2343
2420
  }
2344
2421
  /**
2345
2422
  * @method
2346
- * @name bybit#withdraw
2423
+ * @name tokocrypto#withdraw
2347
2424
  * @see https://www.tokocrypto.com/apidocs/#withdraw-signed
2348
2425
  * @description make a withdrawal
2349
2426
  * @param {string} code unified currency code
@@ -156,6 +156,57 @@ class tradeogre extends tradeogre$1 {
156
156
  },
157
157
  },
158
158
  'options': {},
159
+ 'features': {
160
+ 'spot': {
161
+ 'sandbox': false,
162
+ 'createOrder': {
163
+ 'marginMode': false,
164
+ 'triggerPrice': false,
165
+ 'triggerDirection': false,
166
+ 'triggerPriceType': undefined,
167
+ 'stopLossPrice': false,
168
+ 'takeProfitPrice': false,
169
+ 'attachedStopLossTakeProfit': undefined,
170
+ 'timeInForce': {
171
+ 'IOC': false,
172
+ 'FOK': false,
173
+ 'PO': false,
174
+ 'GTD': false,
175
+ },
176
+ 'hedged': false,
177
+ 'trailing': false,
178
+ 'leverage': false,
179
+ 'marketBuyByCost': false,
180
+ 'marketBuyRequiresPrice': false,
181
+ 'selfTradePrevention': false,
182
+ 'iceberg': false,
183
+ },
184
+ 'createOrders': undefined,
185
+ 'fetchMyTrades': undefined,
186
+ 'fetchOrder': {
187
+ 'marginMode': false,
188
+ 'trigger': false,
189
+ 'trailing': false,
190
+ },
191
+ 'fetchOpenOrders': {
192
+ 'marginMode': false,
193
+ 'limit': undefined,
194
+ 'trigger': false,
195
+ 'trailing': false,
196
+ },
197
+ 'fetchOrders': undefined,
198
+ 'fetchClosedOrders': undefined,
199
+ 'fetchOHLCV': undefined, // todo
200
+ },
201
+ 'swap': {
202
+ 'linear': undefined,
203
+ 'inverse': undefined,
204
+ },
205
+ 'future': {
206
+ 'linear': undefined,
207
+ 'inverse': undefined,
208
+ },
209
+ },
159
210
  });
160
211
  }
161
212
  /**
@@ -446,6 +497,7 @@ class tradeogre extends tradeogre$1 {
446
497
  * @method
447
498
  * @name tradeogre#createOrder
448
499
  * @description create a trade order
500
+ * @see https://tradeogre.com/help/api#:~:text=u%20%27%7Bpublic%7D%3A%7Bprivate%7D%27-,Submit%20Buy%20Order
449
501
  * @param {string} symbol unified symbol of the market to create an order in
450
502
  * @param {string} type must be 'limit'
451
503
  * @param {string} side 'buy' or 'sell'
@@ -513,6 +565,7 @@ class tradeogre extends tradeogre$1 {
513
565
  * @method
514
566
  * @name tradeogre#fetchOpenOrders
515
567
  * @description fetch all unfilled currently open orders
568
+ * @see https://tradeogre.com/help/api#:~:text=%7B%22success%22%3Atrue%7D-,Get%20Orders,-Method%20(POST)
516
569
  * @param {string} symbol unified market symbol of the market orders were made in
517
570
  * @param {int} [since] the earliest time in ms to fetch orders for
518
571
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -534,9 +587,9 @@ class tradeogre extends tradeogre$1 {
534
587
  }
535
588
  /**
536
589
  * @method
537
- * @name ace#fetchOrder
590
+ * @name tradeogre#fetchOrder
538
591
  * @description fetches information on an order made by the user
539
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---order-status
592
+ * @see https://tradeogre.com/help/api#:~:text=market%22%3A%22XMR%2DBTC%22%7D%5D-,Get%20Order,-Method%20(GET)
540
593
  * @param {string} id order id
541
594
  * @param {string} symbol unified symbol of the market the order was made in
542
595
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -259,6 +259,8 @@ class whitebit extends whitebit$1 {
259
259
  },
260
260
  },
261
261
  'options': {
262
+ 'timeDifference': 0,
263
+ 'adjustForTimeDifference': false,
262
264
  'fiatCurrencies': ['EUR', 'USD', 'RUB', 'UAH'],
263
265
  'fetchBalance': {
264
266
  'account': 'spot',
@@ -315,6 +317,9 @@ class whitebit extends whitebit$1 {
315
317
  * @returns {object[]} an array of objects representing market data
316
318
  */
317
319
  async fetchMarkets(params = {}) {
320
+ if (this.options['adjustForTimeDifference']) {
321
+ await this.loadTimeDifference();
322
+ }
318
323
  const markets = await this.v4PublicGetMarkets();
319
324
  //
320
325
  // [
@@ -1239,7 +1244,7 @@ class whitebit extends whitebit$1 {
1239
1244
  const response = await this.v4PublicGetTime(params);
1240
1245
  //
1241
1246
  // {
1242
- // "time":1635467280514
1247
+ // "time":1737380046
1243
1248
  // }
1244
1249
  //
1245
1250
  return this.safeInteger(response, 'time');
@@ -2608,7 +2613,7 @@ class whitebit extends whitebit$1 {
2608
2613
  return this.inArray(currency, fiatCurrencies);
2609
2614
  }
2610
2615
  nonce() {
2611
- return this.milliseconds();
2616
+ return this.milliseconds() - this.options['timeDifference'];
2612
2617
  }
2613
2618
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2614
2619
  const query = this.omit(params, this.extractParams(path));
@@ -2623,10 +2628,12 @@ class whitebit extends whitebit$1 {
2623
2628
  }
2624
2629
  if (accessibility === 'private') {
2625
2630
  this.checkRequiredCredentials();
2626
- const nonce = this.nonce().toString();
2631
+ const nonce = this.nonce();
2632
+ const timestamp = this.parseToInt(nonce / 1000);
2633
+ const timestampString = timestamp.toString();
2627
2634
  const secret = this.encode(this.secret);
2628
2635
  const request = '/' + 'api' + '/' + version + pathWithParams;
2629
- body = this.json(this.extend({ 'request': request, 'nonce': nonce }, params));
2636
+ body = this.json(this.extend({ 'request': request, 'nonce': timestampString }, params));
2630
2637
  const payload = this.stringToBase64(body);
2631
2638
  const signature = this.hmac(this.encode(payload), secret, sha512.sha512);
2632
2639
  headers = {
@@ -54,6 +54,8 @@ python path/to/example.py # substitute for actual filename here
54
54
 
55
55
  ## See Also
56
56
 
57
+ This section includes links to friendly projects, tutorials, articles, videos, courses and other materials related to CCXT.
58
+
57
59
  [Freqtrade](https://www.freqtrade.io) – leading opensource cryptocurrency algorithmic trading software based on CCXT!
58
60
 
59
61
  [Blockpit](https://www.blockpit.io) – Tax reporting and portfolio tracking for Cryptocurrencies, Cryptoderivates and DeFi.
@@ -66,6 +68,10 @@ python path/to/example.py # substitute for actual filename here
66
68
 
67
69
  [Playing with CCXT in Google Colab](https://medium.com/@ccxt/playing-with-ccxt-in-google-colab-23522ac8a6cb) – An article on how useful Colab can be for quick prototyping and testing your trading ideas with CCXT.
68
70
 
71
+ [Ultimate Guide to Mastering Cryptocurrency Trading Orders with Python](https://robottraders.io/blog/guide-ccxt-orders) – A great tutorial on trading orders with CCXT by Robot Traders.
72
+
73
+ [Mastering Cryptocurrency Trading: From Data to Strategy with Python](https://profitview.net/blog/mastering-cryptocurrency-trading-from-data-to-strategy-with-python) – An in-depth article guiding through trading strategy development with CCXT and Python.
74
+
69
75
  [What is the Best Crypto Trading Bot in 2020?](https://www.hodlbot.io/blog/ultimate-guide-on-crypto-trading-bots) – Ultimate guide on crypto trading bots in 2020 by HodlBlog.
70
76
 
71
77
  [Enigma Catalyst](https://blog.enigma.co/enigma-announces-catalyst-0-4-our-biggest-release-yet-fa31a5ffa4b1) – The major effort towards decentralized exchanges integrates ccxt!
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, OpenInterests } 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.48";
7
+ declare const version = "4.4.49";
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.49';
41
+ const version = '4.4.50';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -219,6 +219,7 @@ interface Exchange {
219
219
  sapiGetPortfolioRepayFuturesSwitch(params?: {}): Promise<implicitReturnType>;
220
220
  sapiGetPortfolioMarginAssetLeverage(params?: {}): Promise<implicitReturnType>;
221
221
  sapiGetPortfolioBalance(params?: {}): Promise<implicitReturnType>;
222
+ sapiGetPortfolioNegativeBalanceExchangeRecord(params?: {}): Promise<implicitReturnType>;
222
223
  sapiGetStakingProductList(params?: {}): Promise<implicitReturnType>;
223
224
  sapiGetStakingPosition(params?: {}): Promise<implicitReturnType>;
224
225
  sapiGetStakingStakingRecord(params?: {}): Promise<implicitReturnType>;
@@ -219,6 +219,7 @@ interface binance {
219
219
  sapiGetPortfolioRepayFuturesSwitch(params?: {}): Promise<implicitReturnType>;
220
220
  sapiGetPortfolioMarginAssetLeverage(params?: {}): Promise<implicitReturnType>;
221
221
  sapiGetPortfolioBalance(params?: {}): Promise<implicitReturnType>;
222
+ sapiGetPortfolioNegativeBalanceExchangeRecord(params?: {}): Promise<implicitReturnType>;
222
223
  sapiGetStakingProductList(params?: {}): Promise<implicitReturnType>;
223
224
  sapiGetStakingPosition(params?: {}): Promise<implicitReturnType>;
224
225
  sapiGetStakingStakingRecord(params?: {}): Promise<implicitReturnType>;
@@ -219,6 +219,7 @@ interface binance {
219
219
  sapiGetPortfolioRepayFuturesSwitch(params?: {}): Promise<implicitReturnType>;
220
220
  sapiGetPortfolioMarginAssetLeverage(params?: {}): Promise<implicitReturnType>;
221
221
  sapiGetPortfolioBalance(params?: {}): Promise<implicitReturnType>;
222
+ sapiGetPortfolioNegativeBalanceExchangeRecord(params?: {}): Promise<implicitReturnType>;
222
223
  sapiGetStakingProductList(params?: {}): Promise<implicitReturnType>;
223
224
  sapiGetStakingPosition(params?: {}): Promise<implicitReturnType>;
224
225
  sapiGetStakingStakingRecord(params?: {}): Promise<implicitReturnType>;
@@ -219,6 +219,7 @@ interface binance {
219
219
  sapiGetPortfolioRepayFuturesSwitch(params?: {}): Promise<implicitReturnType>;
220
220
  sapiGetPortfolioMarginAssetLeverage(params?: {}): Promise<implicitReturnType>;
221
221
  sapiGetPortfolioBalance(params?: {}): Promise<implicitReturnType>;
222
+ sapiGetPortfolioNegativeBalanceExchangeRecord(params?: {}): Promise<implicitReturnType>;
222
223
  sapiGetStakingProductList(params?: {}): Promise<implicitReturnType>;
223
224
  sapiGetStakingPosition(params?: {}): Promise<implicitReturnType>;
224
225
  sapiGetStakingStakingRecord(params?: {}): Promise<implicitReturnType>;
@@ -91,6 +91,40 @@ export default class alpaca extends Exchange {
91
91
  */
92
92
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
93
93
  generateClientOrderId(params: any): string;
94
+ /**
95
+ * @method
96
+ * @name alpaca#createMarketOrderWithCost
97
+ * @description create a market order by providing the symbol, side and cost
98
+ * @see https://docs.alpaca.markets/reference/postorder
99
+ * @param {string} symbol unified symbol of the market to create an order in
100
+ * @param {string} side 'buy' or 'sell'
101
+ * @param {float} cost how much you want to trade in units of the quote currency
102
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
103
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
104
+ */
105
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: number, params?: {}): Promise<Order>;
106
+ /**
107
+ * @method
108
+ * @name alpaca#createMarketBuyOrderWithCost
109
+ * @description create a market buy order by providing the symbol and cost
110
+ * @see https://docs.alpaca.markets/reference/postorder
111
+ * @param {string} symbol unified symbol of the market to create an order in
112
+ * @param {float} cost how much you want to trade in units of the quote currency
113
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
114
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
115
+ */
116
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
117
+ /**
118
+ * @method
119
+ * @name alpaca#createMarketSellOrderWithCost
120
+ * @description create a market sell order by providing the symbol and cost
121
+ * @see https://docs.alpaca.markets/reference/postorder
122
+ * @param {string} symbol unified symbol of the market to create an order in
123
+ * @param {float} cost how much you want to trade in units of the quote currency
124
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
125
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
126
+ */
127
+ createMarketSellOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
94
128
  /**
95
129
  * @method
96
130
  * @name alpaca#createOrder
@@ -103,6 +137,7 @@ export default class alpaca extends Exchange {
103
137
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
104
138
  * @param {object} [params] extra parameters specific to the exchange API endpoint
105
139
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
140
+ * @param {float} [params.cost] *market orders only* the cost of the order in units of the quote currency
106
141
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
107
142
  */
108
143
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
package/js/src/alpaca.js CHANGED
@@ -53,6 +53,9 @@ export default class alpaca extends Exchange {
53
53
  'cancelOrder': true,
54
54
  'closeAllPositions': false,
55
55
  'closePosition': false,
56
+ 'createMarketBuyOrder': true,
57
+ 'createMarketBuyOrderWithCost': true,
58
+ 'createMarketOrderWithCost': true,
56
59
  'createOrder': true,
57
60
  'createStopOrder': true,
58
61
  'createTriggerOrder': true,
@@ -912,6 +915,58 @@ export default class alpaca extends Exchange {
912
915
  const clientOrderId = this.safeString(params, 'clientOrderId', defaultClientId);
913
916
  return clientOrderId;
914
917
  }
918
+ /**
919
+ * @method
920
+ * @name alpaca#createMarketOrderWithCost
921
+ * @description create a market order by providing the symbol, side and cost
922
+ * @see https://docs.alpaca.markets/reference/postorder
923
+ * @param {string} symbol unified symbol of the market to create an order in
924
+ * @param {string} side 'buy' or 'sell'
925
+ * @param {float} cost how much you want to trade in units of the quote currency
926
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
927
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
928
+ */
929
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
930
+ await this.loadMarkets();
931
+ const req = {
932
+ 'cost': cost,
933
+ };
934
+ return await this.createOrder(symbol, 'market', side, 0, undefined, this.extend(req, params));
935
+ }
936
+ /**
937
+ * @method
938
+ * @name alpaca#createMarketBuyOrderWithCost
939
+ * @description create a market buy order by providing the symbol and cost
940
+ * @see https://docs.alpaca.markets/reference/postorder
941
+ * @param {string} symbol unified symbol of the market to create an order in
942
+ * @param {float} cost how much you want to trade in units of the quote currency
943
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
944
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
945
+ */
946
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
947
+ await this.loadMarkets();
948
+ const req = {
949
+ 'cost': cost,
950
+ };
951
+ return await this.createOrder(symbol, 'market', 'buy', 0, undefined, this.extend(req, params));
952
+ }
953
+ /**
954
+ * @method
955
+ * @name alpaca#createMarketSellOrderWithCost
956
+ * @description create a market sell order by providing the symbol and cost
957
+ * @see https://docs.alpaca.markets/reference/postorder
958
+ * @param {string} symbol unified symbol of the market to create an order in
959
+ * @param {float} cost how much you want to trade in units of the quote currency
960
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
961
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
962
+ */
963
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
964
+ await this.loadMarkets();
965
+ const req = {
966
+ 'cost': cost,
967
+ };
968
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, this.extend(req, params));
969
+ }
915
970
  /**
916
971
  * @method
917
972
  * @name alpaca#createOrder
@@ -924,6 +979,7 @@ export default class alpaca extends Exchange {
924
979
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
925
980
  * @param {object} [params] extra parameters specific to the exchange API endpoint
926
981
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
982
+ * @param {float} [params.cost] *market orders only* the cost of the order in units of the quote currency
927
983
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
928
984
  */
929
985
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -932,7 +988,6 @@ export default class alpaca extends Exchange {
932
988
  const id = market['id'];
933
989
  const request = {
934
990
  'symbol': id,
935
- 'qty': this.amountToPrecision(symbol, amount),
936
991
  'side': side,
937
992
  'type': type, // market, limit, stop_limit
938
993
  };
@@ -951,6 +1006,14 @@ export default class alpaca extends Exchange {
951
1006
  if (type.indexOf('limit') >= 0) {
952
1007
  request['limit_price'] = this.priceToPrecision(symbol, price);
953
1008
  }
1009
+ const cost = this.safeString(params, 'cost');
1010
+ if (cost !== undefined) {
1011
+ params = this.omit(params, 'cost');
1012
+ request['notional'] = this.costToPrecision(symbol, cost);
1013
+ }
1014
+ else {
1015
+ request['qty'] = this.amountToPrecision(symbol, amount);
1016
+ }
954
1017
  const defaultTIF = this.safeString(this.options, 'defaultTimeInForce');
955
1018
  request['time_in_force'] = this.safeString(params, 'timeInForce', defaultTIF);
956
1019
  params = this.omit(params, ['timeInForce', 'triggerPrice']);
@@ -2469,6 +2469,81 @@ export default class Exchange {
2469
2469
  };
2470
2470
  }
2471
2471
  safeCurrencyStructure(currency) {
2472
+ // derive data from networks: deposit, withdraw, active, fee, limits, precision
2473
+ const networks = this.safeDict(currency, 'networks', {});
2474
+ const keys = Object.keys(networks);
2475
+ const length = keys.length;
2476
+ if (length !== 0) {
2477
+ for (let i = 0; i < length; i++) {
2478
+ const network = networks[keys[i]];
2479
+ const deposit = this.safeBool(network, 'deposit');
2480
+ if (currency['deposit'] === undefined || deposit) {
2481
+ currency['deposit'] = deposit;
2482
+ }
2483
+ const withdraw = this.safeBool(network, 'withdraw');
2484
+ if (currency['withdraw'] === undefined || withdraw) {
2485
+ currency['withdraw'] = withdraw;
2486
+ }
2487
+ const active = this.safeBool(network, 'active');
2488
+ if (currency['active'] === undefined || active) {
2489
+ currency['active'] = active;
2490
+ }
2491
+ // find lowest fee (which is more desired)
2492
+ const fee = this.safeString(network, 'fee');
2493
+ const feeMain = this.safeString(currency, 'fee');
2494
+ if (feeMain === undefined || Precise.stringLt(fee, feeMain)) {
2495
+ currency['fee'] = this.parseNumber(fee);
2496
+ }
2497
+ // find lowest precision (which is more desired)
2498
+ const precision = this.safeString(network, 'precision');
2499
+ const precisionMain = this.safeString(currency, 'precision');
2500
+ if (precisionMain === undefined || Precise.stringLt(precision, precisionMain)) {
2501
+ currency['precision'] = this.parseNumber(precision);
2502
+ }
2503
+ // limits
2504
+ const limits = this.safeDict(network, 'limits');
2505
+ const limitsMain = this.safeDict(currency, 'limits');
2506
+ if (limitsMain === undefined) {
2507
+ currency['limits'] = {};
2508
+ }
2509
+ // deposits
2510
+ const limitsDeposit = this.safeDict(limits, 'deposit');
2511
+ const limitsDepositMain = this.safeDict(limitsMain, 'deposit');
2512
+ if (limitsDepositMain === undefined) {
2513
+ currency['limits']['deposit'] = {};
2514
+ }
2515
+ const limitsDepositMin = this.safeString(limitsDeposit, 'min');
2516
+ const limitsDepositMax = this.safeString(limitsDeposit, 'max');
2517
+ const limitsDepositMinMain = this.safeString(limitsDepositMain, 'min');
2518
+ const limitsDepositMaxMain = this.safeString(limitsDepositMain, 'max');
2519
+ // find min
2520
+ if (limitsDepositMinMain === undefined || Precise.stringLt(limitsDepositMin, limitsDepositMinMain)) {
2521
+ currency['limits']['deposit']['min'] = this.parseNumber(limitsDepositMin);
2522
+ }
2523
+ // find max
2524
+ if (limitsDepositMaxMain === undefined || Precise.stringGt(limitsDepositMax, limitsDepositMaxMain)) {
2525
+ currency['limits']['deposit']['max'] = this.parseNumber(limitsDepositMax);
2526
+ }
2527
+ // withdrawals
2528
+ const limitsWithdraw = this.safeDict(limits, 'withdraw');
2529
+ const limitsWithdrawMain = this.safeDict(limitsMain, 'withdraw');
2530
+ if (limitsWithdrawMain === undefined) {
2531
+ currency['limits']['withdraw'] = {};
2532
+ }
2533
+ const limitsWithdrawMin = this.safeString(limitsWithdraw, 'min');
2534
+ const limitsWithdrawMax = this.safeString(limitsWithdraw, 'max');
2535
+ const limitsWithdrawMinMain = this.safeString(limitsWithdrawMain, 'min');
2536
+ const limitsWithdrawMaxMain = this.safeString(limitsWithdrawMain, 'max');
2537
+ // find min
2538
+ if (limitsWithdrawMinMain === undefined || Precise.stringLt(limitsWithdrawMin, limitsWithdrawMinMain)) {
2539
+ currency['limits']['withdraw']['min'] = this.parseNumber(limitsWithdrawMin);
2540
+ }
2541
+ // find max
2542
+ if (limitsWithdrawMaxMain === undefined || Precise.stringGt(limitsWithdrawMax, limitsWithdrawMaxMain)) {
2543
+ currency['limits']['withdraw']['max'] = this.parseNumber(limitsWithdrawMax);
2544
+ }
2545
+ }
2546
+ }
2472
2547
  return this.extend({
2473
2548
  'info': undefined,
2474
2549
  'id': undefined,
@@ -476,6 +476,7 @@ export default class binance extends Exchange {
476
476
  * @param {string} symbol unified market symbol
477
477
  * @param {object} [params] extra parameters specific to the exchange API endpoint
478
478
  * @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
479
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch for a portfolio margin account
479
480
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
480
481
  */
481
482
  fetchOpenOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;