ccxt 4.4.40 → 4.4.42

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 (183) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ace.js +1 -1
  5. package/dist/cjs/src/alpaca.js +0 -1
  6. package/dist/cjs/src/ascendex.js +0 -1
  7. package/dist/cjs/src/base/Exchange.js +41 -19
  8. package/dist/cjs/src/bigone.js +0 -1
  9. package/dist/cjs/src/binance.js +27 -24
  10. package/dist/cjs/src/bingx.js +6 -1
  11. package/dist/cjs/src/bitfinex.js +124 -1
  12. package/dist/cjs/src/bitget.js +1 -0
  13. package/dist/cjs/src/bitmart.js +254 -1
  14. package/dist/cjs/src/blofin.js +16 -7
  15. package/dist/cjs/src/bybit.js +8 -8
  16. package/dist/cjs/src/cex.js +1 -1
  17. package/dist/cjs/src/coinbase.js +8 -9
  18. package/dist/cjs/src/coinbaseexchange.js +5 -6
  19. package/dist/cjs/src/coinbaseinternational.js +7 -8
  20. package/dist/cjs/src/coincatch.js +0 -1
  21. package/dist/cjs/src/coincheck.js +0 -1
  22. package/dist/cjs/src/coinex.js +91 -6
  23. package/dist/cjs/src/coinlist.js +3 -4
  24. package/dist/cjs/src/coinmate.js +1 -3
  25. package/dist/cjs/src/coinmetro.js +4 -5
  26. package/dist/cjs/src/coinone.js +0 -1
  27. package/dist/cjs/src/coinsph.js +7 -8
  28. package/dist/cjs/src/cryptocom.js +3 -0
  29. package/dist/cjs/src/currencycom.js +3 -4
  30. package/dist/cjs/src/defx.js +6 -7
  31. package/dist/cjs/src/deribit.js +1 -3
  32. package/dist/cjs/src/digifinex.js +0 -1
  33. package/dist/cjs/src/ellipx.js +0 -2
  34. package/dist/cjs/src/exmo.js +63 -6
  35. package/dist/cjs/src/gate.js +2 -3
  36. package/dist/cjs/src/gemini.js +4 -5
  37. package/dist/cjs/src/hashkey.js +79 -83
  38. package/dist/cjs/src/hitbtc.js +49 -5
  39. package/dist/cjs/src/hollaex.js +4 -6
  40. package/dist/cjs/src/htx.js +2 -4
  41. package/dist/cjs/src/huobijp.js +0 -1
  42. package/dist/cjs/src/hyperliquid.js +65 -1
  43. package/dist/cjs/src/idex.js +8 -8
  44. package/dist/cjs/src/independentreserve.js +0 -1
  45. package/dist/cjs/src/indodax.js +0 -1
  46. package/dist/cjs/src/kraken.js +192 -29
  47. package/dist/cjs/src/krakenfutures.js +75 -3
  48. package/dist/cjs/src/kucoin.js +7 -4
  49. package/dist/cjs/src/kucoinfutures.js +10 -9
  50. package/dist/cjs/src/kuna.js +1 -3
  51. package/dist/cjs/src/latoken.js +1 -3
  52. package/dist/cjs/src/lbank.js +0 -1
  53. package/dist/cjs/src/luno.js +0 -1
  54. package/dist/cjs/src/lykke.js +0 -1
  55. package/dist/cjs/src/mercado.js +0 -1
  56. package/dist/cjs/src/mexc.js +6 -7
  57. package/dist/cjs/src/ndax.js +1 -1
  58. package/dist/cjs/src/novadax.js +4 -6
  59. package/dist/cjs/src/oceanex.js +0 -1
  60. package/dist/cjs/src/okcoin.js +1 -3
  61. package/dist/cjs/src/okx.js +7 -4
  62. package/dist/cjs/src/onetrading.js +1 -3
  63. package/dist/cjs/src/p2b.js +1 -1
  64. package/dist/cjs/src/paradex.js +5 -7
  65. package/dist/cjs/src/phemex.js +8 -10
  66. package/dist/cjs/src/poloniex.js +1 -3
  67. package/dist/cjs/src/poloniexfutures.js +6 -6
  68. package/dist/cjs/src/probit.js +0 -1
  69. package/dist/cjs/src/timex.js +0 -1
  70. package/dist/cjs/src/tokocrypto.js +11 -14
  71. package/dist/cjs/src/tradeogre.js +1 -1
  72. package/dist/cjs/src/upbit.js +0 -1
  73. package/dist/cjs/src/wavesexchange.js +4 -5
  74. package/dist/cjs/src/whitebit.js +8 -9
  75. package/dist/cjs/src/woo.js +99 -13
  76. package/dist/cjs/src/woofipro.js +96 -15
  77. package/dist/cjs/src/xt.js +8 -4
  78. package/dist/cjs/src/yobit.js +0 -1
  79. package/dist/cjs/src/zaif.js +0 -1
  80. package/dist/cjs/src/zonda.js +1 -2
  81. package/js/ccxt.d.ts +3 -3
  82. package/js/ccxt.js +1 -1
  83. package/js/src/abstract/binance.d.ts +3 -0
  84. package/js/src/abstract/binancecoinm.d.ts +3 -0
  85. package/js/src/abstract/binanceus.d.ts +3 -0
  86. package/js/src/abstract/binanceusdm.d.ts +3 -0
  87. package/js/src/abstract/bitmart.d.ts +2 -0
  88. package/js/src/abstract/okx.d.ts +5 -0
  89. package/js/src/ace.js +1 -1
  90. package/js/src/alpaca.js +0 -1
  91. package/js/src/ascendex.js +0 -1
  92. package/js/src/base/Exchange.d.ts +12 -9
  93. package/js/src/base/Exchange.js +41 -19
  94. package/js/src/base/types.d.ts +2 -0
  95. package/js/src/bigone.js +0 -1
  96. package/js/src/binance.js +27 -24
  97. package/js/src/bingx.js +6 -1
  98. package/js/src/bitfinex.d.ts +11 -1
  99. package/js/src/bitfinex.js +124 -1
  100. package/js/src/bitget.js +1 -0
  101. package/js/src/bitmart.d.ts +52 -1
  102. package/js/src/bitmart.js +254 -1
  103. package/js/src/blofin.d.ts +1 -1
  104. package/js/src/blofin.js +16 -7
  105. package/js/src/bybit.js +8 -8
  106. package/js/src/cex.js +1 -1
  107. package/js/src/coinbase.js +8 -9
  108. package/js/src/coinbaseexchange.js +5 -6
  109. package/js/src/coinbaseinternational.d.ts +1 -1
  110. package/js/src/coinbaseinternational.js +7 -8
  111. package/js/src/coincatch.js +0 -1
  112. package/js/src/coincheck.js +0 -1
  113. package/js/src/coinex.js +91 -6
  114. package/js/src/coinlist.js +3 -4
  115. package/js/src/coinmate.js +1 -3
  116. package/js/src/coinmetro.js +4 -5
  117. package/js/src/coinone.js +0 -1
  118. package/js/src/coinsph.js +7 -8
  119. package/js/src/cryptocom.js +3 -0
  120. package/js/src/currencycom.js +3 -4
  121. package/js/src/defx.js +6 -7
  122. package/js/src/deribit.js +1 -3
  123. package/js/src/digifinex.js +0 -1
  124. package/js/src/ellipx.js +0 -2
  125. package/js/src/exmo.d.ts +36 -1
  126. package/js/src/exmo.js +63 -6
  127. package/js/src/gate.d.ts +1 -1
  128. package/js/src/gate.js +2 -3
  129. package/js/src/gemini.js +4 -5
  130. package/js/src/hashkey.js +79 -83
  131. package/js/src/hitbtc.d.ts +11 -1
  132. package/js/src/hitbtc.js +49 -5
  133. package/js/src/hollaex.js +4 -6
  134. package/js/src/htx.js +2 -4
  135. package/js/src/huobijp.js +0 -1
  136. package/js/src/hyperliquid.d.ts +20 -1
  137. package/js/src/hyperliquid.js +65 -1
  138. package/js/src/idex.js +8 -8
  139. package/js/src/independentreserve.js +0 -1
  140. package/js/src/indodax.js +0 -1
  141. package/js/src/kraken.d.ts +15 -9
  142. package/js/src/kraken.js +192 -29
  143. package/js/src/krakenfutures.d.ts +2 -2
  144. package/js/src/krakenfutures.js +75 -3
  145. package/js/src/kucoin.js +7 -4
  146. package/js/src/kucoinfutures.d.ts +5 -4
  147. package/js/src/kucoinfutures.js +10 -9
  148. package/js/src/kuna.js +1 -3
  149. package/js/src/latoken.js +1 -3
  150. package/js/src/lbank.js +0 -1
  151. package/js/src/luno.js +0 -1
  152. package/js/src/lykke.js +0 -1
  153. package/js/src/mercado.js +0 -1
  154. package/js/src/mexc.js +6 -7
  155. package/js/src/ndax.js +1 -1
  156. package/js/src/novadax.js +4 -6
  157. package/js/src/oceanex.js +0 -1
  158. package/js/src/okcoin.js +1 -3
  159. package/js/src/okx.js +7 -4
  160. package/js/src/onetrading.js +1 -3
  161. package/js/src/p2b.js +1 -1
  162. package/js/src/paradex.d.ts +1 -1
  163. package/js/src/paradex.js +5 -7
  164. package/js/src/phemex.js +8 -10
  165. package/js/src/poloniex.js +1 -3
  166. package/js/src/poloniexfutures.js +6 -6
  167. package/js/src/probit.js +0 -1
  168. package/js/src/timex.js +0 -1
  169. package/js/src/tokocrypto.js +11 -14
  170. package/js/src/tradeogre.js +1 -1
  171. package/js/src/upbit.js +0 -1
  172. package/js/src/wavesexchange.d.ts +1 -1
  173. package/js/src/wavesexchange.js +4 -5
  174. package/js/src/whitebit.js +8 -9
  175. package/js/src/woo.d.ts +1 -1
  176. package/js/src/woo.js +99 -13
  177. package/js/src/woofipro.js +96 -15
  178. package/js/src/xt.d.ts +2 -1
  179. package/js/src/xt.js +8 -4
  180. package/js/src/yobit.js +0 -1
  181. package/js/src/zaif.js +0 -1
  182. package/js/src/zonda.js +1 -2
  183. package/package.json +2 -2
package/js/src/bitget.js CHANGED
@@ -1246,6 +1246,7 @@ export default class bitget extends Exchange {
1246
1246
  '41103': InvalidOrder,
1247
1247
  '41114': OnMaintenance,
1248
1248
  '43011': InvalidOrder,
1249
+ '43001': OrderNotFound,
1249
1250
  '43012': InsufficientFunds,
1250
1251
  '43025': InvalidOrder,
1251
1252
  '43115': OnMaintenance,
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmart.js';
2
- import type { Int, OrderSide, Balances, OrderType, OHLCV, Order, Str, Trade, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, TransferEntry, Num, TradingFeeInterface, Currencies, IsolatedBorrowRates, IsolatedBorrowRate, Dict, OrderRequest, int, FundingRate, DepositAddress, BorrowInterest } from './base/types.js';
2
+ import type { Int, OrderSide, Balances, OrderType, OHLCV, Order, Str, Trade, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, TransferEntry, Num, TradingFeeInterface, Currencies, IsolatedBorrowRates, IsolatedBorrowRate, Dict, OrderRequest, int, FundingRate, DepositAddress, BorrowInterest, FundingRateHistory, LedgerEntry, FundingHistory } from './base/types.js';
3
3
  /**
4
4
  * @class bitmart
5
5
  * @augments Exchange
@@ -572,6 +572,18 @@ export default class bitmart extends Exchange {
572
572
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
573
573
  */
574
574
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
575
+ /**
576
+ * @method
577
+ * @name bitmart#fetchFundingRateHistory
578
+ * @description fetches historical funding rate prices
579
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-funding-rate-history
580
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
581
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
582
+ * @param {int} [limit] the maximum amount of funding rate structures to fetch
583
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
584
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
585
+ */
586
+ fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
575
587
  parseFundingRate(contract: any, market?: Market): FundingRate;
576
588
  /**
577
589
  * @method
@@ -635,6 +647,45 @@ export default class bitmart extends Exchange {
635
647
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
636
648
  */
637
649
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
650
+ /**
651
+ * @method
652
+ * @name bitmart#fetchLedger
653
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
654
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
655
+ * @param {string} [code] unified currency code
656
+ * @param {int} [since] timestamp in ms of the earliest ledger entry
657
+ * @param {int} [limit] max number of ledger entries to return
658
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
659
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
660
+ * @returns {object[]} a list of [ledger structures]{@link https://docs.ccxt.com/#/?id=ledger}
661
+ */
662
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
663
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
664
+ parseLedgerEntryType(type: any): string;
665
+ fetchTransactionsRequest(flowType?: Int, symbol?: Str, since?: Int, limit?: Int, params?: {}): any;
666
+ /**
667
+ * @method
668
+ * @name bitmart#fetchFundingHistory
669
+ * @description fetch the history of funding payments paid and received on this account
670
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
671
+ * @param {string} [symbol] unified market symbol
672
+ * @param {int} [since] the starting timestamp in milliseconds
673
+ * @param {int} [limit] the number of entries to return
674
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
675
+ * @param {int} [params.until] the latest time in ms to fetch funding history for
676
+ * @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
677
+ */
678
+ fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
679
+ parseFundingHistory(contract: any, market?: Market): {
680
+ info: any;
681
+ symbol: string;
682
+ code: string;
683
+ timestamp: number;
684
+ datetime: string;
685
+ id: string;
686
+ amount: number;
687
+ };
688
+ parseFundingHistories(contracts: any, market?: any, since?: Int, limit?: Int): FundingHistory[];
638
689
  nonce(): number;
639
690
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
640
691
  url: string;
package/js/src/bitmart.js CHANGED
@@ -65,12 +65,13 @@ export default class bitmart extends Exchange {
65
65
  'fetchDeposits': true,
66
66
  'fetchDepositWithdrawFee': true,
67
67
  'fetchDepositWithdrawFees': false,
68
- 'fetchFundingHistory': undefined,
68
+ 'fetchFundingHistory': true,
69
69
  'fetchFundingRate': true,
70
70
  'fetchFundingRateHistory': false,
71
71
  'fetchFundingRates': false,
72
72
  'fetchIsolatedBorrowRate': true,
73
73
  'fetchIsolatedBorrowRates': true,
74
+ 'fetchLedger': true,
74
75
  'fetchLiquidations': false,
75
76
  'fetchMarginMode': false,
76
77
  'fetchMarkets': true,
@@ -157,6 +158,7 @@ export default class bitmart extends Exchange {
157
158
  'contract/public/depth': 5,
158
159
  'contract/public/open-interest': 30,
159
160
  'contract/public/funding-rate': 30,
161
+ 'contract/public/funding-rate-history': 30,
160
162
  'contract/public/kline': 6,
161
163
  'account/v1/currencies': 30,
162
164
  },
@@ -207,6 +209,7 @@ export default class bitmart extends Exchange {
207
209
  'contract/private/position-risk': 10,
208
210
  'contract/private/affilate/rebate-list': 10,
209
211
  'contract/private/affilate/trade-list': 10,
212
+ 'contract/private/transaction-history': 10,
210
213
  },
211
214
  'post': {
212
215
  // sub-account endpoints
@@ -4618,6 +4621,65 @@ export default class bitmart extends Exchange {
4618
4621
  const data = this.safeDict(response, 'data', {});
4619
4622
  return this.parseFundingRate(data, market);
4620
4623
  }
4624
+ /**
4625
+ * @method
4626
+ * @name bitmart#fetchFundingRateHistory
4627
+ * @description fetches historical funding rate prices
4628
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-funding-rate-history
4629
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
4630
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
4631
+ * @param {int} [limit] the maximum amount of funding rate structures to fetch
4632
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4633
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
4634
+ */
4635
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4636
+ if (symbol === undefined) {
4637
+ throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
4638
+ }
4639
+ await this.loadMarkets();
4640
+ const market = this.market(symbol);
4641
+ const request = {
4642
+ 'symbol': market['id'],
4643
+ };
4644
+ if (limit !== undefined) {
4645
+ request['limit'] = limit;
4646
+ }
4647
+ const response = await this.publicGetContractPublicFundingRateHistory(this.extend(request, params));
4648
+ //
4649
+ // {
4650
+ // "code": 1000,
4651
+ // "message": "Ok",
4652
+ // "data": {
4653
+ // "list": [
4654
+ // {
4655
+ // "symbol": "BTCUSDT",
4656
+ // "funding_rate": "0.000091412174",
4657
+ // "funding_time": "1734336000000"
4658
+ // },
4659
+ // ]
4660
+ // },
4661
+ // "trace": "fg73d949fgfdf6a40c8fc7f5ae6738.54.345345345345"
4662
+ // }
4663
+ //
4664
+ const data = this.safeDict(response, 'data', {});
4665
+ const result = this.safeList(data, 'list', []);
4666
+ const rates = [];
4667
+ for (let i = 0; i < result.length; i++) {
4668
+ const entry = result[i];
4669
+ const marketId = this.safeString(entry, 'symbol');
4670
+ const symbolInner = this.safeSymbol(marketId, market, '-', 'swap');
4671
+ const timestamp = this.safeInteger(entry, 'funding_time');
4672
+ rates.push({
4673
+ 'info': entry,
4674
+ 'symbol': symbolInner,
4675
+ 'fundingRate': this.safeNumber(entry, 'funding_rate'),
4676
+ 'timestamp': timestamp,
4677
+ 'datetime': this.iso8601(timestamp),
4678
+ });
4679
+ }
4680
+ const sorted = this.sortBy(rates, 'timestamp');
4681
+ return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
4682
+ }
4621
4683
  parseFundingRate(contract, market = undefined) {
4622
4684
  //
4623
4685
  // {
@@ -5052,6 +5114,197 @@ export default class bitmart extends Exchange {
5052
5114
  const data = this.safeDict(response, 'data', {});
5053
5115
  return this.parseOrder(data, market);
5054
5116
  }
5117
+ /**
5118
+ * @method
5119
+ * @name bitmart#fetchLedger
5120
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
5121
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
5122
+ * @param {string} [code] unified currency code
5123
+ * @param {int} [since] timestamp in ms of the earliest ledger entry
5124
+ * @param {int} [limit] max number of ledger entries to return
5125
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5126
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
5127
+ * @returns {object[]} a list of [ledger structures]{@link https://docs.ccxt.com/#/?id=ledger}
5128
+ */
5129
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
5130
+ await this.loadMarkets();
5131
+ let currency = undefined;
5132
+ if (code !== undefined) {
5133
+ currency = this.currency(code);
5134
+ }
5135
+ let request = {};
5136
+ [request, params] = this.handleUntilOption('end_time', request, params);
5137
+ const transactionsRequest = this.fetchTransactionsRequest(0, undefined, since, limit, params);
5138
+ const response = await this.privateGetContractPrivateTransactionHistory(transactionsRequest);
5139
+ //
5140
+ // {
5141
+ // "code": 1000,
5142
+ // "message": "Ok",
5143
+ // "data": [
5144
+ // {
5145
+ // "time": "1734422402121",
5146
+ // "type": "Funding Fee",
5147
+ // "amount": "-0.00008253",
5148
+ // "asset": "USDT",
5149
+ // "symbol": "LTCUSDT",
5150
+ // "tran_id": "1734422402121",
5151
+ // "flow_type": 3
5152
+ // },
5153
+ // ],
5154
+ // "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
5155
+ // }
5156
+ //
5157
+ const data = this.safeList(response, 'data', []);
5158
+ return this.parseLedger(data, currency, since, limit);
5159
+ }
5160
+ parseLedgerEntry(item, currency = undefined) {
5161
+ //
5162
+ // {
5163
+ // "time": "1734422402121",
5164
+ // "type": "Funding Fee",
5165
+ // "amount": "-0.00008253",
5166
+ // "asset": "USDT",
5167
+ // "symbol": "LTCUSDT",
5168
+ // "tran_id": "1734422402121",
5169
+ // "flow_type": 3
5170
+ // }
5171
+ //
5172
+ let amount = this.safeString(item, 'amount');
5173
+ let direction = undefined;
5174
+ if (Precise.stringLe(amount, '0')) {
5175
+ direction = 'out';
5176
+ amount = Precise.stringMul('-1', amount);
5177
+ }
5178
+ else {
5179
+ direction = 'in';
5180
+ }
5181
+ const currencyId = this.safeString(item, 'asset');
5182
+ const timestamp = this.safeInteger(item, 'time');
5183
+ const type = this.safeString(item, 'type');
5184
+ return this.safeLedgerEntry({
5185
+ 'info': item,
5186
+ 'id': this.safeString(item, 'tran_id'),
5187
+ 'direction': direction,
5188
+ 'account': undefined,
5189
+ 'referenceAccount': undefined,
5190
+ 'referenceId': this.safeString(item, 'tradeId'),
5191
+ 'type': this.parseLedgerEntryType(type),
5192
+ 'currency': this.safeCurrencyCode(currencyId, currency),
5193
+ 'amount': this.parseNumber(amount),
5194
+ 'timestamp': timestamp,
5195
+ 'datetime': this.iso8601(timestamp),
5196
+ 'before': undefined,
5197
+ 'after': undefined,
5198
+ 'status': undefined,
5199
+ 'fee': undefined,
5200
+ }, currency);
5201
+ }
5202
+ parseLedgerEntryType(type) {
5203
+ const ledgerType = {
5204
+ 'Commission Fee': 'fee',
5205
+ 'Funding Fee': 'fee',
5206
+ 'Realized PNL': 'trade',
5207
+ 'Transfer': 'transfer',
5208
+ 'Liquidation Clearance': 'settlement',
5209
+ };
5210
+ return this.safeString(ledgerType, type, type);
5211
+ }
5212
+ fetchTransactionsRequest(flowType = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
5213
+ let request = {};
5214
+ if (flowType !== undefined) {
5215
+ request['flow_type'] = flowType;
5216
+ }
5217
+ let market = undefined;
5218
+ if (symbol !== undefined) {
5219
+ market = this.market(symbol);
5220
+ request['symbol'] = market['id'];
5221
+ }
5222
+ if (since !== undefined) {
5223
+ request['start_time'] = since;
5224
+ }
5225
+ if (limit !== undefined) {
5226
+ request['page_size'] = limit;
5227
+ }
5228
+ [request, params] = this.handleUntilOption('end_time', request, params);
5229
+ return this.extend(request, params);
5230
+ }
5231
+ /**
5232
+ * @method
5233
+ * @name bitmart#fetchFundingHistory
5234
+ * @description fetch the history of funding payments paid and received on this account
5235
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
5236
+ * @param {string} [symbol] unified market symbol
5237
+ * @param {int} [since] the starting timestamp in milliseconds
5238
+ * @param {int} [limit] the number of entries to return
5239
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5240
+ * @param {int} [params.until] the latest time in ms to fetch funding history for
5241
+ * @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
5242
+ */
5243
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5244
+ await this.loadMarkets();
5245
+ let market = undefined;
5246
+ if (symbol !== undefined) {
5247
+ market = this.market(symbol);
5248
+ }
5249
+ let request = {};
5250
+ [request, params] = this.handleUntilOption('end_time', request, params);
5251
+ const transactionsRequest = this.fetchTransactionsRequest(3, symbol, since, limit, params);
5252
+ const response = await this.privateGetContractPrivateTransactionHistory(transactionsRequest);
5253
+ //
5254
+ // {
5255
+ // "code": 1000,
5256
+ // "message": "Ok",
5257
+ // "data": [
5258
+ // {
5259
+ // "time": "1734422402121",
5260
+ // "type": "Funding Fee",
5261
+ // "amount": "-0.00008253",
5262
+ // "asset": "USDT",
5263
+ // "symbol": "LTCUSDT",
5264
+ // "tran_id": "1734422402121",
5265
+ // "flow_type": 3
5266
+ // },
5267
+ // ],
5268
+ // "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
5269
+ // }
5270
+ //
5271
+ const data = this.safeList(response, 'data', []);
5272
+ return this.parseFundingHistories(data, market, since, limit);
5273
+ }
5274
+ parseFundingHistory(contract, market = undefined) {
5275
+ //
5276
+ // {
5277
+ // "time": "1734422402121",
5278
+ // "type": "Funding Fee",
5279
+ // "amount": "-0.00008253",
5280
+ // "asset": "USDT",
5281
+ // "symbol": "LTCUSDT",
5282
+ // "tran_id": "1734422402121",
5283
+ // "flow_type": 3
5284
+ // }
5285
+ //
5286
+ const marketId = this.safeString(contract, 'symbol');
5287
+ const currencyId = this.safeString(contract, 'asset');
5288
+ const timestamp = this.safeInteger(contract, 'time');
5289
+ return {
5290
+ 'info': contract,
5291
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
5292
+ 'code': this.safeCurrencyCode(currencyId),
5293
+ 'timestamp': timestamp,
5294
+ 'datetime': this.iso8601(timestamp),
5295
+ 'id': this.safeString(contract, 'tran_id'),
5296
+ 'amount': this.safeNumber(contract, 'amount'),
5297
+ };
5298
+ }
5299
+ parseFundingHistories(contracts, market = undefined, since = undefined, limit = undefined) {
5300
+ const result = [];
5301
+ for (let i = 0; i < contracts.length; i++) {
5302
+ const contract = contracts[i];
5303
+ result.push(this.parseFundingHistory(contract, market));
5304
+ }
5305
+ const sorted = this.sortBy(result, 'timestamp');
5306
+ return this.filterBySinceLimit(sorted, since, limit);
5307
+ }
5055
5308
  nonce() {
5056
5309
  return this.milliseconds();
5057
5310
  }
@@ -113,7 +113,7 @@ export default class blofin extends Exchange {
113
113
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
114
114
  */
115
115
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
116
- parseBalanceByType(type: any, response: any): Balances;
116
+ parseBalanceByType(response: any): Balances;
117
117
  parseBalance(response: any): Balances;
118
118
  parseFundingBalance(response: any): Balances;
119
119
  parseTradingFee(fee: Dict, market?: Market): TradingFeeInterface;
package/js/src/blofin.js CHANGED
@@ -161,7 +161,7 @@ export default class blofin extends Exchange {
161
161
  'rest': 'https://openapi.blofin.com',
162
162
  },
163
163
  'referral': {
164
- 'url': 'https://blofin.com/register?referral_code=jBd8U1',
164
+ 'url': 'https://blofin.com/register?referral_code=f79EsS',
165
165
  'discount': 0.05,
166
166
  },
167
167
  'www': 'https://www.blofin.com',
@@ -281,10 +281,18 @@ export default class blofin extends Exchange {
281
281
  'brokerId': 'ec6dd3a7dd982d0b',
282
282
  'accountsByType': {
283
283
  'swap': 'futures',
284
+ 'funding': 'funding',
284
285
  'future': 'futures',
286
+ 'copy_trading': 'copy_trading',
287
+ 'earn': 'earn',
288
+ 'spot': 'spot',
285
289
  },
286
290
  'accountsById': {
291
+ 'funding': 'funding',
287
292
  'futures': 'swap',
293
+ 'copy_trading': 'copy_trading',
294
+ 'earn': 'earn',
295
+ 'spot': 'spot',
288
296
  },
289
297
  'sandboxMode': false,
290
298
  'defaultNetwork': 'ERC20',
@@ -882,8 +890,9 @@ export default class blofin extends Exchange {
882
890
  const entry = this.safeDict(data, 0, {});
883
891
  return this.parseFundingRate(entry, market);
884
892
  }
885
- parseBalanceByType(type, response) {
886
- if (type) {
893
+ parseBalanceByType(response) {
894
+ const data = this.safeList(response, 'data');
895
+ if ((data !== undefined) && Array.isArray(data)) {
887
896
  return this.parseFundingBalance(response);
888
897
  }
889
898
  else {
@@ -1001,11 +1010,11 @@ export default class blofin extends Exchange {
1001
1010
  */
1002
1011
  async fetchBalance(params = {}) {
1003
1012
  await this.loadMarkets();
1004
- const accountType = this.safeString2(params, 'accountType', 'type');
1005
- params = this.omit(params, ['accountType', 'type']);
1013
+ let accountType = undefined;
1014
+ [accountType, params] = this.handleOptionAndParams2(params, 'fetchBalance', 'accountType', 'type');
1006
1015
  const request = {};
1007
1016
  let response = undefined;
1008
- if (accountType !== undefined) {
1017
+ if (accountType !== undefined && accountType !== 'swap') {
1009
1018
  const options = this.safeDict(this.options, 'accountsByType', {});
1010
1019
  const parsedAccountType = this.safeString(options, accountType, accountType);
1011
1020
  request['accountType'] = parsedAccountType;
@@ -1014,7 +1023,7 @@ export default class blofin extends Exchange {
1014
1023
  else {
1015
1024
  response = await this.privateGetAccountBalance(this.extend(request, params));
1016
1025
  }
1017
- return this.parseBalanceByType(accountType, response);
1026
+ return this.parseBalanceByType(response);
1018
1027
  }
1019
1028
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1020
1029
  const market = this.market(symbol);
package/js/src/bybit.js CHANGED
@@ -3685,33 +3685,33 @@ export default class bybit extends Exchange {
3685
3685
  const avgPrice = this.omitZero(this.safeString(order, 'avgPrice'));
3686
3686
  const rawTimeInForce = this.safeString(order, 'timeInForce');
3687
3687
  const timeInForce = this.parseTimeInForce(rawTimeInForce);
3688
- const stopPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
3688
+ const triggerPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
3689
3689
  const reduceOnly = this.safeBool(order, 'reduceOnly');
3690
3690
  let takeProfitPrice = this.omitZero(this.safeString(order, 'takeProfit'));
3691
3691
  let stopLossPrice = this.omitZero(this.safeString(order, 'stopLoss'));
3692
3692
  const triggerDirection = this.safeString(order, 'triggerDirection');
3693
3693
  const isAscending = (triggerDirection === '1');
3694
- const isStopOrderType2 = (stopPrice !== undefined) && reduceOnly;
3694
+ const isStopOrderType2 = (triggerPrice !== undefined) && reduceOnly;
3695
3695
  if ((stopLossPrice === undefined) && isStopOrderType2) {
3696
3696
  // check if order is stop order type 2 - stopLossPrice
3697
3697
  if (isAscending && (side === 'buy')) {
3698
3698
  // stopLoss order against short position
3699
- stopLossPrice = stopPrice;
3699
+ stopLossPrice = triggerPrice;
3700
3700
  }
3701
3701
  if (!isAscending && (side === 'sell')) {
3702
3702
  // stopLoss order against a long position
3703
- stopLossPrice = stopPrice;
3703
+ stopLossPrice = triggerPrice;
3704
3704
  }
3705
3705
  }
3706
3706
  if ((takeProfitPrice === undefined) && isStopOrderType2) {
3707
3707
  // check if order is stop order type 2 - takeProfitPrice
3708
3708
  if (isAscending && (side === 'sell')) {
3709
3709
  // takeprofit order against a long position
3710
- takeProfitPrice = stopPrice;
3710
+ takeProfitPrice = triggerPrice;
3711
3711
  }
3712
3712
  if (!isAscending && (side === 'buy')) {
3713
3713
  // takeprofit order against a short position
3714
- takeProfitPrice = stopPrice;
3714
+ takeProfitPrice = triggerPrice;
3715
3715
  }
3716
3716
  }
3717
3717
  return this.safeOrder({
@@ -3729,7 +3729,7 @@ export default class bybit extends Exchange {
3729
3729
  'reduceOnly': this.safeBool(order, 'reduceOnly'),
3730
3730
  'side': side,
3731
3731
  'price': price,
3732
- 'triggerPrice': stopPrice,
3732
+ 'triggerPrice': triggerPrice,
3733
3733
  'takeProfitPrice': takeProfitPrice,
3734
3734
  'stopLossPrice': stopLossPrice,
3735
3735
  'amount': amount,
@@ -6757,7 +6757,7 @@ export default class bybit extends Exchange {
6757
6757
  const data = this.addPaginationCursorToResult(response);
6758
6758
  const id = this.safeString(result, 'symbol');
6759
6759
  market = this.safeMarket(id, market, undefined, 'contract');
6760
- return this.parseOpenInterests(data, market, since, limit);
6760
+ return this.parseOpenInterestsHistory(data, market, since, limit);
6761
6761
  }
6762
6762
  /**
6763
6763
  * @method
package/js/src/cex.js CHANGED
@@ -1090,7 +1090,7 @@ export default class cex extends Exchange {
1090
1090
  'postOnly': undefined,
1091
1091
  'side': this.safeStringLower(order, 'side'),
1092
1092
  'price': this.safeNumber(order, 'price'),
1093
- 'stopPrice': this.safeNumber(order, 'stopPrice'),
1093
+ 'triggerPrice': this.safeNumber(order, 'stopPrice'),
1094
1094
  'amount': requestedBase,
1095
1095
  'cost': executedQuote,
1096
1096
  'average': this.safeNumber(order, 'averagePrice'),
@@ -2893,10 +2893,10 @@ export default class coinbase extends Exchange {
2893
2893
  'product_id': market['id'],
2894
2894
  'side': side.toUpperCase(),
2895
2895
  };
2896
- const stopPrice = this.safeNumberN(params, ['stopPrice', 'stop_price', 'triggerPrice']);
2896
+ const triggerPrice = this.safeNumberN(params, ['stopPrice', 'stop_price', 'triggerPrice']);
2897
2897
  const stopLossPrice = this.safeNumber(params, 'stopLossPrice');
2898
2898
  const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
2899
- const isStop = stopPrice !== undefined;
2899
+ const isStop = triggerPrice !== undefined;
2900
2900
  const isStopLoss = stopLossPrice !== undefined;
2901
2901
  const isTakeProfit = takeProfitPrice !== undefined;
2902
2902
  const timeInForce = this.safeString(params, 'timeInForce');
@@ -2916,7 +2916,7 @@ export default class coinbase extends Exchange {
2916
2916
  'stop_limit_stop_limit_gtd': {
2917
2917
  'base_size': this.amountToPrecision(symbol, amount),
2918
2918
  'limit_price': this.priceToPrecision(symbol, price),
2919
- 'stop_price': this.priceToPrecision(symbol, stopPrice),
2919
+ 'stop_price': this.priceToPrecision(symbol, triggerPrice),
2920
2920
  'stop_direction': stopDirection,
2921
2921
  'end_time': endTime,
2922
2922
  },
@@ -2927,31 +2927,31 @@ export default class coinbase extends Exchange {
2927
2927
  'stop_limit_stop_limit_gtc': {
2928
2928
  'base_size': this.amountToPrecision(symbol, amount),
2929
2929
  'limit_price': this.priceToPrecision(symbol, price),
2930
- 'stop_price': this.priceToPrecision(symbol, stopPrice),
2930
+ 'stop_price': this.priceToPrecision(symbol, triggerPrice),
2931
2931
  'stop_direction': stopDirection,
2932
2932
  },
2933
2933
  };
2934
2934
  }
2935
2935
  }
2936
2936
  else if (isStopLoss || isTakeProfit) {
2937
- let triggerPrice = undefined;
2937
+ let tpslPrice = undefined;
2938
2938
  if (isStopLoss) {
2939
2939
  if (stopDirection === undefined) {
2940
2940
  stopDirection = (side === 'buy') ? 'STOP_DIRECTION_STOP_UP' : 'STOP_DIRECTION_STOP_DOWN';
2941
2941
  }
2942
- triggerPrice = this.priceToPrecision(symbol, stopLossPrice);
2942
+ tpslPrice = this.priceToPrecision(symbol, stopLossPrice);
2943
2943
  }
2944
2944
  else {
2945
2945
  if (stopDirection === undefined) {
2946
2946
  stopDirection = (side === 'buy') ? 'STOP_DIRECTION_STOP_DOWN' : 'STOP_DIRECTION_STOP_UP';
2947
2947
  }
2948
- triggerPrice = this.priceToPrecision(symbol, takeProfitPrice);
2948
+ tpslPrice = this.priceToPrecision(symbol, takeProfitPrice);
2949
2949
  }
2950
2950
  request['order_configuration'] = {
2951
2951
  'stop_limit_stop_limit_gtc': {
2952
2952
  'base_size': this.amountToPrecision(symbol, amount),
2953
2953
  'limit_price': this.priceToPrecision(symbol, price),
2954
- 'stop_price': triggerPrice,
2954
+ 'stop_price': tpslPrice,
2955
2955
  'stop_direction': stopDirection,
2956
2956
  },
2957
2957
  };
@@ -3234,7 +3234,6 @@ export default class coinbase extends Exchange {
3234
3234
  'postOnly': postOnly,
3235
3235
  'side': this.safeStringLower(order, 'side'),
3236
3236
  'price': price,
3237
- 'stopPrice': triggerPrice,
3238
3237
  'triggerPrice': triggerPrice,
3239
3238
  'amount': amount,
3240
3239
  'filled': this.safeString(order, 'filled_size'),
@@ -1064,7 +1064,7 @@ export default class coinbaseexchange extends Exchange {
1064
1064
  const side = this.safeString(order, 'side');
1065
1065
  const timeInForce = this.safeString(order, 'time_in_force');
1066
1066
  const postOnly = this.safeValue(order, 'post_only');
1067
- const stopPrice = this.safeNumber(order, 'stop_price');
1067
+ const triggerPrice = this.safeNumber(order, 'stop_price');
1068
1068
  const clientOrderId = this.safeString(order, 'client_oid');
1069
1069
  return this.safeOrder({
1070
1070
  'id': id,
@@ -1080,8 +1080,7 @@ export default class coinbaseexchange extends Exchange {
1080
1080
  'postOnly': postOnly,
1081
1081
  'side': side,
1082
1082
  'price': price,
1083
- 'stopPrice': stopPrice,
1084
- 'triggerPrice': stopPrice,
1083
+ 'triggerPrice': triggerPrice,
1085
1084
  'cost': cost,
1086
1085
  'amount': amount,
1087
1086
  'filled': filled,
@@ -1257,9 +1256,9 @@ export default class coinbaseexchange extends Exchange {
1257
1256
  if (clientOrderId !== undefined) {
1258
1257
  request['client_oid'] = clientOrderId;
1259
1258
  }
1260
- const stopPrice = this.safeNumberN(params, ['stopPrice', 'stop_price', 'triggerPrice']);
1261
- if (stopPrice !== undefined) {
1262
- request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
1259
+ const triggerPrice = this.safeNumberN(params, ['stopPrice', 'stop_price', 'triggerPrice']);
1260
+ if (triggerPrice !== undefined) {
1261
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
1263
1262
  }
1264
1263
  const timeInForce = this.safeString2(params, 'timeInForce', 'time_in_force');
1265
1264
  if (timeInForce !== undefined) {
@@ -311,7 +311,7 @@ export default class coinbaseinternational extends Exchange {
311
311
  * @param {float} amount how much you want to trade in units of the base currency, quote currency for 'market' 'buy' orders
312
312
  * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
313
313
  * @param {object} [params] extra parameters specific to the exchange API endpoint
314
- * @param {float} [params.stopPrice] price to trigger stop orders
314
+ * @param {float} [params.stopPrice] alias for triggerPrice
315
315
  * @param {float} [params.triggerPrice] price to trigger stop orders
316
316
  * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
317
317
  * @param {bool} [params.postOnly] true or false