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
- standard
Name | Type | Description | Default | Optional |
---|---|---|---|---|
data | list[Data] | The data to be used for the relative rotation calculations. | False | |
benchmark | str | The symbol to be used as the benchmark. | False | |
study | Literal[price, volume, volatility] | The data point for the calculations. If 'price', the closing price will be used. | False | |
long_period | int, optional | The length of the long period for momentum calculation, by default 252. | False | |
short_period | int, optional | The length of the short period for momentum calculation, by default 21. | False | |
window | int, optional | The length of window for the standard deviation calculation, by default 21. | False | |
trading_periods | int, optional | The number of trading periods per year, for the standard deviation calculation, by default 252. | False | |
chart_params | dict[str, Any], optional | Additional parameters to pass when chart=True and the openbb-charting extension is installed. | False | |
date | str, optional | A target end date within the data to use for the chart, by default is the last date in the data. | False | |
show_tails | bool | Show the tails on the chart, by default True. | False | |
tail_periods | int | Number of periods to show in the tails, by default 16. | False | |
tail_interval | Literal[day, week, month] | Interval to show the tails, by default 'week'. | False | |
title | str, optional | Title of the chart. | False | |
results | RelativeRotationData | symbols : list[str]: | False | |
benchmark | str | The benchmark symbol. | False | |
study | Literal[price, volume, volatility] | The data point for the selected. | False | |
long_period | int | The length of the long period for momentum calculation, as entered by the user. | False | |
short_period | int | The length of the short period for momentum calculation, as entered by the user. | False | |
window | int | The length of window for the standard deviation calculation. | False | |
trading_periods | int | The number of trading periods per year, for the standard deviation calculation. | False | |
start_date | str | The start date of the data after adjusting the length of the data for the calculations. | False | |
end_date | str | The end date of the data. | False | |
symbols_data | list[Data] | The data representing the selected 'study' for each symbol. | False | |
benchmark_data | list[Data] | The data representing the selected 'study' for the benchmark. | False | |
rs_ratios | list[Data] | The normalized relative strength ratios data. | False | |
rs_momentum | list[Data] | The normalized relative strength momentum data. | False |
Returns
OBBject
results : RelativeRotationData
results : RelativeRotationData