Files
QuanTAlib/Tests/test_updates_oscillators.cs
T

183 lines
4.2 KiB
C#
Raw Normal View History

2024-11-04 14:28:47 -08:00
using Xunit;
namespace QuanTAlib.Tests;
2024-11-07 09:55:19 -08:00
public class OscillatorsUpdateTests : UpdateTestBase
2024-11-04 14:28:47 -08:00
{
[Fact]
public void Rsi_Update()
{
var indicator = new Rsi(period: 14);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Rsx_Update()
{
var indicator = new Rsx(period: 14);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Cmo_Update()
{
var indicator = new Cmo(period: 14);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Ao_Update()
{
var indicator = new Ao();
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Ac_Update()
{
var indicator = new Ac();
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Aroon_Update()
{
var indicator = new Aroon(period: 25);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Bop_Update()
{
var indicator = new Bop();
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Cci_Update()
{
var indicator = new Cci(period: 20);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Cfo_Update()
{
var indicator = new Cfo(period: 14);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Chop_Update()
{
var indicator = new Chop(period: 14);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Cog_Update()
{
var indicator = new Cog(period: 10);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
}
2024-11-04 14:28:47 -08:00
2024-11-07 09:55:19 -08:00
[Fact]
public void Coppock_Update()
{
var indicator = new Coppock(roc1Period: 14, roc2Period: 11, wmaPeriod: 10);
TestTValueUpdate(indicator, indicator.Calc);
}
2024-11-04 14:28:47 -08:00
2024-11-07 09:55:19 -08:00
[Fact]
public void Crsi_Update()
{
var indicator = new Crsi(period1: 10, period2: 14, period3: 30);
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Smi_Update()
{
var indicator = new Smi(period: 10, smooth1: 3, smooth2: 3);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Srsi_Update()
{
var indicator = new Srsi(rsiPeriod: 14, stochPeriod: 14, smoothK: 3, smoothD: 3);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Stc_Update()
{
var indicator = new Stc(cyclePeriod: 10, fastPeriod: 23, slowPeriod: 50);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Stoch_Update()
{
var indicator = new Stoch(period: 14, smoothK: 3, smoothD: 3);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Tsi_Update()
{
var indicator = new Tsi(firstPeriod: 25, secondPeriod: 13);
2024-11-07 09:55:19 -08:00
TestTValueUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Uo_Update()
{
var indicator = new Uo(period1: 7, period2: 14, period3: 28);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Willr_Update()
{
var indicator = new Willr(period: 14);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Dosc_Update()
{
var indicator = new Dosc();
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
[Fact]
public void Efi_Update()
{
var indicator = new Efi(period: 13);
2024-11-07 09:55:19 -08:00
TestTBarUpdate(indicator, indicator.Calc);
2024-11-04 14:28:47 -08:00
}
2024-11-07 18:48:52 -08:00
[Fact]
public void Fisher_Update()
{
var indicator = new Fisher(period: 10);
double initialValue = indicator.Calc(new TValue(DateTime.Now, ReferenceValue, IsNew: true));
for (int i = 0; i < RandomUpdates; i++)
{
indicator.Calc(new TValue(DateTime.Now, GetRandomDouble(), IsNew: false));
}
double finalValue = indicator.Calc(new TValue(DateTime.Now, ReferenceValue, IsNew: false));
Assert.Equal(initialValue, finalValue, precision);
}
[Fact]
public void Cti_Update()
{
var indicator = new Cti(period: 20);
TestTValueUpdate(indicator, indicator.Calc);
}
2024-11-04 14:28:47 -08:00
}