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
@@ -91,8 +91,13 @@ interface gate {
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>;
@@ -19,6 +19,7 @@ interface Exchange {
19
19
  publicGetMarkPriceSymbolCurrent(params?: {}): Promise<implicitReturnType>;
20
20
  publicGetMarkPriceAllSymbols(params?: {}): Promise<implicitReturnType>;
21
21
  publicGetMarginConfig(params?: {}): Promise<implicitReturnType>;
22
+ publicGetAnnouncements(params?: {}): Promise<implicitReturnType>;
22
23
  publicPostBulletPublic(params?: {}): Promise<implicitReturnType>;
23
24
  privateGetUserInfo(params?: {}): Promise<implicitReturnType>;
24
25
  privateGetAccounts(params?: {}): Promise<implicitReturnType>;
@@ -122,6 +123,7 @@ interface Exchange {
122
123
  privatePostLendPurchaseUpdate(params?: {}): Promise<implicitReturnType>;
123
124
  privatePostBulletPrivate(params?: {}): Promise<implicitReturnType>;
124
125
  privatePostPositionUpdateUserLeverage(params?: {}): Promise<implicitReturnType>;
126
+ privatePostDepositAddressCreate(params?: {}): Promise<implicitReturnType>;
125
127
  privateDeleteSubApiKey(params?: {}): Promise<implicitReturnType>;
126
128
  privateDeleteWithdrawalsWithdrawalId(params?: {}): Promise<implicitReturnType>;
127
129
  privateDeleteHfOrdersOrderId(params?: {}): Promise<implicitReturnType>;
@@ -19,6 +19,7 @@ interface kucoin {
19
19
  publicGetMarkPriceSymbolCurrent(params?: {}): Promise<implicitReturnType>;
20
20
  publicGetMarkPriceAllSymbols(params?: {}): Promise<implicitReturnType>;
21
21
  publicGetMarginConfig(params?: {}): Promise<implicitReturnType>;
22
+ publicGetAnnouncements(params?: {}): Promise<implicitReturnType>;
22
23
  publicPostBulletPublic(params?: {}): Promise<implicitReturnType>;
23
24
  privateGetUserInfo(params?: {}): Promise<implicitReturnType>;
24
25
  privateGetAccounts(params?: {}): Promise<implicitReturnType>;
@@ -122,6 +123,7 @@ interface kucoin {
122
123
  privatePostLendPurchaseUpdate(params?: {}): Promise<implicitReturnType>;
123
124
  privatePostBulletPrivate(params?: {}): Promise<implicitReturnType>;
124
125
  privatePostPositionUpdateUserLeverage(params?: {}): Promise<implicitReturnType>;
126
+ privatePostDepositAddressCreate(params?: {}): Promise<implicitReturnType>;
125
127
  privateDeleteSubApiKey(params?: {}): Promise<implicitReturnType>;
126
128
  privateDeleteWithdrawalsWithdrawalId(params?: {}): Promise<implicitReturnType>;
127
129
  privateDeleteHfOrdersOrderId(params?: {}): Promise<implicitReturnType>;
@@ -47,6 +47,7 @@ interface Exchange {
47
47
  publicGetRubikStatTakerVolume(params?: {}): Promise<implicitReturnType>;
48
48
  publicGetRubikStatMarginLoanRatio(params?: {}): Promise<implicitReturnType>;
49
49
  publicGetRubikStatContractsLongShortAccountRatio(params?: {}): Promise<implicitReturnType>;
50
+ publicGetRubikStatContractsLongShortAccountRatioContract(params?: {}): Promise<implicitReturnType>;
50
51
  publicGetRubikStatContractsOpenInterestVolume(params?: {}): Promise<implicitReturnType>;
51
52
  publicGetRubikStatOptionOpenInterestVolume(params?: {}): Promise<implicitReturnType>;
52
53
  publicGetRubikStatOptionOpenInterestVolumeRatio(params?: {}): Promise<implicitReturnType>;
@@ -152,6 +153,9 @@ interface Exchange {
152
153
  privateGetAccountFixedLoanBorrowingLimit(params?: {}): Promise<implicitReturnType>;
153
154
  privateGetAccountFixedLoanBorrowingQuote(params?: {}): Promise<implicitReturnType>;
154
155
  privateGetAccountFixedLoanBorrowingOrdersList(params?: {}): Promise<implicitReturnType>;
156
+ privateGetAccountSpotManualBorrowRepay(params?: {}): Promise<implicitReturnType>;
157
+ privateGetAccountSetAutoRepay(params?: {}): Promise<implicitReturnType>;
158
+ privateGetAccountSpotBorrowRepayHistory(params?: {}): Promise<implicitReturnType>;
155
159
  privateGetUsersSubaccountList(params?: {}): Promise<implicitReturnType>;
156
160
  privateGetAccountSubaccountBalances(params?: {}): Promise<implicitReturnType>;
157
161
  privateGetAssetSubaccountBalances(params?: {}): Promise<implicitReturnType>;
package/js/src/alpaca.js CHANGED
@@ -63,6 +63,7 @@ export default class alpaca extends Exchange {
63
63
  'fetchDepositsWithdrawals': false,
64
64
  'fetchFundingHistory': false,
65
65
  'fetchFundingRate': false,
66
+ 'fetchFundingRateHistory': false,
66
67
  'fetchFundingRates': false,
67
68
  'fetchL1OrderBook': true,
68
69
  'fetchL2OrderBook': false,
@@ -3,8 +3,8 @@ import { // eslint-disable-line object-curly-newline
3
3
  ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotAvailable, RateLimitExceeded } from "./errors.js";
4
4
  import WsClient from './ws/WsClient.js';
5
5
  import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
6
- import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CancellationRequest, IsolatedBorrowRate, IsolatedBorrowRates, CrossBorrowRates, CrossBorrowRate, Dict, FundingRates, LeverageTiers, Bool, int, DepositAddress } from './types.js';
7
- export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, Bool, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, CrossBorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, Conversion, DepositAddress } from './types.js';
6
+ import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CancellationRequest, IsolatedBorrowRate, IsolatedBorrowRates, CrossBorrowRates, CrossBorrowRate, Dict, FundingRates, LeverageTiers, Bool, int, DepositAddress, LongShortRatio } from './types.js';
7
+ export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, Bool, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, CrossBorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, Conversion, DepositAddress, LongShortRatio } from './types.js';
8
8
  import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
9
9
  import { OrderBook as Ob } from './ws/OrderBook.js';
10
10
  import Client from './ws/Client.js';
@@ -366,7 +366,7 @@ export default class Exchange {
366
366
  getProperty(obj: any, property: any, defaultValue?: any): any;
367
367
  setProperty(obj: any, property: any, defaultValue?: any): void;
368
368
  axolotl(payload: any, hexKey: any, ed25519: any): string;
369
- fixStringifiedJsonMembers(content: string): any;
369
+ fixStringifiedJsonMembers(content: string): string;
370
370
  ethAbiEncode(types: any, args: any): Uint8Array;
371
371
  ethEncodeStructuredData(domain: any, messageTypes: any, messageData: any): Uint8Array;
372
372
  retrieveStarkAccount(signature: any, accountClassHash: any, accountProxyClassHash: any): {
@@ -514,6 +514,8 @@ export default class Exchange {
514
514
  fetchLeverages: any;
515
515
  fetchLeverageTiers: any;
516
516
  fetchLiquidations: any;
517
+ fetchLongShortRatio: any;
518
+ fetchLongShortRatioHistory: any;
517
519
  fetchMarginMode: any;
518
520
  fetchMarginModes: any;
519
521
  fetchMarketLeverageTiers: any;
@@ -792,6 +794,8 @@ export default class Exchange {
792
794
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
793
795
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
794
796
  setMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
797
+ fetchLongShortRatio(symbol: string, timeframe?: Str, params?: {}): Promise<LongShortRatio>;
798
+ fetchLongShortRatioHistory(symbol?: Str, timeframe?: Str, since?: Int, limit?: Int, params?: {}): Promise<LongShortRatio[]>;
795
799
  fetchMarginAdjustmentHistory(symbol?: Str, type?: Str, since?: Num, limit?: Num, params?: {}): Promise<MarginModification[]>;
796
800
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<{}>;
797
801
  fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<DepositAddress[]>;
@@ -1094,11 +1098,15 @@ export default class Exchange {
1094
1098
  parseTickers(tickers: any, symbols?: Strings, params?: {}): Tickers;
1095
1099
  parseDepositAddresses(addresses: any, codes?: Strings, indexed?: boolean, params?: {}): DepositAddress[];
1096
1100
  parseBorrowInterests(response: any, market?: Market): any[];
1101
+ parseBorrowRate(info: any, currency?: Currency): Dict;
1102
+ parseBorrowRateHistory(response: any, code: Str, since: Int, limit: Int): any;
1097
1103
  parseIsolatedBorrowRates(info: any): IsolatedBorrowRates;
1098
1104
  parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int): FundingRateHistory[];
1099
1105
  safeSymbol(marketId: Str, market?: Market, delimiter?: Str, marketType?: Str): string;
1100
1106
  parseFundingRate(contract: string, market?: Market): FundingRate;
1101
1107
  parseFundingRates(response: any, market?: Market): FundingRates;
1108
+ parseLongShortRatio(info: Dict, market?: Market): LongShortRatio;
1109
+ parseLongShortRatioHistory(response: any, market?: any, since?: Int, limit?: Int): LongShortRatio[];
1102
1110
  handleTriggerAndParams(params: any): any[];
1103
1111
  isTriggerOrder(params: any): any[];
1104
1112
  isPostOnly(isMarketOrder: boolean, exchangeSpecificParam: any, params?: {}): boolean;
@@ -1402,6 +1402,8 @@ export default class Exchange {
1402
1402
  'fetchLeverages': undefined,
1403
1403
  'fetchLeverageTiers': undefined,
1404
1404
  'fetchLiquidations': undefined,
1405
+ 'fetchLongShortRatio': undefined,
1406
+ 'fetchLongShortRatioHistory': undefined,
1405
1407
  'fetchMarginMode': undefined,
1406
1408
  'fetchMarginModes': undefined,
1407
1409
  'fetchMarketLeverageTiers': undefined,
@@ -2195,6 +2197,12 @@ export default class Exchange {
2195
2197
  async setMargin(symbol, amount, params = {}) {
2196
2198
  throw new NotSupported(this.id + ' setMargin() is not supported yet');
2197
2199
  }
2200
+ async fetchLongShortRatio(symbol, timeframe = undefined, params = {}) {
2201
+ throw new NotSupported(this.id + ' fetchLongShortRatio() is not supported yet');
2202
+ }
2203
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
2204
+ throw new NotSupported(this.id + ' fetchLongShortRatioHistory() is not supported yet');
2205
+ }
2198
2206
  async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
2199
2207
  /**
2200
2208
  * @method
@@ -5507,6 +5515,19 @@ export default class Exchange {
5507
5515
  }
5508
5516
  return interests;
5509
5517
  }
5518
+ parseBorrowRate(info, currency = undefined) {
5519
+ throw new NotSupported(this.id + ' parseBorrowRate() is not supported yet');
5520
+ }
5521
+ parseBorrowRateHistory(response, code, since, limit) {
5522
+ const result = [];
5523
+ for (let i = 0; i < response.length; i++) {
5524
+ const item = response[i];
5525
+ const borrowRate = this.parseBorrowRate(item);
5526
+ result.push(borrowRate);
5527
+ }
5528
+ const sorted = this.sortBy(result, 'timestamp');
5529
+ return this.filterByCurrencySinceLimit(sorted, code, since, limit);
5530
+ }
5510
5531
  parseIsolatedBorrowRates(info) {
5511
5532
  const result = {};
5512
5533
  for (let i = 0; i < info.length; i++) {
@@ -5542,6 +5563,19 @@ export default class Exchange {
5542
5563
  }
5543
5564
  return result;
5544
5565
  }
5566
+ parseLongShortRatio(info, market = undefined) {
5567
+ throw new NotSupported(this.id + ' parseLongShortRatio() is not supported yet');
5568
+ }
5569
+ parseLongShortRatioHistory(response, market = undefined, since = undefined, limit = undefined) {
5570
+ const rates = [];
5571
+ for (let i = 0; i < response.length; i++) {
5572
+ const entry = response[i];
5573
+ rates.push(this.parseLongShortRatio(entry, market));
5574
+ }
5575
+ const sorted = this.sortBy(rates, 'timestamp');
5576
+ const symbol = (market === undefined) ? undefined : market['symbol'];
5577
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
5578
+ }
5545
5579
  handleTriggerAndParams(params) {
5546
5580
  const isTrigger = this.safeBool2(params, 'trigger', 'stop');
5547
5581
  if (isTrigger) {
@@ -505,6 +505,14 @@ export interface Leverage {
505
505
  longLeverage: number;
506
506
  shortLeverage: number;
507
507
  }
508
+ export interface LongShortRatio {
509
+ info: any;
510
+ symbol: string;
511
+ timestamp?: number;
512
+ datetime?: string;
513
+ timeframe?: string;
514
+ longShortRatio: number;
515
+ }
508
516
  export interface MarginModification {
509
517
  'info': any;
510
518
  'symbol': string;
@@ -5,6 +5,7 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  // @ts-nocheck
8
+ import { Unpromise } from "../../static_dependencies/watchable/src/unpromise.js";
8
9
  export function Future() {
9
10
  let resolve = undefined, reject = undefined;
10
11
  const p = new Promise((resolve_, reject_) => {
@@ -31,4 +32,4 @@ function wrapFuture(aggregatePromise) {
31
32
  aggregatePromise.then(p.resolve, p.reject);
32
33
  return p;
33
34
  }
34
- Future.race = (futures) => wrapFuture(Promise.race(futures));
35
+ Future.race = (futures) => wrapFuture(Unpromise.race(futures));
package/js/src/bigone.js CHANGED
@@ -48,7 +48,10 @@ export default class bigone extends Exchange {
48
48
  'fetchDepositAddresses': false,
49
49
  'fetchDepositAddressesByNetwork': false,
50
50
  'fetchDeposits': true,
51
+ 'fetchFundingHistory': false,
51
52
  'fetchFundingRate': false,
53
+ 'fetchFundingRateHistory': false,
54
+ 'fetchFundingRates': false,
52
55
  'fetchMarkets': true,
53
56
  'fetchMyTrades': true,
54
57
  'fetchOHLCV': true,
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRates, IsolatedBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry, FundingRate, FundingRates, DepositAddress } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRates, IsolatedBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry, FundingRate, FundingRates, DepositAddress, LongShortRatio } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @augments Exchange
@@ -229,7 +229,6 @@ export default class binance extends Exchange {
229
229
  fetchIsolatedBorrowRate(symbol: string, params?: {}): Promise<IsolatedBorrowRate>;
230
230
  fetchIsolatedBorrowRates(params?: {}): Promise<IsolatedBorrowRates>;
231
231
  fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
232
- parseBorrowRateHistory(response: any, code: any, since: any, limit: any): any;
233
232
  parseBorrowRate(info: any, currency?: Currency): {
234
233
  currency: string;
235
234
  rate: number;
@@ -330,4 +329,6 @@ export default class binance extends Exchange {
330
329
  fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
331
330
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
332
331
  fetchFundingIntervals(symbols?: Strings, params?: {}): Promise<FundingRates>;
332
+ fetchLongShortRatioHistory(symbol?: Str, timeframe?: Str, since?: Int, limit?: Int, params?: {}): Promise<LongShortRatio[]>;
333
+ parseLongShortRatio(info: Dict, market?: Market): LongShortRatio;
333
334
  }
package/js/src/binance.js CHANGED
@@ -108,6 +108,8 @@ export default class binance extends Exchange {
108
108
  'fetchLeverages': true,
109
109
  'fetchLeverageTiers': true,
110
110
  'fetchLiquidations': false,
111
+ 'fetchLongShortRatio': false,
112
+ 'fetchLongShortRatioHistory': true,
111
113
  'fetchMarginAdjustmentHistory': true,
112
114
  'fetchMarginMode': 'emulated',
113
115
  'fetchMarginModes': true,
@@ -12118,16 +12120,6 @@ export default class binance extends Exchange {
12118
12120
  //
12119
12121
  return this.parseBorrowRateHistory(response, code, since, limit);
12120
12122
  }
12121
- parseBorrowRateHistory(response, code, since, limit) {
12122
- const result = [];
12123
- for (let i = 0; i < response.length; i++) {
12124
- const item = response[i];
12125
- const borrowRate = this.parseBorrowRate(item);
12126
- result.push(borrowRate);
12127
- }
12128
- const sorted = this.sortBy(result, 'timestamp');
12129
- return this.filterByCurrencySinceLimit(sorted, code, since, limit);
12130
- }
12131
12123
  parseBorrowRate(info, currency = undefined) {
12132
12124
  //
12133
12125
  // {
@@ -13831,4 +13823,105 @@ export default class binance extends Exchange {
13831
13823
  const result = this.parseFundingRates(response, market);
13832
13824
  return this.filterByArray(result, 'symbol', symbols);
13833
13825
  }
13826
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
13827
+ /**
13828
+ * @method
13829
+ * @name binance#fetchLongShortRatioHistory
13830
+ * @description fetches the long short ratio history for a unified market symbol
13831
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
13832
+ * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Long-Short-Ratio
13833
+ * @param {string} symbol unified symbol of the market to fetch the long short ratio for
13834
+ * @param {string} [timeframe] the period for the ratio, default is 24 hours
13835
+ * @param {int} [since] the earliest time in ms to fetch ratios for
13836
+ * @param {int} [limit] the maximum number of long short ratio structures to retrieve
13837
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
13838
+ * @param {int} [params.until] timestamp in ms of the latest ratio to fetch
13839
+ * @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
13840
+ */
13841
+ await this.loadMarkets();
13842
+ const market = this.market(symbol);
13843
+ if (timeframe === undefined) {
13844
+ timeframe = '1d';
13845
+ }
13846
+ let request = {
13847
+ 'period': timeframe,
13848
+ };
13849
+ [request, params] = this.handleUntilOption('endTime', request, params);
13850
+ if (since !== undefined) {
13851
+ request['startTime'] = since;
13852
+ }
13853
+ if (limit !== undefined) {
13854
+ request['limit'] = limit;
13855
+ }
13856
+ let subType = undefined;
13857
+ [subType, params] = this.handleSubTypeAndParams('fetchLongShortRatioHistory', market, params);
13858
+ let response = undefined;
13859
+ if (subType === 'linear') {
13860
+ request['symbol'] = market['id'];
13861
+ response = await this.fapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
13862
+ //
13863
+ // [
13864
+ // {
13865
+ // "symbol": "BTCUSDT",
13866
+ // "longAccount": "0.4558",
13867
+ // "longShortRatio": "0.8376",
13868
+ // "shortAccount": "0.5442",
13869
+ // "timestamp": 1726790400000
13870
+ // },
13871
+ // ]
13872
+ //
13873
+ }
13874
+ else if (subType === 'inverse') {
13875
+ request['pair'] = market['info']['pair'];
13876
+ response = await this.dapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
13877
+ //
13878
+ // [
13879
+ // {
13880
+ // "longAccount": "0.7262",
13881
+ // "longShortRatio": "2.6523",
13882
+ // "shortAccount": "0.2738",
13883
+ // "pair": "BTCUSD",
13884
+ // "timestamp": 1726790400000
13885
+ // },
13886
+ // ]
13887
+ //
13888
+ }
13889
+ else {
13890
+ throw new BadRequest(this.id + ' fetchLongShortRatioHistory() supports linear and inverse subTypes only');
13891
+ }
13892
+ return this.parseLongShortRatioHistory(response, market);
13893
+ }
13894
+ parseLongShortRatio(info, market = undefined) {
13895
+ //
13896
+ // linear
13897
+ //
13898
+ // {
13899
+ // "symbol": "BTCUSDT",
13900
+ // "longAccount": "0.4558",
13901
+ // "longShortRatio": "0.8376",
13902
+ // "shortAccount": "0.5442",
13903
+ // "timestamp": 1726790400000
13904
+ // }
13905
+ //
13906
+ // inverse
13907
+ //
13908
+ // {
13909
+ // "longAccount": "0.7262",
13910
+ // "longShortRatio": "2.6523",
13911
+ // "shortAccount": "0.2738",
13912
+ // "pair": "BTCUSD",
13913
+ // "timestamp": 1726790400000
13914
+ // }
13915
+ //
13916
+ const marketId = this.safeString(info, 'symbol');
13917
+ const timestamp = this.safeIntegerOmitZero(info, 'timestamp');
13918
+ return {
13919
+ 'info': info,
13920
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
13921
+ 'timestamp': timestamp,
13922
+ 'datetime': this.iso8601(timestamp),
13923
+ 'timeframe': undefined,
13924
+ 'longShortRatio': this.safeNumber(info, 'longShortRatio'),
13925
+ };
13926
+ }
13834
13927
  }
package/js/src/bingx.js CHANGED
@@ -5319,7 +5319,7 @@ export default class bingx extends Exchange {
5319
5319
  * @method
5320
5320
  * @name bingx#withdraw
5321
5321
  * @description make a withdrawal
5322
- * @see https://bingx-api.github.io/docs/#/common/account-api.html#Withdraw
5322
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/wallet-api.html#Withdraw
5323
5323
  * @param {string} code unified currency code
5324
5324
  * @param {float} amount the amount to withdraw
5325
5325
  * @param {string} address the address to withdraw to
@@ -5328,6 +5328,8 @@ export default class bingx extends Exchange {
5328
5328
  * @param {int} [params.walletType] 1 fund account, 2 standard account, 3 perpetual account
5329
5329
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
5330
5330
  */
5331
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
5332
+ this.checkAddress(address);
5331
5333
  await this.loadMarkets();
5332
5334
  const currency = this.currency(code);
5333
5335
  let walletType = this.safeInteger(params, 'walletType');
@@ -5347,6 +5349,9 @@ export default class bingx extends Exchange {
5347
5349
  if (network !== undefined) {
5348
5350
  request['network'] = this.networkCodeToId(network);
5349
5351
  }
5352
+ if (tag !== undefined) {
5353
+ request['addressTag'] = tag;
5354
+ }
5350
5355
  params = this.omit(params, ['walletType', 'network']);
5351
5356
  const response = await this.walletsV1PrivatePostCapitalWithdrawApply(this.extend(request, params));
5352
5357
  const data = this.safeValue(response, 'data');
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitflyer.js';
2
- import type { Balances, Currency, Dict, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFeeInterface, Transaction, int } from './base/types.js';
2
+ import type { Balances, Currency, Dict, FundingRate, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFeeInterface, Transaction, int } from './base/types.js';
3
3
  /**
4
4
  * @class bitflyer
5
5
  * @augments Exchange
@@ -33,6 +33,8 @@ export default class bitflyer extends Exchange {
33
33
  parseDepositStatus(status: any): string;
34
34
  parseWithdrawalStatus(status: any): string;
35
35
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
36
+ fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
37
+ parseFundingRate(contract: any, market?: Market): FundingRate;
36
38
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
37
39
  url: string;
38
40
  method: string;
@@ -37,6 +37,8 @@ export default class bitflyer extends Exchange {
37
37
  'fetchBalance': true,
38
38
  'fetchClosedOrders': 'emulated',
39
39
  'fetchDeposits': true,
40
+ 'fetchFundingRate': true,
41
+ 'fetchFundingRateHistory': false,
40
42
  'fetchMarginMode': false,
41
43
  'fetchMarkets': true,
42
44
  'fetchMyTrades': true,
@@ -76,6 +78,7 @@ export default class bitflyer extends Exchange {
76
78
  'gethealth',
77
79
  'getboardstate',
78
80
  'getchats',
81
+ 'getfundingrate',
79
82
  ],
80
83
  },
81
84
  'private': {
@@ -1026,6 +1029,60 @@ export default class bitflyer extends Exchange {
1026
1029
  'fee': fee,
1027
1030
  };
1028
1031
  }
1032
+ async fetchFundingRate(symbol, params = {}) {
1033
+ /**
1034
+ * @method
1035
+ * @name bitflyer#fetchFundingRate
1036
+ * @description fetch the current funding rate
1037
+ * @see https://lightning.bitflyer.com/docs#funding-rate
1038
+ * @param {string} symbol unified market symbol
1039
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1040
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
1041
+ */
1042
+ await this.loadMarkets();
1043
+ const market = this.market(symbol);
1044
+ const request = {
1045
+ 'product_code': market['id'],
1046
+ };
1047
+ const response = await this.publicGetGetfundingrate(this.extend(request, params));
1048
+ //
1049
+ // {
1050
+ // "current_funding_rate": -0.003750000000
1051
+ // "next_funding_rate_settledate": "2024-04-15T13:00:00"
1052
+ // }
1053
+ //
1054
+ return this.parseFundingRate(response, market);
1055
+ }
1056
+ parseFundingRate(contract, market = undefined) {
1057
+ //
1058
+ // {
1059
+ // "current_funding_rate": -0.003750000000
1060
+ // "next_funding_rate_settledate": "2024-04-15T13:00:00"
1061
+ // }
1062
+ //
1063
+ const nextFundingDatetime = this.safeString(contract, 'next_funding_rate_settledate');
1064
+ const nextFundingTimestamp = this.parse8601(nextFundingDatetime);
1065
+ return {
1066
+ 'info': contract,
1067
+ 'symbol': this.safeString(market, 'symbol'),
1068
+ 'markPrice': undefined,
1069
+ 'indexPrice': undefined,
1070
+ 'interestRate': undefined,
1071
+ 'estimatedSettlePrice': undefined,
1072
+ 'timestamp': undefined,
1073
+ 'datetime': undefined,
1074
+ 'fundingRate': undefined,
1075
+ 'fundingTimestamp': undefined,
1076
+ 'fundingDatetime': undefined,
1077
+ 'nextFundingRate': this.safeNumber(contract, 'current_funding_rate'),
1078
+ 'nextFundingTimestamp': nextFundingTimestamp,
1079
+ 'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
1080
+ 'previousFundingRate': undefined,
1081
+ 'previousFundingTimestamp': undefined,
1082
+ 'previousFundingDatetime': undefined,
1083
+ 'interval': undefined,
1084
+ };
1085
+ }
1029
1086
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1030
1087
  let request = '/' + this.version + '/';
1031
1088
  if (api === 'private') {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitget.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRate, Dict, LeverageTier, int, LedgerEntry, FundingRate, DepositAddress } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRate, Dict, LeverageTier, int, LedgerEntry, FundingRate, DepositAddress, LongShortRatio } from './base/types.js';
3
3
  /**
4
4
  * @class bitget
5
5
  * @augments Exchange
@@ -177,6 +177,8 @@ export default class bitget extends Exchange {
177
177
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
178
178
  fetchConvertCurrencies(params?: {}): Promise<Currencies>;
179
179
  fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
180
+ fetchLongShortRatioHistory(symbol?: Str, timeframe?: Str, since?: Int, limit?: Int, params?: {}): Promise<LongShortRatio[]>;
181
+ parseLongShortRatio(info: Dict, market?: Market): LongShortRatio;
180
182
  handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
181
183
  nonce(): number;
182
184
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/bitget.js CHANGED
@@ -95,6 +95,8 @@ export default class bitget extends Exchange {
95
95
  'fetchLeverage': true,
96
96
  'fetchLeverageTiers': false,
97
97
  'fetchLiquidations': false,
98
+ 'fetchLongShortRatio': false,
99
+ 'fetchLongShortRatioHistory': true,
98
100
  'fetchMarginAdjustmentHistory': false,
99
101
  'fetchMarginMode': true,
100
102
  'fetchMarketLeverageTiers': true,
@@ -270,6 +272,7 @@ export default class bitget extends Exchange {
270
272
  'v2/mix/market/current-fund-rate': 1,
271
273
  'v2/mix/market/contracts': 1,
272
274
  'v2/mix/market/query-position-lever': 2,
275
+ 'v2/mix/market/account-long-short': 20,
273
276
  },
274
277
  },
275
278
  'margin': {
@@ -280,6 +283,7 @@ export default class bitget extends Exchange {
280
283
  'margin/v1/isolated/public/tierData': 2,
281
284
  'margin/v1/public/currencies': 1,
282
285
  'v2/margin/currencies': 2,
286
+ 'v2/margin/market/long-short-ratio': 20,
283
287
  },
284
288
  },
285
289
  'earn': {
@@ -442,6 +446,7 @@ export default class bitget extends Exchange {
442
446
  'v2/mix/order/orders-history': 2,
443
447
  'v2/mix/order/orders-plan-pending': 2,
444
448
  'v2/mix/order/orders-plan-history': 2,
449
+ 'v2/mix/market/position-long-short': 20,
445
450
  },
446
451
  'post': {
447
452
  'mix/v1/account/sub-account-contract-assets': 200,
@@ -8903,6 +8908,78 @@ export default class bitget extends Exchange {
8903
8908
  const first = this.safeDict(data, 0, {});
8904
8909
  return this.parseFundingRate(first, market);
8905
8910
  }
8911
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
8912
+ /**
8913
+ * @method
8914
+ * @name bitget#fetchLongShortRatioHistory
8915
+ * @description fetches the long short ratio history for a unified market symbol
8916
+ * @see https://www.bitget.com/api-doc/common/apidata/Margin-Ls-Ratio
8917
+ * @see https://www.bitget.com/api-doc/common/apidata/Account-Long-Short
8918
+ * @param {string} symbol unified symbol of the market to fetch the long short ratio for
8919
+ * @param {string} [timeframe] the period for the ratio
8920
+ * @param {int} [since] the earliest time in ms to fetch ratios for
8921
+ * @param {int} [limit] the maximum number of long short ratio structures to retrieve
8922
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8923
+ * @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
8924
+ */
8925
+ await this.loadMarkets();
8926
+ const market = this.market(symbol);
8927
+ const request = {
8928
+ 'symbol': market['id'],
8929
+ };
8930
+ if (timeframe !== undefined) {
8931
+ request['period'] = timeframe;
8932
+ }
8933
+ let response = undefined;
8934
+ if (market['swap'] || market['future']) {
8935
+ response = await this.publicMixGetV2MixMarketAccountLongShort(this.extend(request, params));
8936
+ //
8937
+ // {
8938
+ // "code": "00000",
8939
+ // "msg": "success",
8940
+ // "requestTime": 1729321233281,
8941
+ // "data": [
8942
+ // {
8943
+ // "longAccountRatio": "0.58",
8944
+ // "shortAccountRatio": "0.42",
8945
+ // "longShortAccountRatio": "0.0138",
8946
+ // "ts": "1729312200000"
8947
+ // },
8948
+ // ]
8949
+ // }
8950
+ //
8951
+ }
8952
+ else {
8953
+ response = await this.publicMarginGetV2MarginMarketLongShortRatio(this.extend(request, params));
8954
+ //
8955
+ // {
8956
+ // "code": "00000",
8957
+ // "msg": "success",
8958
+ // "requestTime": 1729306974712,
8959
+ // "data": [
8960
+ // {
8961
+ // "longShortRatio": "40.66",
8962
+ // "ts": "1729306800000"
8963
+ // },
8964
+ // ]
8965
+ // }
8966
+ //
8967
+ }
8968
+ const data = this.safeList(response, 'data', []);
8969
+ return this.parseLongShortRatioHistory(data, market);
8970
+ }
8971
+ parseLongShortRatio(info, market = undefined) {
8972
+ const marketId = this.safeString(info, 'symbol');
8973
+ const timestamp = this.safeIntegerOmitZero(info, 'ts');
8974
+ return {
8975
+ 'info': info,
8976
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
8977
+ 'timestamp': timestamp,
8978
+ 'datetime': this.iso8601(timestamp),
8979
+ 'timeframe': undefined,
8980
+ 'longShortRatio': this.safeNumber2(info, 'longShortRatio', 'longShortAccountRatio'),
8981
+ };
8982
+ }
8906
8983
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
8907
8984
  if (!response) {
8908
8985
  return undefined; // fallback to default error handler