summaryrefslogtreecommitdiffstats
path: root/test/disparity_index.c
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-07-01 09:42:39 +0400
committerEthan Werner <mail@ethanwerner.com>2026-07-01 09:42:39 +0400
commit07e18043145f3d91c8ea7ec3ad41b3c905585277 (patch)
tree2bdeae46973f4bdfce263679a4008ac768011f28 /test/disparity_index.c
initial commit: ts time series analysis library v0.1.0
- 354 financial and mathematical time-series indicators - Uniform C11 API with consistent function signatures - 349 passing tests with -Werror - Static and shared library builds - pkg-config integration - Python bindings - Fuzzing and sanitizer support - Security hardening flags
Diffstat (limited to 'test/disparity_index.c')
-rw-r--r--test/disparity_index.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/disparity_index.c b/test/disparity_index.c
new file mode 100644
index 0000000..1860f8f
--- /dev/null
+++ b/test/disparity_index.c
@@ -0,0 +1,27 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_disparity_index( void )
+{
+ fp_t const x0[] = { 10, 10, 10, 10, 15, 15, 15 };
+ fp_t const * const x[] = { x0 };
+
+ uint_t k = 3;
+
+ fp_t sma = (10 + 10 + 10) / 3.0;
+ fp_t e[5] = { 0 };
+ e[0] = (10 - sma) / sma * 100;
+ sma = sma + (10 - 10) / 3.0;
+ e[1] = (10 - sma) / sma * 100;
+ sma = sma + (15 - 10) / 3.0;
+ e[2] = (15 - sma) / sma * 100;
+ sma = sma + (15 - 10) / 3.0;
+ e[3] = (15 - sma) / sma * 100;
+ sma = sma + (15 - 10) / 3.0;
+ e[4] = (15 - sma) / sma * 100;
+
+ fp_t const * const exp[1] = { e };
+
+ return ts_test(ts_disparity_index, ts_disparity_index_offset, x, exp, sizeof( x0 ) / sizeof( *x0 ), (ts_constant_t *)&k, &ts_disparity_index_p);
+}