Skip to content

Commit

Permalink
refactor pay expense
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Aug 13, 2023
1 parent 065a2f4 commit ad5f8ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 0 additions & 5 deletions absbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,18 @@ def _send_req(self,_req,_url,timeout=10,headers={})->dict:
r = self.session.post(_url, data=_req.encode('utf-8'), headers=hdrs, verify=False, timeout=timeout)
except (ConnectionRefusedError, ConnectionError):
console.print(f"❌[bold red] Failed to talk to server {_url}")
console.rule()
return None
except ReadTimeout:
console.print(f"❌[bold red] Failed to get response from server")
console.rule()
return None
if r.status_code != 200:
console.print_json(_req)
console.rule()
print(">>>",r.text)
console.print_json(r.text)
console.rule()
return None
try:
return json.loads(r.text)
except JSONDecodeError as e:
console.print(e)
console.rule()
return None

11 changes: 8 additions & 3 deletions absbox/local/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,19 @@ def mkAction(x):
return mkTag(("CalcBondInt", bndNames))
case ["计提支付费用", source, target] | ["calcAndPayFee", source, target]:
return mkTag(("CalcAndPayFee", [source, target]))
case ["支付费用", source, target, _limit] | ["payFee", source, target, _limit]:
limit = mkFeeCapType(_limit)
return mkTag(("PayFeeBy", [limit, source, target]))
case ["支付费用", source, target] | ["payFee", source, target]:
return mkTag(("PayFee", [source, target]))
case ["支付费用限额", source, target, _limit] | ["payFeeBy", source, target, _limit]:
limit = mkFeeCapType(_limit)
return mkTag(("PayFeeBy", [limit, source, target]))
case ["支付费用收益", source, target, _limit] | ["payFeeResidual", source, target, _limit]:
limit = mkAccountCapType(_limit)
return mkTag(("PayFeeResidual", [limit, source, target]))
case ["支付费用收益", source, target] | ["payFeeResidual", source, target]:
return mkTag(("PayFeeResidual", [None, source, target]))
case ["支付费用限额", source, target, _limit] | ["payFeeBy", source, target, _limit]:
limit = mkFeeCapType(_limit)
return mkTag(("PayFeeBy", [limit, source, target]))
case ["计提支付利息", source, target] | ["accrueAndPayInt", source, target]:
return mkTag(("AccrueAndPayInt", [source, target]))
case ["支付利息", source, target] | ["payInt", source, target]:
Expand Down Expand Up @@ -942,6 +945,8 @@ def mkAssumption(x) -> dict:
case {"RevolvingAssets": [rpool,rassumps]} | {"循环资产": [rpool,rassumps]}:
assumps = [ mkAssumption(ra) for ra in rassumps ]
return mkTag(("AvailableAssets",[mkRevolvingPool(rpool), assumps]))
case {"预计费用":[fname,curve]} | {"EstimateExpense":[fname,curve]}:
return mkTag(("ProjectedExpense",[fname, mkTs("BalanceCurve",curve)]))
case _:
raise RuntimeError(f"Failed to match {x}:Assumption")

Expand Down

0 comments on commit ad5f8ac

Please sign in to comment.