mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 20:18:05 +00:00
[CodeFactor] Apply fixes to commit 0606491
This commit is contained in:
@@ -303,14 +303,14 @@ public class TtmTrendIndicatorTests
|
||||
// Feed historical bars
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 2, 110 + i * 2, 90 + i * 2, 105 + i * 2);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 2), 110 + (i * 2), 90 + (i * 2), 105 + (i * 2));
|
||||
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
||||
}
|
||||
|
||||
// Feed new bars
|
||||
for (int i = 5; i < 8; i++)
|
||||
{
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i * 2, 110 + i * 2, 90 + i * 2, 105 + i * 2);
|
||||
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + (i * 2), 110 + (i * 2), 90 + (i * 2), 105 + (i * 2));
|
||||
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.NewBar));
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TtmTrendBasicTests
|
||||
// EMA = alpha * value + (1 - alpha) * prevEMA
|
||||
// EMA = 0.2857 * 107 + 0.7143 * 100 = 30.57 + 71.43 = 102.0
|
||||
double alpha = 2.0 / 7.0;
|
||||
double expected = alpha * 107.0 + (1 - alpha) * 100.0;
|
||||
double expected = (alpha * 107.0) + ((1 - alpha) * 100.0);
|
||||
Assert.Equal(expected, result.Value, 10);
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public class TtmTrendBarCorrectionTests
|
||||
|
||||
// Should use 105 instead of 110
|
||||
double alpha = 2.0 / 7.0;
|
||||
double expected = alpha * 105.0 + (1 - alpha) * 100.0;
|
||||
double expected = (alpha * 105.0) + ((1 - alpha) * 100.0);
|
||||
Assert.Equal(expected, corrected.Value, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TtmTrendValidationTests
|
||||
// Feed enough bars to warm up, then inject consistently rising prices
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
double price = basePrice + i * 2.0;
|
||||
double price = basePrice + (i * 2.0);
|
||||
var bar = new TBar(
|
||||
DateTime.UtcNow.AddMinutes(i),
|
||||
price - 0.5, price + 0.5, price - 0.5, price, 1000);
|
||||
@@ -84,7 +84,7 @@ public class TtmTrendValidationTests
|
||||
// Feed enough bars to warm up, then inject consistently falling prices
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
double price = basePrice - i * 2.0;
|
||||
double price = basePrice - (i * 2.0);
|
||||
var bar = new TBar(
|
||||
DateTime.UtcNow.AddMinutes(i),
|
||||
price + 0.5, price + 0.5, price - 0.5, price, 1000);
|
||||
|
||||
Reference in New Issue
Block a user