Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fints/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def parse(self, lines):
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, acquisitionprice = (None,)*7
isin, name, market_price, price_symbol, price_date, pieces, total_value, acquisitionprice = (None,)*8
for clause in finseg:
# identification of instrument
# e.g. ':35B:ISIN LU0635178014|/DE/ETF127|COMS.-MSCI EM.M.T.U.ETF I'
Expand Down
34 changes: 34 additions & 0 deletions tests/test_mt535.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from fints.utils import MT535_Miniparser


def _mt535_holding(isin, name, pieces, total_value=None):
lines = [
":16R:FIN",
":35B:ISIN {}|/DE/X1|{}".format(isin, name),
":90B::MRKT//ACTU/EUR10,00",
":98A::PRIC//20260101",
":93B::AGGR//UNIT/{},".format(pieces),
]
if total_value is not None:
lines.append(":19A::HOLD//EUR{}".format(total_value))
lines.append(":16S:FIN")
return lines


def test_mt535_holding_without_total_value_does_not_inherit_previous():
lines = _mt535_holding("AA0000000001", "ONE", "5", "50,00")
lines += _mt535_holding("AA0000000002", "TWO", "7")
lines.append("-")

first, second = MT535_Miniparser().parse(lines)

assert first.total_value == 50.0
assert second.total_value is None


def test_mt535_first_holding_without_total_value():
lines = _mt535_holding("AA0000000003", "THREE", "1") + ["-"]

(holding,) = MT535_Miniparser().parse(lines)

assert holding.total_value is None