This commit is contained in:
Miha Kralj
2024-09-30 08:55:50 -07:00
23 changed files with 32 additions and 387 deletions
+1 -8
View File
@@ -6,11 +6,6 @@ namespace QuanTAlib;
/// The weights are decreasing over the period with p^2 decay, and the most recent data has the heaviest weight.
/// </summary>
/// <remarks>
/// Smoothness: ★★★★★ (5/5)
/// Sensitivity: ★★★☆☆ (3/5)
/// Overshooting: ★★★★☆ (4/5)
/// Lag: ★★☆☆☆ (2/5)
///
/// The DWMA is calculated by applying two WMAs in sequence:
/// 1. An inner WMA is applied to the input data.
/// 2. An outer WMA is then applied to the result of the inner WMA.
@@ -28,7 +23,6 @@ namespace QuanTAlib;
public class Dwma : AbstractBase
{
private readonly int _period;
private readonly Wma _innerWma;
private readonly Wma _outerWma;
@@ -38,11 +32,10 @@ public class Dwma : AbstractBase
{
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
}
_period = period;
_innerWma = new Wma(period);
_outerWma = new Wma(period);
Name = "Wma";
WarmupPeriod = 2 * _period - 1;
WarmupPeriod = 2 * period - 1;
Init();
}
+1 -3
View File
@@ -2,7 +2,6 @@ namespace QuanTAlib;
public class Fwma : AbstractBase
{
private readonly int _period;
private readonly Convolution _convolution;
public Fwma(int period)
@@ -11,8 +10,7 @@ public class Fwma : AbstractBase
{
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
}
_period = period;
_convolution = new Convolution(GenerateKernel(_period));
_convolution = new Convolution(GenerateKernel(period));
Name = "Fwma";
WarmupPeriod = period;
Init();
+1 -3
View File
@@ -2,7 +2,6 @@ namespace QuanTAlib;
public class Gma : AbstractBase
{
private readonly int _period;
private readonly Convolution _convolution;
public Gma(int period)
@@ -11,8 +10,7 @@ public class Gma : AbstractBase
{
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
}
_period = period;
_convolution = new Convolution(GenerateKernel(_period));
_convolution = new Convolution(GenerateKernel(period));
Name = "Gma";
WarmupPeriod = period;
Init();
+2 -4
View File
@@ -2,7 +2,6 @@ namespace QuanTAlib;
public class Hma : AbstractBase
{
private readonly int _period, _sqrtPeriod;
private readonly Convolution _wmaHalf, _wmaFull, _wmaFinal;
public Hma(int period)
@@ -11,13 +10,12 @@ public class Hma : AbstractBase
{
throw new ArgumentException("Period must be greater than or equal to 2.", nameof(period));
}
_period = period;
_sqrtPeriod = (int)Math.Sqrt(period);
int _sqrtPeriod = (int)Math.Sqrt(period);
_wmaHalf = new Convolution(GenerateWmaKernel(period / 2));
_wmaFull = new Convolution(GenerateWmaKernel(period));
_wmaFinal = new Convolution(GenerateWmaKernel(_sqrtPeriod));
Name = "Hma";
WarmupPeriod = _period + _sqrtPeriod - 1;
WarmupPeriod = period + _sqrtPeriod - 1;
Init();
}
+1 -3
View File
@@ -2,7 +2,6 @@ namespace QuanTAlib;
public class Sinema : AbstractBase
{
private readonly int _period;
private readonly Convolution _convolution;
public Sinema(int period)
@@ -11,8 +10,7 @@ public class Sinema : AbstractBase
{
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
}
_period = period;
_convolution = new Convolution(GenerateKernel(_period));
_convolution = new Convolution(GenerateKernel(period));
Name = "Sinema";
WarmupPeriod = period;
Init();
-7
View File
@@ -4,7 +4,6 @@ public class Sma : AbstractBase
{
// inherited _index
// inherited _value
private readonly int Period;
private readonly CircularBuffer _buffer;
public Sma(int period)
@@ -13,7 +12,6 @@ public class Sma : AbstractBase
{
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
}
Period = period;
WarmupPeriod = period;
_buffer = new CircularBuffer(period);
Name = "Sma";
@@ -28,11 +26,6 @@ public class Sma : AbstractBase
}
//inhereted public void Sub(object source, in ValueEventArgs args)
public override void Init()
{
base.Init();
}
protected override void ManageState(bool isNew)
{
if (isNew)
+1 -3
View File
@@ -2,7 +2,6 @@ namespace QuanTAlib;
public class Trima : AbstractBase
{
private readonly int _period;
private readonly Convolution _convolution;
public Trima(int period)
@@ -11,8 +10,7 @@ public class Trima : AbstractBase
{
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
}
_period = period;
_convolution = new Convolution(GenerateKernel(_period));
_convolution = new Convolution(GenerateKernel(period));
Name = "Trima";
WarmupPeriod = period;
Init();
+2 -4
View File
@@ -6,7 +6,6 @@ namespace QuanTAlib;
public class Vidya : AbstractBase
{
private readonly int _shortPeriod;
private readonly int _longPeriod;
private readonly double _alpha;
private double _lastVIDYA, _p_lastVIDYA;
@@ -19,12 +18,11 @@ public class Vidya : AbstractBase
{
throw new ArgumentException("Short period must be greater than or equal to 1.", nameof(shortPeriod));
}
_shortPeriod = shortPeriod;
_longPeriod = (longPeriod == 0) ? shortPeriod * 4 : longPeriod;
_alpha = alpha;
WarmupPeriod = _longPeriod;
Name = $"Vidya({_shortPeriod},{_longPeriod})";
_shortBuffer = new CircularBuffer(_shortPeriod);
Name = $"Vidya({shortPeriod},{_longPeriod})";
_shortBuffer = new CircularBuffer(shortPeriod);
_longBuffer = new CircularBuffer(_longPeriod);
Init();
}