mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-26 06:18:05 +00:00
Refactor code formatting and improve consistency across various test files
- Removed unnecessary blank lines in multiple test files to enhance readability. - Ensured consistent spacing and formatting in the `Trima`, `Usf`, `Vidya`, `Wma`, and `Atr` test classes. - Updated comments for clarity and consistency in the `Atr` and `Adl` classes. - Adjusted project files for better structure and maintainability.
This commit is contained in:
@@ -61,7 +61,7 @@ public class JmaIndicator : Indicator, IWatchlistIndicator
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
var item = HistoricalData[Count - 1, SeekOriginHistory.Begin];
|
||||
|
||||
|
||||
TValue result = ma!.Update(new TValue(item.TimeLeft.Ticks, _priceSelector!(item)), isNew: args.IsNewBar());
|
||||
|
||||
Series!.SetValue(result.Value, ma.IsHot, ShowColdValues);
|
||||
|
||||
@@ -183,7 +183,7 @@ public class JmaTests
|
||||
var gbm = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 123);
|
||||
var bars = gbm.Fetch(1000, DateTime.UtcNow.Ticks, TimeSpan.FromMinutes(1));
|
||||
var series = bars.Close;
|
||||
|
||||
|
||||
// 1. Batch Mode
|
||||
var batchSeries = Jma.Batch(series, period);
|
||||
double expected = batchSeries.Last.Value;
|
||||
|
||||
@@ -10,10 +10,10 @@ public class JmaValidationTests
|
||||
{
|
||||
// JMA should generally follow the price.
|
||||
// If price goes up, JMA should eventually go up.
|
||||
|
||||
|
||||
var jma = new Jma(10);
|
||||
double previousJma = 0;
|
||||
|
||||
|
||||
// Uptrend
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
@@ -32,15 +32,15 @@ public class JmaValidationTests
|
||||
// JMA should stay within the range of recent prices (roughly)
|
||||
// It's a moving average, so it shouldn't overshoot wildly unless phase is negative and high volatility?
|
||||
// With default phase 0, it should be well behaved.
|
||||
|
||||
|
||||
var jma = new Jma(10);
|
||||
var gbm = new GBM(startPrice: 100, mu: 0, sigma: 0.5);
|
||||
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var bar = gbm.Next(isNew: true);
|
||||
var result = jma.Update(new TValue(bar.Time, bar.Close));
|
||||
|
||||
|
||||
if (i > 20)
|
||||
{
|
||||
// Update bounds of recent price history (simplified)
|
||||
|
||||
@@ -31,11 +31,11 @@ public class JmaZeroDivTests
|
||||
// Since we can't easily access private fields, we'll rely on the calculation logic check
|
||||
// If the fix is applied, we shouldn't see -Infinity in internal calculations if we could see them.
|
||||
// But we can check if the output is exactly the input, which implies adapt=0 (if logic holds).
|
||||
|
||||
|
||||
var jma = new Jma(period: 1);
|
||||
var result = jma.Update(new TValue(DateTime.UtcNow, 100));
|
||||
Assert.Equal(100, result.Value);
|
||||
|
||||
|
||||
result = jma.Update(new TValue(DateTime.UtcNow, 200));
|
||||
// If adapt is 0 (due to -Infinity log), bands snap to price.
|
||||
// If JMA(1) is identity, result should be 200.
|
||||
|
||||
Reference in New Issue
Block a user