mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 11:08:05 +00:00
[CodeFactor] Apply fixes to commit 0606491
This commit is contained in:
@@ -329,7 +329,7 @@ public sealed class AcTests
|
||||
var ac = new Ac();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
var val = new TValue(DateTime.UtcNow.AddMinutes(i), 100.0 + i * 0.1);
|
||||
var val = new TValue(DateTime.UtcNow.AddMinutes(i), 100.0 + (i * 0.1));
|
||||
_ = ac.Update(val, isNew: true);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public sealed class BbiIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.5, 110 + i * 0.5, 90 + i * 0.5, 105 + i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.5), 110 + (i * 0.5), 90 + (i * 0.5), 105 + (i * 0.5));
|
||||
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
||||
}
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ public sealed class BbiTests
|
||||
int n = 10_000;
|
||||
var source = new double[n];
|
||||
var output = new double[n];
|
||||
for (int i = 0; i < n; i++) { source[i] = 100.0 + i * 0.01; }
|
||||
for (int i = 0; i < n; i++) { source[i] = 100.0 + (i * 0.01); }
|
||||
var ex = Record.Exception(() => Bbi.Batch(source.AsSpan(), output.AsSpan()));
|
||||
Assert.Null(ex);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class BbsTests
|
||||
// Constant price => stddev = 0 => BB width = 0 => bandwidth = 0
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bbs.Update(new TBar(baseTime + i * 60000, 100, 100, 100, 100, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), 100, 100, 100, 100, 1000));
|
||||
}
|
||||
|
||||
Assert.Equal(0.0, bbs.Last.Value, 10);
|
||||
@@ -86,7 +86,7 @@ public sealed class BbsTests
|
||||
// Close is always 100, but high/low create ATR
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
bbs.Update(new TBar(baseTime + i * 60000, 100, 102, 98, 100, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), 100, 102, 98, 100, 1000));
|
||||
}
|
||||
|
||||
// With constant close and non-zero ATR, BB bands (based on close stddev) should be
|
||||
@@ -110,7 +110,7 @@ public sealed class BbsTests
|
||||
double c = closes[i];
|
||||
// H/L track actual price so TR ≈ close-to-close gap (ATR stays proportional)
|
||||
// but BB mult * stddev >> KC mult * ATR when kcMult is small
|
||||
bbs.Update(new TBar(baseTime + i * 60000, c, c + 0.5, c - 0.5, c, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), c, c + 0.5, c - 0.5, c, 1000));
|
||||
}
|
||||
|
||||
// BB bands (3 * stddev) should exceed KC bands (0.5 * ATR)
|
||||
@@ -127,7 +127,7 @@ public sealed class BbsTests
|
||||
// Feed initial bars
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bbs.Update(new TBar(baseTime + i * 60000, 100 + i, 102 + i, 98 + i, 100 + i, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), 100 + i, 102 + i, 98 + i, 100 + i, 1000));
|
||||
}
|
||||
|
||||
// Save state after bar 5 for reference
|
||||
@@ -135,11 +135,11 @@ public sealed class BbsTests
|
||||
_ = bbs.SqueezeOn;
|
||||
|
||||
// Update with new bar
|
||||
bbs.Update(new TBar(baseTime + 5 * 60000, 110, 112, 108, 110, 1000), isNew: true);
|
||||
bbs.Update(new TBar(baseTime + (5 * 60000), 110, 112, 108, 110, 1000), isNew: true);
|
||||
double afterBar6 = bbs.Last.Value;
|
||||
|
||||
// Roll back with isNew=false
|
||||
bbs.Update(new TBar(baseTime + 5 * 60000, 105, 107, 103, 105, 1000), isNew: false);
|
||||
bbs.Update(new TBar(baseTime + (5 * 60000), 105, 107, 103, 105, 1000), isNew: false);
|
||||
double corrected = bbs.Last.Value;
|
||||
|
||||
// Corrected value should differ from bar 6 (different price) but be valid
|
||||
@@ -156,7 +156,7 @@ public sealed class BbsTests
|
||||
// Phase 1: Tight range (squeeze on)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bbs.Update(new TBar(baseTime + i * 60000, 100, 102, 98, 100, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), 100, 102, 98, 100, 1000));
|
||||
}
|
||||
|
||||
_ = bbs.SqueezeOn; // capture pre-breakout state
|
||||
@@ -164,8 +164,8 @@ public sealed class BbsTests
|
||||
// Phase 2: Breakout with huge price movement (squeeze off)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
double price = 100 + (i + 1) * 20; // 120, 140, 160, 180, 200
|
||||
bbs.Update(new TBar(baseTime + (5 + i) * 60000, price, price + 1, price - 1, price, 1000));
|
||||
double price = 100 + ((i + 1) * 20); // 120, 140, 160, 180, 200
|
||||
bbs.Update(new TBar(baseTime + ((5 + i) * 60000), price, price + 1, price - 1, price, 1000));
|
||||
}
|
||||
|
||||
// If squeeze was on and now off, SqueezeFired should have been true at transition
|
||||
@@ -181,8 +181,8 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
double price = 100 + Math.Sin(i) * 5;
|
||||
bbs.Update(new TBar(baseTime + i * 60000, price, price + 2, price - 2, price, 1000));
|
||||
double price = 100 + (Math.Sin(i) * 5);
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), price, price + 2, price - 2, price, 1000));
|
||||
}
|
||||
|
||||
// With varying prices, bandwidth should be positive
|
||||
@@ -214,7 +214,7 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bbs.Update(new TBar(baseTime + i * 60000, 100 + i, 102 + i, 98 + i, 100 + i, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), 100 + i, 102 + i, 98 + i, 100 + i, 1000));
|
||||
}
|
||||
|
||||
Assert.True(bbs.IsHot);
|
||||
@@ -236,7 +236,7 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
series.Add(new TBar(baseTime + i * 60000, 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
series.Add(new TBar(baseTime + (i * 60000), 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
}
|
||||
|
||||
var result = Bbs.Batch(series);
|
||||
@@ -259,7 +259,7 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
series.Add(new TBar(baseTime + i * 60000, 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
series.Add(new TBar(baseTime + (i * 60000), 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
}
|
||||
|
||||
var result = Bbs.Batch(series, bbPeriod: 10, bbMult: 1.5, kcPeriod: 10, kcMult: 2.0);
|
||||
@@ -275,8 +275,8 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
double price = 100 + Math.Sin(i * 0.5) * 10;
|
||||
series.Add(new TBar(baseTime + i * 60000, price, price + 3, price - 3, price, 1000));
|
||||
double price = 100 + (Math.Sin(i * 0.5) * 10);
|
||||
series.Add(new TBar(baseTime + (i * 60000), price, price + 3, price - 3, price, 1000));
|
||||
}
|
||||
|
||||
// Streaming
|
||||
@@ -383,7 +383,7 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
series.Add(new TBar(baseTime + i * 60000, 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
series.Add(new TBar(baseTime + (i * 60000), 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
}
|
||||
|
||||
var (results, indicator) = Bbs.Calculate(series, bbPeriod: 5, bbMult: 2.0, kcPeriod: 5, kcMult: 1.5);
|
||||
@@ -403,7 +403,7 @@ public sealed class BbsTests
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bbs.Update(new TBar(baseTime + i * 60000, 100 + i, 102 + i, 98 + i, 100 + i, 1000));
|
||||
bbs.Update(new TBar(baseTime + (i * 60000), 100 + i, 102 + i, 98 + i, 100 + i, 1000));
|
||||
}
|
||||
|
||||
Assert.Equal(5, eventCount);
|
||||
|
||||
@@ -116,7 +116,7 @@ public sealed class BrarIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
double basePrice = 100.0 + i * 0.5;
|
||||
double basePrice = 100.0 + (i * 0.5);
|
||||
indicator.HistoricalData.AddBar(
|
||||
now.AddMinutes(i),
|
||||
open: basePrice,
|
||||
|
||||
@@ -114,7 +114,7 @@ public sealed class CoppockIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.5, 110 + i * 0.5, 90 + i * 0.5, 105 + i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.5), 110 + (i * 0.5), 90 + (i * 0.5), 105 + (i * 0.5));
|
||||
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public sealed class CoppockBarCorrectionTests
|
||||
var c = new Coppock(longRoc: 3, shortRoc: 2, wmaPeriod: 3);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
c.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2), isNew: true);
|
||||
c.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)), isNew: true);
|
||||
}
|
||||
double val1 = c.Last.Value;
|
||||
c.Update(new TValue(DateTime.UtcNow, 115.0), isNew: true);
|
||||
|
||||
@@ -93,7 +93,7 @@ public sealed class CoppockValidationTests(ITestOutputHelper output)
|
||||
double startPrice = 100.0;
|
||||
int n = 60;
|
||||
double[] prices = new double[n];
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice + i * 0.5; }
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice + (i * 0.5); }
|
||||
|
||||
var spanOut = new double[n];
|
||||
Coppock.Batch(prices, spanOut, longRoc: 5, shortRoc: 4, wmaPeriod: 4);
|
||||
@@ -114,7 +114,7 @@ public sealed class CoppockValidationTests(ITestOutputHelper output)
|
||||
double startPrice = 200.0;
|
||||
int n = 60;
|
||||
double[] prices = new double[n];
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice - i * 0.5; }
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice - (i * 0.5); }
|
||||
|
||||
var spanOut = new double[n];
|
||||
Coppock.Batch(prices, spanOut, longRoc: 5, shortRoc: 4, wmaPeriod: 4);
|
||||
|
||||
@@ -382,7 +382,7 @@ public sealed class CrsiTests
|
||||
var out1 = new double[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
src[i] = 100.0 + i * 0.01;
|
||||
src[i] = 100.0 + (i * 0.01);
|
||||
}
|
||||
|
||||
// rankPeriod > 256 to exercise ArrayPool path
|
||||
|
||||
@@ -372,7 +372,7 @@ public sealed class CtiTests
|
||||
double[] output = new double[10000];
|
||||
for (int i = 0; i < src.Length; i++)
|
||||
{
|
||||
src[i] = 100.0 + i * 0.01;
|
||||
src[i] = 100.0 + (i * 0.01);
|
||||
}
|
||||
var ex = Record.Exception(() => Cti.Batch(src.AsSpan(), output.AsSpan(), DefaultPeriod));
|
||||
Assert.Null(ex);
|
||||
|
||||
@@ -364,7 +364,7 @@ public class DecoTests
|
||||
TValue last = default;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
last = deco.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * i * 0.1));
|
||||
last = deco.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * i * 0.1)));
|
||||
}
|
||||
Assert.NotEqual(0.0, last.Value);
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ public class DecoValidationTests
|
||||
for (int i = 0; i < 60; i++)
|
||||
{
|
||||
double phase = 2.0 * Math.PI * i / 20.0; // period=20 bars
|
||||
var rUp = decoUp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + 10.0 * Math.Sin(phase)));
|
||||
var rDown = decoDown.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 - 10.0 * Math.Sin(phase)));
|
||||
var rUp = decoUp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (10.0 * Math.Sin(phase))));
|
||||
var rDown = decoDown.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 - (10.0 * Math.Sin(phase))));
|
||||
lastUp = rUp.Value;
|
||||
lastDown = rDown.Value;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public sealed class DemIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
double basePrice = 100.0 + i * 0.5;
|
||||
double basePrice = 100.0 + (i * 0.5);
|
||||
indicator.HistoricalData.AddBar(
|
||||
now.AddMinutes(i),
|
||||
open: basePrice,
|
||||
|
||||
@@ -88,7 +88,7 @@ public class DoscTests
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1));
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)));
|
||||
}
|
||||
|
||||
Assert.True(indicator.IsHot);
|
||||
@@ -112,7 +112,7 @@ public class DoscTests
|
||||
// Warm up well past the period threshold
|
||||
for (int i = 0; i < DefaultRsi + DefaultSig + 10; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.5), isNew: true);
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.5)), isNew: true);
|
||||
}
|
||||
|
||||
TValue r1 = indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(50), 120.0), isNew: true);
|
||||
@@ -197,7 +197,7 @@ public class DoscTests
|
||||
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1));
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)));
|
||||
if (indicator.IsHot && hotAt < 0)
|
||||
{
|
||||
hotAt = i;
|
||||
@@ -246,7 +246,7 @@ public class DoscTests
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.5;
|
||||
source[i] = 100.0 + (i * 0.5);
|
||||
}
|
||||
|
||||
source[50] = double.NaN;
|
||||
@@ -348,7 +348,7 @@ public class DoscTests
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.1;
|
||||
source[i] = 100.0 + (i * 0.1);
|
||||
}
|
||||
|
||||
Dosc.Batch(source, output, 14, 5, 3, 9);
|
||||
|
||||
@@ -107,7 +107,7 @@ public sealed class DpoTests
|
||||
double[] data = new double[warmup + 3];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = 100 + i * 2;
|
||||
data[i] = 100 + (i * 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed class DymoiIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 60; i++)
|
||||
{
|
||||
double price = 100.0 + Math.Sin(i * 0.3) * 10.0 + i * 0.1;
|
||||
double price = 100.0 + (Math.Sin(i * 0.3) * 10.0) + (i * 0.1);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), price + 5, price + 10, price - 5, price);
|
||||
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
@@ -122,7 +122,7 @@ public sealed class DymoiIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
double price = 100.0 + i * 0.5;
|
||||
double price = 100.0 + (i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), price + 3, price + 6, price - 3, price);
|
||||
|
||||
var reason = i < 49 ? UpdateReason.HistoricalBar : UpdateReason.NewBar;
|
||||
|
||||
@@ -467,7 +467,7 @@ public sealed class DymoiTests
|
||||
var t = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
source.Add(new TValue(t.AddMinutes(i), 100.0 + i * 0.5));
|
||||
source.Add(new TValue(t.AddMinutes(i), 100.0 + (i * 0.5)));
|
||||
}
|
||||
|
||||
Assert.Equal(30, output.Count);
|
||||
|
||||
@@ -62,7 +62,7 @@ public sealed class ErTests
|
||||
var er = new Er(period: 10);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
er.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2));
|
||||
er.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)));
|
||||
}
|
||||
Assert.True(er.Last.Value > 0.8, "Strongly trending prices should produce high ER");
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public sealed class ErTests
|
||||
double[] data = new double[15];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = 100 + i * 2;
|
||||
data[i] = 100 + (i * 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
|
||||
@@ -99,7 +99,7 @@ public sealed class ErValidationTests(ITestOutputHelper output)
|
||||
const int N = 100;
|
||||
const int period = 10;
|
||||
double[] prices = new double[N];
|
||||
for (int i = 0; i < N; i++) { prices[i] = 100.0 + i * 1.0; }
|
||||
for (int i = 0; i < N; i++) { prices[i] = 100.0 + (i * 1.0); }
|
||||
|
||||
var output2 = new double[N];
|
||||
Er.Batch(prices.AsSpan(), output2.AsSpan(), period);
|
||||
|
||||
@@ -142,7 +142,7 @@ public sealed class FiValidationTests : IDisposable
|
||||
|
||||
// Monotonically increasing force values
|
||||
double[] force = new double[N];
|
||||
for (int i = 0; i < N; i++) { force[i] = 100.0 + i * 10.0; }
|
||||
for (int i = 0; i < N; i++) { force[i] = 100.0 + (i * 10.0); }
|
||||
|
||||
var output = new double[N];
|
||||
Fi.Calculate(force.AsSpan(), output.AsSpan(), period);
|
||||
|
||||
@@ -88,7 +88,7 @@ public sealed class FisherTests
|
||||
var fisher = new Fisher(period: 5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)));
|
||||
}
|
||||
Assert.True(fisher.FisherValue > 0, "Rising prices should produce positive Fisher");
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public sealed class FisherTests
|
||||
var fisher = new Fisher(period: 5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 200.0 - i * 2));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 200.0 - (i * 2)));
|
||||
}
|
||||
Assert.True(fisher.FisherValue < 0, "Falling prices should produce negative Fisher");
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public sealed class FisherTests
|
||||
double[] data = new double[15];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = 100 + i * 2;
|
||||
data[i] = 100 + (i * 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
@@ -388,7 +388,7 @@ public sealed class FisherTests
|
||||
// Create a very strong uptrend
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + i * 10));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 10)));
|
||||
}
|
||||
|
||||
// Fisher should be significantly positive
|
||||
@@ -404,7 +404,7 @@ public sealed class FisherTests
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + i * 5));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 5)));
|
||||
}
|
||||
|
||||
// Both should be positive in uptrend
|
||||
|
||||
@@ -128,7 +128,7 @@ public sealed class FisherValidationTests(ITestOutputHelper output) : IDisposabl
|
||||
}
|
||||
|
||||
// Ehlers 2002: Fish = arctanh(Value1) + 0.5 * Fish[1] (IIR feedback)
|
||||
fisherValue = 0.5 * Math.Log((1.0 + emaValue) / (1.0 - emaValue)) + 0.5 * fisherValue;
|
||||
fisherValue = (0.5 * Math.Log((1.0 + emaValue) / (1.0 - emaValue))) + (0.5 * fisherValue);
|
||||
manualOutput[i] = fisherValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public sealed class Fisher04Tests
|
||||
var fisher = new Fisher04(period: 5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)));
|
||||
}
|
||||
Assert.True(fisher.FisherValue > 0, "Rising prices should produce positive Fisher04");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public sealed class Fisher04Tests
|
||||
var fisher = new Fisher04(period: 5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 200.0 - i * 2));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 200.0 - (i * 2)));
|
||||
}
|
||||
Assert.True(fisher.FisherValue < 0, "Falling prices should produce negative Fisher04");
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public sealed class Fisher04Tests
|
||||
double[] data = new double[15];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = 100 + i * 2;
|
||||
data[i] = 100 + (i * 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
@@ -421,7 +421,7 @@ public sealed class Fisher04Tests
|
||||
// Create a very strong uptrend
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + i * 10));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 10)));
|
||||
}
|
||||
|
||||
// Fisher04 should be positive for uptrend
|
||||
@@ -437,7 +437,7 @@ public sealed class Fisher04Tests
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + i * 5));
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 5)));
|
||||
}
|
||||
|
||||
// Both should be positive in uptrend
|
||||
|
||||
@@ -293,7 +293,7 @@ public sealed class Fisher04ValidationTests(ITestOutputHelper output) : IDisposa
|
||||
// Keep feeding extreme values to push value1 toward clamp
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + (i + 4) * 100.0), isNew: true);
|
||||
fisher.Update(new TValue(DateTime.UtcNow, 100.0 + ((i + 4) * 100.0)), isNew: true);
|
||||
}
|
||||
|
||||
// Fisher should remain finite (clamping prevents log(∞))
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
imi.Update(new TBar(baseTime + i * 60000, 100, 105, 95, 102, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 100, 105, 95, 102, 1000));
|
||||
}
|
||||
|
||||
Assert.False(imi.IsHot);
|
||||
@@ -82,7 +82,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
imi.Update(new TBar(baseTime + i * 60000, 100, 105, 95, 102, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 100, 105, 95, 102, 1000));
|
||||
}
|
||||
|
||||
Assert.True(imi.IsHot);
|
||||
@@ -236,18 +236,18 @@ public class ImiTests
|
||||
// Fill buffer
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
imi.Update(new TBar(baseTime + i * 60000, 100, 105, 95, 102, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 100, 105, 95, 102, 1000));
|
||||
}
|
||||
|
||||
// New bar
|
||||
imi.Update(new TBar(baseTime + 3 * 60000, 100, 110, 99, 108, 1000), isNew: true);
|
||||
imi.Update(new TBar(baseTime + (3 * 60000), 100, 110, 99, 108, 1000), isNew: true);
|
||||
double firstValue = imi.Last.Value;
|
||||
|
||||
// Correction 1
|
||||
imi.Update(new TBar(baseTime + 3 * 60000, 100, 115, 99, 92, 1000), isNew: false);
|
||||
imi.Update(new TBar(baseTime + (3 * 60000), 100, 115, 99, 92, 1000), isNew: false);
|
||||
|
||||
// Correction 2 - same as first new bar
|
||||
imi.Update(new TBar(baseTime + 3 * 60000, 100, 110, 99, 108, 1000), isNew: false);
|
||||
imi.Update(new TBar(baseTime + (3 * 60000), 100, 110, 99, 108, 1000), isNew: false);
|
||||
double secondValue = imi.Last.Value;
|
||||
|
||||
Assert.Equal(firstValue, secondValue, Precision);
|
||||
@@ -311,7 +311,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
imi.Update(new TBar(baseTime + i * 60000, 100, 110, 99, 108, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 100, 110, 99, 108, 1000));
|
||||
}
|
||||
|
||||
Assert.True(imi.IsHot);
|
||||
@@ -331,7 +331,7 @@ public class ImiTests
|
||||
// All up bars
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
imi.Update(new TBar(baseTime + i * 60000, 100, 110, 99, 108, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 100, 110, 99, 108, 1000));
|
||||
}
|
||||
Assert.Equal(100.0, imi.Last.Value, Precision);
|
||||
|
||||
@@ -340,7 +340,7 @@ public class ImiTests
|
||||
// All down bars
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
imi.Update(new TBar(baseTime + i * 60000, 108, 110, 99, 100, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 108, 110, 99, 100, 1000));
|
||||
}
|
||||
Assert.Equal(0.0, imi.Last.Value, Precision);
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
source.Add(new TBar(baseTime + i * 60000, 100, 110, 99, 108, 1000));
|
||||
source.Add(new TBar(baseTime + (i * 60000), 100, 110, 99, 108, 1000));
|
||||
}
|
||||
|
||||
imi.Prime(source);
|
||||
@@ -379,7 +379,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
source.Add(new TBar(baseTime + i * 60000, 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
source.Add(new TBar(baseTime + (i * 60000), 100 + i, 110 + i, 90 + i, 105 + i, 1000));
|
||||
}
|
||||
|
||||
var result = Imi.Batch(source);
|
||||
@@ -404,7 +404,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
source.Add(new TBar(baseTime + i * 60000, 100, 110, 99, 108, 1000));
|
||||
source.Add(new TBar(baseTime + (i * 60000), 100, 110, 99, 108, 1000));
|
||||
}
|
||||
|
||||
var result = Imi.Batch(source, 5);
|
||||
@@ -421,7 +421,7 @@ public class ImiTests
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
source.Add(new TBar(baseTime + i * 60000, 100, 110, 99, 108, 1000));
|
||||
source.Add(new TBar(baseTime + (i * 60000), 100, 110, 99, 108, 1000));
|
||||
}
|
||||
|
||||
var (results, indicator) = Imi.Calculate(source, 10);
|
||||
|
||||
@@ -162,7 +162,7 @@ public sealed class ImiValidationTests : IDisposable
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
// Doji: Open == Close
|
||||
imi.Update(new TBar(baseTime + i * 60000, 100, 105, 95, 100, 1000));
|
||||
imi.Update(new TBar(baseTime + (i * 60000), 100, 105, 95, 100, 1000));
|
||||
}
|
||||
|
||||
Assert.Equal(50.0, imi.Last.Value, 1e-10);
|
||||
|
||||
@@ -381,7 +381,7 @@ public sealed class InertiaTests
|
||||
var inertia = new Inertia(period: 5);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
inertia.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2.0));
|
||||
inertia.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2.0)));
|
||||
}
|
||||
// Perfect linear trend → regression fits perfectly → residual = 0
|
||||
Assert.Equal(0.0, inertia.Last.Value, precision: 10);
|
||||
|
||||
@@ -174,10 +174,10 @@ public sealed class InertiaValidationTests : IDisposable
|
||||
sumX2 += x * x;
|
||||
}
|
||||
|
||||
double denom = n * sumX2 - sumX * sumX;
|
||||
double slope = (n * sumXY - sumX * sumY) / denom;
|
||||
double intercept = (sumY - slope * sumX) / n;
|
||||
double tsf = slope * (n - 1) + intercept;
|
||||
double denom = (n * sumX2) - (sumX * sumX);
|
||||
double slope = ((n * sumXY) - (sumX * sumY)) / denom;
|
||||
double intercept = (sumY - (slope * sumX)) / n;
|
||||
double tsf = (slope * (n - 1)) + intercept;
|
||||
double expected = raw[^1] - tsf;
|
||||
|
||||
_output.WriteLine($"Manual Inertia: {expected:F12}");
|
||||
|
||||
@@ -517,9 +517,9 @@ public sealed class KdjTests
|
||||
|
||||
for (int i = 0; i < barCount; i++)
|
||||
{
|
||||
high[i] = 100.0 + i * 0.1;
|
||||
low[i] = 99.0 + i * 0.1;
|
||||
close[i] = 99.5 + i * 0.1;
|
||||
high[i] = 100.0 + (i * 0.1);
|
||||
low[i] = 99.0 + (i * 0.1);
|
||||
close[i] = 99.5 + (i * 0.1);
|
||||
}
|
||||
|
||||
// Should not throw StackOverflowException (uses ArrayPool for > 256)
|
||||
@@ -582,12 +582,12 @@ public sealed class KdjTests
|
||||
// Now sharp move up
|
||||
for (int i = 3; i < 8; i++)
|
||||
{
|
||||
kdj.Update(new TBar(time.AddSeconds(i), 100 + (i - 2) * 5, 110 + (i - 2) * 5, 95 + (i - 2) * 5, 110 + (i - 2) * 5, 1000));
|
||||
kdj.Update(new TBar(time.AddSeconds(i), 100 + ((i - 2) * 5), 110 + ((i - 2) * 5), 95 + ((i - 2) * 5), 110 + ((i - 2) * 5), 1000));
|
||||
}
|
||||
|
||||
// J should be able to exceed 100 (it's unbounded)
|
||||
// This is a property test - we just verify J is computed as 3K-2D
|
||||
double expectedJ = 3.0 * kdj.K.Value - 2.0 * kdj.D.Value;
|
||||
double expectedJ = (3.0 * kdj.K.Value) - (2.0 * kdj.D.Value);
|
||||
Assert.Equal(expectedJ, kdj.Last.Value, 1e-10);
|
||||
}
|
||||
|
||||
@@ -606,10 +606,10 @@ public sealed class KdjTests
|
||||
// Sharp move down
|
||||
for (int i = 3; i < 8; i++)
|
||||
{
|
||||
kdj.Update(new TBar(time.AddSeconds(i), 200 - (i - 2) * 5, 210 - (i - 2) * 5, 190 - (i - 2) * 5, 190 - (i - 2) * 5, 1000));
|
||||
kdj.Update(new TBar(time.AddSeconds(i), 200 - ((i - 2) * 5), 210 - ((i - 2) * 5), 190 - ((i - 2) * 5), 190 - ((i - 2) * 5), 1000));
|
||||
}
|
||||
|
||||
double expectedJ = 3.0 * kdj.K.Value - 2.0 * kdj.D.Value;
|
||||
double expectedJ = (3.0 * kdj.K.Value) - (2.0 * kdj.D.Value);
|
||||
Assert.Equal(expectedJ, kdj.Last.Value, 1e-10);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public sealed class KdjValidationTests(ITestOutputHelper output) : IDisposable
|
||||
|
||||
for (int i = 0; i < barCount; i++)
|
||||
{
|
||||
double expectedJ = 3.0 * bK.Values[i] - 2.0 * bD.Values[i];
|
||||
double expectedJ = (3.0 * bK.Values[i]) - (2.0 * bD.Values[i]);
|
||||
Assert.Equal(expectedJ, bJ.Values[i], 1e-10);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public sealed class KriTests
|
||||
var k = new Kri(5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
k.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2));
|
||||
k.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)));
|
||||
}
|
||||
Assert.True(k.Last.Value > 0, "Price above SMA should produce positive KRI");
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public sealed class KriTests
|
||||
var k = new Kri(5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
k.Update(new TValue(DateTime.UtcNow, 200.0 - i * 2));
|
||||
k.Update(new TValue(DateTime.UtcNow, 200.0 - (i * 2)));
|
||||
}
|
||||
Assert.True(k.Last.Value < 0, "Price below SMA should produce negative KRI");
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public sealed class KriTests
|
||||
double[] data = new double[15];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = 100 + i * 2;
|
||||
data[i] = 100 + (i * 2);
|
||||
}
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ public sealed class KriValidationTests(ITestOutputHelper output)
|
||||
const int N = 100;
|
||||
const int period = 5;
|
||||
double[] prices = new double[N];
|
||||
for (int i = 0; i < N; i++) { prices[i] = 100.0 + i * 2.0; }
|
||||
for (int i = 0; i < N; i++) { prices[i] = 100.0 + (i * 2.0); }
|
||||
|
||||
var batchOut = new double[N];
|
||||
Kri.Batch(prices.AsSpan(), batchOut.AsSpan(), period);
|
||||
@@ -123,7 +123,7 @@ public sealed class KriValidationTests(ITestOutputHelper output)
|
||||
const int N = 100;
|
||||
const int period = 5;
|
||||
double[] prices = new double[N];
|
||||
for (int i = 0; i < N; i++) { prices[i] = 200.0 - i * 2.0; }
|
||||
for (int i = 0; i < N; i++) { prices[i] = 200.0 - (i * 2.0); }
|
||||
|
||||
var batchOut = new double[N];
|
||||
Kri.Batch(prices.AsSpan(), batchOut.AsSpan(), period);
|
||||
|
||||
@@ -127,7 +127,7 @@ public sealed class KstIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.5, 110 + i * 0.5, 90 + i * 0.5, 105 + i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.5), 110 + (i * 0.5), 90 + (i * 0.5), 105 + (i * 0.5));
|
||||
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public sealed class KstBarCorrectionTests
|
||||
var kst = new Kst(r1: 3, r2: 4, r3: 5, r4: 6, s1: 2, s2: 2, s3: 2, s4: 2, sigPeriod: 2);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
kst.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2), isNew: true);
|
||||
kst.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)), isNew: true);
|
||||
}
|
||||
double val1 = kst.Last.Value;
|
||||
kst.Update(new TValue(DateTime.UtcNow, 110.0), isNew: true);
|
||||
|
||||
@@ -101,7 +101,7 @@ public sealed class KstValidationTests(ITestOutputHelper output)
|
||||
double startPrice = 100.0;
|
||||
int n = 60;
|
||||
double[] prices = new double[n];
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice + i * 0.5; } // constant rise
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice + (i * 0.5); } // constant rise
|
||||
|
||||
var spanK = new double[n];
|
||||
var spanS = new double[n];
|
||||
@@ -124,7 +124,7 @@ public sealed class KstValidationTests(ITestOutputHelper output)
|
||||
double startPrice = 200.0;
|
||||
int n = 60;
|
||||
double[] prices = new double[n];
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice - i * 0.5; } // constant fall
|
||||
for (int i = 0; i < n; i++) { prices[i] = startPrice - (i * 0.5); } // constant fall
|
||||
|
||||
var spanK = new double[n];
|
||||
var spanS = new double[n];
|
||||
|
||||
@@ -66,7 +66,7 @@ public sealed class LrsiIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
double price = 100.0 + Math.Sin(i * 0.3) * 10.0 + i * 0.1;
|
||||
double price = 100.0 + (Math.Sin(i * 0.3) * 10.0) + (i * 0.1);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), price + 5, price + 10, price - 5, price);
|
||||
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
@@ -87,7 +87,7 @@ public sealed class LrsiIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
double price = 100.0 + i * 0.5;
|
||||
double price = 100.0 + (i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), price + 3, price + 6, price - 3, price);
|
||||
|
||||
var reason = i < 19 ? UpdateReason.HistoricalBar : UpdateReason.NewBar;
|
||||
@@ -138,7 +138,7 @@ public sealed class LrsiIndicatorTests
|
||||
// Feed a volatile sine wave to exercise full range
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
double price = 100.0 + Math.Sin(i * 0.2) * 20.0;
|
||||
double price = 100.0 + (Math.Sin(i * 0.2) * 20.0);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), price + 5, price + 10, price - 5, price);
|
||||
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
|
||||
@@ -475,7 +475,7 @@ public sealed class LrsiTests
|
||||
var t = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
source.Add(new TValue(t.AddMinutes(i), 100.0 + i * 0.5));
|
||||
source.Add(new TValue(t.AddMinutes(i), 100.0 + (i * 0.5)));
|
||||
}
|
||||
|
||||
Assert.Equal(30, output.Count);
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class MstochIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.5, 110 + i * 0.5, 90 + i * 0.5, 105 + i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.5), 110 + (i * 0.5), 90 + (i * 0.5), 105 + (i * 0.5));
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
indicator.ProcessUpdate(args);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public sealed class MstochIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.5, 110 + i * 0.5, 90 + i * 0.5, 105 + i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.5), 110 + (i * 0.5), 90 + (i * 0.5), 105 + (i * 0.5));
|
||||
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public sealed class MstochValidationTests
|
||||
// Feed 50 strongly rising bars
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
mstoch.Update(new TValue(t0.AddSeconds(100 + i), 100.0 + i * 2.0));
|
||||
mstoch.Update(new TValue(t0.AddSeconds(100 + i), 100.0 + (i * 2.0)));
|
||||
}
|
||||
double risingVal = mstoch.Last.Value;
|
||||
|
||||
@@ -190,7 +190,7 @@ public sealed class MstochValidationTests
|
||||
}
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
mstoch.Update(new TValue(t0.AddSeconds(100 + i), 100.0 - i * 2.0));
|
||||
mstoch.Update(new TValue(t0.AddSeconds(100 + i), 100.0 - (i * 2.0)));
|
||||
}
|
||||
double fallingVal = mstoch.Last.Value;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public sealed class PgoValidationTests
|
||||
// Feed gradually rising prices
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
double c = 100.0 + i * 2;
|
||||
double c = 100.0 + (i * 2);
|
||||
pgo.Update(new TBar(DateTime.UtcNow, c - 1, c + 3, c - 3, c, 100));
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ public sealed class PgoValidationTests
|
||||
// Feed rising prices first, then drop
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
double c = 100.0 + i * 5;
|
||||
double c = 100.0 + (i * 5);
|
||||
pgo.Update(new TBar(DateTime.UtcNow, c - 1, c + 3, c - 3, c, 100));
|
||||
}
|
||||
// Now drop sharply
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
double c = 80.0 - i * 5;
|
||||
double c = 80.0 - (i * 5);
|
||||
pgo.Update(new TBar(DateTime.UtcNow, c - 1, c + 3, c - 3, c, 100));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public sealed class PslTests
|
||||
var p = new Psl(5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
p.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2));
|
||||
p.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2)));
|
||||
}
|
||||
Assert.True(p.Last.Value > 50, "Rising prices should produce PSL > 50");
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public sealed class PslTests
|
||||
var p = new Psl(5);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
p.Update(new TValue(DateTime.UtcNow, 200.0 - i * 2));
|
||||
p.Update(new TValue(DateTime.UtcNow, 200.0 - (i * 2)));
|
||||
}
|
||||
Assert.True(p.Last.Value < 50, "Falling prices should produce PSL < 50");
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public sealed class PslTests
|
||||
double[] data = new double[15];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = 100 + i * 2;
|
||||
data[i] = 100 + (i * 2);
|
||||
}
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ReflexTests
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1));
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)));
|
||||
}
|
||||
|
||||
Assert.True(indicator.IsHot);
|
||||
@@ -98,7 +98,7 @@ public class ReflexTests
|
||||
// Warm up past the period threshold first
|
||||
for (int i = 0; i < DefaultPeriod + 5; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.5), isNew: true);
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.5)), isNew: true);
|
||||
}
|
||||
|
||||
TValue r1 = indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(30), 120.0), isNew: true);
|
||||
@@ -235,7 +235,7 @@ public class ReflexTests
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.5;
|
||||
source[i] = 100.0 + (i * 0.5);
|
||||
}
|
||||
|
||||
source[50] = double.NaN;
|
||||
@@ -328,7 +328,7 @@ public class ReflexTests
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.1;
|
||||
source[i] = 100.0 + (i * 0.1);
|
||||
}
|
||||
|
||||
Reflex.Batch(source, output, 20);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ReverseEmaTests
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1));
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)));
|
||||
}
|
||||
|
||||
Assert.True(indicator.IsHot);
|
||||
@@ -223,7 +223,7 @@ public class ReverseEmaTests
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.5;
|
||||
source[i] = 100.0 + (i * 0.5);
|
||||
}
|
||||
|
||||
source[50] = double.NaN;
|
||||
@@ -316,7 +316,7 @@ public class ReverseEmaTests
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.1;
|
||||
source[i] = 100.0 + (i * 0.1);
|
||||
}
|
||||
|
||||
ReverseEma.Batch(source, output, 20);
|
||||
|
||||
@@ -116,7 +116,7 @@ public sealed class RvgiIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
double basePrice = 100.0 + i * 0.5;
|
||||
double basePrice = 100.0 + (i * 0.5);
|
||||
indicator.HistoricalData.AddBar(
|
||||
now.AddMinutes(i),
|
||||
open: basePrice,
|
||||
|
||||
@@ -239,7 +239,7 @@ public sealed class RvgiValidationTests(ITestOutputHelper output)
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
double basePrice = 100.0 + i * 0.5;
|
||||
double basePrice = 100.0 + (i * 0.5);
|
||||
rvgi.Update(new TBar(
|
||||
DateTime.UtcNow.AddMinutes(i),
|
||||
open: basePrice,
|
||||
@@ -261,7 +261,7 @@ public sealed class RvgiValidationTests(ITestOutputHelper output)
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
double basePrice = 200.0 - i * 0.5;
|
||||
double basePrice = 200.0 - (i * 0.5);
|
||||
rvgi.Update(new TBar(
|
||||
DateTime.UtcNow.AddMinutes(i),
|
||||
open: basePrice + 2.0,
|
||||
|
||||
@@ -111,7 +111,7 @@ public sealed class SqueezeIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
double price = 50.0 + i * 0.5;
|
||||
double price = 50.0 + (i * 0.5);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 0.5, price - 0.5, price + 0.1);
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
indicator.ProcessUpdate(args);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class StcIndicatorTests
|
||||
double[] closes = new double[100];
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
closes[i] = 100 + Math.Sin(i * 0.1) * 10;
|
||||
closes[i] = 100 + (Math.Sin(i * 0.1) * 10);
|
||||
}
|
||||
|
||||
foreach (var close in closes)
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TrendflexTests
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1));
|
||||
indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)));
|
||||
}
|
||||
|
||||
Assert.True(indicator.IsHot);
|
||||
@@ -223,7 +223,7 @@ public class TrendflexTests
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.5;
|
||||
source[i] = 100.0 + (i * 0.5);
|
||||
}
|
||||
|
||||
source[50] = double.NaN;
|
||||
@@ -316,7 +316,7 @@ public class TrendflexTests
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
source[i] = 100.0 + i * 0.1;
|
||||
source[i] = 100.0 + (i * 0.1);
|
||||
}
|
||||
|
||||
Trendflex.Batch(source, output, 20);
|
||||
@@ -412,7 +412,7 @@ public class TrendflexTests
|
||||
// Strong uptrend
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
TValue r = indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 2.0));
|
||||
TValue r = indicator.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 2.0)));
|
||||
lastResult = r.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ public sealed class TrixValidationTests(ITestOutputHelper output) : IDisposable
|
||||
// Feed a long sustained uptrend to ensure TRIX stabilizes positive
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
trix.Update(new TValue(DateTime.UtcNow, 100 + i * 2));
|
||||
trix.Update(new TValue(DateTime.UtcNow, 100 + (i * 2)));
|
||||
}
|
||||
double uptrendTrix = trix.Last.Value;
|
||||
Assert.True(uptrendTrix > 0, $"Sustained uptrend should produce positive TRIX, got {uptrendTrix}");
|
||||
@@ -346,7 +346,7 @@ public sealed class TrixValidationTests(ITestOutputHelper output) : IDisposable
|
||||
// Feed a long sustained downtrend
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
trix.Update(new TValue(DateTime.UtcNow, 200 - i * 2));
|
||||
trix.Update(new TValue(DateTime.UtcNow, 200 - (i * 2)));
|
||||
}
|
||||
double downtrendTrix = trix.Last.Value;
|
||||
Assert.True(downtrendTrix < 0, $"Sustained downtrend should produce negative TRIX, got {downtrendTrix}");
|
||||
|
||||
@@ -64,7 +64,7 @@ public sealed class TtmWaveIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 800; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.1, 110 + i * 0.1, 90 + i * 0.1, 105 + i * 0.1);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.1), 110 + (i * 0.1), 90 + (i * 0.1), 105 + (i * 0.1));
|
||||
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
indicator.ProcessUpdate(args);
|
||||
@@ -85,7 +85,7 @@ public sealed class TtmWaveIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 800; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.1, 110 + i * 0.1, 90 + i * 0.1, 105 + i * 0.1);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.1), 110 + (i * 0.1), 90 + (i * 0.1), 105 + (i * 0.1));
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
indicator.ProcessUpdate(args);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public sealed class TtmWaveIndicatorTests
|
||||
var now = DateTime.UtcNow;
|
||||
for (int i = 0; i < 800; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 0.1, 110 + i * 0.1, 90 + i * 0.1, 105 + i * 0.1);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 0.1), 110 + (i * 0.1), 90 + (i * 0.1), 105 + (i * 0.1));
|
||||
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
||||
indicator.ProcessUpdate(args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user