mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-24 05:28:05 +00:00
chore: Update action versions in Publish.yml; improve .gitignore entries; refactor Alma, Super, and Trima classes for clarity and performance
This commit is contained in:
@@ -177,7 +177,7 @@ jobs:
|
|||||||
path: .qodana/code-coverage
|
path: .qodana/code-coverage
|
||||||
|
|
||||||
- name: Qodana Scan
|
- name: Qodana Scan
|
||||||
uses: JetBrains/qodana-action@69894e24022a101f3750824b20464654b971a1c3 # v2024.3.4
|
uses: JetBrains/qodana-action@a24ca9b52b6f5a60555b65acf6c8ed388197996131 # v2024.3.4
|
||||||
env:
|
env:
|
||||||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
|
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
|
||||||
with:
|
with:
|
||||||
@@ -201,7 +201,7 @@ jobs:
|
|||||||
path: coverage
|
path: coverage
|
||||||
|
|
||||||
- name: Upload to Codecov
|
- name: Upload to Codecov
|
||||||
uses: codecov/codecov-action@015f24e6818733317a741f027d1017576ed98b3f # v5.1.2
|
uses: codecov/codecov-action@cb6530fbecd68d5f1eee7a3dcd113450ea8d55d6d4 # v5.1.2
|
||||||
with:
|
with:
|
||||||
directory: coverage
|
directory: coverage
|
||||||
verbose: true
|
verbose: true
|
||||||
|
|||||||
+2
-3
@@ -402,7 +402,7 @@ NDependOut/
|
|||||||
# SonarQube/SonarCloud
|
# SonarQube/SonarCloud
|
||||||
.sonarqube/
|
.sonarqube/
|
||||||
|
|
||||||
# Cline Memory Bank - exclude from git
|
# ILSpy decompiler output
|
||||||
ilspy/
|
ilspy/
|
||||||
|
|
||||||
# macOS resource forks and metadata
|
# macOS resource forks and metadata
|
||||||
@@ -411,6 +411,5 @@ ilspy/
|
|||||||
.AppleDouble
|
.AppleDouble
|
||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
|
# Ignore insiders AI rules
|
||||||
#Ignore insiders AI rules
|
|
||||||
.github/instructions/codacy.instructions.md
|
.github/instructions/codacy.instructions.md
|
||||||
|
|||||||
@@ -86,12 +86,7 @@ public sealed class Alma : AbstractBase
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private double GetValidValue(double input)
|
private double GetValidValue(double input)
|
||||||
{
|
{
|
||||||
if (double.IsFinite(input))
|
return double.IsFinite(input) ? input : _state.LastValidValue;
|
||||||
{
|
|
||||||
_state.LastValidValue = input;
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
return _state.LastValidValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@@ -107,6 +102,11 @@ public sealed class Alma : AbstractBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
double val = GetValidValue(input.Value);
|
double val = GetValidValue(input.Value);
|
||||||
|
if (double.IsFinite(input.Value))
|
||||||
|
{
|
||||||
|
_state.LastValidValue = input.Value;
|
||||||
|
}
|
||||||
|
|
||||||
_buffer.Add(val, isNew);
|
_buffer.Add(val, isNew);
|
||||||
|
|
||||||
double result = 0;
|
double result = 0;
|
||||||
|
|||||||
@@ -180,15 +180,29 @@ public sealed class Super : ITValuePublisher
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SuperTrend
|
// SuperTrend
|
||||||
if (input.Close <= (_state.IsBullish ? _state.LowerBand : _state.UpperBand))
|
if (_state.IsBullish)
|
||||||
{
|
{
|
||||||
superTrend = _state.UpperBand;
|
if (input.Close < _state.LowerBand)
|
||||||
_state.IsBullish = false;
|
{
|
||||||
|
_state.IsBullish = false;
|
||||||
|
superTrend = _state.UpperBand;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
superTrend = _state.LowerBand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
superTrend = _state.LowerBand;
|
if (input.Close > _state.UpperBand)
|
||||||
_state.IsBullish = true;
|
{
|
||||||
|
_state.IsBullish = true;
|
||||||
|
superTrend = _state.LowerBand;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
superTrend = _state.UpperBand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upperBand = _state.UpperBand;
|
upperBand = _state.UpperBand;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace QuanTAlib;
|
|||||||
/// Equivalent to a double SMA: SMA(SMA(period1), period2).
|
/// Equivalent to a double SMA: SMA(SMA(period1), period2).
|
||||||
///
|
///
|
||||||
/// Calculation:
|
/// Calculation:
|
||||||
/// p1 = period / 2 + 1
|
/// p1 = (period + 1) / 2
|
||||||
/// p2 = (period + 1) / 2
|
/// p2 = period / 2 + 1
|
||||||
/// TRIMA = SMA(SMA(input, p1), p2)
|
/// TRIMA = SMA(SMA(input, p1), p2)
|
||||||
///
|
///
|
||||||
/// O(1) update:
|
/// O(1) update:
|
||||||
@@ -36,8 +36,8 @@ public sealed class Trima : AbstractBase
|
|||||||
if (period <= 0) throw new ArgumentException("Period must be greater than 0", nameof(period));
|
if (period <= 0) throw new ArgumentException("Period must be greater than 0", nameof(period));
|
||||||
|
|
||||||
_period = period;
|
_period = period;
|
||||||
int p1 = period / 2 + 1;
|
int p1 = (period + 1) / 2;
|
||||||
int p2 = (period + 1) / 2;
|
int p2 = period / 2 + 1;
|
||||||
|
|
||||||
_sma1 = new Sma(p1);
|
_sma1 = new Sma(p1);
|
||||||
_sma2 = new Sma(p2);
|
_sma2 = new Sma(p2);
|
||||||
@@ -94,7 +94,7 @@ public sealed class Trima : AbstractBase
|
|||||||
_sma1.Prime(source);
|
_sma1.Prime(source);
|
||||||
|
|
||||||
// Calculate intermediate SMA series to prime the second SMA
|
// Calculate intermediate SMA series to prime the second SMA
|
||||||
int p1 = _period / 2 + 1;
|
int p1 = (_period + 1) / 2;
|
||||||
double[] tempArray = ArrayPool<double>.Shared.Rent(source.Length);
|
double[] tempArray = ArrayPool<double>.Shared.Rent(source.Length);
|
||||||
Span<double> tempSpan = tempArray.AsSpan(0, source.Length);
|
Span<double> tempSpan = tempArray.AsSpan(0, source.Length);
|
||||||
|
|
||||||
@@ -129,8 +129,8 @@ public sealed class Trima : AbstractBase
|
|||||||
if (period <= 0)
|
if (period <= 0)
|
||||||
throw new ArgumentException("Period must be greater than 0", nameof(period));
|
throw new ArgumentException("Period must be greater than 0", nameof(period));
|
||||||
|
|
||||||
int p1 = period / 2 + 1;
|
int p1 = (period + 1) / 2;
|
||||||
int p2 = (period + 1) / 2;
|
int p2 = period / 2 + 1;
|
||||||
|
|
||||||
double[] tempArray = ArrayPool<double>.Shared.Rent(source.Length);
|
double[] tempArray = ArrayPool<double>.Shared.Rent(source.Length);
|
||||||
Span<double> tempSpan = tempArray.AsSpan(0, source.Length);
|
Span<double> tempSpan = tempArray.AsSpan(0, source.Length);
|
||||||
|
|||||||
Reference in New Issue
Block a user