Skip to content

Commit

Permalink
Limit 'forward only indicator' error log (#8046)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero authored May 21, 2024
1 parent ad663de commit 2c6074b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Indicators/IndicatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public int CompareTo(object obj)
public abstract class IndicatorBase<T> : IndicatorBase
where T : IBaseData
{
private bool _loggedForwardOnlyIndicatorError;

/// <summary>the most recent input that was given to this indicator</summary>
private Dictionary<SecurityIdentifier, T> _previousInput = new Dictionary<SecurityIdentifier, T>();
Expand All @@ -255,8 +256,12 @@ public override bool Update(IBaseData input)
T _previousSymbolInput = default(T);
if (_previousInput.TryGetValue(input.Symbol.ID, out _previousSymbolInput) && input.EndTime < _previousSymbolInput.EndTime)
{
// if we receive a time in the past, log and return
Log.Error($"This is a forward only indicator: {Name} Input: {input.EndTime:u} Previous: {_previousSymbolInput.EndTime:u}. It will not be updated with this input.");
if (!_loggedForwardOnlyIndicatorError)
{
_loggedForwardOnlyIndicatorError = true;
// if we receive a time in the past, log once and return
Log.Error($"IndicatorBase.Update(): This is a forward only indicator: {Name} Input: {input.EndTime:u} Previous: {_previousSymbolInput.EndTime:u}. It will not be updated with this input.");
}
return IsReady;
}
if (!ReferenceEquals(input, _previousSymbolInput))
Expand Down

0 comments on commit 2c6074b

Please sign in to comment.