Repository navigation
MT535: reset total_value for each holding - #231
Open
mankind806 wants to merge 1 commit into
Open
mankind806 wants to merge 1 commit into
mankind806 wants to merge 1 commit into
Conversation
A holding without a :19A::HOLD// clause got the total value of the previous holding; if the first holding had none, parse() raised UnboundLocalError. Reset total_value with the other per-holding values and add two tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NWM3zdiEV9ZBtiNXUKHuqw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the bug
MT535_Miniparser.parsedoes not resettotal_valuefor each holding. A holding without a:19A::HOLD//clause gets the total value of the holding before it in the same message. If the first holding in the message has no:19A:clause,parseraisesUnboundLocalError, soget_holdings()fails.Cause
fints/utils.pyat v5.0.1 (and at mastereda20b4):isin, name, market_price, price_symbol, price_date, pieces, acquisitionprice = (None,)*7resets seven of the eight values of a holding.total_valueis not among them.total_valueis assigned only if a:19A::HOLD//...clause matches.Holding(..., total_value=total_value, ...)always reads it. For the second and later holdings that is the value from the previous loop pass; for the first holding it is a name that was never assigned.get_holdings(fints/client.py:704-714) creates oneMT535_MiniparserperHIWPDsegment and callsparseon its lines, so the carry-over runs across all holdings of one segment.Impact
:19A:is reported with a plausible but wrong total value (the one of its neighbour) and no warning. A caller that sums the depot value or stores it gets a wrong number.:19A:,get_holdings()raisesUnboundLocalError: cannot access local variable 'total_value'and no holding is returned.I did not show that a particular bank omits
:19A:. The parser treats the clause as optional (it only matches it if present), so the missing case should be handled either way.Affected versions
python-fints 5.0.1 (tag
v5.0.1, commiteda20b4fec2e612dc7942234884be2e8c4fe632f) and master at the same commit (checked 2026-11-09;fints/utils.pyis identical in both). Older versions were not tested.Reproduction
No network, synthetic data. Python 3.14.8, python-fints 5.0.1 from PyPI.
Actual output:
Expected:
A TWO 7.0 None, and for B a holding withtotal_value=None.Not checked
:19A:for some holdings (or in which cases) is not known to me. The SWIFT/DK message definition was not read for this report.total_valuewas examined; the other seven values are reset in line 165.Solution
One line (
fints/utils.py:165) and two tests (new filetests/test_mt535.py). The patch is againsteda20b4(=v5.0.1= master on 2026-11-09). The new tests fail before the change (case B withUnboundLocalError, case A with the wrong value50.0) and pass after it.AI disclosure
An AI assistant (Claude, Anthropic) helped find and write this report and the patch. The reproduction and the two tests were run on python-fints 5.0.1, and the cause was checked against the source by a second review step. The account owner allows AI-prepared bug-fix submissions; questions are welcome and will be answered.