[ { 1 3 1 } ] [ { 1 3 2 6 3 } 2 momentum ] unit-test
+{ { 0.0 50.0 25.0 75.0 100.0 125.0 -50.0 -75.0 -90.0 } } [
+ { 1 1.5 1.25 1.75 2.0 2.25 0.5 0.25 0.1 } performance
+] unit-test
+
[ 4+1/6 ] [ 100 semimonthly ] unit-test
! Copyright (C) 2008 John Benediktsson, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs kernel grouping sequences shuffle
-math math.functions math.statistics math.vectors ;
+USING: fry grouping kernel math math.statistics math.vectors
+sequences ;
IN: math.finance
: sma ( seq n -- newseq )
: momentum ( seq n -- newseq )
[ tail-slice ] 2keep [ dup length ] dip - head-slice v- ;
+: performance ( seq -- newseq )
+ dup first '[ _ [ - ] [ /f ] bi 100 * ] map ;
+
: monthly ( x -- y ) 12 / ; inline
: semimonthly ( x -- y ) 24 / ; inline