Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueNina committed Dec 13, 2024
1 parent bbb4ec0 commit 51bc6f4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Indicators/Beta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class Beta : BarIndicator, IIndicatorWarmUpPeriodProvider
/// <summary>
/// Gets a flag indicating when the indicator is ready and fully initialized
/// </summary>
public override bool IsReady => _targetDataPoints.Samples >= WarmUpPeriod && _referenceDataPoints.Samples >= WarmUpPeriod;
public override bool IsReady => _targetReturns.Samples >= WarmUpPeriod && _referenceReturns.Samples >= WarmUpPeriod;

/// <summary>
/// Creates a new Beta indicator with the specified name, target, reference,
Expand All @@ -96,7 +96,7 @@ public Beta(string name, Symbol targetSymbol, Symbol referenceSymbol, int period
throw new ArgumentException($"Period parameter for Beta indicator must be greater than 2 but was {period}");
}

WarmUpPeriod = period + 1;
WarmUpPeriod = period;
_referenceSymbol = referenceSymbol;
_targetSymbol = targetSymbol;

Expand Down Expand Up @@ -149,7 +149,7 @@ protected override decimal ComputeNextValue(IBaseDataBar input)
{
if (input.Symbol != _targetSymbol && input.Symbol != _referenceSymbol)
{
throw new ArgumentException("The given symbol was not target or reference symbol");
throw new ArgumentException($"The given symbol {input.Symbol} was not {_targetSymbol} or {_referenceSymbol} symbol");
}

if (_previousInput == null)
Expand All @@ -159,13 +159,13 @@ protected override decimal ComputeNextValue(IBaseDataBar input)
}

// Process data if symbol has changed and timestamps match
if (input.Symbol.Value != _previousInput.Symbol.Value && input.EndTime == _previousInput.EndTime)
if (input.Symbol != _previousInput.Symbol && input.EndTime == _previousInput.EndTime)
{
AddDataPoint(input);
AddDataPoint(_previousInput);

// Compute beta when both have at least "period" data points
if ((_targetReturns.Count >= WarmUpPeriod - 1) && (_referenceReturns.Count >= WarmUpPeriod - 1))
if (IsReady)
{
ComputeBeta();
}
Expand Down

0 comments on commit 51bc6f4

Please sign in to comment.