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/price_rate_of_change.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/price_rate_of_change.c')
| -rw-r--r-- | test/price_rate_of_change.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/price_rate_of_change.c b/test/price_rate_of_change.c new file mode 100644 index 0000000..ec3eb9c --- /dev/null +++ b/test/price_rate_of_change.c @@ -0,0 +1,27 @@ +#include <math.h> +#include <stddef.h> +#include "ts.h" + +bool ts_test_price_rate_of_change( void ) +{ + fp_t const x[] = { 100, 110, 120, 130, 140, 150, 160, 170, 180, 190 }; + + fp_t const * const inp[1] = { x }; + + /* k=3 */ + /* PROC[3] = (130-100)/100*100 = 30 */ + /* PROC[4] = (140-110)/110*100 = 27.2727 */ + /* PROC[5] = (150-120)/120*100 = 25 */ + /* PROC[6] = (160-130)/130*100 = 23.0769 */ + /* PROC[7] = (170-140)/140*100 = 21.4286 */ + /* PROC[8] = (180-150)/150*100 = 20 */ + /* PROC[9] = (190-160)/160*100 = 18.75 */ + + fp_t e[] = { 30.0, 27.272727272727273, 25.0, 23.076923076923077, 21.428571428571427, 20.0, 18.75 }; + + fp_t const * const exp[1] = { e }; + + uint_t c_val = 3; + + return ts_test(ts_price_rate_of_change, ts_price_rate_of_change_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&c_val, &ts_price_rate_of_change_p); +} |