[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
@@ -132,7 +132,7 @@ public class TtmLrcIndicatorTests
// Add some volatility to ensure non-zero stddev
for (int i = 0; i < 20; i++)
{
double price = 100 + Math.Sin(i * 0.5) * 10;
double price = 100 + (Math.Sin(i * 0.5) * 10);
ind.HistoricalData.AddBar(now.AddMinutes(i), price, price + 5, price - 5, price, 1000);
ind.ProcessUpdate(new UpdateArgs(i == 0 ? UpdateReason.HistoricalBar : UpdateReason.NewBar));
}
@@ -214,7 +214,7 @@ public class TtmLrcIndicatorTests
// Perfect linear data: y = 100 + 2*i
for (int i = 0; i < 20; i++)
{
double price = 100 + i * 2;
double price = 100 + (i * 2);
ind.HistoricalData.AddBar(now.AddMinutes(i), price, price, price, price);
ind.ProcessUpdate(new UpdateArgs(i == 0 ? UpdateReason.HistoricalBar : UpdateReason.NewBar));
}
@@ -264,14 +264,14 @@ public class TtmLrcIndicatorTests
var now = DateTime.UtcNow;
for (int i = 0; i < 30; i++)
{
double price = 100 + i * 2; // Strong uptrend
double price = 100 + (i * 2); // Strong uptrend
ind.HistoricalData.AddBar(now.AddMinutes(i), price, price + 2, price - 2, price);
ind.ProcessUpdate(new UpdateArgs(i == 0 ? UpdateReason.HistoricalBar : UpdateReason.NewBar));
}
// After warmup, midline should be close to the current regression line value
double midline = ind.LinesSeries[0].GetValue(0);
double lastPrice = 100 + 29 * 2; // 158
double lastPrice = 100 + (29 * 2); // 158
// Midline should be close to last price (within reasonable range for regression)
Assert.True(Math.Abs(midline - lastPrice) < 10, $"Midline ({midline}) should be close to last price ({lastPrice})");
+11 -11
View File
@@ -166,7 +166,7 @@ public class TtmLrcTests
// Perfect linear data: y = 100 + 2*x
for (int i = 0; i < 15; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 + 2.0 * i), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 + (2.0 * i)), isNew: true);
}
Assert.True(indicator.IsHot);
@@ -189,7 +189,7 @@ public class TtmLrcTests
for (int i = 0; i < 15; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 + 5.0 * i), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 + (5.0 * i)), isNew: true);
}
Assert.True(indicator.Slope > 0, $"Slope should be positive for uptrend, got {indicator.Slope}");
@@ -203,7 +203,7 @@ public class TtmLrcTests
for (int i = 0; i < 15; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 - 3.0 * i), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 - (3.0 * i)), isNew: true);
}
Assert.True(indicator.Slope < 0, $"Slope should be negative for downtrend, got {indicator.Slope}");
@@ -236,7 +236,7 @@ public class TtmLrcTests
for (int i = 0; i < 15; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 + 2.0 * i), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 + (2.0 * i)), isNew: true);
}
Assert.True(Math.Abs(indicator.RSquared - 1.0) < 1e-9, $"R² should be 1.0 for perfect linear fit, got {indicator.RSquared}");
@@ -313,7 +313,7 @@ public class TtmLrcTests
for (int i = 0; i < 8; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 + i * 2), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 + (i * 2)), isNew: true);
}
double baseMid = indicator.Midline.Value;
@@ -321,11 +321,11 @@ public class TtmLrcTests
// Multiple corrections
for (int j = 0; j < 5; j++)
{
indicator.Update(new TValue(now.AddMinutes(7), 150 + j * 10), isNew: false);
indicator.Update(new TValue(now.AddMinutes(7), 150 + (j * 10)), isNew: false);
}
// Revert to original
indicator.Update(new TValue(now.AddMinutes(7), 100 + 7 * 2), isNew: false);
indicator.Update(new TValue(now.AddMinutes(7), 100 + (7 * 2)), isNew: false);
Assert.Equal(baseMid, indicator.Midline.Value, 10);
}
@@ -492,7 +492,7 @@ public class TtmLrcTests
for (int i = 0; i < 10; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 + i * 2), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 + (i * 2)), isNew: true);
}
Assert.True(indicator.IsHot);
@@ -546,7 +546,7 @@ public class TtmLrcTests
for (int i = 0; i < 15; i++)
{
times.Add(now.AddMinutes(i).Ticks);
values.Add(100 + i * 2);
values.Add(100 + (i * 2));
}
var source = new TSeries(times, values);
@@ -565,7 +565,7 @@ public class TtmLrcTests
for (int i = 0; i < 8; i++)
{
source.Add(new TValue(now.AddMinutes(i), 100 + i * 3), isNew: true);
source.Add(new TValue(now.AddMinutes(i), 100 + (i * 3)), isNew: true);
}
Assert.True(indicator.IsHot);
@@ -720,7 +720,7 @@ public class TtmLrcTests
for (int i = 0; i < 8; i++)
{
indicator.Update(new TValue(now.AddMinutes(i), 100 + i * 2), isNew: true);
indicator.Update(new TValue(now.AddMinutes(i), 100 + (i * 2)), isNew: true);
}
Assert.NotNull(lastPubValue);
@@ -74,8 +74,8 @@ public sealed class TtmLrcValidationTests : IDisposable
Assert.Equal(115.0 - expectedStdDev, ind.Lower1.Value, 1e-10);
// Verify ±2σ bands
Assert.Equal(115.0 + 2.0 * expectedStdDev, ind.Upper2.Value, 1e-10);
Assert.Equal(115.0 - 2.0 * expectedStdDev, ind.Lower2.Value, 1e-10);
Assert.Equal(115.0 + (2.0 * expectedStdDev), ind.Upper2.Value, 1e-10);
Assert.Equal(115.0 - (2.0 * expectedStdDev), ind.Lower2.Value, 1e-10);
_output.WriteLine("TtmLrc manual calculation validated");
}
@@ -89,7 +89,7 @@ public sealed class TtmLrcValidationTests : IDisposable
// Perfect linear trend: 100, 110, 120, 130, 140
for (int i = 0; i < 5; i++)
{
series.Add(new TValue(t0.AddMinutes(i), 100 + i * 10));
series.Add(new TValue(t0.AddMinutes(i), 100 + (i * 10)));
}
var ind = new TtmLrc(5);
@@ -362,7 +362,7 @@ public sealed class TtmLrcValidationTests : IDisposable
// Feed perfect linear data
for (int i = 0; i < 10; i++)
{
ind.Update(new TValue(t0.AddMinutes(i), 100 + i * 5));
ind.Update(new TValue(t0.AddMinutes(i), 100 + (i * 5)));
}
Assert.Equal(1.0, ind.RSquared, 1e-9);
@@ -481,7 +481,7 @@ public sealed class TtmLrcValidationTests : IDisposable
var t0 = DateTime.UtcNow;
for (int i = 0; i < 20; i++)
{
uptrend.Add(new TValue(t0.AddMinutes(i), 100 + i * 2 + (i % 3))); // Noisy uptrend
uptrend.Add(new TValue(t0.AddMinutes(i), 100 + (i * 2) + (i % 3))); // Noisy uptrend
}
var indUp = new TtmLrc(10);
@@ -495,7 +495,7 @@ public sealed class TtmLrcValidationTests : IDisposable
var downtrend = new TSeries();
for (int i = 0; i < 20; i++)
{
downtrend.Add(new TValue(t0.AddMinutes(i), 200 - i * 2 + (i % 3))); // Noisy downtrend
downtrend.Add(new TValue(t0.AddMinutes(i), 200 - (i * 2) + (i % 3))); // Noisy downtrend
}
var indDown = new TtmLrc(10);