Skip to content

Commit 343dcf4

Browse files
committed
expose trigger:effect:changeBondRate
1 parent b285098 commit 343dcf4

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

absbox/local/component.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,8 @@ def mkTriggerEffect(x):
13321332
return mkTag(("ChangeReserveBalance", [vStr(accName), mkAccType(newReserve)]))
13331333
case ["结果", *efs] | ["Effects", *efs] | ("Effects", *efs):
13341334
return mkTag(("TriggerEffects", [mkTriggerEffect(e) for e in efs]))
1335+
case ("changeBondRate", bndName, bondRateType, newRate):
1336+
return mkTag(("ChangeBondRate", [vStr(bndName), mkBondRate(bondRateType), vNum(newRate)]))
13351337
case None:
13361338
return mkTag(("DoNothing"))
13371339
case _:

absbox/tests/regression/test_main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,17 @@ def test_bondGrp(setup_api):
274274
r = setup_api.run(bondGrp , read=True , runAssump = [])
275275
grpFlow = readBondsCf(r['bonds'])['A'].xs('balance',axis=1,level=1)
276276
assert grpFlow.A1.to_list()[:8] == [1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 993.93]
277-
assert grpFlow.A2.to_list()[:8] == [510.6, 436.68, 364.06, 290.75, 217.26, 143.1, 68.74, 0.0,]
277+
assert grpFlow.A2.to_list()[:8] == [510.6, 436.68, 364.06, 290.75, 217.26, 143.1, 68.74, 0.0,]
278+
279+
@pytest.mark.trigger
280+
def test_trigger_chgBondRate(setup_api):
281+
withTrigger = test01 & lens.trigger.set({
282+
"BeforeDistribution":{
283+
"changeBndRt":{"condition":[">=","2021-08-20"]
284+
,"effects":("changeBondRate", "A1", {"floater":[0.05, "SOFR1Y",-0.02,"MonthEnd"]}, 0.12)
285+
,"status":False
286+
,"curable":False}
287+
}
288+
})
289+
r = setup_api.run(withTrigger , read=True ,runAssump = [("interest",("SOFR1Y",0.04))])
290+
assert r['bonds']['A1'].rate.to_list() == [0.07, 0.12, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02]

docs/source/modeling.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,18 @@ Perform Actions
35353535
....
35363536
)
35373537
3538+
Change Bond Rate Type
3539+
.. versionadded:: 0.45.9
3540+
Change the rate type of a bond, which will change the way how interest is calculated.
3541+
3542+
.. code-block:: python
3543+
3544+
"effects":("changeBondRate",<Bond Name>,<Rate Type>,<init rate>)
3545+
3546+
* <Bond Name> : name of the bond
3547+
* <Rate Type> : type of rate, :ref:`Interest` from bond interest rate type section
3548+
* <init rate> : initial rate to be set
3549+
35383550
Combination of above
35393551
a list of above can be combined together with keyword ``Effects``
35403552

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ minversion = "7.0"
5959
addopts = "-ra -q --color=yes --import-mode=importlib"
6060
markers = [
6161
"pool","account","bond","fee","interest","collect","asset","performance",
62+
"trigger",
6263
"TB","analytics","dontrun"
6364
]
6465

0 commit comments

Comments
 (0)