mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 04:58:08 +00:00
- Implemented ChopIndicator for Quantower with configurable period and cold value display. - Created Chop class for calculating the Choppiness Index with detailed documentation. - Added comprehensive unit tests for Chop functionality, covering various market conditions and edge cases. - Developed markdown documentation for CHOP, detailing its historical context, mathematical foundation, and usage examples. - Established a remediation plan for channel indicators documentation, identifying gaps and prioritizing updates.
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System;
|
|
using QuanTAlib;
|
|
using Xunit;
|
|
|
|
namespace QuanTAlib.Tests.Cycles;
|
|
|
|
public class HtDcperiodTests
|
|
{
|
|
[Fact]
|
|
public void Constructor_SetsDefaults()
|
|
{
|
|
var ht = new HtDcperiod();
|
|
Assert.Equal("HtDcperiod", ht.Name);
|
|
Assert.Equal(32, ht.WarmupPeriod);
|
|
Assert.False(ht.IsHot);
|
|
}
|
|
|
|
[Fact]
|
|
public void Update_BecomesHotAfterWarmup()
|
|
{
|
|
var ht = new HtDcperiod();
|
|
var gbm = new GBM(seed: 42);
|
|
var bars = gbm.Fetch(80, DateTime.UtcNow.Ticks, TimeSpan.FromMinutes(1));
|
|
|
|
foreach (var bar in bars)
|
|
{
|
|
ht.Update(new TValue(bar.Time, bar.Close));
|
|
}
|
|
|
|
Assert.True(ht.IsHot);
|
|
Assert.True(double.IsFinite(ht.Last.Value));
|
|
}
|
|
|
|
[Fact]
|
|
public void Reset_ClearsState()
|
|
{
|
|
var ht = new HtDcperiod();
|
|
var now = DateTime.UtcNow;
|
|
for (int i = 0; i < 40; i++)
|
|
{
|
|
ht.Update(new TValue(now.AddMinutes(i), 100 + i));
|
|
}
|
|
|
|
Assert.True(ht.IsHot);
|
|
ht.Reset();
|
|
Assert.False(ht.IsHot);
|
|
Assert.Equal(default, ht.Last);
|
|
}
|
|
}
|