relative_rotation
Compute the Relative Rotation Graph (RRG) for a basket against a benchmark.
Examples
from openbb import obb
# Relative Strength Ratio and Momentum for a basket of symbols against a benchmark.
data = obb.equity.price.historical(symbol='AAPL,MSFT,GOOGL,META,AMZN,TSLA,SPY', start_date='2022-01-01', provider='yfinance').results
rr = obb.technical.relative_rotation(data=data, benchmark='SPY')
obb.technical.relative_rotation(data=[{'date': '2023-01-02', 'open': 110.0, 'high': 120.0, 'low': 100.0, 'close': 115.0, 'volume': 10000.0}, {'date': '2023-01-03', 'open': 165.0, 'high': 180.0, 'low': 150.0, 'close': 172.5, 'volume': 15000.0}, {'date': '2023-01-04', 'open': 146.67, 'high': 160.0, 'low': 133.33, 'close': 153.33, 'volume': 13333.33}, {'date': '2023-01-05', 'open': 137.5, 'high': 150.0, 'low': 125.0, 'close': 143.75, 'volume': 12500.0}, {'date': '2023-01-06', 'open': 132.0, 'high': 144.0, 'low': 120.0, 'close': 138.0, 'volume': 12000.0}], benchmark='SPY')
Parameters
- standard
data: Data | DataFrame | Series | dict | list | list[DataFrame] | list[Data] | list[Series] | ndarray
The data to be used for the relative rotation calculations. This should be the multi-symbol output from the 'equity.price.historical' endpoint, or similar, at a daily interval. Or a pivot table with the 'date' column as the index, the symbols as the columns, and the 'study' as the values. It is recommended to use the 'equity.price.historical' endpoint to get the data, and feed the results as-is.
benchmark: str
The symbol to be used as the benchmark.
study: str
Default: price
The data point for the calculations. If 'price', the closing price will be used. If 'volatility', the standard deviation of the closing price will be used. If 'data' is supplied as a pivot table, the 'study' will assume the values are the closing price and 'volume' will be ignored.
long_period: int
Default: 252
The length of the long period for momentum calculation, by default is 252. Adjust this value, to 365, when supplying assets such as crypto.
short_period: int
Default: 21
The length of the short period for momentum calculation, by default is 21. Adjust this value, to 30, when supplying assets such as crypto.
window: int
Default: 21
The length of window for the standard deviation calculation, by default is 21. Adjust this value, to 30, when supplying assets such as crypto.
trading_periods: int
Default: 252
The number of trading periods per year, for the standard deviation calculation, by default is 252. Adjust this value, to 365, when supplying assets such as crypto.
chart_params: dict[str, Any]
Description
Additional parameters to pass when chart=True and the openbb-charting extension is installed. Parameters can be passed again to redraw the chart using the charting.to_chart() method of the response.
ChartParams
-----------
date: Optional[str]
A target end date within the data, by default is the last date in the data.
show_tails: bool
Show the tails on the chart, by default is True.
tail_periods: Optional[int]
Number of periods to show in the tails, by default is 16.
tail_interval: Literal['day', 'week', 'month']
Interval to show the tails, by default is 'week'.
title: Optional[str]
Title of the chart.
chart: bool
Default: False
Whether to create a chart or not, by default False.
Returns
results: RelativeRotationData
Serializable results.
provider: str
Provider name.
warnings: Optional[list[Warning_]]
List of warnings.
chart: Optional[Chart]
Chart object.
extra: dict[str, Any]
Extra info.
Data
- standard
symbols: list[str]
The symbols that are being compared against the benchmark.
benchmark: str
The benchmark symbol, as entered by the user.
study: str
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.