[CodeFactor] Apply fixes to commit 0606491

This commit is contained in:
codefactor-io
2026-03-12 19:37:50 +00:00
parent 060649192f
commit 8f79257155
384 changed files with 1197 additions and 1215 deletions
@@ -122,7 +122,7 @@ public class CcorIndicatorTests
var now = DateTime.UtcNow;
for (int i = 0; i < 30; i++)
{
double price = 100 + 5 * Math.Sin(2 * Math.PI * i / 20.0);
double price = 100 + (5 * Math.Sin(2 * Math.PI * i / 20.0));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 2, price - 2, price + 1);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
+1 -1
View File
@@ -488,7 +488,7 @@ public class CcorTests
// Feed a perfect sine wave of the same period
for (int i = 0; i < 100; i++)
{
double val = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / period);
double val = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / period));
_ = ind.Update(new TValue(DateTime.UtcNow.AddMinutes(i), val));
}
@@ -116,7 +116,7 @@ public class CcycIndicatorTests
var now = DateTime.UtcNow;
for (int i = 0; i < 20; i++)
{
double price = 100 + 5 * Math.Sin(2 * Math.PI * i / 20.0);
double price = 100 + (5 * Math.Sin(2 * Math.PI * i / 20.0));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 2, price - 2, price + 1);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
+2 -2
View File
@@ -425,7 +425,7 @@ public class CcycTests
for (int i = 0; i < 200; i++)
{
double value = 100 + 10 * Math.Sin(2 * Math.PI * i / period);
double value = 100 + (10 * Math.Sin(2 * Math.PI * i / period));
ccyc.Update(new TValue(DateTime.UtcNow.AddDays(i), value), true);
}
@@ -459,7 +459,7 @@ public class CcycTests
double[] primeData = new double[50];
for (int i = 0; i < 50; i++)
{
primeData[i] = 100 + 5 * Math.Sin(2 * Math.PI * i / 20.0);
primeData[i] = 100 + (5 * Math.Sin(2 * Math.PI * i / 20.0));
}
ccyc.Prime(primeData.AsSpan());
@@ -41,7 +41,7 @@ public class CcycValidationTests
for (int i = 0; i < 500; i++)
{
ccyc.Update(new TValue(DateTime.UtcNow.AddMinutes(i), 100.0 + 0.5 * i), true);
ccyc.Update(new TValue(DateTime.UtcNow.AddMinutes(i), 100.0 + (0.5 * i)), true);
}
// After warmup, should be near zero since linear trend has no cycle component
@@ -58,7 +58,7 @@ public class CcycValidationTests
for (int i = 0; i < 200; i++)
{
double value = 100 + 10 * Math.Sin(2 * Math.PI * i / period);
double value = 100 + (10 * Math.Sin(2 * Math.PI * i / period));
ccyc.Update(new TValue(DateTime.UtcNow.AddMinutes(i), value), true);
}
@@ -80,7 +80,7 @@ public class CcycValidationTests
for (int i = 0; i < 300; i++)
{
double value = 100 + 10 * Math.Sin(2 * Math.PI * i / period);
double value = 100 + (10 * Math.Sin(2 * Math.PI * i / period));
var r = ccyc.Update(new TValue(DateTime.UtcNow.AddMinutes(i), value), true);
if (i > 20 && prev * r.Value < 0 && prev != 0)
@@ -169,7 +169,7 @@ public class CcycValidationTests
double noiseVal = rng.Next().Close;
ccycNoise.Update(new TValue(DateTime.UtcNow.AddMinutes(i), noiseVal), true);
double sineVal = 100 + 10 * Math.Sin(2 * Math.PI * i / 20.0);
double sineVal = 100 + (10 * Math.Sin(2 * Math.PI * i / 20.0));
var sineResult = ccycSine.Update(new TValue(DateTime.UtcNow.AddMinutes(i), sineVal), true);
if (i > 30)
@@ -216,7 +216,7 @@ public class CcycValidationTests
for (int i = 0; i < 300; i++)
{
double value = 100 + 10 * Math.Sin(2 * Math.PI * i / 20.0);
double value = 100 + (10 * Math.Sin(2 * Math.PI * i / 20.0));
ccyc.Update(new TValue(DateTime.UtcNow.AddMinutes(i), value), true);
if (i > 20)
@@ -340,7 +340,7 @@ public class CcycValidationTests
for (int i = 0; i < 20; i++)
{
double value = 100 + 5 * Math.Sin(2 * Math.PI * i / 20.0);
double value = 100 + (5 * Math.Sin(2 * Math.PI * i / 20.0));
var r = ccyc.Update(new TValue(DateTime.UtcNow.AddMinutes(i), value), true);
results.Add(r.Value);
}
+1 -1
View File
@@ -262,7 +262,7 @@ public class CgIndicatorTests
var now = DateTime.UtcNow;
double[] closes = { 100, 102, 98, 105, 97, 110, 95, 108, 92, 115, 90, 120 };
double maxExpectedBound = (10 - 1) / 2.0 + 1.0; // Period-based bound with margin
double maxExpectedBound = ((10 - 1) / 2.0) + 1.0; // Period-based bound with margin
foreach (var close in closes)
{
+3 -3
View File
@@ -79,7 +79,7 @@ public class CgTests
var cg = new Cg(5);
for (int i = 0; i < 10; i++)
{
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100 + i * 10));
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100 + (i * 10)));
}
Assert.True(cg.Last.Value > 0, $"Expected positive CG, got {cg.Last.Value}");
}
@@ -91,7 +91,7 @@ public class CgTests
var cg = new Cg(5);
for (int i = 0; i < 10; i++)
{
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 200 - i * 10));
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 200 - (i * 10)));
}
Assert.True(cg.Last.Value < 0, $"Expected negative CG, got {cg.Last.Value}");
}
@@ -328,7 +328,7 @@ public class CgTests
// Generate and store values
for (int i = 0; i < 20; i++)
{
inputs.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100 + i * 0.5));
inputs.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100 + (i * 0.5)));
}
// First pass
+10 -10
View File
@@ -28,7 +28,7 @@ public class CgValidationTests
var gbm = new GBM(seed: 42);
var bars = gbm.Fetch(500, DateTime.UtcNow.Ticks, TimeSpan.FromMinutes(1));
double maxAbsValue = (period - 1) / 2.0 + 0.5; // Allow small margin
double maxAbsValue = ((period - 1) / 2.0) + 0.5; // Allow small margin
foreach (var bar in bars)
{
@@ -65,7 +65,7 @@ public class CgValidationTests
for (int i = 0; i < 50; i++)
{
double price = 100.0 + i * 1.0; // Linear uptrend
double price = 100.0 + (i * 1.0); // Linear uptrend
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -82,7 +82,7 @@ public class CgValidationTests
for (int i = 0; i < 50; i++)
{
double price = 200.0 - i * 1.0; // Linear downtrend
double price = 200.0 - (i * 1.0); // Linear downtrend
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -100,7 +100,7 @@ public class CgValidationTests
for (int i = 0; i < 50; i++)
{
double expPrice = 100.0 * Math.Exp(i * 0.02);
double linPrice = 100.0 + i * 2.0;
double linPrice = 100.0 + (i * 2.0);
cgExp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), expPrice));
cgLin.Update(new TValue(DateTime.UtcNow.AddSeconds(i), linPrice));
}
@@ -120,7 +120,7 @@ public class CgValidationTests
// Generate sine wave to simulate price oscillation
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.2);
double price = 100.0 + (10.0 * Math.Sin(i * 0.2));
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
if (cg.IsHot)
{
@@ -162,9 +162,9 @@ public class CgValidationTests
// num = 1*10 + 2*12 + 3*11 + 4*13 + 5*15 = 10 + 24 + 33 + 52 + 75 = 194
// den = 10 + 12 + 11 + 13 + 15 = 61
// result = 194/61 - (5+1)/2 = 3.1803... - 3 = 0.1803...
double expectedNum = 1 * 10 + 2 * 12 + 3 * 11 + 4 * 13 + 5 * 15;
double expectedNum = (1 * 10) + (2 * 12) + (3 * 11) + (4 * 13) + (5 * 15);
double expectedDen = 10 + 12 + 11 + 13 + 15;
double expectedCg = (expectedNum / expectedDen) - (period + 1) / 2.0;
double expectedCg = (expectedNum / expectedDen) - ((period + 1) / 2.0);
var cg = new Cg(period);
for (int i = 0; i < prices.Length; i++)
@@ -287,7 +287,7 @@ public class CgValidationTests
Assert.True(double.IsFinite(cg.Last.Value));
// CG bounds check
double maxAbsValue = (period - 1) / 2.0 + 1.0;
double maxAbsValue = ((period - 1) / 2.0) + 1.0;
Assert.True(Math.Abs(cg.Last.Value) <= maxAbsValue,
$"CG with period {period} should be within ±{maxAbsValue}, got {cg.Last.Value}");
}
@@ -337,7 +337,7 @@ public class CgValidationTests
// Uptrend
for (int i = 0; i < 30; i++)
{
double price = 100.0 + i * 0.5;
double price = 100.0 + (i * 0.5);
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
prices.Add(price);
if (cg.IsHot)
@@ -349,7 +349,7 @@ public class CgValidationTests
// Plateau/slight decline
for (int i = 30; i < 50; i++)
{
double price = 115.0 - (i - 30) * 0.2;
double price = 115.0 - ((i - 30) * 0.2);
cg.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
prices.Add(price);
cgValues.Add(cg.Last.Value);
+1 -1
View File
@@ -326,7 +326,7 @@ public class DspIndicatorTests
// Generate sine wave price pattern
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.1);
double price = 100.0 + (10.0 * Math.Sin(i * 0.1));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
values.Add(indicator.LinesSeries[0].GetValue(0));
+3 -3
View File
@@ -103,7 +103,7 @@ public class DspTests
for (int i = 0; i < 100; i++)
{
double price = 100.0 + i * 1.0;
double price = 100.0 + (i * 1.0);
dsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -118,7 +118,7 @@ public class DspTests
for (int i = 0; i < 100; i++)
{
double price = 200.0 - i * 1.0;
double price = 200.0 - (i * 1.0);
dsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -414,7 +414,7 @@ public class DspTests
for (int i = 0; i < 100; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
// Both should have values
+4 -4
View File
@@ -69,7 +69,7 @@ public class DspValidationTests
// Generate sine wave to simulate price oscillation
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.1);
double price = 100.0 + (10.0 * Math.Sin(i * 0.1));
dsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
if (dsp.IsHot)
{
@@ -310,7 +310,7 @@ public class DspValidationTests
for (int i = 0; i < 100; i++)
{
double price = 0.0001 + i * 0.00001;
double price = 0.0001 + (i * 0.00001);
dsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -325,7 +325,7 @@ public class DspValidationTests
for (int i = 0; i < 100; i++)
{
double price = 1e10 + i * 1e8;
double price = 1e10 + (i * 1e8);
dsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -363,7 +363,7 @@ public class DspValidationTests
// Strong uptrend with some noise
for (int i = 0; i < 300; i++)
{
double trend = 100.0 + i * 0.5;
double trend = 100.0 + (i * 0.5);
double noise = Math.Sin(i * 0.3) * 2.0;
double price = trend + noise;
dsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
@@ -305,7 +305,7 @@ public class EacpIndicatorTests
// Generate sine wave pattern
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / knownPeriod);
double price = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / knownPeriod));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -324,7 +324,7 @@ public class EacpIndicatorTests
var now = DateTime.UtcNow;
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 20.0);
double price = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 20.0));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -348,7 +348,7 @@ public class EacpIndicatorTests
// Add same data to both
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 20.0);
double price = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 20.0));
indicatorEnhanced.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicatorNormal.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicatorEnhanced.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
+5 -5
View File
@@ -169,7 +169,7 @@ public class EacpTests
// Build some history
for (int i = 0; i < 100; i++)
{
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10), isNew: true);
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)), isNew: true);
}
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(100), 110.0), isNew: true);
@@ -237,7 +237,7 @@ public class EacpTests
// First run
for (int i = 0; i < 200; i++)
{
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
var firstResult = eacp.Last.Value;
@@ -246,7 +246,7 @@ public class EacpTests
// Second run with same data
for (int i = 0; i < 200; i++)
{
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
var secondResult = eacp.Last.Value;
@@ -431,7 +431,7 @@ public class EacpTests
for (int i = 0; i < 200; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
Assert.True(eacp.IsHot);
@@ -447,7 +447,7 @@ public class EacpTests
for (int i = 0; i < 300; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
// Both should have values
@@ -316,7 +316,7 @@ public class EbswIndicatorTests
// Add varying price bars
for (int i = 0; i < 100; i++)
{
double price = 100 + 20 * Math.Sin(i * 0.2);
double price = 100 + (20 * Math.Sin(i * 0.2));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 2, price - 2, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
@@ -338,7 +338,7 @@ public class EbswIndicatorTests
// Generate sine wave price pattern
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.1);
double price = 100.0 + (10.0 * Math.Sin(i * 0.1));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
values.Add(indicator.LinesSeries[0].GetValue(0));
@@ -364,7 +364,7 @@ public class EbswIndicatorTests
// Generate sine wave price pattern
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.15);
double price = 100.0 + (10.0 * Math.Sin(i * 0.15));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
values.Add(indicator.LinesSeries[0].GetValue(0));
+5 -5
View File
@@ -137,7 +137,7 @@ public class EbswTests
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * frequency);
double price = 100.0 + (10.0 * Math.Sin(i * frequency));
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -235,7 +235,7 @@ public class EbswTests
// First run
for (int i = 0; i < 100; i++)
{
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
var firstResult = ebsw.Last.Value;
@@ -244,7 +244,7 @@ public class EbswTests
// Second run with same data
for (int i = 0; i < 100; i++)
{
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
var secondResult = ebsw.Last.Value;
@@ -451,7 +451,7 @@ public class EbswTests
for (int i = 0; i < 100; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
Assert.True(ebsw.IsHot);
@@ -467,7 +467,7 @@ public class EbswTests
for (int i = 0; i < 200; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
// Both should have values
@@ -89,7 +89,7 @@ public class EbswValidationTests
// Generate sine wave to simulate price oscillation
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.1);
double price = 100.0 + (10.0 * Math.Sin(i * 0.1));
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
if (ebsw.IsHot)
{
@@ -186,7 +186,7 @@ public class EbswValidationTests
// Larger amplitude oscillation to ensure EBSW detects cycles
for (int i = 0; i < 300; i++)
{
double trend = 100.0 + i * 0.5;
double trend = 100.0 + (i * 0.5);
double oscillation = Math.Sin(i * 0.15) * 10.0; // Larger amplitude, longer period
double price = trend + oscillation;
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
@@ -252,7 +252,7 @@ public class EbswValidationTests
double frequency = 2.0 * Math.PI / 40.0;
for (int i = 0; i < 500; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * frequency);
double price = 100.0 + (10.0 * Math.Sin(i * frequency));
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
if (ebsw.IsHot)
{
@@ -405,7 +405,7 @@ public class EbswValidationTests
for (int i = 0; i < 100; i++)
{
double price = 0.0001 + i * 0.00001;
double price = 0.0001 + (i * 0.00001);
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -421,7 +421,7 @@ public class EbswValidationTests
for (int i = 0; i < 100; i++)
{
double price = 1e10 + i * 1e8;
double price = 1e10 + (i * 1e8);
ebsw.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -269,7 +269,7 @@ public class HomodIndicatorTests
// Generate sine wave pattern
for (int i = 0; i < 200; i++)
{
double price = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / knownPeriod);
double price = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / knownPeriod));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -309,7 +309,7 @@ public class HomodIndicatorTests
for (int i = 0; i < 100; i++)
{
double price = 100.0 + i * 0.5; // Trending up
double price = 100.0 + (i * 0.5); // Trending up
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
+5 -5
View File
@@ -146,7 +146,7 @@ public class HomodTests
// Build some history
for (int i = 0; i < 100; i++)
{
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10), isNew: true);
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)), isNew: true);
}
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(100), 110.0), isNew: true);
@@ -213,7 +213,7 @@ public class HomodTests
// First run
for (int i = 0; i < 200; i++)
{
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
var firstResult = homod.Last.Value;
@@ -222,7 +222,7 @@ public class HomodTests
// Second run with same data
for (int i = 0; i < 200; i++)
{
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
var secondResult = homod.Last.Value;
@@ -407,7 +407,7 @@ public class HomodTests
for (int i = 0; i < 200; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
Assert.True(homod.IsHot);
@@ -423,7 +423,7 @@ public class HomodTests
for (int i = 0; i < 300; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
// Both should have values
@@ -110,7 +110,7 @@ public class HomodValidationTests
// Generate 500 bars of sine wave
for (int i = 0; i < 500; i++)
{
double value = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / knownPeriod);
double value = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / knownPeriod));
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), value));
}
@@ -131,7 +131,7 @@ public class HomodValidationTests
// Generate sine wave with specified period
for (int i = 0; i < 600; i++)
{
double value = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / period);
double value = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / period));
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), value));
}
@@ -282,7 +282,7 @@ public class HomodValidationTests
// Strong uptrend with no cyclical component
for (int i = 0; i < 500; i++)
{
double value = 100.0 + i * 0.5;
double value = 100.0 + (i * 0.5);
var result = homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), value));
Assert.True(double.IsFinite(result.Value));
}
@@ -339,7 +339,7 @@ public class HomodValidationTests
// Generate synthetic cycle
for (int i = 0; i < 200; i++)
{
double value = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 20);
double value = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 20));
homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), value));
}
@@ -347,7 +347,7 @@ public class HomodValidationTests
var postWarmupValues = new List<double>();
for (int i = 200; i < 400; i++)
{
double value = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 20);
double value = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 20));
var result = homod.Update(new TValue(DateTime.UtcNow.AddSeconds(i), value));
postWarmupValues.Add(result.Value);
}
@@ -178,7 +178,7 @@ public class HtDcperiodIndicatorTests
// HT_DCPERIOD needs significant warmup - feed sinusoidal data
for (int i = 0; i < 100; i++)
{
double price = 100 + 10 * Math.Sin(i * 0.3);
double price = 100 + (10 * Math.Sin(i * 0.3));
indicator.HistoricalData.AddBar(
time: now.AddMinutes(i),
open: price - 1,
@@ -339,7 +339,7 @@ public class HtDcperiodIndicatorTests
// Feed sinusoidal data with known period (~21 bars)
for (int i = 0; i < 100; i++)
{
double price = 100 + 10 * Math.Sin(2 * Math.PI * i / 21.0);
double price = 100 + (10 * Math.Sin(2 * Math.PI * i / 21.0));
indicator.HistoricalData.AddBar(
time: now.AddMinutes(i),
open: price - 0.5,
@@ -27,7 +27,7 @@ public class HtDcperiodTests
// Feed data through publisher
for (int i = 0; i < 40; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddMinutes(i), 100 + Math.Sin(i * 0.3) * 10));
source.Add(new TValue(DateTime.UtcNow.AddMinutes(i), 100 + (Math.Sin(i * 0.3) * 10)));
}
Assert.True(ht.IsHot);
@@ -144,7 +144,7 @@ public class HtDcperiodTests
// Prime with data
for (int i = 0; i < 50; i++)
{
ht.Update(new TValue(now.AddMinutes(i), 100 + Math.Sin(i * 0.1) * 10));
ht.Update(new TValue(now.AddMinutes(i), 100 + (Math.Sin(i * 0.1) * 10)));
}
Assert.True(ht.IsHot);
@@ -203,7 +203,7 @@ public class HtDcperiodTests
// Feed valid data to warm up
for (int i = 0; i < 50; i++)
{
ht.Update(new TValue(now.AddMinutes(i), 100 + Math.Sin(i * 0.2) * 5));
ht.Update(new TValue(now.AddMinutes(i), 100 + (Math.Sin(i * 0.2) * 5)));
}
Assert.True(ht.IsHot);
@@ -221,7 +221,7 @@ public class HtDcperiodTests
for (int i = 0; i < 50; i++)
{
ht.Update(new TValue(now.AddMinutes(i), 100 + i * 0.5));
ht.Update(new TValue(now.AddMinutes(i), 100 + (i * 0.5)));
}
var result = ht.Update(new TValue(now.AddMinutes(50), double.PositiveInfinity));
@@ -255,7 +255,7 @@ public class HtDcperiodTests
// First use
for (int i = 0; i < 50; i++)
{
ht.Update(new TValue(now.AddMinutes(i), 100 + Math.Sin(i * 0.2) * 5));
ht.Update(new TValue(now.AddMinutes(i), 100 + (Math.Sin(i * 0.2) * 5)));
}
Assert.True(ht.IsHot);
var firstResult = ht.Last.Value;
@@ -266,7 +266,7 @@ public class HtDcperiodTests
for (int i = 0; i < 50; i++)
{
ht.Update(new TValue(now.AddMinutes(i), 100 + Math.Sin(i * 0.2) * 5));
ht.Update(new TValue(now.AddMinutes(i), 100 + (Math.Sin(i * 0.2) * 5)));
}
Assert.True(ht.IsHot);
Assert.Equal(firstResult, ht.Last.Value);
@@ -387,7 +387,7 @@ public class HtDcperiodTests
var values = new double[50];
for (int i = 0; i < 50; i++)
{
values[i] = 100 + Math.Sin(i * 0.2) * 5;
values[i] = 100 + (Math.Sin(i * 0.2) * 5);
}
ht.Prime(values, TimeSpan.FromMinutes(5));
@@ -443,7 +443,7 @@ public class HtDcperiodTests
for (int i = 0; i < 300; i++)
{
ht.Update(new TValue(now.AddMinutes(i), 100 + 10 * Math.Sin(omega * i)));
ht.Update(new TValue(now.AddMinutes(i), 100 + (10 * Math.Sin(omega * i))));
}
// After sufficient data, the detected period should be
+3 -3
View File
@@ -54,7 +54,7 @@ public class HtPhasorTests
for (int i = 0; i < 100; i++)
{
phasor.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 5));
phasor.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 5)));
}
Assert.True(double.IsFinite(phasor.Quadrature));
@@ -126,7 +126,7 @@ public class HtPhasorTests
for (int i = 0; i < 50; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.2) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.2) * 10)));
}
Assert.True(phasor.IsHot);
@@ -238,7 +238,7 @@ public class HtPhasorTests
double[] data = new double[50];
for (int i = 0; i < 50; i++)
{
data[i] = 100.0 + Math.Sin(i * 0.3) * 10;
data[i] = 100.0 + (Math.Sin(i * 0.3) * 10);
}
phasor1.Prime(data);
@@ -207,7 +207,7 @@ public class HtSineIndicatorTests
// Add enough bars to pass warmup (63 bars)
for (int i = 0; i < 70; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.15);
double price = 100.0 + (10.0 * Math.Sin(i * 0.15));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -231,7 +231,7 @@ public class HtSineIndicatorTests
// Generate enough data
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.15);
double price = 100.0 + (10.0 * Math.Sin(i * 0.15));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -260,7 +260,7 @@ public class HtSineIndicatorTests
// Generate cyclic price pattern
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.15);
double price = 100.0 + (10.0 * Math.Sin(i * 0.15));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
sineValues.Add(indicator.LinesSeries[0].GetValue(0));
+8 -8
View File
@@ -91,7 +91,7 @@ public class HtSineTests
for (int i = 0; i < 100; i++)
{
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
Assert.True(double.IsFinite(htSine.LeadSine));
@@ -106,7 +106,7 @@ public class HtSineTests
const int period = 20;
for (int i = 0; i < 500; i++)
{
double price = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / period);
double price = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / period));
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -128,7 +128,7 @@ public class HtSineTests
// Build some history first
for (int i = 0; i < 100; i++)
{
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1), isNew: true);
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)), isNew: true);
}
var first = htSine.Last.Value;
@@ -147,7 +147,7 @@ public class HtSineTests
// Build some history first
for (int i = 0; i < 100; i++)
{
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1), isNew: true);
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)), isNew: true);
}
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(100), 150.0), isNew: true);
@@ -168,7 +168,7 @@ public class HtSineTests
// Build some history
for (int i = 0; i < 100; i++)
{
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + i * 0.1), isNew: true);
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (i * 0.1)), isNew: true);
}
// Add a new bar
@@ -215,7 +215,7 @@ public class HtSineTests
// First run
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.1);
double price = 100.0 + (10.0 * Math.Sin(i * 0.1));
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
var firstResult = htSine.Last.Value;
@@ -225,7 +225,7 @@ public class HtSineTests
// Second run with same data
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.1);
double price = 100.0 + (10.0 * Math.Sin(i * 0.1));
htSine.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
var secondResult = htSine.Last.Value;
@@ -412,7 +412,7 @@ public class HtSineTests
for (int i = 0; i < 100; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
Assert.True(htSine.IsHot);
@@ -247,7 +247,7 @@ public class SsfdspIndicatorTests
// Generate trending then ranging price pattern
for (int i = 0; i < 100; i++)
{
double price = 100.0 + 10.0 * Math.Sin(i * 0.15);
double price = 100.0 + (10.0 * Math.Sin(i * 0.15));
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 1, price - 1, price);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
values.Add(indicator.LinesSeries[0].GetValue(0));
+3 -3
View File
@@ -103,7 +103,7 @@ public class SsfdspTests
for (int i = 0; i < 100; i++)
{
double price = 100.0 + i * 1.0;
double price = 100.0 + (i * 1.0);
ssfdsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -118,7 +118,7 @@ public class SsfdspTests
for (int i = 0; i < 100; i++)
{
double price = 200.0 - i * 1.0;
double price = 200.0 - (i * 1.0);
ssfdsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -423,7 +423,7 @@ public class SsfdspTests
for (int i = 0; i < 100; i++)
{
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + Math.Sin(i * 0.1) * 10));
source.Add(new TValue(DateTime.UtcNow.AddSeconds(i), 100.0 + (Math.Sin(i * 0.1) * 10)));
}
// Both should have values
@@ -159,7 +159,7 @@ public class SsfdspValidationTests
for (int i = 0; i < 200; i++)
{
double price = 100 + 10 * Math.Sin(frequency * i);
double price = 100 + (10 * Math.Sin(frequency * i));
ssfdsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
if (i >= 80) // After warmup
{
@@ -337,7 +337,7 @@ public class SsfdspValidationTests
for (int i = 0; i < 1000; i++)
{
double price = 100 + 10 * Math.Sin(2 * Math.PI * i / 40);
double price = 100 + (10 * Math.Sin(2 * Math.PI * i / 40));
ssfdsp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
if (i >= 100) // After warmup