Skip to content

Commit 8f16374

Browse files
committed
expose RF: irr & balance
1 parent 5479144 commit 8f16374

File tree

2 files changed

+91
-2
lines changed

2 files changed

+91
-2
lines changed

absbox/rootFinder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ def mkTweak(x):
77
return mkTag(("StressPoolDefault"))
88
case ("maxSpread", bn):
99
return mkTag(("MaxSpreadTo", vStr(bn)))
10+
case ("splitBalance", bn1 ,bn2):
11+
return mkTag(("SplitFixedBalance", [vStr(bn1), vStr(bn2)]))
1012
case _:
1113
raise RuntimeError(f"failed to match {x}:mkTweak")
1214

@@ -16,5 +18,7 @@ def mkStop(x):
1618
return mkTag(("BondIncurLoss", vStr(bn)))
1719
case ("bondPricingEqOriginBal", bn, f1, f2):
1820
return mkTag(("BondPricingEqOriginBal", [vStr(bn), f1, f2] ))
21+
case ("bondMetTargetIrr", bn, irr):
22+
return mkTag(("BondMetTargetIrr", [vStr(bn), irr]))
1923
case _:
2024
raise RuntimeError(f"failed to match {x}:mkStop")

docs/source/analytics.rst

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,10 +2165,97 @@ In combination of above three.
21652165
Root Finder
21662166
----------------------
21672167
2168+
.. versionchanged:: 0.46.1
2169+
21682170
.. warning::
21692171
21702172
This a collection of advance analytics which involves CPU intenstive task. Pls don't abuse these functions in public server.
21712173
2174+
.. warning::
2175+
2176+
The root finder has been a major upgrade in version 0.46.1, the old root finder will be deprecated in future release.
2177+
2178+
`Root Finder` is an advance analytics with enables user to quick find a breakeven point given an range of tweak.
2179+
2180+
For example, the `First Loss Run`:
2181+
2182+
* breakeven point is "A specific bond incur a 0.01 loss"
2183+
* "range of tweak" is the `Different level of Default` in `Pool Performance Assumption`.
2184+
2185+
2186+
2187+
`Tweak` and `Stop Condition`
2188+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2189+
2190+
The seperation of `Tweak` and `Stop Condition` is to make the root finder more flexible.
2191+
2192+
For example, in `First Loss Run`, what if user want to stress the `Recovery Rate` instead of the `Default Rate` ?
2193+
2194+
The genious design is to *Seperate* the `Tweak` and `Stop Condition`, into a 2-element tuple:
2195+
2196+
"FirstLossRun" -> ("Pool Default Stress", "Bond Incur 0.01 Loss")
2197+
2198+
That would ganrantee long term flexibility of the root finder. User can swap the first element to stress on `Recovery Rate` to find the breakeven point too.
2199+
2200+
"FirstLossRun" -> ("Recovery Stress", "Bond Incur 0.01 Loss")
2201+
2202+
2203+
syntax
2204+
^^^^^^^^^^^^^^^^
2205+
Use ``runRootFinder()`` to run root finder, it has four parameters:
2206+
2207+
2208+
.. code-block:: python
2209+
2210+
r0 = api.runRootFinder(
2211+
<Deal Object>
2212+
,<Pool Assumption>
2213+
,<Run Assumption>
2214+
,(<Tweak>, <Stop Condition>>)
2215+
)
2216+
2217+
Tweak
2218+
""""""""
2219+
2220+
Stress Default
2221+
It will stress the default component in the pool performance assumption.
2222+
2223+
syntax
2224+
``stressDefault``
2225+
2226+
Max Spread
2227+
It will increase the spread of bond.
2228+
2229+
syntax
2230+
``("maxSpread", <bondName>)``
2231+
2232+
Split Balance
2233+
It will adjust balance distribution of two bonds.
2234+
2235+
syntax
2236+
``("splitBalance", <bondName1>, <bondName2>)``
2237+
2238+
Stop Condition
2239+
"""""""""""""""""""""
2240+
2241+
Bond Incur Loss
2242+
The search stop when a bond incur a loss of 0.01
2243+
2244+
syntax
2245+
``("bondIncurLoss", <bondName>)``
2246+
2247+
Bond Pricing Equals to Face
2248+
The search stop when a bond pricing equals to face value.
2249+
2250+
syntax
2251+
``("bondPricingEqToOrigin", <bondName>, <TestBondFlag>, <TestFeeFlag>)``
2252+
2253+
Bond with target IRR
2254+
The search stop when a bond hit a target IRR.
2255+
2256+
syntax
2257+
``("bondMetTargetIrr", <bondName>, <targetIRR>)``
2258+
21722259
21732260
First Loss Run
21742261
^^^^^^^^^^^^^^^^^^^^
@@ -2187,7 +2274,6 @@ User can input with an assumption with one more field ("Bond Name") compare to s
21872274
21882275
Using endpoint of ``runRootFinder()``
21892276
2190-
.. versionchanged:: 0.46.1
21912277
syntax
21922278
``(<deal>,<poolAssump>,<runAssump>,("firstLoss", <bondName>))``
21932279
@@ -2226,7 +2312,6 @@ Then engine return a tuple
22262312
Spread Breakeven
22272313
^^^^^^^^^^^^^^^^^^^^
22282314
.. versionadded:: 0.45.3
2229-
.. versionchanged:: 0.46.1
22302315
.. deprecated:: 0.46.1
22312316
22322317
It will tune up the spread/interest rate of a bond gradually till ``pricing of bond equals to originBalance``

0 commit comments

Comments
 (0)