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/fill_indicator.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/fill_indicator.c (limited to 'test/fill_indicator.c') diff --git a/test/fill_indicator.c b/test/fill_indicator.c new file mode 100644 index 0000000..071c245 --- /dev/null +++ b/test/fill_indicator.c @@ -0,0 +1,40 @@ +#include +#include +#include "ts.h" + +bool ts_test_fill_indicator( void ) +{ + uint_t k = 3; + + fp_t const o[] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; + fp_t const h[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }; + fp_t const l[] = { 8, 10, 10, 11, 12, 13, 14, 15, 16, 17 }; + fp_t const c[] = { 11, 12, 10, 14, 15, 16, 14, 18, 17, 20 }; + + fp_t const * const x[] = { o, h, l, c }; + + /* fill values: + * i=0: |11-10|/(12-8)*100 = 1/4*100 = 25 + * i=1: |12-11|/(13-10)*100 = 1/3*100 = 33.333 + * i=2: |10-12|/(14-10)*100 = 2/4*100 = 50 + * i=3: |14-13|/(15-11)*100 = 1/4*100 = 25 + * i=4: |15-14|/(16-12)*100 = 1/4*100 = 25 + * i=5: |16-15|/(17-13)*100 = 1/4*100 = 25 + * i=6: |14-16|/(18-14)*100 = 2/4*100 = 50 + * i=7: |18-17|/(19-15)*100 = 1/4*100 = 25 + * i=8: |17-18|/(20-16)*100 = 1/4*100 = 25 + * i=9: |20-19|/(21-17)*100 = 1/4*100 = 25 + * SMA(3): i=2: (25+33.333+50)/3 = 36.111 + * i=3: 36.111 + (25-25)/3 = 36.111 + * i=4: 36.111 + (25-33.333)/3 = 33.333 + * i=5: 33.333 + (25-50)/3 = 25 + * i=6: 25 + (50-25)/3 = 33.333 + * i=7: 33.333 + (25-25)/3 = 33.333 + * i=8: 33.333 + (25-25)/3 = 33.333 + * i=9: 33.333 + (25-50)/3 = 25 + */ + fp_t const e[] = { 36.11111, 36.11111, 33.33333, 25, 33.33333, 33.33333, 33.33333, 25 }; + fp_t const * const exp[1] = { e }; + + return ts_test(ts_fill_indicator, ts_fill_indicator_offset, x, exp, sizeof( o ) / sizeof( *o ), (ts_constant_t *)&k, &ts_fill_indicator_p); +} -- cgit v1.3.1