Skip to content

Commit

Permalink
prep
Browse files Browse the repository at this point in the history
  • Loading branch information
mihakralj committed Nov 10, 2024
1 parent 770b1e0 commit 4286113
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 69 deletions.
6 changes: 0 additions & 6 deletions QuanTAlib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Momentum", "quantower\Momen
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiments", "quantower\Experiments\_Experiments.csproj", "{F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntheticVendor", "SyntheticVendor\SyntheticVendor.csproj", "{1CF111D9-33E6-4A11-8FEC-F23300A78D15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{2D97C971-20BF-40DB-94AA-3279F787D3CB}"
EndProject
Global
Expand Down Expand Up @@ -65,10 +63,6 @@ Global
{F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Release|Any CPU.Build.0 = Release|Any CPU
{1CF111D9-33E6-4A11-8FEC-F23300A78D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CF111D9-33E6-4A11-8FEC-F23300A78D15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CF111D9-33E6-4A11-8FEC-F23300A78D15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CF111D9-33E6-4A11-8FEC-F23300A78D15}.Release|Any CPU.Build.0 = Release|Any CPU
{2D97C971-20BF-40DB-94AA-3279F787D3CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D97C971-20BF-40DB-94AA-3279F787D3CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D97C971-20BF-40DB-94AA-3279F787D3CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
85 changes: 29 additions & 56 deletions Tests/test_eventing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,74 @@ public class EventingTests
private const int DefaultPeriod = 10;
private const double Tolerance = 1e-9;

private static readonly (string Name, object[] DirectParams, object[] EventParams)[] ValueIndicators = new[]
private static readonly (string Name, object[] DirectParams, object[] EventParams)[] ValueIndicators =
{
("Afirma", new object[] { DefaultPeriod, DefaultPeriod, Afirma.WindowType.BlackmanHarris }, new object[] { new TSeries(), DefaultPeriod, DefaultPeriod, Afirma.WindowType.BlackmanHarris }),
("Alma", new object[] { DefaultPeriod, 0.85, 6.0 }, new object[] { new TSeries(), DefaultPeriod, 0.85, 6.0 }),
("Beta", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Convolution", new object[] { new double[] {1,2,3,2,1} }, new object[] { new TSeries(), new double[] {1,2,3,2,1} }),
("Corr", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Covar", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Curvature", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Dema", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Dsma", new object[] { DefaultPeriod, 0.9 }, new object[] { new TSeries(), DefaultPeriod, 0.9 }),
("Dwma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Ema", new object[] { DefaultPeriod, true }, new object[] { new TSeries(), DefaultPeriod, true }),
("Entropy", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Epma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Pwma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Fisher", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Frama", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Fwma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Gma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Granger", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Hma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Htit", System.Array.Empty<object>(), new object[] { new TSeries() }),
("Htit", Array.Empty<object>(), new object[] { new TSeries() }),
("Hwma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Jma", new object[] { DefaultPeriod, 0, 0.45, 10 }, new object[] { new TSeries(), DefaultPeriod, 0, 0.45, 10 }),
("Kama", new object[] { DefaultPeriod, 2, 30 }, new object[] { new TSeries(), DefaultPeriod, 2, 30 }),
("Kendall", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Kurtosis", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Ltma", new object[] { 0.2 }, new object[] { new TSeries(), 0.2 }),
("Maaf", new object[] { 39, 0.002 }, new object[] { new TSeries(), 39, 0.002 }),
("Mama", new object[] { 0.5, 0.05 }, new object[] { new TSeries(), 0.5, 0.05 }),
("Max", new object[] { DefaultPeriod, 0.0 }, new object[] { new TSeries(), DefaultPeriod, 0.0 }),
("Median", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mgdi", new object[] { DefaultPeriod, 0.6 }, new object[] { new TSeries(), DefaultPeriod, 0.6 }),
("Min", new object[] { DefaultPeriod, 0.0 }, new object[] { new TSeries(), DefaultPeriod, 0.0 }),
("Mma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mode", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Percentile", new object[] { DefaultPeriod, 0.5 }, new object[] { new TSeries(), DefaultPeriod, 0.5 }),
("Pwma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Qema", new object[] { 0.2, 0.2, 0.2, 0.2 }, new object[] { new TSeries(), 0.2, 0.2, 0.2, 0.2 }),
("Rema", new object[] { DefaultPeriod, 0.5 }, new object[] { new TSeries(), DefaultPeriod, 0.5 }),
("Rma", new object[] { DefaultPeriod, true }, new object[] { new TSeries(), DefaultPeriod, true }),
("Skew", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Slope", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Sma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Wma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Tema", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Zlema", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Sinema", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Smma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Spearman", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Stddev", new object[] { DefaultPeriod, false }, new object[] { new TSeries(), DefaultPeriod, false }),
("T3", new object[] { DefaultPeriod, 0.7, true }, new object[] { new TSeries(), DefaultPeriod, 0.7, true }),
("Tema", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Trima", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Vidya", new object[] { DefaultPeriod, 0, 0.2 }, new object[] { new TSeries(), DefaultPeriod, 0, 0.2 }),
("Apo", new object[] { 12, 26 }, new object[] { new TSeries(), 12, 26 }),
("Macd", new object[] { 12, 26, 9 }, new object[] { new TSeries(), 12, 26, 9 }),
("Rsi", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Rsx", new object[] { DefaultPeriod, 0, 0.55 }, new object[] { new TSeries(), DefaultPeriod, 0, 0.55 }),
("Cmo", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Cog", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Curvature", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Entropy", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Kurtosis", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Max", new object[] { DefaultPeriod, 0.0 }, new object[] { new TSeries(), DefaultPeriod, 0.0 }),
("Median", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Min", new object[] { DefaultPeriod, 0.0 }, new object[] { new TSeries(), DefaultPeriod, 0.0 }),
("Mode", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Percentile", new object[] { DefaultPeriod, 0.5 }, new object[] { new TSeries(), DefaultPeriod, 0.5 }),
("Skew", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Slope", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Stddev", new object[] { DefaultPeriod, false }, new object[] { new TSeries(), DefaultPeriod, false }),
("Variance", new object[] { DefaultPeriod, false }, new object[] { new TSeries(), DefaultPeriod, false }),
("Zscore", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Beta", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Corr", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Covar", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Kendall", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Spearman", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Hv", new object[] { DefaultPeriod, false }, new object[] { new TSeries(), DefaultPeriod, false }),
("Jvolty", new object[] { DefaultPeriod, 0 }, new object[] { new TSeries(), DefaultPeriod, 0 }),
("Rv", new object[] { DefaultPeriod, false }, new object[] { new TSeries(), DefaultPeriod, false }),
("Rvi", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mae", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mapd", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mape", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mase", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mda", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Me", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mpe", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Mse", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Msle", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Rae", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Rmse", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Rmsle", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Rse", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Smape", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Rsquared", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Huber", new object[] { DefaultPeriod, 1.0 }, new object[] { new TSeries(), DefaultPeriod, 1.0 }),
("Cti", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod })
("Vidya", new object[] { DefaultPeriod, 0, 0.2 }, new object[] { new TSeries(), DefaultPeriod, 0, 0.2 }),
("Wma", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Zlema", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
("Zscore", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod })
};

private static readonly (string Name, object[] DirectParams, object[] EventParams)[] BarIndicators = new[]
private static readonly (string Name, object[] DirectParams, object[] EventParams)[] BarIndicators =
{
("Adl", System.Array.Empty<object>(), new object[] { new TBarSeries() }),
("Adl", Array.Empty<object>(), new object[] { new TBarSeries() }),
("Adosc", new object[] { 3, 10 }, new object[] { new TBarSeries(), 3, 10 }),
("Aobv", System.Array.Empty<object>(), new object[] { new TBarSeries() }),
("Aobv", Array.Empty<object>(), new object[] { new TBarSeries() }),
("Cmf", new object[] { 20 }, new object[] { new TBarSeries(), 20 }),
("Eom", new object[] { 14 }, new object[] { new TBarSeries(), 14 }),
("Kvo", new object[] { 34, 55 }, new object[] { new TBarSeries(), 34, 55 }),
("Atr", new object[] { 14 }, new object[] { new TBarSeries(), 14 }),
("Chop", new object[] { 14 }, new object[] { new TBarSeries(), 14 }),
("Dosc", System.Array.Empty<object>(), new object[] { new TBarSeries() })
("Dosc", Array.Empty<object>(), new object[] { new TBarSeries() })
};

public static IEnumerable<object[]> GetValueIndicatorData()
Expand Down
7 changes: 7 additions & 0 deletions Tests/test_updates_statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public void Entropy_Update()
TestTValueUpdate(indicator, indicator.Calc);
}

[Fact]
public void Granger_Update()
{
var indicator = new Granger(lags: 5);
TestDualTValueUpdate(indicator, indicator.Calc);
}

[Fact]
public void Hurst_Update()
{
Expand Down
8 changes: 4 additions & 4 deletions lib/_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
| Momentum | 17 | 0 | 17 |
| Oscillators| 24 | 5 | 29 |
| Patterns | 0 | 8 | 8 |
| Statistics | 21 | 2 | 23 |
| Statistics | 22 | 1 | 23 |
| Volatility | 31 | 4 | 35 |
| Total | 126 | 19 | 145 |
| Total | 127 | 18 | 145 |

## Indicators by Category

Expand Down Expand Up @@ -110,12 +110,13 @@ RPP - Rolling Pivot Points (Support 1-3, Pivot, Resistance 1-3)
WF - Williams Fractal
ZZ - Zig Zag Pattern

### Statistics (21/23)
### Statistics (22/23)
✔️ BETA - Beta coefficient measuring volatility relative to market
✔️ CORR - Correlation coefficient between two series
✔️ COVAR - Covariance between two series
✔️ CURVATURE - Curvature of a time series
✔️ ENTROPY - Information entropy of a series
✔️ GRANGER - Granger causality test
✔️ HURST - Hurst exponent for trend strength
✔️ KENDALL - Kendall rank correlation
✔️ KURTOSIS - Kurtosis measuring tail extremity
Expand All @@ -133,7 +134,6 @@ ZZ - Zig Zag Pattern
✔️ VARIANCE - Statistical variance
✔️ ZSCORE - Z-score standardization
COINTEGRATION - Test for cointegrated series
GRANGER - Granger causality test

### Volatility (31/35)
✔️ ADR - Average Daily Range
Expand Down
86 changes: 86 additions & 0 deletions lib/class_types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# QuanTAlib Class Types by Input Requirements

## Two TValues Required
- Huber
- Mae
- Mapd
- Mape
- Mase
- Mda
- Me
- Mpe
- Mse
- Msle
- Rae
- Rmse
- Rmsle
- Rse
- Rsquared
- Smape
- Beta (asset vs market returns)
- Corr (correlation between two series)
- Covar (covariance between two series)
- Granger (Granger causality test)
- Kendall (Kendall rank correlation)
- Spearman (Spearman rank correlation)
- Theil (Theil's U statistic)

## One TValue Required
- Curvature
- Entropy
- Hurst
- Kurtosis
- Max
- Median
- Min
- Mode
- Percentile
- Skew
- Slope
- Stddev
- Tsf
- Variance
- Zscore
- Apo
- Dpo
- Macd
- Mom
- Pmo
- Po
- Ppo
- Roc
- Trix
- Vel
- Ac
- Ao
- Bop
- Cci
- Cfo
- Chop
- Cmo
- Cog
- Coppock
- Crsi
- Cti
- Dosc
- Efi
- Fisher
- Rsi
- Rsx
- Smi
- Srsi
- Stc
- Stoch
- Tsi
- Uo
- Willr

## One TBar Required
- Aroon (uses high/low)
- Vortex (uses high/low/close)

## Two TBars Required
- Adx (requires two bars for true range calculation)
- Adxr (requires two bars for directional movement)
- Dmi (requires two bars for directional movement)
- Dmx (requires two bars for directional comparison)
Loading

0 comments on commit 4286113

Please sign in to comment.