From e4efe6ec24832848efca2c6e9332cbb0df3992c5 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 6 Dec 2008 23:05:02 -0600 Subject: [PATCH] add finance words to math.finance --- extra/math/finance/finance-docs.factor | 41 ++++++++++++++++++++++++++ extra/math/finance/finance.factor | 11 +++++++ 2 files changed, 52 insertions(+) diff --git a/extra/math/finance/finance-docs.factor b/extra/math/finance/finance-docs.factor index 5024e83bff..97e44d2927 100644 --- a/extra/math/finance/finance-docs.factor +++ b/extra/math/finance/finance-docs.factor @@ -32,3 +32,44 @@ HELP: momentum { $list "MOM[t] = SEQ[t] - SEQ[t-n]" } } ; +HELP: biweekly +{ $values + { "x" number } + { "y" number } +} +{ $description "Divides a number by the number of two week periods in a year." } ; + +HELP: daily-360 +{ $values + { "x" number } + { "y" number } +} +{ $description "Divides a number by the number of days in a 360-day year." } ; + +HELP: daily-365 +{ $values + { "x" number } + { "y" number } +} +{ $description "Divides a number by the number of days in a 365-day year." } ; + +HELP: monthly +{ $values + { "x" number } + { "y" number } +} +{ $description "Divides a number by the number of months in a year." } ; + +HELP: semimonthly +{ $values + { "x" number } + { "y" number } +} +{ $description "Divides a number by the number of half-months in a year. Note that biweekly has two more periods than semimonthly." } ; + +HELP: weekly +{ $values + { "x" number } + { "y" number } +} +{ $description "Divides a number by the number of weeks in a year." } ; diff --git a/extra/math/finance/finance.factor b/extra/math/finance/finance.factor index e02f4be624..a1f2316c38 100644 --- a/extra/math/finance/finance.factor +++ b/extra/math/finance/finance.factor @@ -26,3 +26,14 @@ PRIVATE> : momentum ( seq n -- newseq ) [ tail-slice ] 2keep [ dup length ] dip - head-slice v- ; +: monthly ( x -- y ) 12 / ; inline + +: semimonthly ( x -- y ) 24 / ; inline + +: biweekly ( x -- y ) 26 / ; inline + +: weekly ( x -- y ) 52 / ; inline + +: daily-360 ( x -- y ) 360 / ; inline + +: daily-365 ( x -- y ) 365 / ; inline