mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-13 08:08:05 +00:00
feat: Add new CodeQL extension for C# and SonarLint configuration
- Introduced a new CodeQL extension for C# in `.github/codeql/extensions/quantalib-csharp/codeql-pack.yml`. - Added SonarLint configuration in `.sonarlint/CSharp/SonarLint.xml` and `.sonarlint/csharp.ruleset` to suppress specific rules for high-performance indicators. - Removed outdated `.vscode/launch.json` configurations. - Updated `.vscode/tasks.json` to streamline build and test tasks, including renaming and consolidating tasks. - Modified `Directory.Build.props` to enhance SARIF output directory handling and integrate SonarLint rules. - Refactored various indicator classes to improve code clarity and maintainability, including updates to method parameters for consistency. - Added XML documentation comments to several classes and methods for better code understanding. - Improved numerical stability in calculations by replacing direct comparisons with `double.Epsilon` checks in multiple classes.
This commit is contained in:
@@ -27,6 +27,9 @@ public sealed class Change : AbstractBase
|
||||
|
||||
public override bool IsHot => _buffer.Count > _period;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="period">Lookback period (must be >= 1)</param>
|
||||
public Change(int period = 1)
|
||||
{
|
||||
@@ -39,6 +42,9 @@ public sealed class Change : AbstractBase
|
||||
WarmupPeriod = period + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="period">Lookback period</param>
|
||||
public Change(ITValuePublisher source, int period = 1) : this(period)
|
||||
@@ -99,7 +105,7 @@ public sealed class Change : AbstractBase
|
||||
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
Update(new TValue(time, source[i]), true);
|
||||
Update(new TValue(time, value: source[i]), isNew: true);
|
||||
time += interval;
|
||||
}
|
||||
}
|
||||
@@ -189,4 +195,4 @@ public sealed class Change : AbstractBase
|
||||
_p_state = default;
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public sealed class Exptrans : AbstractBase
|
||||
WarmupPeriod = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates Exptrans with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
public Exptrans(ITValuePublisher source) : this()
|
||||
{
|
||||
@@ -146,4 +149,4 @@ public sealed class Exptrans : AbstractBase
|
||||
_p_state = new(1.0);
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ public sealed class Highest : AbstractBase
|
||||
|
||||
public override bool IsHot => _buffer.Count >= _period;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Highest indicator with specified lookback period.
|
||||
/// </summary>
|
||||
/// <param name="period">Lookback window size (must be >= 1)</param>
|
||||
public Highest(int period)
|
||||
{
|
||||
@@ -38,6 +41,9 @@ public sealed class Highest : AbstractBase
|
||||
WarmupPeriod = period;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Highest indicator with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="period">Lookback window size</param>
|
||||
public Highest(ITValuePublisher source, int period) : this(period)
|
||||
@@ -89,7 +95,7 @@ public sealed class Highest : AbstractBase
|
||||
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
Update(new TValue(time, source[i]), true);
|
||||
Update(input: new TValue(time, source[i]), isNew: true);
|
||||
time += interval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ public sealed class Lineartrans : AbstractBase
|
||||
WarmupPeriod = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Linear transformer with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="slope">Multiplicative factor (default: 1.0)</param>
|
||||
/// <param name="intercept">Additive constant (default: 0.0)</param>
|
||||
|
||||
@@ -30,6 +30,9 @@ public sealed class Logtrans : AbstractBase
|
||||
WarmupPeriod = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates Logtrans with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
public Logtrans(ITValuePublisher source) : this()
|
||||
{
|
||||
@@ -132,4 +135,4 @@ public sealed class Logtrans : AbstractBase
|
||||
_p_state = default;
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ public sealed class Lowest : AbstractBase
|
||||
|
||||
public override bool IsHot => _buffer.Count >= _period;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Lowest indicator with specified lookback period.
|
||||
/// </summary>
|
||||
/// <param name="period">Lookback window size (must be >= 1)</param>
|
||||
public Lowest(int period)
|
||||
{
|
||||
@@ -38,6 +41,9 @@ public sealed class Lowest : AbstractBase
|
||||
WarmupPeriod = period;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Lowest indicator with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="period">Lookback window size</param>
|
||||
public Lowest(ITValuePublisher source, int period) : this(period)
|
||||
@@ -192,4 +198,4 @@ public sealed class Lowest : AbstractBase
|
||||
_p_state = default;
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ public sealed class Midpoint : AbstractBase
|
||||
|
||||
public override bool IsHot => _highest.IsHot && _lowest.IsHot;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Midpoint indicator with specified lookback period.
|
||||
/// </summary>
|
||||
/// <param name="period">Lookback window size (must be >= 1)</param>
|
||||
public Midpoint(int period)
|
||||
{
|
||||
@@ -38,6 +41,9 @@ public sealed class Midpoint : AbstractBase
|
||||
WarmupPeriod = period;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Midpoint indicator with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="period">Lookback window size</param>
|
||||
public Midpoint(ITValuePublisher source, int period) : this(period)
|
||||
@@ -157,4 +163,4 @@ public sealed class Midpoint : AbstractBase
|
||||
_lowest.Reset();
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public sealed class Normalize : AbstractBase
|
||||
|
||||
public override bool IsHot => _buffer.Count >= _period;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Normalize indicator with specified lookback period.
|
||||
/// </summary>
|
||||
/// <param name="period">Lookback period for min/max calculation (default 14)</param>
|
||||
public Normalize(int period = 14)
|
||||
{
|
||||
@@ -44,6 +47,9 @@ public sealed class Normalize : AbstractBase
|
||||
_p_state = _state;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Normalize indicator with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="period">Lookback period (default 14)</param>
|
||||
public Normalize(ITValuePublisher source, int period = 14) : this(period)
|
||||
|
||||
@@ -34,6 +34,9 @@ public sealed class Relu : AbstractBase
|
||||
WarmupPeriod = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
public Relu(ITValuePublisher source) : this()
|
||||
{
|
||||
|
||||
@@ -30,6 +30,9 @@ public sealed class Sigmoid : AbstractBase
|
||||
|
||||
public override bool IsHot => true; // No warmup needed
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Sigmoid indicator with specified steepness and midpoint.
|
||||
/// </summary>
|
||||
/// <param name="k">Steepness factor (default 1.0). Higher values create steeper transitions.</param>
|
||||
/// <param name="x0">Midpoint value where output equals 0.5 (default 0.0).</param>
|
||||
public Sigmoid(double k = 1.0, double x0 = 0.0)
|
||||
@@ -43,6 +46,9 @@ public sealed class Sigmoid : AbstractBase
|
||||
WarmupPeriod = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Sigmoid indicator with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
/// <param name="k">Steepness factor (default 1.0)</param>
|
||||
/// <param name="x0">Midpoint value (default 0.0)</param>
|
||||
|
||||
@@ -30,6 +30,9 @@ public sealed class Sqrttrans : AbstractBase
|
||||
WarmupPeriod = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Square Root transformer with source for event-based chaining.
|
||||
/// </summary>
|
||||
/// <param name="source">Source indicator for chaining</param>
|
||||
public Sqrttrans(ITValuePublisher source) : this()
|
||||
{
|
||||
@@ -131,4 +134,4 @@ public sealed class Sqrttrans : AbstractBase
|
||||
_p_state = default;
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user