mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 13:08:04 +00:00
validation and profiles
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
|
||||
using OoplesFinance.StockIndicators;
|
||||
using OoplesFinance.StockIndicators.Models;
|
||||
// PIVOT Validation Tests - Classic Pivot Points (Floor Trader Pivots)
|
||||
// Self-consistency validation across all API modes.
|
||||
//
|
||||
@@ -257,4 +260,24 @@ public sealed class PivotValidationTests
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[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 Pivot_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).CalculateStandardPivotPoints();
|
||||
var values = result.OutputValues.Values.First();
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,24 @@ R2/S2 add the full range to/from PP. R3/S3 extend beyond the previous extremes b
|
||||
|
||||
## Performance Profile
|
||||
|
||||
### Operation Count (Streaming Mode)
|
||||
|
||||
Classic Pivot Points compute PP and 6 support/resistance levels from previous bar HLC — O(1).
|
||||
|
||||
| Operation | Count | Cost (cycles) | Subtotal |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Store prev HLC | 3 | 1 cy | ~3 cy |
|
||||
| PP = (H + L + C) / 3 | 1 | 2 cy | ~2 cy |
|
||||
| R1 = 2*PP - L | 1 | 2 cy | ~2 cy |
|
||||
| S1 = 2*PP - H | 1 | 2 cy | ~2 cy |
|
||||
| R2 = PP + (H - L) | 1 | 2 cy | ~2 cy |
|
||||
| S2 = PP - (H - L) | 1 | 2 cy | ~2 cy |
|
||||
| R3/S3 extensions | 2 | 2 cy | ~4 cy |
|
||||
| NaN guard + state update | 1 | 2 cy | ~2 cy |
|
||||
| **Total** | **O(1)** | — | **~19 cy** |
|
||||
|
||||
Cheapest O(1) pivot variant — pure previous-bar arithmetic, no smoothing, no buffers beyond a 1-bar state.
|
||||
|
||||
### Implementation Design
|
||||
|
||||
Pure arithmetic with no loops, no buffers, no auxiliary data structures. Each `Update` call performs 3 divisions (via the single division in PP), 6 multiplications/additions, and 3 comparisons for NaN validation.
|
||||
|
||||
Reference in New Issue
Block a user