Beta Coefficient
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] 💬
// C# usage syntax
IEnumerable<BetaResult> results = quotesEval
.GetBeta(quotesMarket, lookbackPeriods, type);
Parameters
quotesMarket
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.
lookbackPeriods
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 +/-.
type
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 quotesMarket
. An 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.
BetaType options
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 Ratio
and 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
quotes
and a value of 60 forlookbackPeriods
. If you only have smaller bars, use the Aggregate() utility to convert it.Alpha is calculated as
R – Rf – Beta (Rm - Rf)
, whereRf
is the risk-free rate.
Response
IEnumerable<BetaResult>
- This method returns a time series of all available indicator values for the
quotes
provided. - 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-1
periods will havenull
values since there’s not enough data to calculate.
BetaResult
Date
DateTime
- Date from evaluated TQuote
Beta
double
- Beta coefficient based
BetaUp
double
- Beta+ (Up Beta)
BetaDown
double
- Beta- (Down Beta)
Ratio
double
- Beta ratio is BetaUp/BetaDown
Convexity
double
- Beta convexity is (BetaUp-BetaDown)2
ReturnsEval
double
- Returns of evaluated quotes (R
)
ReturnsMrkt
double
- Returns of market quotes (Rm
)
Utilities
See Utilities and helpers for more information.
Chaining
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
.Use()
method.
Results can be further processed on Beta
with additional chain-enabled indicators.
// example
var results = quotesEval
.GetBeta(quotesMarket, ..)
.GetSlope(..);