mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-09 06:27:45 +00:00
3dd05f23e4
- Updated the name and description of the Hilbert Trendline (HTIT) to "Ehlers Hilbert Transform Instantaneous Trend (HTIT)". - Changed the name and description of the MESA Adaptive Moving Average (MAMA) to "Ehlers MESA Adaptive Moving Average". - Modified the Center of Gravity (CG) indicator to "Ehlers Center of Gravity (CG)". - Renamed the Detrended Synthetic Price (DSP) to "Ehlers Detrended Synthetic Price (DSP)". - Updated the Autocorrelation Periodogram (EACP) to "Ehlers Autocorrelation Periodogram (EACP)". - Changed the Homodyne Discriminator (HOMOD) to "Ehlers Homodyne Discriminator (HOMOD)". - Updated the Hilbert Transform Dominant Cycle Period and Phase indicators to include "Ehlers" in their names. - Renamed the Hilbert Transform Phasor Components to "Ehlers Hilbert Transform Phasor Components (HT_PHASOR)". - Updated the SineWave indicator to "Ehlers Hilbert Transform SineWave (HT_SINE)". - Changed the Phasor Analysis indicator to "Ehlers Hilbert Transform Phasor Components (HT_PHASOR)". - Updated the SSF-Based Detrended Synthetic Price to "Ehlers SSF Detrended Synthetic Price (SSFDSP)". - Renamed the Ultimate Channel to "Ehlers Ultimate Channel (UCHANNEL)". - Added new indicators: Moving Average Variable Period (MAVP), Ehlers Predictive Moving Average (PMA), Ehlers Reverse EMA (REVERSEEMA), and Ehlers Trendflex Indicator (TRENDFLEX). - Updated various SVG badges to reflect changes in classes, comments, source files, lines of code, methods, and public types.
121 lines
3.8 KiB
C#
121 lines
3.8 KiB
C#
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib.Quantower.Tests;
|
|
|
|
public class HtDcphaseIndicatorTests
|
|
{
|
|
[Fact]
|
|
public void HtDcphaseIndicator_Constructor_SetsDefaults()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
|
|
Assert.Equal(SourceType.Close, indicator.Source);
|
|
Assert.True(indicator.ShowColdValues);
|
|
Assert.Equal("HT_DCPHASE - Ehlers Hilbert Transform Dominant Cycle Phase", indicator.Name);
|
|
Assert.True(indicator.SeparateWindow);
|
|
Assert.True(indicator.OnBackGround);
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_MinHistoryDepths_EqualsLookback()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
|
|
Assert.Equal(63, HtDcphaseIndicator.MinHistoryDepths);
|
|
Assert.Equal(63, ((IWatchlistIndicator)indicator).MinHistoryDepths);
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_ShortName_IsFixed()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
Assert.Equal("HT_DCPHASE", indicator.ShortName);
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_Initialize_CreatesInternalHtDcphase()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
|
|
indicator.Initialize();
|
|
|
|
// 2 line series: DCPhase + Zero
|
|
Assert.Equal(2, indicator.LinesSeries.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_ProcessUpdate_HistoricalBar_ComputesValue()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
indicator.Initialize();
|
|
|
|
var now = DateTime.UtcNow;
|
|
indicator.HistoricalData.AddBar(now, 100, 105, 95, 102);
|
|
|
|
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
|
indicator.ProcessUpdate(args);
|
|
|
|
Assert.Equal(1, indicator.LinesSeries[0].Count);
|
|
Assert.True(double.IsFinite(indicator.LinesSeries[0].GetValue(0)));
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_ProcessUpdate_NewBar_ComputesValue()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
indicator.Initialize();
|
|
|
|
var now = DateTime.UtcNow;
|
|
indicator.HistoricalData.AddBar(now, 100, 105, 95, 102);
|
|
indicator.HistoricalData.AddBar(now.AddMinutes(1), 102, 108, 100, 106);
|
|
|
|
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
|
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.NewBar));
|
|
|
|
Assert.Equal(2, indicator.LinesSeries[0].Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_ProcessUpdate_NewTick_NoThrow()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
indicator.Initialize();
|
|
|
|
var now = DateTime.UtcNow;
|
|
indicator.HistoricalData.AddBar(now, 100, 105, 95, 102);
|
|
|
|
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
|
double first = indicator.LinesSeries[0].GetValue(0);
|
|
|
|
// simulate same-bar update should not advance or corrupt; value remains finite
|
|
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.NewTick));
|
|
double second = indicator.LinesSeries[0].GetValue(0);
|
|
|
|
Assert.True(double.IsFinite(first));
|
|
Assert.True(double.IsFinite(second));
|
|
Assert.Equal(first, second);
|
|
}
|
|
|
|
[Fact]
|
|
public void HtDcphaseIndicator_MultipleUpdates_ProducesSequence()
|
|
{
|
|
var indicator = new HtDcphaseIndicator();
|
|
indicator.Initialize();
|
|
|
|
var now = DateTime.UtcNow;
|
|
double[] closes = { 100, 102, 104, 103, 105, 106, 107, 108 };
|
|
|
|
foreach (var close in closes)
|
|
{
|
|
indicator.HistoricalData.AddBar(now, close, close + 2, close - 2, close);
|
|
indicator.ProcessUpdate(new UpdateArgs(UpdateReason.HistoricalBar));
|
|
now = now.AddMinutes(1);
|
|
}
|
|
|
|
for (int j = 0; j < indicator.LinesSeries[0].Count; j++)
|
|
{
|
|
Assert.True(double.IsFinite(indicator.LinesSeries[0].GetValue(j)));
|
|
}
|
|
}
|
|
}
|