mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
[CodeFactor] Apply fixes to commit 03fb54b
This commit is contained in:
@@ -88,7 +88,7 @@ public class RsTests
|
|||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
double basePrice = 200.0 + i;
|
double basePrice = 200.0 + i;
|
||||||
double compPrice = 100.0 + i * 0.5;
|
double compPrice = 100.0 + (i * 0.5);
|
||||||
rs.Update(basePrice, compPrice);
|
rs.Update(basePrice, compPrice);
|
||||||
results.Add(rs.Last.Value);
|
results.Add(rs.Last.Value);
|
||||||
}
|
}
|
||||||
@@ -382,8 +382,8 @@ public class RsTests
|
|||||||
// Base grows faster than comparison
|
// Base grows faster than comparison
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
double basePrice = 100.0 + i * 2; // +2 per bar
|
double basePrice = 100.0 + (i * 2); // +2 per bar
|
||||||
double compPrice = 100.0 + i * 1; // +1 per bar
|
double compPrice = 100.0 + (i * 1); // +1 per bar
|
||||||
rs.Update(basePrice, compPrice);
|
rs.Update(basePrice, compPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,8 +399,8 @@ public class RsTests
|
|||||||
// Base grows slower than comparison
|
// Base grows slower than comparison
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
double basePrice = 100.0 + i * 1; // +1 per bar
|
double basePrice = 100.0 + (i * 1); // +1 per bar
|
||||||
double compPrice = 100.0 + i * 2; // +2 per bar
|
double compPrice = 100.0 + (i * 2); // +2 per bar
|
||||||
rs.Update(basePrice, compPrice);
|
rs.Update(basePrice, compPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,8 +416,8 @@ public class RsTests
|
|||||||
// Both grow at same rate
|
// Both grow at same rate
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
double basePrice = 100.0 + i * 2;
|
double basePrice = 100.0 + (i * 2);
|
||||||
double compPrice = 50.0 + i * 1;
|
double compPrice = 50.0 + (i * 1);
|
||||||
rs.Update(basePrice, compPrice);
|
rs.Update(basePrice, compPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,12 +150,12 @@ public sealed class SarBasicTests
|
|||||||
// Steady uptrend - SAR should trail below
|
// Steady uptrend - SAR should trail below
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
double price = 100.0 + i * 2;
|
double price = 100.0 + (i * 2);
|
||||||
_ = sar.Update(new TBar(DateTime.UtcNow.AddMinutes(i),
|
_ = sar.Update(new TBar(DateTime.UtcNow.AddMinutes(i),
|
||||||
price + 1, price - 1, price + 0.5, price, 1000));
|
price + 1, price - 1, price + 0.5, price, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
double lastClose = 100.0 + 19 * 2;
|
double lastClose = 100.0 + (19 * 2);
|
||||||
Assert.True(sar.SarValue < lastClose, "SAR should be below price in uptrend");
|
Assert.True(sar.SarValue < lastClose, "SAR should be below price in uptrend");
|
||||||
Assert.True(sar.IsLong, "Should be in long mode during uptrend");
|
Assert.True(sar.IsLong, "Should be in long mode during uptrend");
|
||||||
}
|
}
|
||||||
@@ -168,12 +168,12 @@ public sealed class SarBasicTests
|
|||||||
// Steady downtrend - SAR should trail above
|
// Steady downtrend - SAR should trail above
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
double price = 200.0 - i * 2;
|
double price = 200.0 - (i * 2);
|
||||||
_ = sar.Update(new TBar(DateTime.UtcNow.AddMinutes(i),
|
_ = sar.Update(new TBar(DateTime.UtcNow.AddMinutes(i),
|
||||||
price + 1, price - 1, price + 0.5, price, 1000));
|
price + 1, price - 1, price + 0.5, price, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
double lastClose = 200.0 - 19 * 2;
|
double lastClose = 200.0 - (19 * 2);
|
||||||
Assert.True(sar.SarValue > lastClose, "SAR should be above price in downtrend");
|
Assert.True(sar.SarValue > lastClose, "SAR should be above price in downtrend");
|
||||||
Assert.False(sar.IsLong, "Should be in short mode during downtrend");
|
Assert.False(sar.IsLong, "Should be in short mode during downtrend");
|
||||||
}
|
}
|
||||||
@@ -423,7 +423,7 @@ public sealed class SarConsistencyTests
|
|||||||
// Continue uptrend
|
// Continue uptrend
|
||||||
for (int i = 1; i <= 5; i++)
|
for (int i = 1; i <= 5; i++)
|
||||||
{
|
{
|
||||||
double price = 105 + i * 2;
|
double price = 105 + (i * 2);
|
||||||
_ = sar.Update(new TBar(dt.AddMinutes(i),
|
_ = sar.Update(new TBar(dt.AddMinutes(i),
|
||||||
price + 1, price - 1, price + 0.5, price, 1000), isNew: true);
|
price + 1, price - 1, price + 0.5, price, 1000), isNew: true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user