summaryrefslogtreecommitdiffstats
path: root/test/price_rate_of_change.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/price_rate_of_change.c')
-rw-r--r--test/price_rate_of_change.c27
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);
+}