Skip to content

Commit

Permalink
fix case 18 and china reader
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Jun 9, 2024
1 parent ee9e02b commit a012df1
Show file tree
Hide file tree
Showing 4 changed files with 3,863 additions and 12,052 deletions.
12 changes: 12 additions & 0 deletions absbox/local/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import enum
from absbox.local.util import *


# Bond
Expand Down Expand Up @@ -197,3 +198,14 @@ class SubAssetType(str, enum.Enum):
Installment = "Installment"
FixedAsset = "FixedAsset"


def readBondStmt(respBond):
match 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 = 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)

11 changes: 7 additions & 4 deletions absbox/local/china.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from functools import reduce
from pyspecter import query,S
import toolz as tz
from absbox.local.base import *


from absbox.local.util import *
from absbox.local.component import *
Expand Down Expand Up @@ -109,15 +111,16 @@ def read(resp):
output['agg_accounts'] = aggAccs(output['accounts'], 'chinese')

output['pool'] = {}
if deal_content['pool']['contents']['futureCf'] is None:
mFutureFlow = tz.get_in(['pool','contents','futureCf'], deal_content, default=None)
if mFutureFlow is None:
output['pool']['flow'] = None
else:
_pool_cf_header, _, expandFlag = guess_pool_flow_header(deal_content['pool']['contents']['futureCf']['contents'][0], "chinese")
_pool_cf_header, _, expandFlag = guess_pool_flow_header(mFutureFlow['contents'][1][0], "chinese")
if not expandFlag:
output['pool']['flow'] = pd.DataFrame([_['contents'] for _ in deal_content['pool']['contents']['futureCf']['contents']]
output['pool']['flow'] = pd.DataFrame([_['contents'] for _ in mFutureFlow['contents'][1]]
, columns=_pool_cf_header)
else:
output['pool']['flow'] = pd.DataFrame([_['contents'][:-1]+mapNone(_['contents'][-1],[None]*6) for _ in deal_content['pool']['contents']['futureCf']['contents']]
output['pool']['flow'] = pd.DataFrame([_['contents'][:-1]+mapNone(_['contents'][-1],[None]*6) for _ in mFutureFlow['contents'][1]]
, columns=_pool_cf_header)

pool_idx = "日期"
Expand Down
10 changes: 0 additions & 10 deletions absbox/local/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ def read_pricing(self, pricing):

@staticmethod
def read(resp):
def readBondStmt(respBond):
match 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 = 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)

read_paths = {
'fees': ('feeStmt', english_fee_flow_fields_d, "fee")
, 'accounts': ('accStmt', english_acc_flow_fields_d, "account")
Expand Down
Loading

0 comments on commit a012df1

Please sign in to comment.