[CodeFactor] Apply fixes to commit 4a01f03

This commit is contained in:
codefactor-io
2026-03-11 03:35:12 +00:00
parent 4a01f03cb4
commit 567fa89465
63 changed files with 293 additions and 302 deletions
+8 -8
View File
@@ -40,7 +40,7 @@ public class EacpValidationTests
// Generate sine wave with known period
for (int i = 0; i < 500; 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));
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -155,7 +155,7 @@ public class EacpValidationTests
// Generate sine wave
for (int i = 0; i < 300; 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));
eacpEnhanced.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
eacpNormal.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -293,7 +293,7 @@ public class EacpValidationTests
for (int i = 0; i < 200; i++)
{
double price = 0.0001 + 0.00001 * Math.Sin(2.0 * Math.PI * i / 20.0);
double price = 0.0001 + (0.00001 * Math.Sin(2.0 * Math.PI * i / 20.0));
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -308,7 +308,7 @@ public class EacpValidationTests
for (int i = 0; i < 200; i++)
{
double price = 1e10 + 1e9 * Math.Sin(2.0 * Math.PI * i / 20.0);
double price = 1e10 + (1e9 * Math.Sin(2.0 * Math.PI * i / 20.0));
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -360,7 +360,7 @@ public class EacpValidationTests
// Generate pure sine wave
for (int i = 0; i < 300; 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));
eacp.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price));
}
@@ -406,8 +406,8 @@ public class EacpValidationTests
// Generate two different sine waves
for (int i = 0; i < 500; i++)
{
double price1 = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / period1);
double price2 = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / period2);
double price1 = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / period1));
double price2 = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / period2));
eacp1.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price1));
eacp2.Update(new TValue(DateTime.UtcNow.AddSeconds(i), price2));
@@ -428,7 +428,7 @@ public class EacpValidationTests
for (int i = 0; i < 100; i++)
{
ind.Update(new TValue(t0.AddMinutes(i),
100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 20.0)), isNew: true);
100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 20.0))), isNew: true);
}
// Anchor bar
+8 -8
View File
@@ -191,10 +191,10 @@ public sealed class Eacp : AbstractBase
// High-pass filter: removes DC and low-frequency trend
double hp2 = s.Hp1;
double hp1 = s.Hp0;
double coef = (1.0 - _alphaHP / 2.0);
double hp0 = coef * coef * (price0 - 2.0 * price1 + price2)
+ 2.0 * (1.0 - _alphaHP) * hp1
- (1.0 - _alphaHP) * (1.0 - _alphaHP) * hp2;
double coef = (1.0 - (_alphaHP / 2.0));
double hp0 = (coef * coef * (price0 - (2.0 * price1) + price2))
+ (2.0 * (1.0 - _alphaHP) * hp1)
- ((1.0 - _alphaHP) * (1.0 - _alphaHP) * hp2);
// Super-smoother filter: removes high-frequency noise
double filt2 = s.Filt1;
@@ -290,12 +290,12 @@ public sealed class Eacp : AbstractBase
double corrVal = 0;
if (valid > 1)
{
double denomX = valid * sxx - sx * sx;
double denomY = valid * syy - sy * sy;
double denomX = (valid * sxx) - (sx * sx);
double denomY = (valid * syy) - (sy * sy);
double denom = denomX * denomY;
if (denom > 0)
{
corrVal = (valid * sxy - sx * sy) / Math.Sqrt(denom);
corrVal = ((valid * sxy) - (sx * sy)) / Math.Sqrt(denom);
}
}
@@ -319,7 +319,7 @@ public sealed class Eacp : AbstractBase
}
// Power = amplitude squared
double sq = cosAcc * cosAcc + sinAcc * sinAcc;
double sq = (cosAcc * cosAcc) + (sinAcc * sinAcc);
// Smooth the power spectrum (EMA-like smoothing)
// Power squared per Ehlers: emphasizes spectral peaks, suppresses noise