diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2026-07-01 09:42:39 +0400 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-07-01 09:42:39 +0400 |
| commit | 07e18043145f3d91c8ea7ec3ad41b3c905585277 (patch) | |
| tree | 2bdeae46973f4bdfce263679a4008ac768011f28 /test/ichimoku.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/ichimoku.c')
| -rw-r--r-- | test/ichimoku.c | 49 |
1 files changed, 49 insertions, 0 deletions
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 <math.h> +#include <stddef.h> +#include <stdlib.h> +#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; +} |