]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Add support for acquisition price (Einstandspreis) for holdings. (#21)
authorChristopher Grebs <cg@webshox.org>
Tue, 16 Jan 2018 16:54:41 +0000 (17:54 +0100)
committerRaphael Michel <mail@raphaelmichel.de>
Tue, 16 Jan 2018 16:54:41 +0000 (17:54 +0100)
* Add support for acquisition price (Einstandspreis) for holdings.

* Fix namingf

fints/models.py
fints/utils.py

index 67f6640d2356260c763e021cc71cfbd2f7556c99..c78af2b3dd680cb8365a69ce09bfcbde690b6261 100644 (file)
@@ -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')
index 8eea5b95f511cd66f29a5067a9ad010b53abf5e4..e3b1ff0b0473a3bc90b568a0c7b16e014036edab 100644 (file)
@@ -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):