mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 13:58:04 +00:00
style patterns
This commit is contained in:
@@ -137,4 +137,4 @@ public class SqrttransIndicatorTests
|
||||
Assert.Equal(expectedRoots[i], indicator.LinesSeries[0].GetValue(0), 1e-10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,10 @@ public class SqrttransIndicator : Indicator, IWatchlistIndicator
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
if (_sqrttrans == null || _selector == null) return;
|
||||
if (_sqrttrans == null || _selector == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = HistoricalData[0, SeekOriginHistory.End];
|
||||
double value = _selector(item);
|
||||
@@ -53,4 +56,4 @@ public class SqrttransIndicator : Indicator, IWatchlistIndicator
|
||||
|
||||
LinesSeries[0].SetValue(_sqrttrans.Last.Value, isHot, ShowColdValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,4 +324,4 @@ public class SqrttransTests
|
||||
Assert.True(indicator.Last.Value >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,4 +236,4 @@ public class SqrttransValidationTests
|
||||
Assert.Equal(Math.Sqrt(largeValues[i]), indicator.Last.Value, Tolerance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,13 @@ public sealed class Sqrttrans : AbstractBase
|
||||
public override TValue Update(TValue input, bool isNew = true)
|
||||
{
|
||||
if (isNew)
|
||||
{
|
||||
_p_state = _state;
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = _p_state;
|
||||
}
|
||||
|
||||
double value = input.Value;
|
||||
double result;
|
||||
@@ -107,9 +111,14 @@ public sealed class Sqrttrans : AbstractBase
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output)
|
||||
{
|
||||
if (source.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Source cannot be empty", nameof(source));
|
||||
}
|
||||
|
||||
if (output.Length < source.Length)
|
||||
{
|
||||
throw new ArgumentException("Output length must be >= source length", nameof(output));
|
||||
}
|
||||
|
||||
double lastValid = 0.0; // sqrt(0) = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user