From: Christopher Grebs Date: Tue, 16 Jan 2018 16:54:41 +0000 (+0100) Subject: Add support for acquisition price (Einstandspreis) for holdings. (#21) X-Git-Tag: v0.3.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e85afb2071b8767968dd83d5b1926ae0057b7961;p=thirdparty%2Fpython-fints.git Add support for acquisition price (Einstandspreis) for holdings. (#21) * Add support for acquisition price (Einstandspreis) for holdings. * Fix namingf --- diff --git a/fints/models.py b/fints/models.py index 67f6640..c78af2b 100644 --- a/fints/models.py +++ b/fints/models.py @@ -4,4 +4,4 @@ SEPAAccount = namedtuple('SEPAAccount', 'iban bic accountnumber subaccount blz') Saldo = namedtuple('Saldo', 'account date value currency') -Holding = namedtuple('Holding', 'ISIN name market_value value_symbol valuation_date pieces total_value') +Holding = namedtuple('Holding', 'ISIN name market_value value_symbol valuation_date pieces total_value acquisitionprice') diff --git a/fints/utils.py b/fints/utils.py index 8eea5b9..e3b1ff0 100644 --- a/fints/utils.py +++ b/fints/utils.py @@ -46,6 +46,7 @@ class MT535_Miniparser: re_pricedate = re.compile(r"^:98A::PRIC\/\/(\d*)$") re_pieces = re.compile(r"^:93B::AGGR\/\/UNIT\/(\d*),(\d*)$") re_totalvalue = re.compile(r"^:19A::HOLD\/\/([A-Z]{3})(\d*),{1}(\d*)$") + re_acquisitionprice = re.compile(r"^:70E::HOLD\/\/\d*STK\|2(\d*?),{1}(\d*?)\+([A-Z]{3})$") def parse(self, lines): retval = [] @@ -56,7 +57,7 @@ class MT535_Miniparser: finsegs = self.grab_financial_instrument_segments(clauses) # Third: Extract financial instrument data for finseg in finsegs: - isin, name, market_price, price_symbol, price_date, pieces = (None,)*6 + isin, name, market_price, price_symbol, price_date, pieces, acquisitionprice = (None,)*7 for clause in finseg: # identification of instrument # e.g. ':35B:ISIN LU0635178014|/DE/ETF127|COMS.-MSCI EM.M.T.U.ETF I' @@ -85,12 +86,19 @@ class MT535_Miniparser: m = self.re_totalvalue.match(clause) if m: total_value = float(m.group(2) + "." + m.group(3)) + # Acquisition price + # e.g ':70E::HOLD//1STK23,968293+EUR' + m = self.re_acquisitionprice.match(clause) + if m: + acquisitionprice = float(m.group(1) + '.' + m.group(2)) + # processed all clauses retval.append( Holding( ISIN=isin, name=name, market_value=market_price, value_symbol=price_symbol, valuation_date=price_date, - pieces=pieces, total_value=total_value)) + pieces=pieces, total_value=total_value, + acquisitionprice=acquisitionprice)) return retval def collapse_multilines(self, lines):