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

NameTypeDescriptionDefaultOptional
datalist[Data]The data to be used for the relative rotation calculations.False
benchmarkstrThe symbol to be used as the benchmark.False
studyLiteral[price, volume, volatility]The data point for the calculations. If 'price', the closing price will be used.False
long_periodint, optionalThe length of the long period for momentum calculation, by default 252.False
short_periodint, optionalThe length of the short period for momentum calculation, by default 21.False
windowint, optionalThe length of window for the standard deviation calculation, by default 21.False
trading_periodsint, optionalThe number of trading periods per year, for the standard deviation calculation, by default 252.False
chart_paramsdict[str, Any], optionalAdditional parameters to pass when chart=True and the openbb-charting extension is installed.False
datestr, optionalA target end date within the data to use for the chart, by default is the last date in the data.False
show_tailsboolShow the tails on the chart, by default True.False
tail_periodsintNumber of periods to show in the tails, by default 16.False
tail_intervalLiteral[day, week, month]Interval to show the tails, by default 'week'.False
titlestr, optionalTitle of the chart.False
resultsRelativeRotationDatasymbols : list[str]:False
benchmarkstrThe benchmark symbol.False
studyLiteral[price, volume, volatility]The data point for the selected.False
long_periodintThe length of the long period for momentum calculation, as entered by the user.False
short_periodintThe length of the short period for momentum calculation, as entered by the user.False
windowintThe length of window for the standard deviation calculation.False
trading_periodsintThe number of trading periods per year, for the standard deviation calculation.False
start_datestrThe start date of the data after adjusting the length of the data for the calculations.False
end_datestrThe end date of the data.False
symbols_datalist[Data]The data representing the selected 'study' for each symbol.False
benchmark_datalist[Data]The data representing the selected 'study' for the benchmark.False
rs_ratioslist[Data]The normalized relative strength ratios data.False
rs_momentumlist[Data]The normalized relative strength momentum data.False

Returns

OBBject
results : RelativeRotationData
results : RelativeRotationData