schwab_equity_award_json.py parser: avoid unnecessary quantity recalculation. #575
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.
This can introduce rounding errors.
This fixes #574.
Basically, there's some code in
cgt_calc/parsers/schwab_equity_award_json.py
, which tries to work around some issues in data exported from Schwab:This codepath is triggered unconditionally when an integer number of shares is sold - even when there isn't an issue with the exported data. This change makes that codepath conditional on there actually being an issue with the exported data.
Without the change in
cgt_calc/parsers/schwab_equity_award_json.py
, the test triggers the following error:The test data is fictional and purely there to reproduce the error, but it is plausible based on data I've seen and I have seen the rounding errors happen in real data.
Note that because quantities matter for S104 pool calculations this may introduce deltas in outputs between
calculations before and after this change. However, without this change you may run into asserts, depending
on what kinds of trades/gifts you make.
This contribution has been developed in my spare time. Disclaimer: I'm not a financial advisor/accountant.