XML Documentation

This commit is contained in:
Miha Kralj
2024-10-05 15:20:13 -07:00
parent 30d93e724d
commit 3458b14ebb
23 changed files with 1596 additions and 986 deletions
+32 -12
View File
@@ -2,29 +2,29 @@ namespace QuanTAlib;
/// <summary>
/// Provides a base implementation for financial indicators in the QuanTAlib library.
/// This abstract class implements the iTValue interface and defines common properties
/// and methods used by inheriting indicator types.
/// </summary>
/// <remarks>
/// This abstract class implements the iTValue interface and defines common properties
/// and methods used by inheriting indicator types. It handles the basic flow of
/// receiving data, performing calculations, and publishing results.
/// </remarks>
public abstract class AbstractBase : iTValue
{
public DateTime Time { get; set; }
public double Value { get; set; }
public bool IsNew { get; set; }
public bool IsHot { get; set; }
public TValue Input { get; set; }
public String Name { get; set; } = "";
public int WarmupPeriod { get; set; }
public TValue Tick => new(Time, Value, IsNew, IsHot); // Stores the current value of indicator
public event ValueSignal Pub = delegate { }; // Publisher of generated values
protected int _index; //tracking the position of output
public TValue Tick => new(Time, Value, IsNew, IsHot);
public event ValueSignal Pub = delegate { };
protected int _index;
protected double _lastValidValue;
// other _internal vars defined here
protected AbstractBase()
{ //add parameters into constructor
{
// Add parameters into constructor if needed
}
/// <summary>
@@ -34,6 +34,9 @@ public abstract class AbstractBase : iTValue
/// <param name="args">The argument containing the new data point.</param>
public void Sub(object source, in ValueEventArgs args) => Calc(args.Tick);
/// <summary>
/// Initializes the indicator's state.
/// </summary>
public virtual void Init()
{
_index = 0;
@@ -41,11 +44,14 @@ public abstract class AbstractBase : iTValue
}
/// <summary>
/// Calculates the indicator value based on the input; calls specific Calculation() method
/// where implementation is
/// Calculates the indicator value based on the input.
/// </summary>
/// <param name="input">The input value for the calculation.</param>
/// <returns>A TValue representing the calculated indicator value.</returns>
/// <remarks>
/// This method calls the specific Calculation() method where the actual implementation is.
/// If the input value is NaN or infinity, it returns the last valid value instead.
/// </remarks>
public virtual TValue Calc(TValue input)
{
Input = input;
@@ -57,11 +63,25 @@ public abstract class AbstractBase : iTValue
return Process(new TValue(Time: Input.Time, Value: this.Value, IsNew: Input.IsNew, IsHot: this.IsHot));
}
/// <summary>
/// Retrieves the last valid calculated value.
/// </summary>
/// <returns>The last valid value of the indicator.</returns>
protected virtual double GetLastValid()
{
return this.Value;
}
/// <summary>
/// Manages the state of the indicator based on whether a new data point is being processed.
/// </summary>
/// <param name="isNew">Indicates whether the current input is a new data point.</param>
protected abstract void ManageState(bool isNew);
/// <summary>
/// Performs the actual calculation of the indicator value.
/// </summary>
/// <returns>The calculated indicator value.</returns>
protected abstract double Calculation();
/// <summary>