Skip to content

Commit

Permalink
prevent exception when no bond cashflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Jun 8, 2024
1 parent dc723b2 commit 7fba807
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions absbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from importlib.metadata import version
from json.decoder import JSONDecodeError
from dataclasses import dataclass
from datetime import datetime

import requests
from requests.exceptions import ConnectionError, ReadTimeout
Expand Down Expand Up @@ -281,7 +282,6 @@ def build_pool_req(self, pool, poolAssump, rateAssumps, isMultiScenario=False) -
r = None
_rateAssump = map(mkRateAssumption, rateAssumps) if rateAssumps else None
assetDate = getValWithKs(pool, ['cutoffDate', '封包日'])
#assetDate = pool['cutoffDate']

def buildPoolType(p) -> dict:
""" build type for `PoolTypeWrap` """
Expand Down Expand Up @@ -319,7 +319,7 @@ def run(self, deal,
:type showWarning: bool, optional
:param debug: return request text instead of sending out such request, defaults to False
:type debug: bool, optional
:return: result of run, a dict or dataframe
:return: result of run, a dict of dataframe if `read` is True.
:rtype: dict
"""
Expand All @@ -345,9 +345,9 @@ def run(self, deal,
if result is None or 'error' in result:
raise AbsboxError(f"❌{MsgColor.Error.value}Failed to get response from run")

rawWarnMsg = [f"{MsgColor.Warning.value}{_['contents']}" for _ in filter_by_tags(result[RunResp.LogResp.value], enumVals(ValidationMsg))]
rawWarnMsg = map( lambda x:f"{MsgColor.Warning.value}{x['contents']}", filter_by_tags(result[RunResp.LogResp.value], enumVals(ValidationMsg)))
if rawWarnMsg and showWarning:
console.print("Warning Message from server:\n"+"\n".join(rawWarnMsg))
console.print("Warning Message from server:\n"+"\n".join(list(rawWarnMsg)))

if read:
return deal.read(result)
Expand Down
2 changes: 1 addition & 1 deletion absbox/local/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def readBondStmt(respBond):
case {'tag':'BondGroup','contents':bndMap }:
return {k: pd.DataFrame(list(tz.pluck("contents",[] if v['bndStmt'] is None else v['bndStmt'])), columns=english_bondflow_fields).set_index("date") for k,v in bndMap.items() }
case {'tag':'Bond', **singleBndMap }:
bStmt = singleBndMap.get('bndStmt',[])
bStmt = mapNone(singleBndMap.get('bndStmt',[]),[])
return pd.DataFrame(list(tz.pluck("contents", bStmt)), columns=english_bondflow_fields).set_index("date")
case _:
raise RuntimeError("Failed to read bond flow from resp",respBond)
Expand Down

0 comments on commit 7fba807

Please sign in to comment.