From 07e18043145f3d91c8ea7ec3ad41b3c905585277 Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Wed, 1 Jul 2026 09:42:39 +0400 Subject: 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 --- test/disparity_index.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/disparity_index.c (limited to 'test/disparity_index.c') 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 +#include +#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); +} -- cgit v1.3.1