diff --git a/extra/math/finance/finance-tests.factor b/extra/math/finance/finance-tests.factor index fc4ad0d07e..eb4b238f61 100644 --- a/extra/math/finance/finance-tests.factor +++ b/extra/math/finance/finance-tests.factor @@ -2,6 +2,8 @@ USING: kernel math math.functions math.finance tools.test ; IN: math.finance.tests +[ { 1 2 3 4 } ] [ { 1 2 3 4 5 } 1 ema ] unit-test + [ { 2 4 } ] [ { 1 3 5 } 2 sma ] unit-test [ { 1 3 1 } ] [ { 1 3 2 6 3 } 2 momentum ] unit-test diff --git a/extra/math/finance/finance.factor b/extra/math/finance/finance.factor index f1c608bad9..12f58c891b 100644 --- a/extra/math/finance/finance.factor +++ b/extra/math/finance/finance.factor @@ -15,7 +15,7 @@ IN: math.finance PRIVATE> : ema ( seq n -- newseq ) - a swap unclip [ [ dup ] 2dip spin weighted ] accumulate 2nip ; + a swap unclip [ swap pick weighted ] accumulate 2nip ; : sma ( seq n -- newseq ) clump [ mean ] map ;