diff options
author | Eduardo Julian | 2022-12-12 03:47:35 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-12-12 03:47:35 -0400 |
commit | fe9a58dfcd5732ef0c5e5c4b7e85370cdc0db45a (patch) | |
tree | 5ad844ea2bdf33a67cceaad437efaf82cf773a02 /stdlib/source/test/lux/world/money.lux | |
parent | eef4422b1f16be2b8c651461f2c006dc4c11f314 (diff) |
Added trade session (OHLCV) abstraction.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/world/finance/money.lux (renamed from stdlib/source/test/lux/world/money.lux) | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/stdlib/source/test/lux/world/money.lux b/stdlib/source/test/lux/world/finance/money.lux index 4cddc38ee..773589a15 100644 --- a/stdlib/source/test/lux/world/money.lux +++ b/stdlib/source/test/lux/world/finance/money.lux @@ -13,48 +13,46 @@ ["[0]" text (.only) ["%" \\format]]] [math - ["[0]" random (.only Random)] + ["[0]" random (.only Random) (.use "[1]#[0]" functor)] [number ["n" nat]]] [test ["_" property (.only Test)]]]] [\\library ["[0]" / (.only) - ["[0]" currency]]] + ["[0]" currency (.only Currency)]]] ["[0]" / ["[1][0]" currency]]) -(def .public random - (Random (Ex (_ of) - (/.Money of))) - (do random.monad - [expected_currency /currency.random - expected_amount random.nat] - (in (/.money expected_currency expected_amount)))) +(def .public (random $) + (All (_ $) + (-> (Currency $) + (Random (/.Money $)))) + (random#each (/.money $) + random.nat)) (def .public test Test (<| (_.covering /._) (do [! random.monad] - [.let [expected_currency currency.usd] - expected_amount random.nat + [expected_amount random.nat expected_parameter (random.only (n.> 0) random.nat) expected_subject random.nat]) (_.for [/.Money]) (all _.and (_.for [/.equivalence /.=] - (equivalenceS.spec /.equivalence ..random)) + (equivalenceS.spec /.equivalence (..random currency.usd))) (_.for [/.order /.<] - (orderS.spec /.order ..random)) + (orderS.spec /.order (..random currency.usd))) (_.coverage [/.money /.currency /.amount] - (let [it (/.money expected_currency expected_amount)] - (and (same? expected_currency (/.currency it)) + (let [it (/.money currency.usd expected_amount)] + (and (same? currency.usd (/.currency it)) (same? expected_amount (/.amount it))))) (_.coverage [/.+ /.-] - (let [parameter (/.money expected_currency expected_parameter) - subject (/.money expected_currency expected_subject)] + (let [parameter (/.money currency.usd expected_parameter) + subject (/.money currency.usd expected_subject)] (and (|> subject (/.+ parameter) (of /.equivalence = subject) @@ -65,21 +63,21 @@ (maybe#each (of /.equivalence = subject)) (maybe.else false))))) (_.coverage [/.min] - (let [expected_parameter (/.money expected_currency expected_parameter) - expected_subject (/.money expected_currency expected_subject)] + (let [expected_parameter (/.money currency.usd expected_parameter) + expected_subject (/.money currency.usd expected_subject)] (and (/.<= expected_parameter (/.min expected_parameter expected_subject)) (/.<= expected_subject (/.min expected_parameter expected_subject))))) (_.coverage [/.max] - (let [expected_parameter (/.money expected_currency expected_parameter) - expected_subject (/.money expected_currency expected_subject)] + (let [expected_parameter (/.money currency.usd expected_parameter) + expected_subject (/.money currency.usd expected_subject)] (and (/.>= expected_parameter (/.max expected_parameter expected_subject)) (/.>= expected_subject (/.max expected_parameter expected_subject))))) - (let [expected_parameter (/.money expected_currency expected_parameter) - expected_subject (/.money expected_currency expected_subject)] + (let [expected_parameter (/.money currency.usd expected_parameter) + expected_subject (/.money currency.usd expected_subject)] (all _.and (_.coverage [/.>] (bit#= (/.> expected_parameter expected_subject) @@ -89,17 +87,17 @@ (/.>= expected_subject expected_parameter))) )) (_.coverage [/.units /.sub_units] - (let [expected (/.money expected_currency expected_amount) - actual (/.money expected_currency (n.+ (/.units expected) - (/.sub_units expected)))] + (let [expected (/.money currency.usd expected_amount) + actual (/.money currency.usd (n.+ (/.units expected) + (/.sub_units expected)))] (/.= expected actual))) (_.coverage [/.of_units /.of_sub_units] - (let [expected (/.money expected_currency expected_amount) - actual (/.+ (/.of_units expected_currency (/.units expected)) - (/.of_sub_units expected_currency (/.sub_units expected)))] + (let [expected (/.money currency.usd expected_amount) + actual (/.+ (/.of_units currency.usd (/.units expected)) + (/.of_sub_units currency.usd (/.sub_units expected)))] (/.= expected actual))) (do ! - [it ..random] + [it (..random currency.usd)] (_.coverage [/.format] (and (text.starts_with? (%.nat (/.amount it)) (text.replaced_once "." "" (/.format it))) |