yellowbean / Hastructure

ABS/MBS cashflow engine written in Haskell, with API to Python and C/Java (on the way)
https://deal-bench.xyz
Other
16 stars 4 forks source link

[Feature] Enable clean up call in multiple locations #218

Closed yellowbean closed 3 weeks ago

yellowbean commented 1 month ago

current implementation

The clean up test only was performed at beginning of bond waterfall execution (which is defined by "bond payment frequency"

Propose

The clean up test should be performed in multiple locations

Location of changes:

in Deal Run assumption

Syntax

current syntax

The statement will be executed right before each waterfall/liability payment day

("call", ("if", `<Condition>`))

new syntax

 # backward compatible -> test on each day of waterfall/liability payment day (before waterfall execution)
 ("call", ("if", `<Condition>` ))

 # test on dates described by <DatePattern>, the `if` is redundant.
 ("callWhen", ("onDates", `<DatePattern>`, `<Condition 1>`, `<Condition 2>`, `<Condition 3>` )
             , ("if", `<Condition 1>`, `<Condition 2 >`)
 )
yellowbean commented 3 weeks ago

Step 1 , clean up current code

current logic:

case fruit of 
   Just apple ->
       if testSweet apple then 
           <ProcessA>
       else
           <ProcessB>
   Nothing ->
           <ProcessB>

Done with : https://stackoverflow.com/questions/79152742/how-to-factor-out-duplication-code-haskell-maybe-if-else

yellowbean commented 3 weeks ago

d49fbaf