style patterns

This commit is contained in:
Miha Kralj
2026-01-25 16:01:45 -08:00
parent 2836f253c4
commit e59665c8f0
399 changed files with 6892 additions and 1323 deletions
+10
View File
@@ -58,11 +58,19 @@ public sealed class Apo : ITValuePublisher
public Apo(int fastPeriod = 12, int slowPeriod = 26)
{
if (fastPeriod <= 0)
{
throw new ArgumentException("Fast period must be greater than 0", nameof(fastPeriod));
}
if (slowPeriod <= 0)
{
throw new ArgumentException("Slow period must be greater than 0", nameof(slowPeriod));
}
if (fastPeriod >= slowPeriod)
{
throw new ArgumentException("Fast period must be less than slow period", nameof(fastPeriod));
}
_emaFast = new Ema(fastPeriod);
_emaSlow = new Ema(slowPeriod);
@@ -174,7 +182,9 @@ public sealed class Apo : ITValuePublisher
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int fastPeriod = 12, int slowPeriod = 26)
{
if (source.Length != output.Length)
{
throw new ArgumentException("Source and output spans must be of the same length.", nameof(output));
}
Span<double> fastEma = source.Length <= 1024 ? stackalloc double[source.Length] : new double[source.Length];
Span<double> slowEma = source.Length <= 1024 ? stackalloc double[source.Length] : new double[source.Length];