Skip to content

Commit eb59e65

Browse files
committed
expose formula in rate swap
1 parent e73635c commit eb59e65

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

absbox/local/component.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ def mkDs(x):
272272
return mkTag(("BondRate", vStr(bn)))
273273
case ("债券加权利率", *bn) | ("bondWaRate", *bn):
274274
return mkTag(("BondWaRate", vList(bn, str)))
275-
case ("资产池利率", *pNames) | ("poolWaRate", *pNames):
276-
if pNames:
277-
return mkTag(("PoolWaRate", lmap(mkPid, pNames)))
275+
case ("资产池利率", pName) | ("poolWaRate", pName):
276+
return mkTag(("PoolWaRate", mkPid(pName)))
277+
case ("资产池利率",) | ("poolWaRate",):
278278
return mkTag(("PoolWaRate", None))
279279
case ("所有账户余额",) | ("accountBalance"):
280280
return mkTag("AllAccBalance")
@@ -776,16 +776,20 @@ def mkLiqRepayType(x):
776776

777777
def mkRateSwapType(pr, rr):
778778
def isFloater(y):
779-
if isinstance(y, tuple):
779+
if isinstance(y, tuple) and len(y) == 2 and isinstance(y[1],float):
780780
return True
781781
return False
782782
match (isFloater(pr), isFloater(rr)):
783-
case (True, True):
784-
return mkTag(("FloatingToFloating", [pr, rr]))
785-
case (False, True):
783+
case (False, True) if isinstance(pr, float):
786784
return mkTag(("FixedToFloating", [pr, rr]))
787-
case (True, False):
785+
case (False, True):
786+
return mkTag(("FormulaToFloating",[mkDs(pr), rr]))
787+
case (True, False) if isinstance(rr, float):
788788
return mkTag(("FloatingToFixed", [pr, rr]))
789+
case (True, False):
790+
return mkTag(("FloatingToFormula",[pr, mkDs(rr)]))
791+
case (True, True):
792+
return mkTag(("FloatingToFloating", [pr, rr]))
789793
case _:
790794
raise RuntimeError(f"Failed to match :{rr,pr}:Interest Swap Type")
791795

absbox/tests/benchmark/china/test22.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from absbox import API
22

3+
import
4+
35
localAPI = API("https://absbox.org/api/latest",'chinese')
46

57
mypool = {"清单":[["租赁",{"初始租金":100,"初始期限":12,"频率":"月末","起始日":"2021-01-31","计提周期":"季度末", "涨幅":0.085}]

0 commit comments

Comments
 (0)