Skip to main content

relative_rotation

Calculate the Relative Strength Ratio and Relative Strength Momentum for a group of symbols against a benchmark.

Examples

from openbb import obb
# Calculate the Relative Strength Ratio and Relative Strength Momentum for a group of symbols against a benchmark.
stock_data = obb.equity.price.historical(symbol='AAPL,MSFT,GOOGL,META,AMZN,TSLA,SPY', start_date='2022-01-01', provider='yfinance')
rr_data = obb.technical.relative_rotation(data=stock_data.results, benchmark='SPY')
rs_ratios = rr_data.results.rs_ratios
rs_momentum = rr_data.results.rs_momentum
# When the assets are not traded 252 days per year,adjust the momentum and volatility periods accordingly.
crypto_data = obb.crypto.price.historical( symbol='BTCUSD,ETHUSD,SOLUSD', start_date='2021-01-01', provider='yfinance')
rr_data = obb.technical.relative_rotation(data=crypto_data.results, benchmark='BTC-USD', long_period=365, short_period=30, window=30, trading_periods=365)

Parameters

data: list[openbb_core.provider.abstract.data.Data]
The data to be used for the relative rotation calculations.

benchmark: str
The symbol to be used as the benchmark.

study: Literal['price', 'volume', 'volatility']
Default: price
The data point for the calculations. If 'price', the closing price will be used.

long_period: int
Default: 252
The length of the long period for momentum calculation, by default 252.

short_period: int
Default: 21
The length of the short period for momentum calculation, by default 21.

window: int
Default: 21
The length of window for the standard deviation calculation, by default 21.

trading_periods: int
Default: 252
The number of trading periods per year, for the standard deviation calculation, by default 252.

chart_params: dict[str, Any]
Additional parameters to pass when chart=True and the openbb-charting extension is installed.


Returns

results: list[RelativeRotationData]

Serializable results.

provider: None

Provider name.

warnings: Optional[list[Warning_]]

list of warnings.

chart: Optional[Chart]

Chart object.

extra: dict[str, Any]

Extra info.


Data

symbols: list[str]
The symbols that are being compared against the benchmark.

benchmark: str
The benchmark symbol, as entered by the user.

study: Literal['price', 'volume', 'volatility']
The data point for the study, as entered by the user.

long_period: int
The length of the long period for momentum calculation, as entered by the user.

short_period: int
The length of the short period for momentum calculation, as entered by the user.

window: int
The length of window for the standard deviation calculation, as entered by the user.

trading_periods: int
The number of trading periods per year, for the standard deviation calculation, as entered by the user.

start_date: str
The start date of the data after adjusting the length of the data for the calculations.

end_date: str
The end date of the data.

symbols_data: list[Data]
The data representing the selected 'study' for each symbol.

benchmark_data: list[Data]
The data representing the selected 'study' for the benchmark.

rs_ratios: list[Data]
The normalized relative strength ratios data.

rs_momentum: list[Data]
The normalized relative strength momentum data.