ccxt 4.4.21 → 4.4.23

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 (86) hide show
  1. package/README.md +112 -111
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/coincatch.js +9 -0
  5. package/dist/cjs/src/alpaca.js +1 -0
  6. package/dist/cjs/src/base/Exchange.js +21 -0
  7. package/dist/cjs/src/bigone.js +3 -0
  8. package/dist/cjs/src/binance.js +172 -44
  9. package/dist/cjs/src/bitfinex.js +4 -0
  10. package/dist/cjs/src/bitflyer.js +58 -0
  11. package/dist/cjs/src/bitget.js +77 -0
  12. package/dist/cjs/src/bitrue.js +3 -0
  13. package/dist/cjs/src/bybit.js +80 -2
  14. package/dist/cjs/src/cex.js +1307 -1381
  15. package/dist/cjs/src/coinbase.js +1 -1
  16. package/dist/cjs/src/coinbaseexchange.js +3 -0
  17. package/dist/cjs/src/coincatch.js +5370 -0
  18. package/dist/cjs/src/coinex.js +63 -1
  19. package/dist/cjs/src/cryptocom.js +1 -1
  20. package/dist/cjs/src/gate.js +103 -3
  21. package/dist/cjs/src/htx.js +1 -7
  22. package/dist/cjs/src/hyperliquid.js +10 -8
  23. package/dist/cjs/src/kucoin.js +27 -59
  24. package/dist/cjs/src/latoken.js +6 -0
  25. package/dist/cjs/src/mexc.js +1 -1
  26. package/dist/cjs/src/oceanex.js +2 -0
  27. package/dist/cjs/src/okcoin.js +1 -0
  28. package/dist/cjs/src/okx.js +74 -0
  29. package/dist/cjs/src/poloniex.js +5 -0
  30. package/dist/cjs/src/pro/coincatch.js +1554 -0
  31. package/js/ccxt.d.ts +9 -3
  32. package/js/ccxt.js +6 -2
  33. package/js/src/abstract/binance.d.ts +21 -0
  34. package/js/src/abstract/binancecoinm.d.ts +21 -0
  35. package/js/src/abstract/binanceus.d.ts +21 -0
  36. package/js/src/abstract/binanceusdm.d.ts +21 -0
  37. package/js/src/abstract/bitflyer.d.ts +1 -0
  38. package/js/src/abstract/bitget.d.ts +3 -0
  39. package/js/src/abstract/cex.d.ts +28 -29
  40. package/js/src/abstract/coincatch.d.ts +97 -0
  41. package/js/src/abstract/coincatch.js +11 -0
  42. package/js/src/abstract/gate.d.ts +5 -0
  43. package/js/src/abstract/gateio.d.ts +5 -0
  44. package/js/src/abstract/kucoin.d.ts +1 -0
  45. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  46. package/js/src/abstract/okx.d.ts +1 -0
  47. package/js/src/alpaca.js +1 -0
  48. package/js/src/base/Exchange.d.ts +8 -2
  49. package/js/src/base/Exchange.js +21 -0
  50. package/js/src/base/types.d.ts +8 -0
  51. package/js/src/bigone.js +3 -0
  52. package/js/src/binance.d.ts +3 -1
  53. package/js/src/binance.js +172 -44
  54. package/js/src/bitfinex.js +4 -0
  55. package/js/src/bitflyer.d.ts +3 -1
  56. package/js/src/bitflyer.js +58 -0
  57. package/js/src/bitget.d.ts +3 -1
  58. package/js/src/bitget.js +77 -0
  59. package/js/src/bitrue.js +3 -0
  60. package/js/src/bybit.d.ts +3 -1
  61. package/js/src/bybit.js +80 -2
  62. package/js/src/cex.d.ts +34 -20
  63. package/js/src/cex.js +1308 -1382
  64. package/js/src/coinbase.js +1 -1
  65. package/js/src/coinbaseexchange.js +3 -0
  66. package/js/src/coincatch.d.ts +130 -0
  67. package/js/src/coincatch.js +5371 -0
  68. package/js/src/coinex.d.ts +1 -0
  69. package/js/src/coinex.js +63 -1
  70. package/js/src/cryptocom.js +1 -1
  71. package/js/src/gate.d.ts +2 -0
  72. package/js/src/gate.js +103 -3
  73. package/js/src/htx.js +1 -7
  74. package/js/src/hyperliquid.js +10 -8
  75. package/js/src/kucoin.d.ts +0 -1
  76. package/js/src/kucoin.js +27 -59
  77. package/js/src/latoken.js +6 -0
  78. package/js/src/mexc.js +1 -1
  79. package/js/src/oceanex.js +2 -0
  80. package/js/src/okcoin.js +1 -0
  81. package/js/src/okx.d.ts +3 -1
  82. package/js/src/okx.js +74 -0
  83. package/js/src/poloniex.js +5 -0
  84. package/js/src/pro/coincatch.d.ts +57 -0
  85. package/js/src/pro/coincatch.js +1555 -0
  86. package/package.json +1 -1
@@ -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>;
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';
@@ -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[]>;
@@ -1101,6 +1105,8 @@ export default class Exchange {
1101
1105
  safeSymbol(marketId: Str, market?: Market, delimiter?: Str, marketType?: Str): string;
1102
1106
  parseFundingRate(contract: string, market?: Market): FundingRate;
1103
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[];
1104
1110
  handleTriggerAndParams(params: any): any[];
1105
1111
  isTriggerOrder(params: any): any[];
1106
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
@@ -5555,6 +5563,19 @@ export default class Exchange {
5555
5563
  }
5556
5564
  return result;
5557
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
+ }
5558
5579
  handleTriggerAndParams(params) {
5559
5580
  const isTrigger = this.safeBool2(params, 'trigger', 'stop');
5560
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;
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
@@ -329,4 +329,6 @@ export default class binance extends Exchange {
329
329
  fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
330
330
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
331
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;
332
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,
@@ -472,6 +474,7 @@ export default class binance extends Exchange {
472
474
  'portfolio/asset-index-price': 0.1,
473
475
  'portfolio/repay-futures-switch': 3,
474
476
  'portfolio/margin-asset-leverage': 5,
477
+ 'portfolio/balance': 2,
475
478
  // staking
476
479
  'staking/productList': 0.1,
477
480
  'staking/position': 0.1,
@@ -673,7 +676,8 @@ export default class binance extends Exchange {
673
676
  'loan/flexible/repay/history': 40,
674
677
  'loan/flexible/ltv/adjustment/history': 40,
675
678
  'loan/flexible/loanable/data': 40,
676
- 'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
679
+ 'loan/flexible/collateral/data': 40,
680
+ 'portfolio/account': 2,
677
681
  },
678
682
  'post': {
679
683
  'eth-staking/eth/stake': 15,
@@ -751,6 +755,10 @@ export default class binance extends Exchange {
751
755
  'commissionRate': 20,
752
756
  'income/asyn': 5,
753
757
  'income/asyn/id': 5,
758
+ 'trade/asyn': 0.5,
759
+ 'trade/asyn/id': 0.5,
760
+ 'order/asyn': 0.5,
761
+ 'order/asyn/id': 0.5,
754
762
  'pmExchangeInfo': 0.5,
755
763
  'pmAccountInfo': 0.5, // Weight(IP): 5 => cost = 0.1 * 5 = 0.5
756
764
  },
@@ -1029,8 +1037,12 @@ export default class binance extends Exchange {
1029
1037
  },
1030
1038
  },
1031
1039
  'papi': {
1040
+ // IP (papi) request rate limit of 6000 per minute
1041
+ // 1 IP (papi) => cost = 0.2 => (1000 / (50 * 0.2)) * 60 = 6000
1042
+ // Order (papi) request rate limit of 1200 per minute
1043
+ // 1 Order (papi) => cost = 1 => (1000 / (50 * 1)) * 60 = 1200
1032
1044
  'get': {
1033
- 'ping': 1,
1045
+ 'ping': 0.2,
1034
1046
  'um/order': 1,
1035
1047
  'um/openOrder': 1,
1036
1048
  'um/openOrders': { 'cost': 1, 'noSymbol': 40 },
@@ -1042,72 +1054,87 @@ export default class binance extends Exchange {
1042
1054
  'um/conditional/openOrder': 1,
1043
1055
  'um/conditional/openOrders': { 'cost': 1, 'noSymbol': 40 },
1044
1056
  'um/conditional/orderHistory': 1,
1045
- 'um/conditional/allOrders': 40,
1057
+ 'um/conditional/allOrders': { 'cost': 1, 'noSymbol': 40 },
1046
1058
  'cm/conditional/openOrder': 1,
1047
1059
  'cm/conditional/openOrders': { 'cost': 1, 'noSymbol': 40 },
1048
1060
  'cm/conditional/orderHistory': 1,
1049
1061
  'cm/conditional/allOrders': 40,
1050
- 'margin/order': 5,
1062
+ 'margin/order': 10,
1051
1063
  'margin/openOrders': 5,
1052
1064
  'margin/allOrders': 100,
1053
1065
  'margin/orderList': 5,
1054
1066
  'margin/allOrderList': 100,
1055
1067
  'margin/openOrderList': 5,
1056
1068
  'margin/myTrades': 5,
1057
- 'balance': 20,
1058
- 'account': 20,
1059
- 'margin/maxBorrowable': 5,
1060
- 'margin/maxWithdraw': 5,
1061
- 'um/positionRisk': 5,
1062
- 'cm/positionRisk': 1,
1063
- 'um/positionSide/dual': 30,
1064
- 'cm/positionSide/dual': 30,
1069
+ 'balance': 4,
1070
+ 'account': 4,
1071
+ 'margin/maxBorrowable': 1,
1072
+ 'margin/maxWithdraw': 1,
1073
+ 'um/positionRisk': 1,
1074
+ 'cm/positionRisk': 0.2,
1075
+ 'um/positionSide/dual': 6,
1076
+ 'cm/positionSide/dual': 6,
1065
1077
  'um/userTrades': 5,
1066
1078
  'cm/userTrades': 20,
1067
- 'um/leverageBracket': 1,
1068
- 'cm/leverageBracket': 1,
1079
+ 'um/leverageBracket': 0.2,
1080
+ 'cm/leverageBracket': 0.2,
1069
1081
  'margin/forceOrders': 1,
1070
- 'um/forceOrders': 20,
1071
- 'cm/forceOrders': 20,
1072
- 'um/apiTradingStatus': 1,
1073
- 'um/commissionRate': 20,
1074
- 'cm/commissionRate': 20,
1075
- 'margin/marginLoan': 10,
1076
- 'margin/repayLoan': 10,
1077
- 'margin/marginInterestHistory': 1,
1078
- 'portfolio/interest-history': 50,
1079
- 'um/income': 30,
1080
- 'cm/income': 30,
1081
- 'um/account': 5,
1082
- 'cm/account': 5,
1083
- 'repay-futures-switch': 3,
1082
+ 'um/forceOrders': { 'cost': 20, 'noSymbol': 50 },
1083
+ 'cm/forceOrders': { 'cost': 20, 'noSymbol': 50 },
1084
+ 'um/apiTradingStatus': { 'cost': 0.2, 'noSymbol': 2 },
1085
+ 'um/commissionRate': 4,
1086
+ 'cm/commissionRate': 4,
1087
+ 'margin/marginLoan': 2,
1088
+ 'margin/repayLoan': 2,
1089
+ 'margin/marginInterestHistory': 0.2,
1090
+ 'portfolio/interest-history': 10,
1091
+ 'um/income': 6,
1092
+ 'cm/income': 6,
1093
+ 'um/account': 1,
1094
+ 'cm/account': 1,
1095
+ 'repay-futures-switch': 6,
1084
1096
  'um/adlQuantile': 5,
1085
1097
  'cm/adlQuantile': 5,
1098
+ 'um/trade/asyn': 300,
1099
+ 'um/trade/asyn/id': 2,
1100
+ 'um/order/asyn/': 300,
1101
+ 'um/order/asyn/id': 2,
1102
+ 'um/income/asyn': 300,
1103
+ 'um/income/asyn/id': 2,
1104
+ 'um/orderAmendment': 1,
1105
+ 'cm/orderAmendment': 1,
1106
+ 'um/feeBurn': 30,
1107
+ 'um/accountConfig': 1,
1108
+ 'um/symbolConfig': 1,
1109
+ 'cm/accountConfig': 1,
1110
+ 'cm/symbolConfig': 1,
1086
1111
  },
1087
1112
  'post': {
1088
1113
  'um/order': 1,
1089
1114
  'um/conditional/order': 1,
1090
1115
  'cm/order': 1,
1091
1116
  'cm/conditional/order': 1,
1092
- 'margin/order': 0.0133,
1093
- 'marginLoan': 0.1333,
1094
- 'repayLoan': 0.1333,
1095
- 'margin/order/oco': 0.0400,
1096
- 'um/leverage': 1,
1097
- 'cm/leverage': 1,
1098
- 'um/positionSide/dual': 1,
1099
- 'cm/positionSide/dual': 1,
1100
- 'auto-collection': 0.6667,
1101
- 'bnb-transfer': 0.6667,
1117
+ 'margin/order': 1,
1118
+ 'marginLoan': 100,
1119
+ 'repayLoan': 100,
1120
+ 'margin/order/oco': 1,
1121
+ 'um/leverage': 0.2,
1122
+ 'cm/leverage': 0.2,
1123
+ 'um/positionSide/dual': 0.2,
1124
+ 'cm/positionSide/dual': 0.2,
1125
+ 'auto-collection': 150,
1126
+ 'bnb-transfer': 150,
1102
1127
  'repay-futures-switch': 150,
1103
1128
  'repay-futures-negative-balance': 150,
1104
- 'listenKey': 1,
1105
- 'asset-collection': 3,
1106
- 'margin/repay-debt': 0.4,
1129
+ 'listenKey': 0.2,
1130
+ 'asset-collection': 6,
1131
+ 'margin/repay-debt': 3000,
1107
1132
  'um/feeBurn': 1,
1108
1133
  },
1109
1134
  'put': {
1110
- 'listenKey': 1, // 1
1135
+ 'listenKey': 0.2,
1136
+ 'um/order': 1,
1137
+ 'cm/order': 1,
1111
1138
  },
1112
1139
  'delete': {
1113
1140
  'um/order': 1,
@@ -1118,10 +1145,10 @@ export default class binance extends Exchange {
1118
1145
  'cm/conditional/order': 1,
1119
1146
  'cm/allOpenOrders': 1,
1120
1147
  'cm/conditional/allOpenOrders': 1,
1121
- 'margin/order': 1,
1148
+ 'margin/order': 2,
1122
1149
  'margin/allOpenOrders': 5,
1123
1150
  'margin/orderList': 2,
1124
- 'listenKey': 1, // 1
1151
+ 'listenKey': 0.2,
1125
1152
  },
1126
1153
  },
1127
1154
  },
@@ -13821,4 +13848,105 @@ export default class binance extends Exchange {
13821
13848
  const result = this.parseFundingRates(response, market);
13822
13849
  return this.filterByArray(result, 'symbol', symbols);
13823
13850
  }
13851
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
13852
+ /**
13853
+ * @method
13854
+ * @name binance#fetchLongShortRatioHistory
13855
+ * @description fetches the long short ratio history for a unified market symbol
13856
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
13857
+ * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Long-Short-Ratio
13858
+ * @param {string} symbol unified symbol of the market to fetch the long short ratio for
13859
+ * @param {string} [timeframe] the period for the ratio, default is 24 hours
13860
+ * @param {int} [since] the earliest time in ms to fetch ratios for
13861
+ * @param {int} [limit] the maximum number of long short ratio structures to retrieve
13862
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
13863
+ * @param {int} [params.until] timestamp in ms of the latest ratio to fetch
13864
+ * @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
13865
+ */
13866
+ await this.loadMarkets();
13867
+ const market = this.market(symbol);
13868
+ if (timeframe === undefined) {
13869
+ timeframe = '1d';
13870
+ }
13871
+ let request = {
13872
+ 'period': timeframe,
13873
+ };
13874
+ [request, params] = this.handleUntilOption('endTime', request, params);
13875
+ if (since !== undefined) {
13876
+ request['startTime'] = since;
13877
+ }
13878
+ if (limit !== undefined) {
13879
+ request['limit'] = limit;
13880
+ }
13881
+ let subType = undefined;
13882
+ [subType, params] = this.handleSubTypeAndParams('fetchLongShortRatioHistory', market, params);
13883
+ let response = undefined;
13884
+ if (subType === 'linear') {
13885
+ request['symbol'] = market['id'];
13886
+ response = await this.fapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
13887
+ //
13888
+ // [
13889
+ // {
13890
+ // "symbol": "BTCUSDT",
13891
+ // "longAccount": "0.4558",
13892
+ // "longShortRatio": "0.8376",
13893
+ // "shortAccount": "0.5442",
13894
+ // "timestamp": 1726790400000
13895
+ // },
13896
+ // ]
13897
+ //
13898
+ }
13899
+ else if (subType === 'inverse') {
13900
+ request['pair'] = market['info']['pair'];
13901
+ response = await this.dapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
13902
+ //
13903
+ // [
13904
+ // {
13905
+ // "longAccount": "0.7262",
13906
+ // "longShortRatio": "2.6523",
13907
+ // "shortAccount": "0.2738",
13908
+ // "pair": "BTCUSD",
13909
+ // "timestamp": 1726790400000
13910
+ // },
13911
+ // ]
13912
+ //
13913
+ }
13914
+ else {
13915
+ throw new BadRequest(this.id + ' fetchLongShortRatioHistory() supports linear and inverse subTypes only');
13916
+ }
13917
+ return this.parseLongShortRatioHistory(response, market);
13918
+ }
13919
+ parseLongShortRatio(info, market = undefined) {
13920
+ //
13921
+ // linear
13922
+ //
13923
+ // {
13924
+ // "symbol": "BTCUSDT",
13925
+ // "longAccount": "0.4558",
13926
+ // "longShortRatio": "0.8376",
13927
+ // "shortAccount": "0.5442",
13928
+ // "timestamp": 1726790400000
13929
+ // }
13930
+ //
13931
+ // inverse
13932
+ //
13933
+ // {
13934
+ // "longAccount": "0.7262",
13935
+ // "longShortRatio": "2.6523",
13936
+ // "shortAccount": "0.2738",
13937
+ // "pair": "BTCUSD",
13938
+ // "timestamp": 1726790400000
13939
+ // }
13940
+ //
13941
+ const marketId = this.safeString(info, 'symbol');
13942
+ const timestamp = this.safeIntegerOmitZero(info, 'timestamp');
13943
+ return {
13944
+ 'info': info,
13945
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
13946
+ 'timestamp': timestamp,
13947
+ 'datetime': this.iso8601(timestamp),
13948
+ 'timeframe': undefined,
13949
+ 'longShortRatio': this.safeNumber(info, 'longShortRatio'),
13950
+ };
13951
+ }
13824
13952
  }
@@ -47,6 +47,10 @@ export default class bitfinex extends Exchange {
47
47
  'fetchDepositsWithdrawals': true,
48
48
  'fetchDepositWithdrawFee': 'emulated',
49
49
  'fetchDepositWithdrawFees': true,
50
+ 'fetchFundingHistory': false,
51
+ 'fetchFundingRate': false,
52
+ 'fetchFundingRateHistory': false,
53
+ 'fetchFundingRates': false,
50
54
  'fetchIndexOHLCV': false,
51
55
  'fetchLeverageTiers': false,
52
56
  'fetchMarginMode': false,
@@ -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,9 @@ export default class bitflyer extends Exchange {
37
37
  'fetchBalance': true,
38
38
  'fetchClosedOrders': 'emulated',
39
39
  'fetchDeposits': true,
40
+ 'fetchFundingRate': true,
41
+ 'fetchFundingRateHistory': false,
42
+ 'fetchFundingRates': false,
40
43
  'fetchMarginMode': false,
41
44
  'fetchMarkets': true,
42
45
  'fetchMyTrades': true,
@@ -76,6 +79,7 @@ export default class bitflyer extends Exchange {
76
79
  'gethealth',
77
80
  'getboardstate',
78
81
  'getchats',
82
+ 'getfundingrate',
79
83
  ],
80
84
  },
81
85
  'private': {
@@ -1026,6 +1030,60 @@ export default class bitflyer extends Exchange {
1026
1030
  'fee': fee,
1027
1031
  };
1028
1032
  }
1033
+ async fetchFundingRate(symbol, params = {}) {
1034
+ /**
1035
+ * @method
1036
+ * @name bitflyer#fetchFundingRate
1037
+ * @description fetch the current funding rate
1038
+ * @see https://lightning.bitflyer.com/docs#funding-rate
1039
+ * @param {string} symbol unified market symbol
1040
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1041
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
1042
+ */
1043
+ await this.loadMarkets();
1044
+ const market = this.market(symbol);
1045
+ const request = {
1046
+ 'product_code': market['id'],
1047
+ };
1048
+ const response = await this.publicGetGetfundingrate(this.extend(request, params));
1049
+ //
1050
+ // {
1051
+ // "current_funding_rate": -0.003750000000
1052
+ // "next_funding_rate_settledate": "2024-04-15T13:00:00"
1053
+ // }
1054
+ //
1055
+ return this.parseFundingRate(response, market);
1056
+ }
1057
+ parseFundingRate(contract, market = undefined) {
1058
+ //
1059
+ // {
1060
+ // "current_funding_rate": -0.003750000000
1061
+ // "next_funding_rate_settledate": "2024-04-15T13:00:00"
1062
+ // }
1063
+ //
1064
+ const nextFundingDatetime = this.safeString(contract, 'next_funding_rate_settledate');
1065
+ const nextFundingTimestamp = this.parse8601(nextFundingDatetime);
1066
+ return {
1067
+ 'info': contract,
1068
+ 'symbol': this.safeString(market, 'symbol'),
1069
+ 'markPrice': undefined,
1070
+ 'indexPrice': undefined,
1071
+ 'interestRate': undefined,
1072
+ 'estimatedSettlePrice': undefined,
1073
+ 'timestamp': undefined,
1074
+ 'datetime': undefined,
1075
+ 'fundingRate': undefined,
1076
+ 'fundingTimestamp': undefined,
1077
+ 'fundingDatetime': undefined,
1078
+ 'nextFundingRate': this.safeNumber(contract, 'current_funding_rate'),
1079
+ 'nextFundingTimestamp': nextFundingTimestamp,
1080
+ 'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
1081
+ 'previousFundingRate': undefined,
1082
+ 'previousFundingTimestamp': undefined,
1083
+ 'previousFundingDatetime': undefined,
1084
+ 'interval': undefined,
1085
+ };
1086
+ }
1029
1087
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1030
1088
  let request = '/' + this.version + '/';
1031
1089
  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): {