Beta shows how strongly one asset’s price responds to systemic volatility of the entire market. Upside Beta (Beta+) and Downside Beta (Beta-), popularized by Harry M. Markowitz, are also included. [Discuss] 💬
// usage IEnumerable<BetaResult> results = quotesEval .GetBeta(quotesMarket, lookbackPeriods, type);
IEnumerable<TQuote> - Historical quotes market data should be at any consistent frequency (day, hour, minute, etc). This
market quotes will be used to establish the baseline.
int - Number of periods (
N) in the lookback window. Must be greater than 0 to calculate; however we suggest a larger period for statistically appropriate sample size and especially when using Beta +/-.
BetaType - Type of Beta to calculate. Default is
BetaType.Standard. See BetaType options below.
Historical quotes requirements
You must have at least
N periods of
quotesEval to cover the warmup periods. You must have at least the same matching date elements of
InvalidQuotesException will be thrown if not matched. Historical price quotes should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.
Standard - Standard Beta only. Uses all historical quotes.
Up - Upside Beta only. Uses historical quotes from market up bars only.
Down - Downside Beta only. Uses historical quotes from market down bars only.
All - Returns all of the above. Use this option if you want
Convexity values returned. Note: 3× slower to calculate.
💡 Pro tip
Financial institutions often depict a single number for Beta on their sites. To get that same long-term Beta value, use 5 years of monthly bars for
quotesand a value of 60 for
lookbackPeriods. If you only have smaller bars, use the Aggregate() utility to convert it.
Alpha is calculated as
R – Rf – Beta (Rm - Rf), where
Rfis the risk-free rate.
- This method returns a time series of all available indicator values for the
- It always returns the same number of elements as there are in the historical quotes.
- It does not return a single incremental indicator value.
- The first
N-1periods will have
nullvalues since there’s not enough data to calculate.
DateTime - Date from evaluated
double - Beta coefficient based
double - Beta+ (Up Beta)
double - Beta- (Down Beta)
double - Beta ratio is
double - Beta convexity is
double - Returns of evaluated quotes (
double - Returns of market quotes (
See Utilities and helpers for more information.
This indicator may be generated from any chain-enabled indicator or method.
// example var results = quotesEval .Use(CandlePart.HL2) .GetBeta(quotesMarket.Use(CandlePart.HL2), ..);
🚩 Warning! Both eval and market arguments must contain the same number of elements and be the results of a chainable indicator or
Results can be further processed on
Beta with additional chain-enabled indicators.
// example var results = quotesEval .GetBeta(quotesMarket, ..) .GetSlope(..);