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/ichimoku.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/ichimoku.c (limited to 'test/ichimoku.c') diff --git a/test/ichimoku.c b/test/ichimoku.c new file mode 100644 index 0000000..ea20056 --- /dev/null +++ b/test/ichimoku.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include "ts.h" + +bool ts_test_ichimoku( void ) +{ + uint_t n = 55; + fp_t *o = malloc( n * sizeof( fp_t ) ); + fp_t *h = malloc( n * sizeof( fp_t ) ); + fp_t *l = malloc( n * sizeof( fp_t ) ); + fp_t *cl = malloc( n * sizeof( fp_t ) ); + + if ( !o || !h || !l || !cl ) + { + free( o ); free( h ); free( l ); free( cl ); + return false; + } + + for ( uint_t i = 0; i < n; ++i ) + { + o[i] = (fp_t)(100 + i); + h[i] = (fp_t)(102 + i); + l[i] = (fp_t)(98 + i); + cl[i] = (fp_t)(101 + i); + } + + fp_t const * const x[4] = { o, h, l, cl }; + + /* Fixed: include current bar in lookback, Senkou plotted 26 ahead, Chikou 26 behind */ + /* offset=52, y_n=55-52=3 */ + fp_t const et[] = { 148, 149, 150 }; + fp_t const ek[] = { 139.5, 140.5, 141.5 }; + fp_t const esa[] = { 117.75, 118.75, 119.75 }; + fp_t const esb[] = { 0, 0, 0 }; + fp_t const ec[] = { 127, 128, 129 }; + fp_t const * const exp[5] = { et, ek, esa, esb, ec }; + + ts_constant_t c; + memset(&c, 0, sizeof(c)); + bool result = ts_test(ts_ichimoku, ts_ichimoku_offset, x, exp, n, &c, &ts_ichimoku_p); + + free( o ); + free( h ); + free( l ); + free( cl ); + + return result; +} -- cgit v1.3.1