Investment Studio > Expressions > Functions > Indicator > BA
float array[1][2] ba(float array[*][2] dc_asset, float array[*][2] dc_market, float risk_free_rate = 0)
Returns a two-column row vector containing the b (first column) and a (second column) coefficients of the single-factor model for excess returns on an asset with daily closes dc_asset, relative to a market index with daily closes dc_market and given the risk-free interest rate risk_free_rate.
dc_asset is a two-column array containing dates (first column) and corresponding daily closing prices (second column) for the asset under study. The array is assumed to be time-sorted, with earlier dates preceding later dates.
dc_market is a two-column array containing dates (first column) and corresponding daily closing prices (second column) for the market index relative to which the asset's b and a are to be computed. The array is assumed to be time-sorted, with earlier dates preceding later dates.
Asset and market quotes are matched by date; asset quotes without a matching market quote are discarded (and vice versa). Quotes from at least three separate dates (preferably many more) are needed.
Automatic type conversion allows the use of date strings as arguments instead of explicit date values.
risk_free_rate is the average daily interest rate which can be earned by leaving money in risk-free assets such as US Treasury bills during the period under consideration. Given the effective annual interest rate and the number of interest-bearing days in a year,
daily rate = (1 + annual rate)^(1 / days) - 1
For instance, a 5% annual rate accrued in 250 days is equivalent to the daily rate (1 + 5%)^(1 / 250) - 1 » 0.0195%.
If omitted, risk_free_rate defaults to 0.
The excess return on an asset is the rate of return in excess of the risk-free rate. In the commonly used single-factor model, it's decomposed into three components:
asset's excess return = a + b * market's excess return + asset-specific surprises
a is the asset's excess return when the overall market's excess return is zero.
b is the asset's responsiveness to overall market moves. The common term "high-beta stocks" refers to stocks which tend to amplify market moves, rallying strongly when the market is up and falling sharply when it's down. Such behaviour implies b > 1.
Asset-specific surprises are "noise" introduced by unexpected events specific to the asset, i.e. uncorrelated with the market's return.
It follows from the definition of the single-factor model that
variance(asset's excess return) = b2 * variance(market's excess return) + asset-specific variance
The first term is often referred to as "systematic risk" (or "systemic risk"), the second term as "asset-specific risk". Loosely speaking, this expression tells us that if market risk increases by one unit, then asset risk will increase by b2 units.
The BA function returns the values of b and a which provide the best fit (in the least square sense) to historic asset and market data. The line described by a (the intercept) and b (the slope) is known as the "security characteristic line". An equivalent (but more laborious) way of obtaining it is to define
_synched = sync(dc_asset, dc_market, FALSE)
_roc_assets = roc(subarray(array(_synched), 1, 0, 1, 2), 1)
_roc_market = roc(subarray(swapcols(array(_synched), 2, 3), 1, 0, 1, 2), 1)
and then compute
=linest(0.01 * index(array(_roc_assets), 0, 2) - risk_free_rate, 0.01 * index(array(_roc_market), 0, 2) - risk_free_rate)
This method has one major advantage: unlike ba, linest can optionally return extra statistics (standard errors, F statistic etc.) which can be used to verify the validity of the single-factor model. See linest for details.
Example
Assuming standard US date format settings,
=ba({{"1/1/1990", 100}, {"1/2/1990", 90}, {"1/3/1990", 72}}, {{"1/1/1990", 100}, {"1/2/1990", 110}, {"1/3/1990", 165}})
returns {{-0.25, -0.075}}, i.e. b = -0.25 and a = -7.5%. Negative b means that the asset tends to fall when the market rallies, and vice versa.