fix: Binance Spot export format change (UTC_Time→Time, YY year)#81
Merged
Conversation
Binance renamed the time column ("UTC_Time" → "Time"), added a leading
"User ID" column, and shortened timestamps from 4-digit to 2-digit year
in recent Spot exports. The parser now reads row["time"] and uses
"%y-%m-%d %H:%M:%S". Legacy exports need to be regenerated from the
Binance portal — back-compat would require a heuristic fallback that
isn't worth the surface area.
Also:
- First unit tests for the Binance parser (there were none before) —
cover deposit-skip, convert-pair grouping, transaction-triple fee
aggregation, and the YY vs YYYY guard.
- Anonymized 7-row fixture (User ID 999999999, round amounts).
- CliRunner test for `pit38 import binance` for parity with
revolut-stock and ibi-capital.
Noted as out-of-scope for this fix: FiatValue.currency is populated
with the raw "PLN" string instead of Currency.ZLOTY (pre-existing
quirk). Tests assert on components so they're honest about the drift
without endorsing it.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Problem
Binance changed the Spot transaction history CSV format. Running the existing importer on a current export crashes:
```
File "pit38/plugins/crypto/binance/csv.py", line 22, in init
self.utc_time = datetime.strptime(row["utc_time"], "%Y-%m-%d %H:%M:%S")
KeyError: 'utc_time'
```
What changed
Fix
Two-line change in `BinanceTransaction.init`:
The new `User ID` column is simply ignored (parser never reads it). BOM + lowercase headers already handled by `open_csv_reader`.
Scope
Only the format change. No backward compatibility with pre-2025 exports — users with stale files can re-download from the Binance portal.
Out of scope (follow-up candidates)
Tests
Test plan