mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 12:08:05 +00:00
sonar fixes
This commit is contained in:
@@ -18,7 +18,6 @@ namespace QuanTAlib;
|
||||
/// </remarks>
|
||||
public class Dema : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly double _k;
|
||||
private readonly double _epsilon = 1e-10;
|
||||
private double _lastEma1, _p_lastEma1;
|
||||
@@ -31,8 +30,7 @@ public class Dema : AbstractBase
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
|
||||
}
|
||||
_period = period;
|
||||
_k = 2.0 / (_period + 1);
|
||||
_k = 2.0 / (period + 1);
|
||||
Name = "Dema";
|
||||
double percentile = 0.85; //targeting 85th percentile of correctness of converging EMA
|
||||
WarmupPeriod = (int)System.Math.Ceiling(-period * System.Math.Log(1 - percentile));
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace QuanTAlib;
|
||||
/// </remarks>
|
||||
public class Dsma : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly double _c1, _c2, _c3;
|
||||
private readonly double _scaleFactor;
|
||||
@@ -49,7 +48,6 @@ public class Dsma : AbstractBase
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(scaleFactor), "Scale factor must be between 0 and 1 (exclusive).");
|
||||
}
|
||||
_period = period;
|
||||
_periodRecip = 1.0 / period;
|
||||
_scaleFactor = scaleFactor;
|
||||
_buffer = new CircularBuffer(period);
|
||||
|
||||
@@ -26,7 +26,6 @@ public class Epma : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly Convolution _convolution;
|
||||
private readonly double[] _baseKernel;
|
||||
|
||||
/// <param name="period">The number of data points used in the EPMA calculation.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
|
||||
@@ -37,7 +36,7 @@ public class Epma : AbstractBase
|
||||
throw new System.ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_period = period;
|
||||
_baseKernel = GenerateKernel(_period);
|
||||
double[] _baseKernel = GenerateKernel(_period);
|
||||
_convolution = new Convolution(_baseKernel);
|
||||
Name = "Epma";
|
||||
WarmupPeriod = period;
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace QuanTAlib;
|
||||
public class Fwma : AbstractBase
|
||||
{
|
||||
private readonly Convolution _convolution;
|
||||
private readonly double[] _kernel;
|
||||
|
||||
/// <param name="period">The number of data points used in the FWMA calculation.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
|
||||
@@ -36,7 +35,7 @@ public class Fwma : AbstractBase
|
||||
{
|
||||
throw new System.ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_kernel = GenerateKernel(period);
|
||||
double[] _kernel = GenerateKernel(period);
|
||||
_convolution = new Convolution(_kernel);
|
||||
Name = "Fwma";
|
||||
WarmupPeriod = period;
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ namespace QuanTAlib;
|
||||
public class Gma : AbstractBase
|
||||
{
|
||||
private readonly Convolution _convolution;
|
||||
private readonly double[] _kernel;
|
||||
|
||||
/// <param name="period">The number of data points used in the GMA calculation.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
|
||||
@@ -36,7 +35,7 @@ public class Gma : AbstractBase
|
||||
{
|
||||
throw new System.ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_kernel = GenerateKernel(period);
|
||||
double[] _kernel = GenerateKernel(period);
|
||||
_convolution = new Convolution(_kernel);
|
||||
Name = "Gma";
|
||||
WarmupPeriod = period;
|
||||
|
||||
+4
-10
@@ -28,11 +28,6 @@ namespace QuanTAlib;
|
||||
public class Hma : AbstractBase
|
||||
{
|
||||
private readonly Convolution _wmaHalf, _wmaFull, _wmaFinal;
|
||||
private readonly int _period;
|
||||
private readonly int _sqrtPeriod;
|
||||
private readonly double[] _kernelHalf;
|
||||
private readonly double[] _kernelFull;
|
||||
private readonly double[] _kernelFinal;
|
||||
|
||||
/// <param name="period">The number of data points used in the HMA calculation. Must be at least 2.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 2.</exception>
|
||||
@@ -42,13 +37,12 @@ public class Hma : AbstractBase
|
||||
{
|
||||
throw new System.ArgumentException("Period must be greater than or equal to 2.", nameof(period));
|
||||
}
|
||||
_period = period;
|
||||
_sqrtPeriod = (int)System.Math.Sqrt(period);
|
||||
int _sqrtPeriod = (int)System.Math.Sqrt(period);
|
||||
|
||||
// Generate all kernels once
|
||||
_kernelHalf = GenerateWmaKernel(period / 2);
|
||||
_kernelFull = GenerateWmaKernel(period);
|
||||
_kernelFinal = GenerateWmaKernel(_sqrtPeriod);
|
||||
double[] _kernelHalf = GenerateWmaKernel(period / 2);
|
||||
double[] _kernelFull = GenerateWmaKernel(period);
|
||||
double[] _kernelFinal = GenerateWmaKernel(_sqrtPeriod);
|
||||
|
||||
// Initialize convolutions with pre-generated kernels
|
||||
_wmaHalf = new Convolution(_kernelHalf);
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace QuanTAlib;
|
||||
public class Sinema : AbstractBase
|
||||
{
|
||||
private readonly Convolution _convolution;
|
||||
private readonly double[] _kernel;
|
||||
|
||||
/// <param name="period">The number of data points used in the SINEMA calculation.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
|
||||
@@ -38,7 +37,7 @@ public class Sinema : AbstractBase
|
||||
{
|
||||
throw new System.ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_kernel = GenerateKernel(period);
|
||||
double[] _kernel = GenerateKernel(period);
|
||||
_convolution = new Convolution(_kernel);
|
||||
Name = "Sinema";
|
||||
WarmupPeriod = period;
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace QuanTAlib;
|
||||
public class Sma : AbstractBase
|
||||
{
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly int _period;
|
||||
|
||||
/// <param name="period">The number of data points used in the SMA calculation.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown when period is less than 1.</exception>
|
||||
@@ -37,7 +36,6 @@ public class Sma : AbstractBase
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
|
||||
}
|
||||
_period = period;
|
||||
_buffer = new CircularBuffer(period);
|
||||
Name = "Sma";
|
||||
WarmupPeriod = period;
|
||||
|
||||
+1
-3
@@ -28,7 +28,6 @@ namespace QuanTAlib;
|
||||
public class T3 : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly double _vfactor;
|
||||
private readonly bool _useSma;
|
||||
private readonly double _k;
|
||||
private readonly double _c1, _c2, _c3, _c4;
|
||||
@@ -48,7 +47,6 @@ public class T3 : AbstractBase
|
||||
throw new System.ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_period = period;
|
||||
_vfactor = vfactor;
|
||||
_useSma = useSma;
|
||||
WarmupPeriod = period;
|
||||
|
||||
@@ -69,7 +67,7 @@ public class T3 : AbstractBase
|
||||
_buffer5 = new(period);
|
||||
_buffer6 = new(period);
|
||||
|
||||
Name = $"T3({_period}, {_vfactor})";
|
||||
Name = $"T3({_period}, {vfactor})";
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
<RootNamespace>QuanTAlib</RootNamespace>
|
||||
<AssemblyName>QuanTAlib</AssemblyName>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>0.0.0.1</AssemblyVersion>
|
||||
<IsPublishable>True</IsPublishable>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>full</DebugType>
|
||||
|
||||
Reference in New Issue
Block a user