mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 11:08:05 +00:00
chore: repo cleanup and code quality improvements
- Remove global.json (SDK pinning unnecessary) - Remove nuget.config, move MyGet source to .csproj RestoreAdditionalProjectSources - Gitignore ndepend/ entirely, move badges to docs/img/ - Update README.md and docs/ndepend.md badge paths - Add NDepend project property to QuanTAlib.slnx - Expand .editorconfig ReSharper/diagnostic suppressions - Use ArgumentOutOfRangeException instead of ArgumentException - Use discard _ for unused event sender parameters - Remove quantalib.code-workspace and sonar-suppressions.json - Add filter signature SVGs
This commit is contained in:
+16
-14
@@ -96,12 +96,12 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
{
|
||||
if (period <= 0)
|
||||
{
|
||||
throw new ArgumentException("Period must be greater than 0", nameof(period));
|
||||
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than 0");
|
||||
}
|
||||
|
||||
if (multiplier <= 0)
|
||||
{
|
||||
throw new ArgumentException("Multiplier must be greater than 0", nameof(multiplier));
|
||||
throw new ArgumentOutOfRangeException(nameof(multiplier), "Multiplier must be greater than 0");
|
||||
}
|
||||
|
||||
_period = period;
|
||||
@@ -132,13 +132,13 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
_source.Pub += _handler;
|
||||
}
|
||||
|
||||
private void HandleValue(object? sender, in TValueEventArgs e) => Update(e.Value, e.IsNew);
|
||||
private void HandleValue(object? _, in TValueEventArgs e) => Update(e.Value, e.IsNew);
|
||||
|
||||
/// <summary>
|
||||
/// Helper to invoke the Pub event.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void PubEvent(TValue value, bool isNew = true)
|
||||
private void PubEvent(TValue value, bool isNew)
|
||||
{
|
||||
Pub?.Invoke(this, new TValueEventArgs { Value = value, IsNew = isNew });
|
||||
}
|
||||
@@ -301,7 +301,8 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
double recalcSumSource = 0, recalcSumDeviation = 0;
|
||||
double recalcSumSource = 0;
|
||||
double recalcSumDeviation = 0;
|
||||
for (int k = 0; k < period; k++)
|
||||
{
|
||||
recalcSumSource += buffers.Source[k];
|
||||
@@ -439,11 +440,11 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
private ref struct ScalarState
|
||||
{
|
||||
public double SumSource;
|
||||
public double SumDeviation;
|
||||
public double LastValidValue;
|
||||
public int BufferIndex;
|
||||
public int TickCount;
|
||||
internal double SumSource;
|
||||
internal double SumDeviation;
|
||||
internal double LastValidValue;
|
||||
internal int BufferIndex;
|
||||
internal int TickCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -452,8 +453,8 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
private readonly ref struct WorkBuffers(Span<double> source, Span<double> deviation)
|
||||
{
|
||||
public readonly Span<double> Source = source;
|
||||
public readonly Span<double> Deviation = deviation;
|
||||
internal readonly Span<double> Source = source;
|
||||
internal readonly Span<double> Deviation = deviation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -510,12 +511,12 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
|
||||
if (period <= 0)
|
||||
{
|
||||
throw new ArgumentException("Period must be greater than 0", nameof(period));
|
||||
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than 0");
|
||||
}
|
||||
|
||||
if (multiplier <= 0)
|
||||
{
|
||||
throw new ArgumentException("Multiplier must be greater than 0", nameof(multiplier));
|
||||
throw new ArgumentOutOfRangeException(nameof(multiplier), "Multiplier must be greater than 0");
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
@@ -701,5 +702,6 @@ public sealed class Aberr : ITValuePublisher, IDisposable
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,14 +528,14 @@ public sealed class AccBands : ITValuePublisher, IDisposable
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
private ref struct ScalarState
|
||||
{
|
||||
public double SumAdjHigh;
|
||||
public double SumAdjLow;
|
||||
public double SumClose;
|
||||
public double LastValidHigh;
|
||||
public double LastValidLow;
|
||||
public double LastValidClose;
|
||||
public int BufferIndex;
|
||||
public int TickCount;
|
||||
internal double SumAdjHigh;
|
||||
internal double SumAdjLow;
|
||||
internal double SumClose;
|
||||
internal double LastValidHigh;
|
||||
internal double LastValidLow;
|
||||
internal double LastValidClose;
|
||||
internal int BufferIndex;
|
||||
internal int TickCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -544,9 +544,9 @@ public sealed class AccBands : ITValuePublisher, IDisposable
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
private readonly ref struct WorkBuffers(Span<double> adjHigh, Span<double> adjLow, Span<double> close)
|
||||
{
|
||||
public readonly Span<double> AdjHigh = adjHigh;
|
||||
public readonly Span<double> AdjLow = adjLow;
|
||||
public readonly Span<double> Close = close;
|
||||
internal readonly Span<double> AdjHigh = adjHigh;
|
||||
internal readonly Span<double> AdjLow = adjLow;
|
||||
internal readonly Span<double> Close = close;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -439,15 +439,15 @@ public sealed class Apz : ITValuePublisher
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
private ref struct ScalarState
|
||||
{
|
||||
public double Ema1Price;
|
||||
public double Ema2Price;
|
||||
public double Ema1Range;
|
||||
public double Ema2Range;
|
||||
public double E;
|
||||
public double LastValidPrice;
|
||||
public double LastValidHigh;
|
||||
public double LastValidLow;
|
||||
public bool IsHot;
|
||||
internal double Ema1Price;
|
||||
internal double Ema2Price;
|
||||
internal double Ema1Range;
|
||||
internal double Ema2Range;
|
||||
internal double E;
|
||||
internal double LastValidPrice;
|
||||
internal double LastValidHigh;
|
||||
internal double LastValidLow;
|
||||
internal bool IsHot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -269,8 +269,8 @@ public sealed class Dchannel : ITValuePublisher
|
||||
|
||||
try
|
||||
{
|
||||
QuanTAlib.Highest.Batch(high, top.AsSpan(0, len), period);
|
||||
QuanTAlib.Lowest.Batch(low, bot.AsSpan(0, len), period);
|
||||
Highest.Batch(high, top.AsSpan(0, len), period);
|
||||
Lowest.Batch(low, bot.AsSpan(0, len), period);
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
|
||||
@@ -16,8 +16,8 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
private readonly double _decayLambda;
|
||||
private readonly double[] _hBuf;
|
||||
private readonly double[] _lBuf;
|
||||
private readonly double[] _hBuf_prev;
|
||||
private readonly double[] _lBuf_prev;
|
||||
private readonly double[] _hBufPrev;
|
||||
private readonly double[] _lBufPrev;
|
||||
|
||||
private int _count;
|
||||
private long _index;
|
||||
@@ -42,7 +42,7 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
long Index);
|
||||
|
||||
private State _state;
|
||||
private State _p_state;
|
||||
private State _pState;
|
||||
|
||||
private readonly TBarPublishedHandler _barHandler;
|
||||
|
||||
@@ -66,8 +66,8 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
_decayLambda = Math.Log(2.0) / period;
|
||||
_hBuf = new double[_period];
|
||||
_lBuf = new double[_period];
|
||||
_hBuf_prev = new double[_period];
|
||||
_lBuf_prev = new double[_period];
|
||||
_hBufPrev = new double[_period];
|
||||
_lBufPrev = new double[_period];
|
||||
_count = 0;
|
||||
_index = -1;
|
||||
_currentMax = double.NaN;
|
||||
@@ -78,7 +78,7 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
_minAge = 0;
|
||||
|
||||
_state = new State(double.NaN, double.NaN, double.NaN, double.NaN, 0, 0, double.NaN, double.NaN, 0, -1);
|
||||
_p_state = _state;
|
||||
_pState = _state;
|
||||
|
||||
Name = $"Decaychannel({period})";
|
||||
WarmupPeriod = period;
|
||||
@@ -135,25 +135,25 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
_index);
|
||||
|
||||
// Save buffer contents
|
||||
Array.Copy(_hBuf, _hBuf_prev, _period);
|
||||
Array.Copy(_lBuf, _lBuf_prev, _period);
|
||||
Array.Copy(_hBuf, _hBufPrev, _period);
|
||||
Array.Copy(_lBuf, _lBufPrev, _period);
|
||||
}
|
||||
|
||||
private void RestoreState()
|
||||
{
|
||||
_currentMax = _p_state.CurrentMax;
|
||||
_currentMin = _p_state.CurrentMin;
|
||||
_maxAge = _p_state.MaxAge;
|
||||
_minAge = _p_state.MinAge;
|
||||
_rawMax = _p_state.RawMax;
|
||||
_rawMin = _p_state.RawMin;
|
||||
_count = _p_state.Count;
|
||||
_index = _p_state.Index;
|
||||
_state = _p_state;
|
||||
_currentMax = _pState.CurrentMax;
|
||||
_currentMin = _pState.CurrentMin;
|
||||
_maxAge = _pState.MaxAge;
|
||||
_minAge = _pState.MinAge;
|
||||
_rawMax = _pState.RawMax;
|
||||
_rawMin = _pState.RawMin;
|
||||
_count = _pState.Count;
|
||||
_index = _pState.Index;
|
||||
_state = _pState;
|
||||
|
||||
// Restore buffer contents
|
||||
Array.Copy(_hBuf_prev, _hBuf, _period);
|
||||
Array.Copy(_lBuf_prev, _lBuf, _period);
|
||||
Array.Copy(_hBufPrev, _hBuf, _period);
|
||||
Array.Copy(_lBufPrev, _lBuf, _period);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -200,7 +200,7 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
{
|
||||
// Save state BEFORE advancing (this is state from end of previous bar)
|
||||
SaveState();
|
||||
_p_state = _state;
|
||||
_pState = _state;
|
||||
|
||||
// Now advance to new bar
|
||||
_index++;
|
||||
@@ -379,8 +379,8 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
{
|
||||
Array.Clear(_hBuf);
|
||||
Array.Clear(_lBuf);
|
||||
Array.Clear(_hBuf_prev);
|
||||
Array.Clear(_lBuf_prev);
|
||||
Array.Clear(_hBufPrev);
|
||||
Array.Clear(_lBufPrev);
|
||||
_count = 0;
|
||||
_index = -1;
|
||||
_currentMax = double.NaN;
|
||||
@@ -390,7 +390,7 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
_maxAge = 0;
|
||||
_minAge = 0;
|
||||
_state = new State(double.NaN, double.NaN, double.NaN, double.NaN, 0, 0, double.NaN, double.NaN, 0, -1);
|
||||
_p_state = _state;
|
||||
_pState = _state;
|
||||
Last = default;
|
||||
Upper = default;
|
||||
Lower = default;
|
||||
@@ -436,8 +436,8 @@ public sealed class Decaychannel : ITValuePublisher
|
||||
|
||||
try
|
||||
{
|
||||
QuanTAlib.Highest.Batch(high, rawMaxArr.AsSpan(0, len), period);
|
||||
QuanTAlib.Lowest.Batch(low, rawMinArr.AsSpan(0, len), period);
|
||||
Highest.Batch(high, rawMaxArr.AsSpan(0, len), period);
|
||||
Lowest.Batch(low, rawMinArr.AsSpan(0, len), period);
|
||||
|
||||
double currentMax = double.NaN;
|
||||
double currentMin = double.NaN;
|
||||
|
||||
@@ -58,18 +58,6 @@ public class VwapsdIndicator : Indicator, IWatchlistIndicator
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
private void UpdateSeriesNames()
|
||||
{
|
||||
if (UpperSeries != null)
|
||||
{
|
||||
UpperSeries.Name = $"Upper (+{NumDevs:F1}σ)";
|
||||
}
|
||||
if (LowerSeries != null)
|
||||
{
|
||||
LowerSeries.Name = $"Lower (-{NumDevs:F1}σ)";
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
var item = HistoricalData[0, SeekOriginHistory.End];
|
||||
|
||||
Reference in New Issue
Block a user