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/coppock_curve.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/coppock_curve.c')
| -rw-r--r-- | test/coppock_curve.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/coppock_curve.c b/test/coppock_curve.c new file mode 100644 index 0000000..48239e4 --- /dev/null +++ b/test/coppock_curve.c @@ -0,0 +1,26 @@ +#include <math.h> +#include <stddef.h> +#include "ts.h" + +bool ts_test_coppock_curve( void ) +{ + fp_t const x[] = { 100, 105, 98, 110, 102, 115, 108, 120, 106, 112, 118, 99, 113, 107, 121, 114, 109, 116, 103, 111, 119, 104, 117, 108, 122, 110, 115, 107, 121, 105 }; + + fp_t const * const inp[1] = { x }; + + /* + * Coppock = expanding WMA(ROC(14) + ROC(11)), full WMA(10) from idx 9, + * then rolling WMA(10). ROC(k) = (x[i] - x[i-k]) / x[i-k] * 100. + * WMA weights: most recent value gets highest weight. + * Offset = 14, first output at index 14. + */ + fp_t const e[] = { + 31.00000000, 27.44537815, 23.27989457, 20.98845532, 17.79356430, + 15.48386172, 14.28049689, 12.48191637, 11.72007206, 10.86293252, + 6.25323376, 3.24940269, 2.78976008, 0.81656550, 3.89753260, + 4.22501503 + }; + fp_t const * const exp[1] = { e }; + + return ts_test(ts_coppock_curve, ts_coppock_curve_offset, inp, exp, 30, (ts_constant_t *)NULL, &ts_coppock_curve_p); +} |