summaryrefslogtreecommitdiffstats
path: root/test/historical_volatility.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/historical_volatility.c')
-rw-r--r--test/historical_volatility.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/historical_volatility.c b/test/historical_volatility.c
new file mode 100644
index 0000000..1d57f54
--- /dev/null
+++ b/test/historical_volatility.c
@@ -0,0 +1,16 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_historical_volatility( void )
+{
+ fp_t const x[] = { 100, 101, 100, 102, 101, 100, 103, 101, 102, 100 };
+ fp_t const * const inp[1] = { x };
+
+ /* k=3, initial window at y[0][2], rolling windows at y[0][3..8] */
+ fp_t const e[] = { 0.196453, 0.222285, 0.222285, 0.295293, 0.337649, 0.320724, 0.221194, 0 };
+ fp_t const * const exp[1] = { e };
+
+ uint_t k = 3;
+ return ts_test(ts_historical_volatility, ts_historical_volatility_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&k, &ts_historical_volatility_p);
+}