ccxt 4.3.6 → 4.3.7

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 (193) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ace.js +5 -0
  4. package/dist/cjs/src/alpaca.js +6 -0
  5. package/dist/cjs/src/base/Exchange.js +34 -0
  6. package/dist/cjs/src/binance.js +2 -0
  7. package/dist/cjs/src/bingx.js +2 -0
  8. package/dist/cjs/src/bitbank.js +3 -0
  9. package/dist/cjs/src/bitget.js +74 -1
  10. package/dist/cjs/src/bithumb.js +4 -0
  11. package/dist/cjs/src/bitmex.js +2 -0
  12. package/dist/cjs/src/bitopro.js +5 -0
  13. package/dist/cjs/src/bitso.js +3 -0
  14. package/dist/cjs/src/bitstamp.js +3 -0
  15. package/dist/cjs/src/bitteam.js +4 -0
  16. package/dist/cjs/src/bitvavo.js +3 -0
  17. package/dist/cjs/src/bl3p.js +3 -0
  18. package/dist/cjs/src/btcalpha.js +3 -0
  19. package/dist/cjs/src/btcbox.js +3 -0
  20. package/dist/cjs/src/btcmarkets.js +3 -0
  21. package/dist/cjs/src/btcturk.js +3 -0
  22. package/dist/cjs/src/bybit.js +123 -12
  23. package/dist/cjs/src/cex.js +6 -0
  24. package/dist/cjs/src/coinbase.js +95 -17
  25. package/dist/cjs/src/coinbaseinternational.js +2 -0
  26. package/dist/cjs/src/coinbasepro.js +6 -0
  27. package/dist/cjs/src/coincheck.js +3 -0
  28. package/dist/cjs/src/coinex.js +150 -43
  29. package/dist/cjs/src/coinlist.js +4 -0
  30. package/dist/cjs/src/coinmate.js +3 -0
  31. package/dist/cjs/src/coinone.js +3 -0
  32. package/dist/cjs/src/coinsph.js +4 -0
  33. package/dist/cjs/src/coinspot.js +3 -0
  34. package/dist/cjs/src/cryptocom.js +2 -0
  35. package/dist/cjs/src/exmo.js +5 -0
  36. package/dist/cjs/src/gate.js +124 -22
  37. package/dist/cjs/src/hitbtc.js +4 -3
  38. package/dist/cjs/src/htx.js +2 -0
  39. package/dist/cjs/src/idex.js +3 -0
  40. package/dist/cjs/src/independentreserve.js +3 -0
  41. package/dist/cjs/src/indodax.js +3 -0
  42. package/dist/cjs/src/kucoin.js +2 -0
  43. package/dist/cjs/src/kucoinfutures.js +2 -0
  44. package/dist/cjs/src/latoken.js +6 -0
  45. package/dist/cjs/src/luno.js +3 -0
  46. package/dist/cjs/src/lykke.js +5 -0
  47. package/dist/cjs/src/mercado.js +3 -0
  48. package/dist/cjs/src/mexc.js +111 -0
  49. package/dist/cjs/src/ndax.js +4 -0
  50. package/dist/cjs/src/novadax.js +4 -0
  51. package/dist/cjs/src/okx.js +83 -0
  52. package/dist/cjs/src/onetrading.js +3 -0
  53. package/dist/cjs/src/p2b.js +3 -0
  54. package/dist/cjs/src/pro/bybit.js +1 -1
  55. package/dist/cjs/src/pro/coinbase.js +30 -29
  56. package/dist/cjs/src/probit.js +3 -0
  57. package/dist/cjs/src/timex.js +3 -0
  58. package/dist/cjs/src/tradeogre.js +3 -0
  59. package/dist/cjs/src/wavesexchange.js +3 -0
  60. package/dist/cjs/src/wazirx.js +3 -0
  61. package/dist/cjs/src/woo.js +2 -0
  62. package/dist/cjs/src/yobit.js +3 -0
  63. package/js/ccxt.d.ts +1 -1
  64. package/js/ccxt.js +1 -1
  65. package/js/src/abstract/coinbase.d.ts +5 -0
  66. package/js/src/ace.js +5 -0
  67. package/js/src/alpaca.js +6 -0
  68. package/js/src/ascendex.d.ts +2 -2
  69. package/js/src/base/Exchange.d.ts +4 -0
  70. package/js/src/base/Exchange.js +34 -0
  71. package/js/src/bigone.d.ts +1 -1
  72. package/js/src/binance.d.ts +3 -3
  73. package/js/src/binance.js +2 -0
  74. package/js/src/bingx.d.ts +1 -1
  75. package/js/src/bingx.js +2 -0
  76. package/js/src/bitbank.d.ts +1 -1
  77. package/js/src/bitbank.js +3 -0
  78. package/js/src/bitfinex.d.ts +1 -1
  79. package/js/src/bitfinex2.d.ts +1 -1
  80. package/js/src/bitflyer.d.ts +1 -1
  81. package/js/src/bitget.d.ts +4 -3
  82. package/js/src/bitget.js +74 -1
  83. package/js/src/bithumb.d.ts +1 -1
  84. package/js/src/bithumb.js +4 -0
  85. package/js/src/bitmart.d.ts +1 -1
  86. package/js/src/bitmex.d.ts +1 -1
  87. package/js/src/bitmex.js +2 -0
  88. package/js/src/bitopro.d.ts +1 -1
  89. package/js/src/bitopro.js +5 -0
  90. package/js/src/bitrue.d.ts +1 -1
  91. package/js/src/bitso.d.ts +1 -1
  92. package/js/src/bitso.js +3 -0
  93. package/js/src/bitstamp.d.ts +1 -1
  94. package/js/src/bitstamp.js +3 -0
  95. package/js/src/bitteam.js +4 -0
  96. package/js/src/bitvavo.d.ts +1 -1
  97. package/js/src/bitvavo.js +3 -0
  98. package/js/src/bl3p.js +3 -0
  99. package/js/src/blockchaincom.d.ts +1 -1
  100. package/js/src/btcalpha.js +3 -0
  101. package/js/src/btcbox.js +3 -0
  102. package/js/src/btcmarkets.d.ts +1 -1
  103. package/js/src/btcmarkets.js +3 -0
  104. package/js/src/btcturk.js +3 -0
  105. package/js/src/bybit.d.ts +7 -6
  106. package/js/src/bybit.js +123 -12
  107. package/js/src/cex.js +6 -0
  108. package/js/src/coinbase.d.ts +1 -1
  109. package/js/src/coinbase.js +95 -17
  110. package/js/src/coinbaseinternational.d.ts +1 -1
  111. package/js/src/coinbaseinternational.js +2 -0
  112. package/js/src/coinbasepro.d.ts +1 -1
  113. package/js/src/coinbasepro.js +6 -0
  114. package/js/src/coincheck.js +3 -0
  115. package/js/src/coinex.d.ts +8 -7
  116. package/js/src/coinex.js +150 -43
  117. package/js/src/coinlist.d.ts +1 -1
  118. package/js/src/coinlist.js +4 -0
  119. package/js/src/coinmate.d.ts +1 -1
  120. package/js/src/coinmate.js +3 -0
  121. package/js/src/coinone.js +3 -0
  122. package/js/src/coinsph.d.ts +1 -1
  123. package/js/src/coinsph.js +4 -0
  124. package/js/src/coinspot.js +3 -0
  125. package/js/src/cryptocom.d.ts +1 -1
  126. package/js/src/cryptocom.js +2 -0
  127. package/js/src/delta.d.ts +2 -2
  128. package/js/src/deribit.d.ts +1 -1
  129. package/js/src/digifinex.d.ts +3 -3
  130. package/js/src/exmo.d.ts +3 -3
  131. package/js/src/exmo.js +5 -0
  132. package/js/src/gate.d.ts +8 -7
  133. package/js/src/gate.js +124 -22
  134. package/js/src/gemini.d.ts +1 -1
  135. package/js/src/hitbtc.d.ts +3 -3
  136. package/js/src/hitbtc.js +4 -3
  137. package/js/src/hollaex.d.ts +1 -1
  138. package/js/src/htx.d.ts +1 -1
  139. package/js/src/htx.js +2 -0
  140. package/js/src/huobijp.d.ts +1 -1
  141. package/js/src/hyperliquid.d.ts +2 -2
  142. package/js/src/idex.d.ts +1 -1
  143. package/js/src/idex.js +3 -0
  144. package/js/src/independentreserve.js +3 -0
  145. package/js/src/indodax.d.ts +1 -1
  146. package/js/src/indodax.js +3 -0
  147. package/js/src/kraken.d.ts +1 -1
  148. package/js/src/kucoin.d.ts +1 -1
  149. package/js/src/kucoin.js +2 -0
  150. package/js/src/kucoinfutures.d.ts +1 -1
  151. package/js/src/kucoinfutures.js +2 -0
  152. package/js/src/kuna.d.ts +1 -1
  153. package/js/src/latoken.js +6 -0
  154. package/js/src/lbank.d.ts +1 -1
  155. package/js/src/luno.js +3 -0
  156. package/js/src/lykke.d.ts +1 -1
  157. package/js/src/lykke.js +5 -0
  158. package/js/src/mercado.d.ts +1 -1
  159. package/js/src/mercado.js +3 -0
  160. package/js/src/mexc.d.ts +4 -3
  161. package/js/src/mexc.js +111 -0
  162. package/js/src/ndax.d.ts +1 -1
  163. package/js/src/ndax.js +4 -0
  164. package/js/src/novadax.d.ts +1 -1
  165. package/js/src/novadax.js +4 -0
  166. package/js/src/okcoin.d.ts +1 -1
  167. package/js/src/okx.d.ts +9 -8
  168. package/js/src/okx.js +83 -0
  169. package/js/src/onetrading.d.ts +1 -1
  170. package/js/src/onetrading.js +3 -0
  171. package/js/src/p2b.js +3 -0
  172. package/js/src/phemex.d.ts +1 -1
  173. package/js/src/poloniex.d.ts +1 -1
  174. package/js/src/pro/bybit.js +1 -1
  175. package/js/src/pro/coinbase.d.ts +2 -2
  176. package/js/src/pro/coinbase.js +30 -29
  177. package/js/src/probit.d.ts +1 -1
  178. package/js/src/probit.js +3 -0
  179. package/js/src/timex.js +3 -0
  180. package/js/src/tokocrypto.d.ts +1 -1
  181. package/js/src/tradeogre.js +3 -0
  182. package/js/src/upbit.d.ts +1 -1
  183. package/js/src/wavesexchange.d.ts +1 -1
  184. package/js/src/wavesexchange.js +3 -0
  185. package/js/src/wazirx.js +3 -0
  186. package/js/src/whitebit.d.ts +1 -1
  187. package/js/src/woo.d.ts +1 -1
  188. package/js/src/woo.js +2 -0
  189. package/js/src/yobit.d.ts +1 -1
  190. package/js/src/yobit.js +3 -0
  191. package/js/src/zaif.d.ts +1 -1
  192. package/js/src/zonda.d.ts +1 -1
  193. package/package.json +1 -1
@@ -117,7 +117,7 @@ class bybit extends bybit$1 {
117
117
  },
118
118
  'streaming': {
119
119
  'ping': this.ping,
120
- 'keepAlive': 20000,
120
+ 'keepAlive': 19000,
121
121
  },
122
122
  });
123
123
  }
@@ -46,7 +46,7 @@ class coinbase extends coinbase$1 {
46
46
  },
47
47
  });
48
48
  }
49
- async subscribe(name, symbol = undefined, params = {}) {
49
+ async subscribe(name, isPrivate, symbol = undefined, params = {}) {
50
50
  /**
51
51
  * @ignore
52
52
  * @method
@@ -58,7 +58,6 @@ class coinbase extends coinbase$1 {
58
58
  * @returns {object} subscription to a websocket channel
59
59
  */
60
60
  await this.loadMarkets();
61
- this.checkRequiredCredentials();
62
61
  let market = undefined;
63
62
  let messageHash = name;
64
63
  let productIds = [];
@@ -75,8 +74,6 @@ class coinbase extends coinbase$1 {
75
74
  }
76
75
  const url = this.urls['api']['ws'];
77
76
  const timestamp = this.numberToString(this.seconds());
78
- const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
79
- const auth = timestamp + name + productIds.join(',');
80
77
  const subscribe = {
81
78
  'type': 'subscribe',
82
79
  'product_ids': productIds,
@@ -85,25 +82,30 @@ class coinbase extends coinbase$1 {
85
82
  // 'timestamp': timestamp,
86
83
  // 'signature': this.hmac (this.encode (auth), this.encode (this.secret), sha256),
87
84
  };
88
- if (!isCloudAPiKey) {
89
- subscribe['api_key'] = this.apiKey;
90
- subscribe['timestamp'] = timestamp;
91
- subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
92
- }
93
- else {
94
- if (this.apiKey.startsWith('-----BEGIN')) {
95
- throw new errors.ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
85
+ if (isPrivate) {
86
+ this.checkRequiredCredentials();
87
+ const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
88
+ const auth = timestamp + name + productIds.join(',');
89
+ if (!isCloudAPiKey) {
90
+ subscribe['api_key'] = this.apiKey;
91
+ subscribe['timestamp'] = timestamp;
92
+ subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
96
93
  }
97
- const currentToken = this.safeString(this.options, 'wsToken');
98
- const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
99
- const seconds = this.seconds();
100
- if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
101
- // we should generate new token
102
- const token = this.createAuthToken(seconds);
103
- this.options['wsToken'] = token;
104
- this.options['wsTokenTimestamp'] = seconds;
94
+ else {
95
+ if (this.apiKey.startsWith('-----BEGIN')) {
96
+ throw new errors.ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
97
+ }
98
+ const currentToken = this.safeString(this.options, 'wsToken');
99
+ const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
100
+ const seconds = this.seconds();
101
+ if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
102
+ // we should generate new token
103
+ const token = this.createAuthToken(seconds);
104
+ this.options['wsToken'] = token;
105
+ this.options['wsTokenTimestamp'] = seconds;
106
+ }
107
+ subscribe['jwt'] = this.safeString(this.options, 'wsToken');
105
108
  }
106
- subscribe['jwt'] = this.safeString(this.options, 'wsToken');
107
109
  }
108
110
  return await this.watch(url, messageHash, subscribe, messageHash);
109
111
  }
@@ -118,7 +120,7 @@ class coinbase extends coinbase$1 {
118
120
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
119
121
  */
120
122
  const name = 'ticker';
121
- return await this.subscribe(name, symbol, params);
123
+ return await this.subscribe(name, false, symbol, params);
122
124
  }
123
125
  async watchTickers(symbols = undefined, params = {}) {
124
126
  /**
@@ -134,7 +136,7 @@ class coinbase extends coinbase$1 {
134
136
  symbols = this.symbols;
135
137
  }
136
138
  const name = 'ticker_batch';
137
- const tickers = await this.subscribe(name, symbols, params);
139
+ const tickers = await this.subscribe(name, false, symbols, params);
138
140
  if (this.newUpdates) {
139
141
  return tickers;
140
142
  }
@@ -298,7 +300,7 @@ class coinbase extends coinbase$1 {
298
300
  await this.loadMarkets();
299
301
  symbol = this.symbol(symbol);
300
302
  const name = 'market_trades';
301
- const trades = await this.subscribe(name, symbol, params);
303
+ const trades = await this.subscribe(name, false, symbol, params);
302
304
  if (this.newUpdates) {
303
305
  limit = trades.getLimit(symbol, limit);
304
306
  }
@@ -318,7 +320,7 @@ class coinbase extends coinbase$1 {
318
320
  */
319
321
  await this.loadMarkets();
320
322
  const name = 'user';
321
- const orders = await this.subscribe(name, symbol, params);
323
+ const orders = await this.subscribe(name, true, symbol, params);
322
324
  if (this.newUpdates) {
323
325
  limit = orders.getLimit(symbol, limit);
324
326
  }
@@ -339,7 +341,7 @@ class coinbase extends coinbase$1 {
339
341
  const name = 'level2';
340
342
  const market = this.market(symbol);
341
343
  symbol = market['symbol'];
342
- const orderbook = await this.subscribe(name, symbol, params);
344
+ const orderbook = await this.subscribe(name, false, symbol, params);
343
345
  return orderbook.limit();
344
346
  }
345
347
  handleTrade(client, message) {
@@ -557,8 +559,8 @@ class coinbase extends coinbase$1 {
557
559
  this.orderbooks[symbol] = this.orderBook({}, limit);
558
560
  const orderbook = this.orderbooks[symbol];
559
561
  this.handleOrderBookHelper(orderbook, updates);
560
- orderbook['timestamp'] = undefined;
561
- orderbook['datetime'] = undefined;
562
+ orderbook['timestamp'] = this.parse8601(datetime);
563
+ orderbook['datetime'] = datetime;
562
564
  orderbook['symbol'] = symbol;
563
565
  client.resolve(orderbook, messageHash);
564
566
  if (messageHash.endsWith('USD')) {
@@ -577,7 +579,6 @@ class coinbase extends coinbase$1 {
577
579
  }
578
580
  }
579
581
  }
580
- return message;
581
582
  }
582
583
  handleSubscriptionStatus(client, message) {
583
584
  //
@@ -67,8 +67,11 @@ class probit extends probit$1 {
67
67
  'fetchOrder': true,
68
68
  'fetchOrderBook': true,
69
69
  'fetchPosition': false,
70
+ 'fetchPositionHistory': false,
70
71
  'fetchPositionMode': false,
71
72
  'fetchPositions': false,
73
+ 'fetchPositionsForSymbol': false,
74
+ 'fetchPositionsHistory': false,
72
75
  'fetchPositionsRisk': false,
73
76
  'fetchPremiumIndexOHLCV': false,
74
77
  'fetchTicker': true,
@@ -64,8 +64,11 @@ class timex extends timex$1 {
64
64
  'fetchOrder': true,
65
65
  'fetchOrderBook': true,
66
66
  'fetchPosition': false,
67
+ 'fetchPositionHistory': false,
67
68
  'fetchPositionMode': false,
68
69
  'fetchPositions': false,
70
+ 'fetchPositionsForSymbol': false,
71
+ 'fetchPositionsHistory': false,
69
72
  'fetchPositionsRisk': false,
70
73
  'fetchPremiumIndexOHLCV': false,
71
74
  'fetchTicker': true,
@@ -79,8 +79,11 @@ class tradeogre extends tradeogre$1 {
79
79
  'fetchOrderTrades': false,
80
80
  'fetchPermissions': false,
81
81
  'fetchPosition': false,
82
+ 'fetchPositionHistory': false,
83
+ 'fetchPositionMode': false,
82
84
  'fetchPositions': false,
83
85
  'fetchPositionsForSymbol': false,
86
+ 'fetchPositionsHistory': false,
84
87
  'fetchPositionsRisk': false,
85
88
  'fetchPremiumIndexOHLCV': false,
86
89
  'fetchTicker': true,
@@ -66,8 +66,11 @@ class wavesexchange extends wavesexchange$1 {
66
66
  'fetchOrderBook': true,
67
67
  'fetchOrders': true,
68
68
  'fetchPosition': false,
69
+ 'fetchPositionHistory': false,
69
70
  'fetchPositionMode': false,
70
71
  'fetchPositions': false,
72
+ 'fetchPositionsForSymbol': false,
73
+ 'fetchPositionsHistory': false,
71
74
  'fetchPositionsRisk': false,
72
75
  'fetchPremiumIndexOHLCV': false,
73
76
  'fetchTicker': true,
@@ -71,8 +71,11 @@ class wazirx extends wazirx$1 {
71
71
  'fetchOrderBook': true,
72
72
  'fetchOrders': true,
73
73
  'fetchPosition': false,
74
+ 'fetchPositionHistory': false,
74
75
  'fetchPositionMode': false,
75
76
  'fetchPositions': false,
77
+ 'fetchPositionsForSymbol': false,
78
+ 'fetchPositionsHistory': false,
76
79
  'fetchPositionsRisk': false,
77
80
  'fetchPremiumIndexOHLCV': false,
78
81
  'fetchStatus': true,
@@ -88,8 +88,10 @@ class woo extends woo$1 {
88
88
  'fetchOrders': true,
89
89
  'fetchOrderTrades': true,
90
90
  'fetchPosition': true,
91
+ 'fetchPositionHistory': false,
91
92
  'fetchPositionMode': false,
92
93
  'fetchPositions': true,
94
+ 'fetchPositionsHistory': false,
93
95
  'fetchPremiumIndexOHLCV': false,
94
96
  'fetchStatus': true,
95
97
  'fetchTicker': false,
@@ -65,8 +65,11 @@ class yobit extends yobit$1 {
65
65
  'fetchOrderBook': true,
66
66
  'fetchOrderBooks': true,
67
67
  'fetchPosition': false,
68
+ 'fetchPositionHistory': false,
68
69
  'fetchPositionMode': false,
69
70
  'fetchPositions': false,
71
+ 'fetchPositionsForSymbol': false,
72
+ 'fetchPositionsHistory': false,
70
73
  'fetchPositionsRisk': false,
71
74
  'fetchPremiumIndexOHLCV': false,
72
75
  'fetchTicker': true,
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.5";
7
+ declare const version = "4.3.6";
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, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.6';
41
+ const version = '4.3.7';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -47,6 +47,11 @@ interface Exchange {
47
47
  v2PrivateDeleteAccountsId(params?: {}): Promise<implicitReturnType>;
48
48
  v2PrivateDeleteAccountsAccountIdTransactionsTransactionId(params?: {}): Promise<implicitReturnType>;
49
49
  v3PublicGetBrokerageTime(params?: {}): Promise<implicitReturnType>;
50
+ v3PublicGetBrokerageMarketProductBook(params?: {}): Promise<implicitReturnType>;
51
+ v3PublicGetBrokerageMarketProducts(params?: {}): Promise<implicitReturnType>;
52
+ v3PublicGetBrokerageMarketProductsProductId(params?: {}): Promise<implicitReturnType>;
53
+ v3PublicGetBrokerageMarketProductsProductIdCandles(params?: {}): Promise<implicitReturnType>;
54
+ v3PublicGetBrokerageMarketProductsProductIdTicker(params?: {}): Promise<implicitReturnType>;
50
55
  v3PrivateGetBrokerageAccounts(params?: {}): Promise<implicitReturnType>;
51
56
  v3PrivateGetBrokerageAccountsAccountUuid(params?: {}): Promise<implicitReturnType>;
52
57
  v3PrivateGetBrokerageOrdersHistoricalBatch(params?: {}): Promise<implicitReturnType>;
package/js/src/ace.js CHANGED
@@ -65,8 +65,13 @@ export default class ace extends Exchange {
65
65
  'fetchOrderBook': true,
66
66
  'fetchOrders': false,
67
67
  'fetchOrderTrades': true,
68
+ 'fetchPosition': false,
69
+ 'fetchPositionHistory': false,
68
70
  'fetchPositionMode': false,
69
71
  'fetchPositions': false,
72
+ 'fetchPositionsForSymbol': false,
73
+ 'fetchPositionsHistory': false,
74
+ 'fetchPositionsRisk': false,
70
75
  'fetchPremiumIndexOHLCV': false,
71
76
  'fetchTicker': true,
72
77
  'fetchTickers': true,
package/js/src/alpaca.js CHANGED
@@ -74,7 +74,13 @@ export default class alpaca extends Exchange {
74
74
  'fetchOrder': true,
75
75
  'fetchOrderBook': true,
76
76
  'fetchOrders': true,
77
+ 'fetchPosition': false,
78
+ 'fetchPositionHistory': false,
79
+ 'fetchPositionMode': false,
77
80
  'fetchPositions': false,
81
+ 'fetchPositionsForSymbol': false,
82
+ 'fetchPositionsHistory': false,
83
+ 'fetchPositionsRisk': false,
78
84
  'fetchStatus': false,
79
85
  'fetchTicker': false,
80
86
  'fetchTickers': false,
@@ -72,8 +72,8 @@ export default class ascendex extends Exchange {
72
72
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<any>;
73
73
  modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
74
74
  parseMarginModification(data: any, market?: Market): MarginModification;
75
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
76
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
75
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
76
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
77
77
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
78
78
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
79
79
  fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<{}>;
@@ -432,6 +432,8 @@ export default class Exchange {
432
432
  fetchOrderWs: any;
433
433
  fetchPermissions: any;
434
434
  fetchPosition: any;
435
+ fetchPositionHistory: any;
436
+ fetchPositionsHistory: any;
435
437
  fetchPositionWs: any;
436
438
  fetchPositionMode: any;
437
439
  fetchPositions: any;
@@ -1075,6 +1077,8 @@ export default class Exchange {
1075
1077
  convertExpireDate(date: string): string;
1076
1078
  convertExpireDateToMarketIdDate(date: string): string;
1077
1079
  convertMarketIdExpireDate(date: string): string;
1080
+ fetchPositionHistory(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Position>;
1081
+ fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
1078
1082
  parseMarginModification(data: any, market?: Market): MarginModification;
1079
1083
  parseMarginModifications(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): MarginModification[];
1080
1084
  }
@@ -490,6 +490,8 @@ export default class Exchange {
490
490
  'fetchOrderWs': undefined,
491
491
  'fetchPermissions': undefined,
492
492
  'fetchPosition': undefined,
493
+ 'fetchPositionHistory': undefined,
494
+ 'fetchPositionsHistory': undefined,
493
495
  'fetchPositionWs': undefined,
494
496
  'fetchPositionMode': undefined,
495
497
  'fetchPositions': undefined,
@@ -6194,6 +6196,38 @@ export default class Exchange {
6194
6196
  const reconstructedDate = day + month + year;
6195
6197
  return reconstructedDate;
6196
6198
  }
6199
+ async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
6200
+ /**
6201
+ * @method
6202
+ * @name exchange#fetchPositionHistory
6203
+ * @description fetches the history of margin added or reduced from contract isolated positions
6204
+ * @param {string} [symbol] unified market symbol
6205
+ * @param {int} [since] timestamp in ms of the position
6206
+ * @param {int} [limit] the maximum amount of candles to fetch, default=1000
6207
+ * @param {object} params extra parameters specific to the exchange api endpoint
6208
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
6209
+ */
6210
+ if (this.has['fetchPositionsHistory']) {
6211
+ const positions = await this.fetchPositionsHistory([symbol], since, limit, params);
6212
+ return this.safeDict(positions, 0);
6213
+ }
6214
+ else {
6215
+ throw new NotSupported(this.id + ' fetchPositionHistory () is not supported yet');
6216
+ }
6217
+ }
6218
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
6219
+ /**
6220
+ * @method
6221
+ * @name exchange#fetchPositionsHistory
6222
+ * @description fetches the history of margin added or reduced from contract isolated positions
6223
+ * @param {string} [symbol] unified market symbol
6224
+ * @param {int} [since] timestamp in ms of the position
6225
+ * @param {int} [limit] the maximum amount of candles to fetch, default=1000
6226
+ * @param {object} params extra parameters specific to the exchange api endpoint
6227
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
6228
+ */
6229
+ throw new NotSupported(this.id + ' fetchPositionsHistory () is not supported yet');
6230
+ }
6197
6231
  parseMarginModification(data, market = undefined) {
6198
6232
  throw new NotSupported(this.id + ' parseMarginModification() is not supported yet');
6199
6233
  }
@@ -64,6 +64,6 @@ export default class bigone extends Exchange {
64
64
  status: string;
65
65
  };
66
66
  parseTransferStatus(status: any): string;
67
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
67
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
68
68
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
69
69
  }
@@ -135,7 +135,7 @@ export default class binance extends Exchange {
135
135
  }>;
136
136
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
137
137
  parseDepositWithdrawFee(fee: any, currency?: Currency): any;
138
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
138
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
139
139
  parseTradingFee(fee: any, market?: Market): TradingFeeInterface;
140
140
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
141
141
  fetchTradingFees(params?: {}): Promise<TradingFees>;
@@ -301,8 +301,8 @@ export default class binance extends Exchange {
301
301
  request(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any, config?: {}): Promise<any>;
302
302
  modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
303
303
  parseMarginModification(data: any, market?: Market): MarginModification;
304
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
305
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
304
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
305
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
306
306
  fetchCrossBorrowRate(code: string, params?: {}): Promise<{
307
307
  currency: string;
308
308
  rate: number;
package/js/src/binance.js CHANGED
@@ -128,8 +128,10 @@ export default class binance extends Exchange {
128
128
  'fetchOrders': true,
129
129
  'fetchOrderTrades': true,
130
130
  'fetchPosition': true,
131
+ 'fetchPositionHistory': false,
131
132
  'fetchPositionMode': true,
132
133
  'fetchPositions': true,
134
+ 'fetchPositionsHistory': false,
133
135
  'fetchPositionsRisk': true,
134
136
  'fetchPremiumIndexOHLCV': false,
135
137
  'fetchSettlementHistory': true,
package/js/src/bingx.d.ts CHANGED
@@ -132,7 +132,7 @@ export default class bingx extends Exchange {
132
132
  networks: {};
133
133
  };
134
134
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
135
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
135
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
136
136
  parseParams(params: any): {};
137
137
  fetchMyLiquidations(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
138
138
  parseLiquidation(liquidation: any, market?: Market): import("./base/types.js").Liquidation;
package/js/src/bingx.js CHANGED
@@ -75,8 +75,10 @@ export default class bingx extends Exchange {
75
75
  'fetchOrder': true,
76
76
  'fetchOrderBook': true,
77
77
  'fetchOrders': true,
78
+ 'fetchPositionHistory': false,
78
79
  'fetchPositionMode': true,
79
80
  'fetchPositions': true,
81
+ 'fetchPositionsHistory': false,
80
82
  'fetchTicker': true,
81
83
  'fetchTickers': true,
82
84
  'fetchTime': true,
@@ -32,7 +32,7 @@ export default class bitbank extends Exchange {
32
32
  network: any;
33
33
  info: any;
34
34
  }>;
35
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
35
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
36
36
  parseTransaction(transaction: any, currency?: Currency): Transaction;
37
37
  nonce(): number;
38
38
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/bitbank.js CHANGED
@@ -59,8 +59,11 @@ export default class bitbank extends Exchange {
59
59
  'fetchOrder': true,
60
60
  'fetchOrderBook': true,
61
61
  'fetchPosition': false,
62
+ 'fetchPositionHistory': false,
62
63
  'fetchPositionMode': false,
63
64
  'fetchPositions': false,
65
+ 'fetchPositionsForSymbol': false,
66
+ 'fetchPositionsHistory': false,
64
67
  'fetchPositionsRisk': false,
65
68
  'fetchPremiumIndexOHLCV': false,
66
69
  'fetchTicker': true,
@@ -74,7 +74,7 @@ export default class bitfinex extends Exchange {
74
74
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
75
75
  parseTransaction(transaction: any, currency?: Currency): Transaction;
76
76
  parseTransactionStatus(status: any): string;
77
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
77
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
78
78
  fetchPositions(symbols?: Strings, params?: {}): Promise<any>;
79
79
  nonce(): number;
80
80
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
@@ -78,7 +78,7 @@ export default class bitfinex2 extends Exchange {
78
78
  parseTransaction(transaction: any, currency?: Currency): Transaction;
79
79
  fetchTradingFees(params?: {}): Promise<TradingFees>;
80
80
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
81
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<any>;
81
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<any>;
82
82
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
83
83
  parsePosition(position: any, market?: Market): import("./base/types.js").Position;
84
84
  nonce(): number;
@@ -27,7 +27,7 @@ export default class bitflyer extends Exchange {
27
27
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
28
28
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
29
29
  fetchPositions(symbols?: Strings, params?: {}): Promise<any>;
30
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
30
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
31
31
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
32
32
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
33
33
  parseDepositStatus(status: any): string;
@@ -17,7 +17,7 @@ export default class bitget extends Exchange {
17
17
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
18
18
  parseMarketLeverageTiers(info: any, market?: Market): any[];
19
19
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
20
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
20
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
21
21
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
22
22
  parseTransaction(transaction: any, currency?: Currency): Transaction;
23
23
  parseTransactionStatus(status: any): string;
@@ -145,8 +145,8 @@ export default class bitget extends Exchange {
145
145
  parseFundingHistories(contracts: any, market?: any, since?: Int, limit?: Int): FundingHistory[];
146
146
  modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
147
147
  parseMarginModification(data: any, market?: Market): MarginModification;
148
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
149
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
148
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
149
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
150
150
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
151
151
  parseLeverage(leverage: any, market?: any): Leverage;
152
152
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
@@ -282,6 +282,7 @@ export default class bitget extends Exchange {
282
282
  closeAllPositions(params?: {}): Promise<Position[]>;
283
283
  fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
284
284
  parseMarginMode(marginMode: any, market?: any): MarginMode;
285
+ fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
285
286
  fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
286
287
  createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
287
288
  fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
package/js/src/bitget.js CHANGED
@@ -109,8 +109,10 @@ export default class bitget extends Exchange {
109
109
  'fetchOrders': false,
110
110
  'fetchOrderTrades': false,
111
111
  'fetchPosition': true,
112
+ 'fetchPositionHistory': 'emulated',
112
113
  'fetchPositionMode': false,
113
114
  'fetchPositions': true,
115
+ 'fetchPositionsHistory': true,
114
116
  'fetchPositionsRisk': false,
115
117
  'fetchPremiumIndexOHLCV': false,
116
118
  'fetchStatus': false,
@@ -6551,7 +6553,7 @@ export default class bitget extends Exchange {
6551
6553
  // "cTime": "1700807507275"
6552
6554
  // }
6553
6555
  //
6554
- // fetchPositions: privateMixGetV2MixPositionHistoryPosition
6556
+ // fetchPositionsHistory: privateMixGetV2MixPositionHistoryPosition
6555
6557
  //
6556
6558
  // {
6557
6559
  // "symbol": "BTCUSDT",
@@ -8450,6 +8452,77 @@ export default class bitget extends Exchange {
8450
8452
  'marginMode': marginType,
8451
8453
  };
8452
8454
  }
8455
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
8456
+ /**
8457
+ * @method
8458
+ * @name bitget#fetchPositionsHistory
8459
+ * @description fetches historical positions
8460
+ * @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
8461
+ * @param {string} [symbol] unified contract symbols
8462
+ * @param {int} [since] timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
8463
+ * @param {int} [limit] the maximum amount of records to fetch, default=20, max=100
8464
+ * @param {object} params extra parameters specific to the exchange api endpoint
8465
+ * @param {int} [params.until] timestamp in ms of the latest position to fetch, max range for params["until"] - since is 3 months
8466
+ *
8467
+ * EXCHANGE SPECIFIC PARAMETERS
8468
+ * @param {string} [params.productType] USDT-FUTURES (default), COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, or SUSDC-FUTURES
8469
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
8470
+ */
8471
+ await this.loadMarkets();
8472
+ const until = this.safeInteger(params, 'until');
8473
+ params = this.omit(params, 'until');
8474
+ const request = {};
8475
+ if (symbols !== undefined) {
8476
+ const symbolsLength = symbols.length;
8477
+ if (symbolsLength > 0) {
8478
+ const market = this.market(symbols[0]);
8479
+ request['symbol'] = market['id'];
8480
+ }
8481
+ }
8482
+ if (since !== undefined) {
8483
+ request['startTime'] = since;
8484
+ }
8485
+ if (limit !== undefined) {
8486
+ request['limit'] = limit;
8487
+ }
8488
+ if (until !== undefined) {
8489
+ request['endTime'] = until;
8490
+ }
8491
+ const response = await this.privateMixGetV2MixPositionHistoryPosition(this.extend(request, params));
8492
+ //
8493
+ // {
8494
+ // code: '00000',
8495
+ // msg: 'success',
8496
+ // requestTime: '1712794148791',
8497
+ // data: {
8498
+ // list: [
8499
+ // {
8500
+ // symbol: 'XRPUSDT',
8501
+ // marginCoin: 'USDT',
8502
+ // holdSide: 'long',
8503
+ // openAvgPrice: '0.64967',
8504
+ // closeAvgPrice: '0.58799',
8505
+ // marginMode: 'isolated',
8506
+ // openTotalPos: '10',
8507
+ // closeTotalPos: '10',
8508
+ // pnl: '-0.62976205',
8509
+ // netProfit: '-0.65356802',
8510
+ // totalFunding: '-0.01638',
8511
+ // openFee: '-0.00389802',
8512
+ // closeFee: '-0.00352794',
8513
+ // ctime: '1709590322199',
8514
+ // utime: '1709667583395'
8515
+ // },
8516
+ // ...
8517
+ // ]
8518
+ // }
8519
+ // }
8520
+ //
8521
+ const data = this.safeDict(response, 'data');
8522
+ const responseList = this.safeList(data, 'list');
8523
+ const positions = this.parsePositions(responseList, symbols, params);
8524
+ return this.filterBySinceLimit(positions, since, limit);
8525
+ }
8453
8526
  async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
8454
8527
  /**
8455
8528
  * @method