ccxt 4.4.20 → 4.4.22

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 (77) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +5 -5
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +1 -0
  5. package/dist/cjs/src/base/Exchange.js +34 -0
  6. package/dist/cjs/src/base/ws/Future.js +3 -1
  7. package/dist/cjs/src/bigone.js +3 -0
  8. package/dist/cjs/src/binance.js +103 -10
  9. package/dist/cjs/src/bingx.js +6 -1
  10. package/dist/cjs/src/bitflyer.js +57 -0
  11. package/dist/cjs/src/bitget.js +77 -0
  12. package/dist/cjs/src/bybit.js +143 -3
  13. package/dist/cjs/src/cex.js +1307 -1385
  14. package/dist/cjs/src/cryptocom.js +1 -1
  15. package/dist/cjs/src/gate.js +103 -3
  16. package/dist/cjs/src/htx.js +29 -7
  17. package/dist/cjs/src/hyperliquid.js +15 -12
  18. package/dist/cjs/src/kucoin.js +43 -95
  19. package/dist/cjs/src/kucoinfutures.js +2 -2
  20. package/dist/cjs/src/okx.js +82 -10
  21. package/dist/cjs/src/paradex.js +1 -2
  22. package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -1
  23. package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -1
  24. package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -1
  25. package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +298 -0
  26. package/js/ccxt.d.ts +3 -3
  27. package/js/ccxt.js +1 -1
  28. package/js/src/abstract/bitflyer.d.ts +1 -0
  29. package/js/src/abstract/bitget.d.ts +3 -0
  30. package/js/src/abstract/bybit.d.ts +1 -0
  31. package/js/src/abstract/cex.d.ts +28 -29
  32. package/js/src/abstract/gate.d.ts +5 -0
  33. package/js/src/abstract/gateio.d.ts +5 -0
  34. package/js/src/abstract/kucoin.d.ts +2 -0
  35. package/js/src/abstract/kucoinfutures.d.ts +2 -0
  36. package/js/src/abstract/okx.d.ts +4 -0
  37. package/js/src/alpaca.js +1 -0
  38. package/js/src/base/Exchange.d.ts +11 -3
  39. package/js/src/base/Exchange.js +34 -0
  40. package/js/src/base/types.d.ts +8 -0
  41. package/js/src/base/ws/Future.js +2 -1
  42. package/js/src/bigone.js +3 -0
  43. package/js/src/binance.d.ts +3 -2
  44. package/js/src/binance.js +103 -10
  45. package/js/src/bingx.js +6 -1
  46. package/js/src/bitflyer.d.ts +3 -1
  47. package/js/src/bitflyer.js +57 -0
  48. package/js/src/bitget.d.ts +3 -1
  49. package/js/src/bitget.js +77 -0
  50. package/js/src/bybit.d.ts +4 -1
  51. package/js/src/bybit.js +143 -3
  52. package/js/src/cex.d.ts +34 -20
  53. package/js/src/cex.js +1308 -1386
  54. package/js/src/cryptocom.js +1 -1
  55. package/js/src/gate.d.ts +2 -0
  56. package/js/src/gate.js +103 -3
  57. package/js/src/htx.d.ts +2 -2
  58. package/js/src/htx.js +29 -7
  59. package/js/src/hyperliquid.js +15 -12
  60. package/js/src/kucoin.d.ts +0 -2
  61. package/js/src/kucoin.js +43 -95
  62. package/js/src/kucoinfutures.js +2 -2
  63. package/js/src/okx.d.ts +3 -2
  64. package/js/src/okx.js +83 -11
  65. package/js/src/paradex.js +1 -1
  66. package/js/src/static_dependencies/noble-hashes/_blake2.js +1 -1
  67. package/js/src/static_dependencies/noble-hashes/_sha2.js +1 -1
  68. package/js/src/static_dependencies/noble-hashes/hmac.js +1 -1
  69. package/js/src/static_dependencies/noble-hashes/sha3-addons.js +5 -5
  70. package/js/src/static_dependencies/noble-hashes/sha3.js +1 -1
  71. package/js/src/static_dependencies/watchable/src/index.d.ts +2 -0
  72. package/js/src/static_dependencies/watchable/src/index.js +7 -0
  73. package/js/src/static_dependencies/watchable/src/types.d.ts +28 -0
  74. package/js/src/static_dependencies/watchable/src/types.js +8 -0
  75. package/js/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  76. package/js/src/static_dependencies/watchable/src/unpromise.js +297 -0
  77. package/package.json +1 -1
@@ -93,6 +93,8 @@ class okx extends okx$1 {
93
93
  'fetchLedgerEntry': undefined,
94
94
  'fetchLeverage': true,
95
95
  'fetchLeverageTiers': false,
96
+ 'fetchLongShortRatio': false,
97
+ 'fetchLongShortRatioHistory': true,
96
98
  'fetchMarginAdjustmentHistory': true,
97
99
  'fetchMarketLeverageTiers': true,
98
100
  'fetchMarkets': true,
@@ -235,6 +237,7 @@ class okx extends okx$1 {
235
237
  'rubik/stat/margin/loan-ratio': 4,
236
238
  // long/short
237
239
  'rubik/stat/contracts/long-short-account-ratio': 4,
240
+ 'rubik/stat/contracts/long-short-account-ratio-contract': 4,
238
241
  'rubik/stat/contracts/open-interest-volume': 4,
239
242
  'rubik/stat/option/open-interest-volume': 4,
240
243
  // put/call
@@ -353,6 +356,9 @@ class okx extends okx$1 {
353
356
  'account/fixed-loan/borrowing-limit': 4,
354
357
  'account/fixed-loan/borrowing-quote': 5,
355
358
  'account/fixed-loan/borrowing-orders-list': 5,
359
+ 'account/spot-manual-borrow-repay': 10,
360
+ 'account/set-auto-repay': 4,
361
+ 'account/spot-borrow-repay-history': 4,
356
362
  // subaccount
357
363
  'users/subaccount/list': 10,
358
364
  'account/subaccount/balances': 10 / 3,
@@ -884,6 +890,11 @@ class okx extends okx$1 {
884
890
  '59301': errors.ExchangeError,
885
891
  '59313': errors.ExchangeError,
886
892
  '59401': errors.ExchangeError,
893
+ '59410': errors.OperationRejected,
894
+ '59411': errors.InsufficientFunds,
895
+ '59412': errors.OperationRejected,
896
+ '59413': errors.OperationRejected,
897
+ '59414': errors.BadRequest,
887
898
  '59500': errors.ExchangeError,
888
899
  '59501': errors.ExchangeError,
889
900
  '59502': errors.ExchangeError,
@@ -6673,16 +6684,6 @@ class okx extends okx$1 {
6673
6684
  }
6674
6685
  return borrowRateHistories;
6675
6686
  }
6676
- parseBorrowRateHistory(response, code, since, limit) {
6677
- const result = [];
6678
- for (let i = 0; i < response.length; i++) {
6679
- const item = response[i];
6680
- const borrowRate = this.parseBorrowRate(item);
6681
- result.push(borrowRate);
6682
- }
6683
- const sorted = this.sortBy(result, 'timestamp');
6684
- return this.filterByCurrencySinceLimit(sorted, code, since, limit);
6685
- }
6686
6687
  async fetchBorrowRateHistories(codes = undefined, since = undefined, limit = undefined, params = {}) {
6687
6688
  /**
6688
6689
  * @method
@@ -8499,6 +8500,77 @@ class okx extends okx$1 {
8499
8500
  const positions = this.parsePositions(data, symbols, params);
8500
8501
  return this.filterBySinceLimit(positions, since, limit);
8501
8502
  }
8503
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
8504
+ /**
8505
+ * @method
8506
+ * @name okx#fetchLongShortRatioHistory
8507
+ * @description fetches the long short ratio history for a unified market symbol
8508
+ * @see https://www.okx.com/docs-v5/en/#trading-statistics-rest-api-get-contract-long-short-ratio
8509
+ * @param {string} symbol unified symbol of the market to fetch the long short ratio for
8510
+ * @param {string} [timeframe] the period for the ratio
8511
+ * @param {int} [since] the earliest time in ms to fetch ratios for
8512
+ * @param {int} [limit] the maximum number of long short ratio structures to retrieve
8513
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8514
+ * @param {int} [params.until] timestamp in ms of the latest ratio to fetch
8515
+ * @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
8516
+ */
8517
+ await this.loadMarkets();
8518
+ const market = this.market(symbol);
8519
+ const request = {
8520
+ 'instId': market['id'],
8521
+ };
8522
+ const until = this.safeString2(params, 'until', 'end');
8523
+ params = this.omit(params, 'until');
8524
+ if (until !== undefined) {
8525
+ request['end'] = until;
8526
+ }
8527
+ if (timeframe !== undefined) {
8528
+ request['period'] = timeframe;
8529
+ }
8530
+ if (since !== undefined) {
8531
+ request['begin'] = since;
8532
+ }
8533
+ if (limit !== undefined) {
8534
+ request['limit'] = limit;
8535
+ }
8536
+ const response = await this.publicGetRubikStatContractsLongShortAccountRatioContract(this.extend(request, params));
8537
+ //
8538
+ // {
8539
+ // "code": "0",
8540
+ // "data": [
8541
+ // ["1729323600000", "0.9398602814619824"],
8542
+ // ["1729323300000", "0.9398602814619824"],
8543
+ // ["1729323000000", "0.9398602814619824"],
8544
+ // ],
8545
+ // "msg": ""
8546
+ // }
8547
+ //
8548
+ const data = this.safeList(response, 'data', []);
8549
+ const result = [];
8550
+ for (let i = 0; i < data.length; i++) {
8551
+ const entry = data[i];
8552
+ result.push({
8553
+ 'timestamp': this.safeString(entry, 0),
8554
+ 'longShortRatio': this.safeString(entry, 1),
8555
+ });
8556
+ }
8557
+ return this.parseLongShortRatioHistory(result, market);
8558
+ }
8559
+ parseLongShortRatio(info, market = undefined) {
8560
+ const timestamp = this.safeInteger(info, 'timestamp');
8561
+ let symbol = undefined;
8562
+ if (market !== undefined) {
8563
+ symbol = market['symbol'];
8564
+ }
8565
+ return {
8566
+ 'info': info,
8567
+ 'symbol': symbol,
8568
+ 'timestamp': timestamp,
8569
+ 'datetime': this.iso8601(timestamp),
8570
+ 'timeframe': undefined,
8571
+ 'longShortRatio': this.safeNumber(info, 'longShortRatio'),
8572
+ };
8573
+ }
8502
8574
  }
8503
8575
 
8504
8576
  module.exports = okx;
@@ -1,13 +1,12 @@
1
1
  'use strict';
2
2
 
3
- require('../ccxt.js');
3
+ var Precise = require('./base/Precise.js');
4
4
  var paradex$1 = require('./abstract/paradex.js');
5
5
  var errors = require('./base/errors.js');
6
6
  var number = require('./base/functions/number.js');
7
7
  var crypto = require('./base/functions/crypto.js');
8
8
  var sha3 = require('./static_dependencies/noble-hashes/sha3.js');
9
9
  var secp256k1 = require('./static_dependencies/noble-curves/secp256k1.js');
10
- var Precise = require('./base/Precise.js');
11
10
 
12
11
  // ---------------------------------------------------------------------------
13
12
  // ---------------------------------------------------------------------------
@@ -104,7 +104,7 @@ class SHA2 extends utils.Hash {
104
104
  return res;
105
105
  }
106
106
  _cloneInto(to) {
107
- to || (to = new this.constructor());
107
+ to ||= new this.constructor();
108
108
  to.set(...this.get());
109
109
  const { blockLen, buffer, length, finished, destroyed, pos } = this;
110
110
  to.length = length;
@@ -54,7 +54,7 @@ class HMAC extends utils.Hash {
54
54
  }
55
55
  _cloneInto(to) {
56
56
  // Create new instance without calling constructor since key already in state and we don't know it.
57
- to || (to = Object.create(Object.getPrototypeOf(this), {}));
57
+ to ||= Object.create(Object.getPrototypeOf(this), {});
58
58
  const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
59
59
  to = to;
60
60
  to.finished = finished;
@@ -174,7 +174,7 @@ class Keccak extends utils.Hash {
174
174
  }
175
175
  _cloneInto(to) {
176
176
  const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
177
- to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
177
+ to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
178
178
  to.state32.set(this.state32);
179
179
  to.pos = this.pos;
180
180
  to.posOut = this.posOut;
@@ -0,0 +1,298 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /* eslint-disable @typescript-eslint/unbound-method */
6
+ /* eslint-disable @typescript-eslint/return-await */
7
+ /* eslint-disable @typescript-eslint/promise-function-async */
8
+ var _a;
9
+ /** Memory safe (weakmapped) cache of the ProxyPromise for each Promise,
10
+ * which is retained for the lifetime of the original Promise.
11
+ */
12
+ const subscribableCache = new WeakMap();
13
+ /** A NOOP function allowing a consistent interface for settled
14
+ * SubscribedPromises (settled promises are not subscribed - they resolve
15
+ * immediately). */
16
+ const NOOP = () => { };
17
+ /**
18
+ * Every `Promise<T>` can be shadowed by a single `ProxyPromise<T>`. It is
19
+ * created once, cached and reused throughout the lifetime of the Promise. Get a
20
+ * Promise's ProxyPromise using `Unpromise.proxy(promise)`.
21
+ *
22
+ * The `ProxyPromise<T>` attaches handlers to the original `Promise<T>`
23
+ * `.then()` and `.catch()` just once. Promises derived from it use a
24
+ * subscription- (and unsubscription-) based mechanism that monitors these
25
+ * handlers.
26
+ *
27
+ * Every time you call `.subscribe()`, `.then()` `.catch()` or `.finally()` on a
28
+ * `ProxyPromise<T>` it returns a `SubscribedPromise<T>` having an additional
29
+ * `unsubscribe()` method. Calling `unsubscribe()` detaches reference chains
30
+ * from the original, potentially long-lived Promise, eliminating memory leaks.
31
+ *
32
+ * This approach can eliminate the memory leaks that otherwise come about from
33
+ * repeated `race()` or `any()` calls invoking `.then()` and `.catch()` multiple
34
+ * times on the same long-lived native Promise (subscriptions which can never be
35
+ * cleaned up).
36
+ *
37
+ * `Unpromise.race(promises)` is a reference implementation of `Promise.race`
38
+ * avoiding memory leaks when using long-lived unsettled Promises.
39
+ *
40
+ * `Unpromise.any(promises)` is a reference implementation of `Promise.any`
41
+ * avoiding memory leaks when using long-lived unsettled Promises.
42
+ *
43
+ * `Unpromise.resolve(promise)` returns an ephemeral `SubscribedPromise<T>` for
44
+ * any given `Promise<T>` facilitating arbitrary async/await patterns. Behind
45
+ * the scenes, `resolve` is implemented simply as
46
+ * `Unpromise.proxy(promise).subscribe()`. Don't forget to call `.unsubscribe()`
47
+ * to tidy up!
48
+ *
49
+ */
50
+ class Unpromise {
51
+ constructor(arg) {
52
+ /** Promises expecting eventual settlement (unless unsubscribed first). This list is deleted
53
+ * after the original promise settles - no further notifications will be issued. */
54
+ this.subscribers = [];
55
+ /** The Promise's settlement (recorded when it fulfils or rejects). This is consulted when
56
+ * calling .subscribe() .then() .catch() .finally() to see if an immediately-resolving Promise
57
+ * can be returned, and therefore subscription can be bypassed. */
58
+ this.settlement = null;
59
+ /** TOSTRING SUPPORT */
60
+ this[_a] = "Unpromise";
61
+ // handle either a Promise or a Promise executor function
62
+ if (typeof arg === "function") {
63
+ this.promise = new Promise(arg);
64
+ }
65
+ else {
66
+ this.promise = arg;
67
+ }
68
+ // subscribe for eventual fulfilment and rejection
69
+ // handle PromiseLike objects (that at least have .then)
70
+ const thenReturn = this.promise.then((value) => {
71
+ // atomically record fulfilment and detach subscriber list
72
+ const { subscribers } = this;
73
+ this.subscribers = null;
74
+ this.settlement = {
75
+ status: "fulfilled",
76
+ value,
77
+ };
78
+ // notify fulfilment to subscriber list
79
+ subscribers?.forEach(({ resolve }) => {
80
+ resolve(value);
81
+ });
82
+ });
83
+ // handle Promise (that also have a .catch behaviour)
84
+ if ("catch" in thenReturn) {
85
+ thenReturn.catch((reason) => {
86
+ // atomically record rejection and detach subscriber list
87
+ const { subscribers } = this;
88
+ this.subscribers = null;
89
+ this.settlement = {
90
+ status: "rejected",
91
+ reason,
92
+ };
93
+ // notify rejection to subscriber list
94
+ subscribers?.forEach(({ reject }) => {
95
+ reject(reason);
96
+ });
97
+ });
98
+ }
99
+ }
100
+ /** Create a promise that mitigates uncontrolled subscription to a long-lived
101
+ * Promise via .then() and .catch() - otherwise a source of memory leaks.
102
+ *
103
+ * The returned promise has an `unsubscribe()` method which can be called when
104
+ * the Promise is no longer being tracked by application logic, and which
105
+ * ensures that there is no reference chain from the original promise to the
106
+ * new one, and therefore no memory leak.
107
+ *
108
+ * If original promise has not yet settled, this adds a new unique promise
109
+ * that listens to then/catch events, along with an `unsubscribe()` method to
110
+ * detach it.
111
+ *
112
+ * If original promise has settled, then creates a new Promise.resolve() or
113
+ * Promise.reject() and provided unsubscribe is a noop.
114
+ *
115
+ * If you call `unsubscribe()` before the returned Promise has settled, it
116
+ * will never settle.
117
+ */
118
+ subscribe() {
119
+ // in all cases we will combine some promise with its unsubscribe function
120
+ let promise;
121
+ let unsubscribe;
122
+ const { settlement } = this;
123
+ if (settlement === null) {
124
+ // not yet settled - subscribe new promise. Expect eventual settlement
125
+ if (this.subscribers === null) {
126
+ // invariant - it is not settled, so it must have subscribers
127
+ throw new Error("Unpromise settled but still has subscribers");
128
+ }
129
+ const subscriber = withResolvers();
130
+ this.subscribers = listWithMember(this.subscribers, subscriber);
131
+ promise = subscriber.promise;
132
+ unsubscribe = () => {
133
+ if (this.subscribers !== null) {
134
+ this.subscribers = listWithoutMember(this.subscribers, subscriber);
135
+ }
136
+ };
137
+ }
138
+ else {
139
+ // settled - don't create subscribed promise. Just resolve or reject
140
+ const { status } = settlement;
141
+ if (status === "fulfilled") {
142
+ promise = Promise.resolve(settlement.value);
143
+ }
144
+ else {
145
+ promise = Promise.reject(settlement.reason);
146
+ }
147
+ unsubscribe = NOOP;
148
+ }
149
+ // extend promise signature with the extra method
150
+ return Object.assign(promise, { unsubscribe });
151
+ }
152
+ /** STANDARD PROMISE METHODS (but returning a SubscribedPromise) */
153
+ then(onfulfilled, onrejected) {
154
+ const subscribed = this.subscribe();
155
+ const { unsubscribe } = subscribed;
156
+ return Object.assign(subscribed.then(onfulfilled, onrejected), {
157
+ unsubscribe,
158
+ });
159
+ }
160
+ catch(onrejected) {
161
+ const subscribed = this.subscribe();
162
+ const { unsubscribe } = subscribed;
163
+ return Object.assign(subscribed.catch(onrejected), {
164
+ unsubscribe,
165
+ });
166
+ }
167
+ finally(onfinally) {
168
+ const subscribed = this.subscribe();
169
+ const { unsubscribe } = subscribed;
170
+ return Object.assign(subscribed.finally(onfinally), {
171
+ unsubscribe,
172
+ });
173
+ }
174
+ /** Unpromise STATIC METHODS */
175
+ /** Create or Retrieve the proxy Unpromise (a re-used Unpromise for the VM lifetime
176
+ * of the provided Promise reference) */
177
+ static proxy(promise) {
178
+ const cached = Unpromise.getSubscribablePromise(promise);
179
+ return typeof cached !== "undefined"
180
+ ? cached
181
+ : Unpromise.createSubscribablePromise(promise);
182
+ }
183
+ /** Create and store an Unpromise keyed by an original Promise. */
184
+ static createSubscribablePromise(promise) {
185
+ const created = new Unpromise(promise);
186
+ subscribableCache.set(promise, created); // resolve promise to unpromise
187
+ subscribableCache.set(created, created); // resolve the unpromise to itself
188
+ return created;
189
+ }
190
+ /** Retrieve a previously-created Unpromise keyed by an original Promise. */
191
+ static getSubscribablePromise(promise) {
192
+ return subscribableCache.get(promise);
193
+ }
194
+ /** Promise STATIC METHODS */
195
+ /** Lookup the Unpromise for this promise, and derive a SubscribedPromise from
196
+ * it (that can be later unsubscribed to eliminate Memory leaks) */
197
+ static resolve(value) {
198
+ const promise = typeof value === "object" &&
199
+ value !== null &&
200
+ "then" in value &&
201
+ typeof value.then === "function"
202
+ ? value
203
+ : Promise.resolve(value);
204
+ return Unpromise.proxy(promise).subscribe();
205
+ }
206
+ static async any(values) {
207
+ const valuesArray = Array.isArray(values) ? values : [...values];
208
+ const subscribedPromises = valuesArray.map(Unpromise.resolve);
209
+ try {
210
+ return await Promise.any(subscribedPromises);
211
+ }
212
+ finally {
213
+ subscribedPromises.forEach(({ unsubscribe }) => {
214
+ unsubscribe();
215
+ });
216
+ }
217
+ }
218
+ static async race(values) {
219
+ const valuesArray = Array.isArray(values) ? values : [...values];
220
+ const subscribedPromises = valuesArray.map(Unpromise.resolve);
221
+ try {
222
+ return await Promise.race(subscribedPromises);
223
+ }
224
+ finally {
225
+ subscribedPromises.forEach(({ unsubscribe }) => {
226
+ unsubscribe();
227
+ });
228
+ }
229
+ }
230
+ /** Create a race of SubscribedPromises that will fulfil to a single winning
231
+ * Promise (in a 1-Tuple). Eliminates memory leaks from long-lived promises
232
+ * accumulating .then() and .catch() subscribers. Allows simple logic to
233
+ * consume the result, like...
234
+ * ```ts
235
+ * const [ winner ] = await Unpromise.race([ promiseA, promiseB ]);
236
+ * if(winner === promiseB){
237
+ * const result = await promiseB;
238
+ * // do the thing
239
+ * }
240
+ * ```
241
+ * */
242
+ static async raceReferences(promises) {
243
+ // map each promise to an eventual 1-tuple containing itself
244
+ const selfPromises = promises.map(resolveSelfTuple);
245
+ // now race them. They will fulfil to a readonly [P] or reject.
246
+ try {
247
+ return await Promise.race(selfPromises);
248
+ }
249
+ finally {
250
+ for (const promise of selfPromises) {
251
+ // unsubscribe proxy promises when the race is over to mitigate memory leaks
252
+ promise.unsubscribe();
253
+ }
254
+ }
255
+ }
256
+ }
257
+ _a = Symbol.toStringTag;
258
+ /** Promises a 1-tuple containing the original promise when it resolves. Allows
259
+ * awaiting the eventual Promise ***reference*** (easy to destructure and
260
+ * exactly compare with ===). Avoids resolving to the Promise ***value*** (which
261
+ * may be ambiguous and therefore hard to identify as the winner of a race).
262
+ * You can call unsubscribe on the Promise to mitigate memory leaks.
263
+ * */
264
+ function resolveSelfTuple(promise) {
265
+ return Unpromise.proxy(promise).then(() => [promise]);
266
+ }
267
+ /** VENDORED (Future) PROMISE UTILITIES */
268
+ /** Reference implementation of https://github.com/tc39/proposal-promise-with-resolvers */
269
+ function withResolvers() {
270
+ let resolve;
271
+ let reject;
272
+ const promise = new Promise((_resolve, _reject) => {
273
+ resolve = _resolve;
274
+ reject = _reject;
275
+ });
276
+ return {
277
+ promise,
278
+ resolve,
279
+ reject,
280
+ };
281
+ }
282
+ /** IMMUTABLE LIST OPERATIONS */
283
+ function listWithMember(arr, member) {
284
+ return [...arr, member];
285
+ }
286
+ function listWithoutIndex(arr, index) {
287
+ return [...arr.slice(0, index), ...arr.slice(index + 1)];
288
+ }
289
+ function listWithoutMember(arr, member) {
290
+ const index = arr.indexOf(member);
291
+ if (index !== -1) {
292
+ return listWithoutIndex(arr, index);
293
+ }
294
+ return arr;
295
+ }
296
+
297
+ exports.Unpromise = Unpromise;
298
+ exports.resolveSelfTuple = resolveSelfTuple;
package/js/ccxt.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
2
2
  import { Precise } from './src/base/Precise.js';
3
3
  import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
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 } from './src/base/types.js';
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.19";
7
+ declare const version = "4.4.21";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -558,5 +558,5 @@ declare const ccxt: {
558
558
  zaif: typeof zaif;
559
559
  zonda: typeof zonda;
560
560
  } & typeof functions & typeof errors;
561
- export { version, Exchange, exchanges, pro, Precise, functions, errors, 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, 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, MarketMarginModes, 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, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hashkey, hitbtc, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
561
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, 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, 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, MarketMarginModes, 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, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, LongShortRatio, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hashkey, hitbtc, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
562
562
  export default ccxt;
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.20';
41
+ const version = '4.4.22';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -10,6 +10,7 @@ interface Exchange {
10
10
  publicGetGethealth(params?: {}): Promise<implicitReturnType>;
11
11
  publicGetGetboardstate(params?: {}): Promise<implicitReturnType>;
12
12
  publicGetGetchats(params?: {}): Promise<implicitReturnType>;
13
+ publicGetGetfundingrate(params?: {}): Promise<implicitReturnType>;
13
14
  privateGetGetpermissions(params?: {}): Promise<implicitReturnType>;
14
15
  privateGetGetbalance(params?: {}): Promise<implicitReturnType>;
15
16
  privateGetGetbalancehistory(params?: {}): Promise<implicitReturnType>;
@@ -67,12 +67,14 @@ interface Exchange {
67
67
  publicMixGetV2MixMarketCurrentFundRate(params?: {}): Promise<implicitReturnType>;
68
68
  publicMixGetV2MixMarketContracts(params?: {}): Promise<implicitReturnType>;
69
69
  publicMixGetV2MixMarketQueryPositionLever(params?: {}): Promise<implicitReturnType>;
70
+ publicMixGetV2MixMarketAccountLongShort(params?: {}): Promise<implicitReturnType>;
70
71
  publicMarginGetMarginV1CrossPublicInterestRateAndLimit(params?: {}): Promise<implicitReturnType>;
71
72
  publicMarginGetMarginV1IsolatedPublicInterestRateAndLimit(params?: {}): Promise<implicitReturnType>;
72
73
  publicMarginGetMarginV1CrossPublicTierData(params?: {}): Promise<implicitReturnType>;
73
74
  publicMarginGetMarginV1IsolatedPublicTierData(params?: {}): Promise<implicitReturnType>;
74
75
  publicMarginGetMarginV1PublicCurrencies(params?: {}): Promise<implicitReturnType>;
75
76
  publicMarginGetV2MarginCurrencies(params?: {}): Promise<implicitReturnType>;
77
+ publicMarginGetV2MarginMarketLongShortRatio(params?: {}): Promise<implicitReturnType>;
76
78
  publicEarnGetV2EarnLoanPublicCoinInfos(params?: {}): Promise<implicitReturnType>;
77
79
  publicEarnGetV2EarnLoanPublicHourInterest(params?: {}): Promise<implicitReturnType>;
78
80
  privateSpotGetSpotV1WalletDepositAddress(params?: {}): Promise<implicitReturnType>;
@@ -219,6 +221,7 @@ interface Exchange {
219
221
  privateMixGetV2MixOrderOrdersHistory(params?: {}): Promise<implicitReturnType>;
220
222
  privateMixGetV2MixOrderOrdersPlanPending(params?: {}): Promise<implicitReturnType>;
221
223
  privateMixGetV2MixOrderOrdersPlanHistory(params?: {}): Promise<implicitReturnType>;
224
+ privateMixGetV2MixMarketPositionLongShort(params?: {}): Promise<implicitReturnType>;
222
225
  privateMixPostMixV1AccountSubAccountContractAssets(params?: {}): Promise<implicitReturnType>;
223
226
  privateMixPostMixV1AccountOpenCount(params?: {}): Promise<implicitReturnType>;
224
227
  privateMixPostMixV1AccountSetLeverage(params?: {}): Promise<implicitReturnType>;
@@ -162,6 +162,7 @@ interface Exchange {
162
162
  privateGetV5UserDelSubmember(params?: {}): Promise<implicitReturnType>;
163
163
  privateGetV5UserSubmembers(params?: {}): Promise<implicitReturnType>;
164
164
  privateGetV5SpotLeverTokenOrderRecord(params?: {}): Promise<implicitReturnType>;
165
+ privateGetV5SpotMarginTradeInterestRateHistory(params?: {}): Promise<implicitReturnType>;
165
166
  privateGetV5SpotMarginTradeState(params?: {}): Promise<implicitReturnType>;
166
167
  privateGetV5SpotCrossMarginTradeLoanInfo(params?: {}): Promise<implicitReturnType>;
167
168
  privateGetV5SpotCrossMarginTradeAccount(params?: {}): Promise<implicitReturnType>;
@@ -1,35 +1,34 @@
1
1
  import { implicitReturnType } from '../base/types.js';
2
2
  import { Exchange as _Exchange } from '../base/Exchange.js';
3
3
  interface Exchange {
4
- publicGetCurrencyProfile(params?: {}): Promise<implicitReturnType>;
5
- publicGetCurrencyLimits(params?: {}): Promise<implicitReturnType>;
6
- publicGetLastPricePair(params?: {}): Promise<implicitReturnType>;
7
- publicGetLastPricesCurrencies(params?: {}): Promise<implicitReturnType>;
8
- publicGetOhlcvHdYyyymmddPair(params?: {}): Promise<implicitReturnType>;
9
- publicGetOrderBookPair(params?: {}): Promise<implicitReturnType>;
10
- publicGetTickerPair(params?: {}): Promise<implicitReturnType>;
11
- publicGetTickersCurrencies(params?: {}): Promise<implicitReturnType>;
12
- publicGetTradeHistoryPair(params?: {}): Promise<implicitReturnType>;
13
- publicPostConvertPair(params?: {}): Promise<implicitReturnType>;
14
- publicPostPriceStatsPair(params?: {}): Promise<implicitReturnType>;
15
- privatePostActiveOrdersStatus(params?: {}): Promise<implicitReturnType>;
16
- privatePostArchivedOrdersPair(params?: {}): Promise<implicitReturnType>;
17
- privatePostBalance(params?: {}): Promise<implicitReturnType>;
18
- privatePostCancelOrder(params?: {}): Promise<implicitReturnType>;
19
- privatePostCancelOrdersPair(params?: {}): Promise<implicitReturnType>;
20
- privatePostCancelReplaceOrderPair(params?: {}): Promise<implicitReturnType>;
21
- privatePostClosePositionPair(params?: {}): Promise<implicitReturnType>;
22
- privatePostGetAddress(params?: {}): Promise<implicitReturnType>;
23
- privatePostGetCryptoAddress(params?: {}): Promise<implicitReturnType>;
24
- privatePostGetMyfee(params?: {}): Promise<implicitReturnType>;
25
- privatePostGetOrder(params?: {}): Promise<implicitReturnType>;
26
- privatePostGetOrderTx(params?: {}): Promise<implicitReturnType>;
27
- privatePostOpenOrdersPair(params?: {}): Promise<implicitReturnType>;
28
- privatePostOpenOrders(params?: {}): Promise<implicitReturnType>;
29
- privatePostOpenPositionPair(params?: {}): Promise<implicitReturnType>;
30
- privatePostOpenPositionsPair(params?: {}): Promise<implicitReturnType>;
31
- privatePostPlaceOrderPair(params?: {}): Promise<implicitReturnType>;
32
- privatePostRawTxHistory(params?: {}): Promise<implicitReturnType>;
4
+ publicPostGetServerTime(params?: {}): Promise<implicitReturnType>;
5
+ publicPostGetPairsInfo(params?: {}): Promise<implicitReturnType>;
6
+ publicPostGetCurrenciesInfo(params?: {}): Promise<implicitReturnType>;
7
+ publicPostGetProcessingInfo(params?: {}): Promise<implicitReturnType>;
8
+ publicPostGetTicker(params?: {}): Promise<implicitReturnType>;
9
+ publicPostGetTradeHistory(params?: {}): Promise<implicitReturnType>;
10
+ publicPostGetOrderBook(params?: {}): Promise<implicitReturnType>;
11
+ publicPostGetCandles(params?: {}): Promise<implicitReturnType>;
12
+ privatePostGetMyCurrentFee(params?: {}): Promise<implicitReturnType>;
13
+ privatePostGetFeeStrategy(params?: {}): Promise<implicitReturnType>;
14
+ privatePostGetMyVolume(params?: {}): Promise<implicitReturnType>;
15
+ privatePostDoCreateAccount(params?: {}): Promise<implicitReturnType>;
16
+ privatePostGetMyAccountStatusV3(params?: {}): Promise<implicitReturnType>;
17
+ privatePostGetMyWalletBalance(params?: {}): Promise<implicitReturnType>;
18
+ privatePostGetMyOrders(params?: {}): Promise<implicitReturnType>;
19
+ privatePostDoMyNewOrder(params?: {}): Promise<implicitReturnType>;
20
+ privatePostDoCancelMyOrder(params?: {}): Promise<implicitReturnType>;
21
+ privatePostDoCancelAllOrders(params?: {}): Promise<implicitReturnType>;
22
+ privatePostGetOrderBook(params?: {}): Promise<implicitReturnType>;
23
+ privatePostGetCandles(params?: {}): Promise<implicitReturnType>;
24
+ privatePostGetTradeHistory(params?: {}): Promise<implicitReturnType>;
25
+ privatePostGetMyTransactionHistory(params?: {}): Promise<implicitReturnType>;
26
+ privatePostGetMyFundingHistory(params?: {}): Promise<implicitReturnType>;
27
+ privatePostDoMyInternalTransfer(params?: {}): Promise<implicitReturnType>;
28
+ privatePostGetProcessingInfo(params?: {}): Promise<implicitReturnType>;
29
+ privatePostGetDepositAddress(params?: {}): Promise<implicitReturnType>;
30
+ privatePostDoDepositFundsFromWallet(params?: {}): Promise<implicitReturnType>;
31
+ privatePostDoWithdrawalFundsToWallet(params?: {}): Promise<implicitReturnType>;
33
32
  }
34
33
  declare abstract class Exchange extends _Exchange {
35
34
  }
@@ -91,8 +91,13 @@ interface Exchange {
91
91
  privateUnifiedGetInterestRecords(params?: {}): Promise<implicitReturnType>;
92
92
  privateUnifiedGetEstimateRate(params?: {}): Promise<implicitReturnType>;
93
93
  privateUnifiedGetCurrencyDiscountTiers(params?: {}): Promise<implicitReturnType>;
94
+ privateUnifiedGetRiskUnits(params?: {}): Promise<implicitReturnType>;
95
+ privateUnifiedGetUnifiedMode(params?: {}): Promise<implicitReturnType>;
96
+ privateUnifiedGetLoanMarginTiers(params?: {}): Promise<implicitReturnType>;
94
97
  privateUnifiedPostAccountMode(params?: {}): Promise<implicitReturnType>;
95
98
  privateUnifiedPostLoans(params?: {}): Promise<implicitReturnType>;
99
+ privateUnifiedPostPortfolioCalculator(params?: {}): Promise<implicitReturnType>;
100
+ privateUnifiedPutUnifiedMode(params?: {}): Promise<implicitReturnType>;
96
101
  privateSpotGetFee(params?: {}): Promise<implicitReturnType>;
97
102
  privateSpotGetBatchFee(params?: {}): Promise<implicitReturnType>;
98
103
  privateSpotGetAccounts(params?: {}): Promise<implicitReturnType>;