[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
@@ -56,7 +56,7 @@ public class YzvIndicatorTests
for (int i = 0; i < 50; i++)
{
// Create price movement that generates volatility
double basePrice = 100 + Math.Sin(i * 0.3) * (5 + i * 0.1);
double basePrice = 100 + (Math.Sin(i * 0.3) * (5 + (i * 0.1)));
indicator.HistoricalData.AddBar(now.AddMinutes(i), basePrice, basePrice + 2, basePrice - 2, basePrice, 1000);
// Process update for each bar to simulate history loading
@@ -106,7 +106,7 @@ public class YzvIndicatorTests
for (int i = 0; i < 60; i++)
{
// Create price movement with varying amplitude
double basePrice = 100 + Math.Sin(i * 0.2) * 5;
double basePrice = 100 + (Math.Sin(i * 0.2) * 5);
indicator.HistoricalData.AddBar(now.AddMinutes(i), basePrice, basePrice + 2, basePrice - 2, basePrice, 1000);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -204,10 +204,10 @@ public class YzvIndicatorTests
// Price with varying OHLC
for (int i = 0; i < 20; i++)
{
double open = 100 + Math.Sin(i * 0.3) * 3;
double open = 100 + (Math.Sin(i * 0.3) * 3);
double high = open + 2 + Math.Abs(Math.Sin(i * 0.5));
double low = open - 2 - Math.Abs(Math.Cos(i * 0.5));
double close = open + Math.Sin(i * 0.4) * 2;
double close = open + (Math.Sin(i * 0.4) * 2);
indicator.HistoricalData.AddBar(now.AddMinutes(i), open, high, low, close, 1000);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -232,7 +232,7 @@ public class YzvIndicatorTests
for (int i = 0; i < 60; i++)
{
double price = 100 + Math.Sin(i * 0.3) * 5;
double price = 100 + (Math.Sin(i * 0.3) * 5);
indicator1.HistoricalData.AddBar(now.AddMinutes(i), price, price + 2, price - 2, price, 1000);
indicator2.HistoricalData.AddBar(now.AddMinutes(i), price, price + 2, price - 2, price, 1000);
indicator1.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
@@ -292,7 +292,7 @@ public class YzvIndicatorTests
// Large gap up (open much higher than previous close)
for (int i = 10; i < 20; i++)
{
double open = 120 + (i - 10) * 2; // Large gaps
double open = 120 + ((i - 10) * 2); // Large gaps
indicator.HistoricalData.AddBar(now.AddMinutes(i), open, open + 2, open - 2, open + 1, 1000);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -316,7 +316,7 @@ public class YzvIndicatorTests
// Low volatility regime
for (int i = 0; i < 20; i++)
{
double price = 100 + Math.Sin(i * 0.5) * 0.5; // Small movements
double price = 100 + (Math.Sin(i * 0.5) * 0.5); // Small movements
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 0.2, price - 0.2, price, 1000);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
@@ -326,7 +326,7 @@ public class YzvIndicatorTests
// High volatility regime
for (int i = 20; i < 40; i++)
{
double price = 100 + Math.Sin(i * 0.5) * 10; // Large movements
double price = 100 + (Math.Sin(i * 0.5) * 10); // Large movements
indicator.HistoricalData.AddBar(now.AddMinutes(i), price, price + 5, price - 5, price, 1000);
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
}
+2 -2
View File
@@ -112,14 +112,14 @@ public class YzvTests
// Low volatility: small H-L range
for (int i = 0; i < 30; i++)
{
double price = 100.0 + (i % 2) * 0.1;
double price = 100.0 + ((i % 2) * 0.1);
yzvLow.Update(new TBar(DateTime.UtcNow, price, price + 0.05, price - 0.05, price, 1000));
}
// High volatility: large H-L range
for (int i = 0; i < 30; i++)
{
double price = 100.0 + (i % 2) * 5.0;
double price = 100.0 + ((i % 2) * 5.0);
yzvHigh.Update(new TBar(DateTime.UtcNow, price, price + 5.0, price - 5.0, price + 2.0, 1000));
}
@@ -41,12 +41,12 @@ public class YzvValidationTests
double sOSq = ro * ro;
double sCSq = rc * rc;
double sRsSq = rh * (rh - rc) + rl * (rl - rc);
double sRsSq = (rh * (rh - rc)) + (rl * (rl - rc));
double ratioN = (double)(period + 1) / (period - 1);
double kYz = 0.34 / (1.34 + ratioN);
double sSqDaily = sOSq + kYz * sCSq + (1.0 - kYz) * sRsSq;
double sSqDaily = sOSq + (kYz * sCSq) + ((1.0 - kYz) * sRsSq);
// First bar: RMA = value, eComp = 1 - alpha
double alpha = 1.0 / period;
@@ -85,7 +85,7 @@ public class YzvValidationTests
double ratioN = (double)(period + 1) / (period - 1);
double kYz = 0.34 / (1.34 + ratioN);
double expectedK = 0.34 / (1.34 + 21.0 / 19.0);
double expectedK = 0.34 / (1.34 + (21.0 / 19.0));
Assert.Equal(expectedK, kYz, 10);
// Verify k is in reasonable range (0 < k < 0.5)
@@ -103,7 +103,7 @@ public class YzvValidationTests
double rh = Math.Log(high / open);
double rl = Math.Log(low / open);
double sRsSq = rh * (rh - rc) + rl * (rl - rc);
double sRsSq = (rh * (rh - rc)) + (rl * (rl - rc));
// Verify this is positive for typical bar
Assert.True(sRsSq >= 0, "Rogers-Satchell should be non-negative for valid OHLC");
@@ -225,8 +225,8 @@ public class YzvValidationTests
double moveSmall = 1.0;
double moveLarge = 10.0;
yzvSmall.Update(new TBar(DateTime.UtcNow, baseSmall, baseSmall + moveSmall, baseSmall - moveSmall, baseSmall + (i % 2) * moveSmall, 1000));
yzvLarge.Update(new TBar(DateTime.UtcNow, baseLarge, baseLarge + moveLarge, baseLarge - moveLarge, baseLarge + (i % 2) * moveLarge, 1000));
yzvSmall.Update(new TBar(DateTime.UtcNow, baseSmall, baseSmall + moveSmall, baseSmall - moveSmall, baseSmall + ((i % 2) * moveSmall), 1000));
yzvLarge.Update(new TBar(DateTime.UtcNow, baseLarge, baseLarge + moveLarge, baseLarge - moveLarge, baseLarge + ((i % 2) * moveLarge), 1000));
}
// Larger moves should produce larger YZV (roughly 10x)
@@ -272,7 +272,7 @@ public class YzvValidationTests
// No gap scenario
for (int i = 0; i < 30; i++)
{
double close = 100 + i * 0.1;
double close = 100 + (i * 0.1);
yzvNoGap.Update(new TBar(DateTime.UtcNow, close, close + 1, close - 1, close, 1000));
}
@@ -297,7 +297,7 @@ public class YzvValidationTests
// No gap scenario
for (int i = 0; i < 30; i++)
{
double close = 100 - i * 0.1;
double close = 100 - (i * 0.1);
yzvNoGap.Update(new TBar(DateTime.UtcNow, close, close + 1, close - 1, close, 1000));
}