Repository navigation
Support the current Trading 212 export and read dates in UK time - #1000
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1000 +/- ##
==========================================
+ Coverage 94.07% 94.10% +0.02%
==========================================
Files 37 37
Lines 4847 4867 +20
Branches 800 804 +4
==========================================
+ Hits 4560 4580 +20
Misses 149 149
Partials 138 138
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Thanks! I can review it and fix tests later. Just to confirm: these changes are coming from your recent export? In the meantime, please take a look at tqdm/shtab#256 🙂 |
55fd072 to
0adf60c
Compare
|
Tested manually today, yes. Also, while we're off-topic: https://github.com/KapJI/capital-gains-calculator/blob/0adf60ce8f83600c6cf8ef5f90564724fccd78fc/cgt_calc/isin_converter.py#L106 was annoying. Can it be a warning instead of an exception? Or perhaps at least have some common aliases built in to suppress the error? ISIN,symbol
US67066G1040,NVD,NVDA
US11135F1012,1YD,AVGO |
vmartinv
left a comment
There was a problem hiding this comment.
it looks like this change would break the previous format. Can you make the change backwards compatible?
Recent exports renamed the Time column to "Time (UTC)", but older exports still use "Time" and a directory is expected to hold several years of them, so accept both spellings. Parse timestamps with fromisoformat so whole seconds, milliseconds and a zone designator all work, and an unparsable value still raises a ParsingError with the row instead of being silently truncated. The spurious dividend price warning comes from withholding tax: the Total is net of it while the Price per Share stays gross. Add the tax back for the consistency check only. It is not a dealing cost, so it never reaches the reported fees.
|
📖 Docs preview: https://pr-1000.cgt-calc.pages.dev Built from b43633b · updated 2026-08-25 21:27 BST |
The tax year boundary and the same-day and 30-day matching rules run on UK calendar days, and 5 April always falls inside BST. Taking the date straight from the UTC instant put anything stamped after 23:00 UTC on 5 April in the previous tax year. Keep the instant in UTC for ordering and derive the date in Europe/London. zoneinfo needs tzdata where the OS ships no tz database.
The Freetrade export timestamps every transaction in UTC, and the parser took the calendar date straight from that instant. The tax year boundary and the same-day and 30-day matching rules run on UK calendar days, and 5 April always falls inside BST, so anything stamped after 23:00 UTC on 5 April was filed in the previous tax year. Convert to Europe/London before taking the date, the same way Trading 212 does since #1000. A zone-less timestamp is read as UTC rather than as the machine's local time, so the parsed date does not depend on where the calculation is run. Document the behaviour on the Freetrade page. The date-only exports (Schwab, Interactive Brokers, Hargreaves Lansdown, Vanguard, Morgan Stanley, Sharesight and RAW) carry no time to convert, so say so once on the brokers index rather than on each page. Co-authored-by: Martín Villagra <mvillagra0@gmail.com>
Haven't bothered updating tests, but seems like the format needs updating (at least as per exports today).