18 using MathNet.Numerics.Statistics;
48 public override bool IsReady => _targetReturns.IsReady && _referenceReturns.IsReady;
59 : base(name, targetSymbol, referenceSymbol, 2)
64 throw new ArgumentException($
"Period parameter for Beta indicator must be greater than 2 but was {period}.");
80 : this($
"B({period})", targetSymbol, referenceSymbol, period)
94 : this(name, targetSymbol, referenceSymbol, period)
123 throw new ArgumentException($
"The given symbol {input.Symbol} was not {TargetSymbol} or {ReferenceSymbol} symbol");
135 return (
double)((rollingWindow[0].SafeDivision(rollingWindow[1]) - 1));
144 var varianceComputed = _referenceReturns.Variance();
145 var covarianceComputed = _targetReturns.Covariance(_referenceReturns);
148 var variance = !varianceComputed.IsNaNOrZero() ? varianceComputed : 1;
149 var covariance = !covarianceComputed.IsNaNOrZero() ? covarianceComputed : 0;
158 _targetReturns.Reset();
159 _referenceReturns.Reset();