mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 11:08:05 +00:00
style patterns
This commit is contained in:
@@ -117,4 +117,4 @@ public class LogtransIndicatorTests
|
||||
Assert.True(double.IsFinite(indicator.LinesSeries[0].GetValue(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,10 @@ public class LogtransIndicator : Indicator, IWatchlistIndicator
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
if (_logtrans == null || _selector == null) return;
|
||||
if (_logtrans == null || _selector == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = HistoricalData[0, SeekOriginHistory.End];
|
||||
double value = _selector(item);
|
||||
@@ -53,4 +56,4 @@ public class LogtransIndicator : Indicator, IWatchlistIndicator
|
||||
|
||||
LinesSeries[0].SetValue(_logtrans.Last.Value, isHot, ShowColdValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,4 +258,4 @@ public class LogtransTests
|
||||
// exp(logtrans(x)) should equal x
|
||||
Assert.Equal(original, Math.Exp(logtransResult), Tolerance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,13 @@ public sealed class Logtrans : AbstractBase
|
||||
public override TValue Update(TValue input, bool isNew = true)
|
||||
{
|
||||
if (isNew)
|
||||
{
|
||||
_p_state = _state;
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = _p_state;
|
||||
}
|
||||
|
||||
// Handle non-positive and non-finite values
|
||||
double value = input.Value;
|
||||
@@ -108,9 +112,14 @@ public sealed class Logtrans : 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user