Files
QuanTAlib/lib/volume/efi/Efi.Validation.Tests.cs
T
Miha Kralj c7e55c2f1e Add Intraday Intensity Index (III) implementation and tests
- Implemented the III indicator in Iii.Quantower.cs, measuring buying/selling pressure based on close price within the day's range, weighted by volume.
- Added unit tests for III functionality in Iii.Tests.cs, covering various scenarios including default parameters, updates, and cumulative mode.
- Created validation tests in Iii.Validation.Tests.cs to ensure consistency between streaming, batch, and span calculations.
- Developed comprehensive documentation for III in Iii.md, detailing its historical context, mathematical foundation, and common pitfalls.
2026-01-28 08:56:41 -08:00

86 lines
2.4 KiB
C#

using Skender.Stock.Indicators;
using OoplesFinance.StockIndicators;
using OoplesFinance.StockIndicators.Models;
namespace QuanTAlib.Tests;
public class EfiValidationTests
{
private readonly ValidationTestData _data;
private const int DefaultPeriod = 13;
public EfiValidationTests()
{
_data = new ValidationTestData();
}
[Fact]
public void Efi_Matches_Skender()
{
// Note: Skender's ElderRay is different from Force Index
// Skender does not have a direct Force Index implementation
// Skip this test
Assert.True(true, "Skender does not have a direct Force Index implementation");
}
[Fact]
public void Efi_Matches_Talib()
{
// TA-Lib does not have EFI/Force Index
Assert.True(true, "TA-Lib does not have a Force Index implementation");
}
[Fact]
public void Efi_Matches_Tulip()
{
// Tulip does not have Force Index
Assert.True(true, "Tulip does not have a Force Index implementation");
}
[Fact]
public void Efi_Matches_Ooples()
{
// Ooples does not have CalculateElderForceIndex method
// Skip this test
Assert.True(true, "Ooples does not have a Force Index implementation");
}
[Fact]
public void Efi_Streaming_Matches_Batch()
{
// Streaming
var efi = new Efi(DefaultPeriod);
var streamingValues = new List<double>();
foreach (var bar in _data.Bars)
{
streamingValues.Add(efi.Update(bar).Value);
}
// Batch
var batchResult = Efi.Calculate(_data.Bars, DefaultPeriod);
var batchValues = batchResult.Values.ToArray();
ValidationHelper.VerifyData(streamingValues.ToArray(), batchValues, 0, 100, 1e-12);
}
[Fact]
public void Efi_Span_Matches_Streaming()
{
// Streaming
var efi = new Efi(DefaultPeriod);
var streamingValues = new List<double>();
foreach (var bar in _data.Bars)
{
streamingValues.Add(efi.Update(bar).Value);
}
// Span
var close = _data.Bars.Close.Values.ToArray();
var volume = _data.Bars.Volume.Values.ToArray();
var spanValues = new double[close.Length];
Efi.Calculate(close, volume, spanValues, DefaultPeriod);
ValidationHelper.VerifyData(streamingValues.ToArray(), spanValues, 0, 100, 1e-12);
}
}