mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-14 00:28: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:
@@ -54,7 +54,7 @@ public class AtrnTests
|
||||
public void Update_ReturnsValidTValue()
|
||||
{
|
||||
var atrn = new Atrn(DefaultPeriod);
|
||||
var result = atrn.Update(_bars[0], true);
|
||||
var result = atrn.Update(_bars[0], isNew: true);
|
||||
|
||||
Assert.IsType<TValue>(result);
|
||||
Assert.Equal(_bars[0].Time, result.Time);
|
||||
@@ -67,7 +67,7 @@ public class AtrnTests
|
||||
|
||||
for (int i = 0; i < _bars.Count; i++)
|
||||
{
|
||||
var result = atrn.Update(_bars[i], true);
|
||||
var result = atrn.Update(_bars[i], isNew: true);
|
||||
Assert.True(result.Value >= 0 && result.Value <= 1,
|
||||
$"Value {result.Value} at index {i} is outside [0,1] range");
|
||||
}
|
||||
@@ -447,4 +447,4 @@ public class AtrnTests
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public sealed class Atrn : AbstractBase
|
||||
|
||||
Name = $"Atrn({period})";
|
||||
WarmupPeriod = _rma.WarmupPeriod + _lookbackWindow;
|
||||
_state = new State(default, false, 0.0, 0.0);
|
||||
_state = new State(PrevBar: default, IsInitialized: false, LastValidTr: 0.0, LastValidAtr: 0.0);
|
||||
_p_state = _state;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public sealed class Atrn : AbstractBase
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
double tr = source[i];
|
||||
TValue atr = _rma.Update(new TValue(DateTime.UtcNow.AddMinutes(i), tr), true);
|
||||
TValue atr = _rma.Update(new TValue(DateTime.UtcNow.AddMinutes(i), tr), isNew: true);
|
||||
_atrBuffer.Add(atr.Value);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public sealed class Atrn : AbstractBase
|
||||
{
|
||||
_rma.Reset();
|
||||
_atrBuffer.Clear();
|
||||
_state = new State(default, false, 0.0, 0.0);
|
||||
_state = new State(PrevBar: default, IsInitialized: false, LastValidTr: 0.0, LastValidAtr: 0.0);
|
||||
_p_state = _state;
|
||||
Last = default;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public sealed class Atrn : AbstractBase
|
||||
|
||||
// Update state
|
||||
_state = isNew
|
||||
? new State(input, true, tr, currentAtr)
|
||||
? new State(PrevBar: input, IsInitialized: true, LastValidTr: tr, LastValidAtr: currentAtr)
|
||||
: _state with { LastValidTr = tr, LastValidAtr = currentAtr };
|
||||
|
||||
TValue result = new(input.Time, normalized);
|
||||
@@ -246,7 +246,7 @@ public sealed class Atrn : AbstractBase
|
||||
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
TValue result = Update(source[i], true);
|
||||
TValue result = Update(source[i], isNew: true);
|
||||
t.Add(result.Time);
|
||||
v.Add(result.Value);
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public sealed class Atrn : AbstractBase
|
||||
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
TValue result = Update(source[i], true);
|
||||
TValue result = Update(source[i], isNew: true);
|
||||
t.Add(source[i].Time);
|
||||
v.Add(result.Value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user