fix(lightyear): parse FX conversions as CASH trades for FX FIFO engine#161
Conversation
…(÷100) Trading 212 reports prices in GBX (pence) for UK stocks. The ECB only publishes GBP rates, so the parser must normalize GBX→GBP and divide amounts by 100. Also handles ZAc→ZAR and ILA→ILS. Closes #86
Conversions were incorrectly skipped, causing detectAutoConvert() to assume auto-convert (no CASH trades = broker does it automatically). This meant FX gains/losses on manual EUR↔FCY conversions were never computed per Art. 37.1.l LIRPF (DGT V2324-10). Now emits assetCategory=CASH trades for non-EUR conversion legs, enabling the FX FIFO engine to track lots and compute taxable FX gains.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughTwo independent parser improvements: Lightyear now emits CASH FX trades for non-EUR conversions instead of skipping them, with FIFO fields populated for downstream processing. Trading 212 normalizes fractional currencies (GBX, ZAC, ILA) to base ISO codes by scaling all monetary amounts by ÷100. ChangesLightyear FX Conversion Handling
Trading 212 Fractional Currency Normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #161 +/- ##
==========================================
+ Coverage 97.63% 97.65% +0.01%
==========================================
Files 38 38
Lines 7622 7669 +47
Branches 1549 1563 +14
==========================================
+ Hits 7442 7489 +47
Misses 179 179
Partials 1 1
🚀 New features to boost your workflow:
|
Summary
detectAutoConvert()to assume the account uses auto-convert (no manual CASH trades → broker does it)assetCategory=CASHtrades for non-EUR conversion legs, enabling the FX FIFO engine to track lots and compute taxable FX gainsTest plan
Summary by CodeRabbit
New Features
Bug Fixes