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/synthetic_yield.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/synthetic_yield.c (limited to 'test/synthetic_yield.c') diff --git a/test/synthetic_yield.c b/test/synthetic_yield.c new file mode 100644 index 0000000..526b00f --- /dev/null +++ b/test/synthetic_yield.c @@ -0,0 +1,24 @@ +#include +#include +#include "ts.h" + +bool ts_test_synthetic_yield( void ) +{ + /* k=3, prices: 100, 101, 102, 104, 106, 108, 110, 112, 114, 116 */ + fp_t const x[] = { 100, 101, 102, 104, 106, 108, 110, 112, 114, 116 }; + + fp_t const * const inp[1] = { x }; + + /* i=3: (104-100)/100 * 252/3 * 100 = 336 */ + /* i=4: (106-101)/101 * 84 * 100 = 42000/101 = 415.84158... */ + /* i=5: (108-102)/102 * 84 * 100 = 50400/102 = 494.11765... */ + /* i=6: (110-104)/104 * 84 * 100 = 50400/104 = 484.61538... */ + /* i=7: (112-106)/106 * 84 * 100 = 50400/106 = 475.47170... */ + /* i=8: (114-108)/108 * 84 * 100 = 50400/108 = 466.66667... */ + /* i=9: (116-110)/110 * 84 * 100 = 50400/110 = 458.18182... */ + fp_t const e[] = { 336, 415.84158, 494.11765, 484.61538, 475.47170, 466.66667, 458.18182 }; + fp_t const * const exp[1] = { e }; + + uint_t k = 3; + return ts_test(ts_synthetic_yield, ts_synthetic_yield_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&k, &ts_synthetic_yield_p); +} -- cgit v1.3.1