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

Rolling Triggers #213

Closed Orangemaple23 closed 3 weeks ago

Orangemaple23 commented 4 weeks ago

Hi @yellowbean, thanks for all the development you've implemented so far!

I see wtihin the documentation that you've defined a 3 month rolling default rate trigger as ("avg", ("cumPoolDefaultedRate",) , ("cumPoolDefaultedRateTill",-1,) , ("cumPoolDefaultedRateTill",-2,) ) However, would it be possible to get a tag for curPoolDefaultedRate instead of cumPoolDefaultedRate? I tried to replicate a Default rate trigger to try and replicate the current pool defaulted rate `[ ("/", ("-", #avg works ('cumPoolDefaultedRate',), ('cumPoolDefaultedRateTill', -1),

('cumPoolDefaultedRateTill', -2),

                      ),
                      ("constant",2)
                      ),
            ">",
            x,
        ],`  

      However, these triggers do not work, I have attached a notebook showing this. Let me know what you think!

rolling_triggers.zip

yellowbean commented 3 weeks ago

Hi @Orangemaple23

May I have some context from the deal documents ? that would help me better to see how to build a right formula

If you want to get "current default balance / current pool balance "

Here : https://absbox-doc.readthedocs.io/en/latest/modeling.html#pool Screenshot 2024-09-17 at 00 54 37

If you try to replicate cumulative default rate formula

you can get cumulative default balance via cumulative pool collection and divide by a current pool balance

Screenshot 2024-09-17 at 01 06 41

    curCumDefaultRate = ("/", ("cumPoolCollection", None, "Defaults"),("poolBalance",))

Let me know if that works , I'm happy to assist further.

Orangemaple23 commented 3 weeks ago

Hi @yellowbean, so for example there could be a 3 month default rate trigger defined like: "3-Month Average Default Rate" refers to, on each calculation date, the rate calculated by taking (A) the sum of (i) the Default Rate as of the Calculation Date two (2) months prior; (ii) the Default Rate as of the Calculation Date one (1) month prior; and (iii) the Default Rate as of the current Calculation Date, and then dividing that total by (B) 3.

Where default rate is the current default rate of the previous period only

yellowbean commented 3 weeks ago

Hi @yellowbean, so for example there could be a 3 month default rate trigger defined like: "3-Month Average Default Rate" refers to, on each calculation date, the rate calculated by taking (A) the sum of (i) the Default Rate as of the Calculation Date two (2) months prior; (ii) the Default Rate as of the Calculation Date one (1) month prior; and (iii) the Default Rate as of the current Calculation Date, and then dividing that total by (B) 3.

Where default rate is the current default rate of the previous period only

what's the definition of Default Rate ? is it

I see. the formula is :

new default balance at (t-2) / pool balance at (t-2) + new default balance at (t-1) / pool balance at (t-1) + new default balance at (t) / pool balance at (t)

and divide by 3

yes ?

Orangemaple23 commented 3 weeks ago

Hi @yellowbean Yes precisely!

yellowbean commented 3 weeks ago

Hi @yellowbean Yes precisely!

Getting new default at last N period is not implemented. I'll think about it ,hopefully it should be ready in dev branch before this Friday.

yellowbean commented 3 weeks ago

rolling default rate 02.ipynb.zip

new propose formula

hastructure: 0.29.5 absbox: 0.29.6

@Orangemaple23 pls let me know if the formula works as expected. (see the notebook example)

Orangemaple23 commented 3 weeks ago

Hi @yellowbean Yes I can confirm that the formula works as expected. Thank you very much for the support and the developments!