validation and profiles

This commit is contained in:
Miha Kralj
2026-02-26 22:02:52 -08:00
parent 9ab37c1200
commit 8a1ba95173
317 changed files with 18704 additions and 622 deletions
@@ -1,3 +1,6 @@
using OoplesFinance.StockIndicators;
using OoplesFinance.StockIndicators.Models;
// PIVOTDEM Validation Tests - DeMark Pivot Points
// Self-consistency validation across all API modes.
//
@@ -238,4 +241,24 @@ public sealed class PivotdemValidationTests
}
}
}
}
[Fact(Skip = "Ooples pivot indicators group by calendar day — 500×1-min bars yields ~3 daily pivots. Requires daily OHLCV input; not comparable with intraday GBM data.")]
public void Pivotdem_MatchesOoples_Structural()
{
var gbm = new GBM(startPrice: 100.0, mu: 0.02, sigma: 0.15, seed: 42);
var bars = gbm.Fetch(500, DateTime.UtcNow.Ticks, TimeSpan.FromMinutes(1));
var ooplesData = bars.Select(b => new TickerData
{
Date = new DateTime(b.Time, DateTimeKind.Utc),
Open = b.Open,
High = b.High,
Low = b.Low,
Close = b.Close,
Volume = b.Volume
}).ToList();
var result = new StockData(ooplesData).CalculateDemarkPivotPoints();
var values = result.OutputValues.Values.First();
int finiteCount = values.Count(v => double.IsFinite(v));
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
}
}
+15
View File
@@ -96,6 +96,21 @@ This means R1 and S1 are always equidistant from PP, separated by one-quarter of
## Performance Profile
### Operation Count (Streaming Mode)
DeMark Pivot uses a conditional pivot formula based on whether Open == Close vs C vs O > C — O(1).
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Store prev OHLC | 4 | 1 cy | ~4 cy |
| Conditional X formula (3-way branch) | 1 | 4 cy | ~4 cy |
| PP = X / 4 | 1 | 2 cy | ~2 cy |
| R1 = X/2 - L, S1 = X/2 - H | 2 | 2 cy | ~4 cy |
| NaN guard + state update | 1 | 2 cy | ~2 cy |
| **Total** | **O(1)** | — | **~16 cy** |
O(1) arithmetic with one 3-way conditional on price relationship. Branch predictor will learn the dominant market regime quickly.
### Implementation Design
Pure arithmetic with no loops, no buffers, no auxiliary data structures. Each `Update` call performs one conditional branch, 3 multiplications, 3 additions/subtractions, and 4 comparisons for NaN validation.