Repository navigation
Add binanceReturns: Binance law enforcement returns (.xlsx) - #661
Merged
Merged
Conversation
Reads the one-workbook-per-account returns Binance produces, recognised by content (a Customer Information and an Access Logs sheet), not file name. Layouts observed in three 2022 returns, one of 8 sheets and two of 18, are handled: plain table sheets, the block-structured Customer Information and Account Balance sheets, Approved Devices with its Key/Value continuation rows and bilingual headers, and images embedded on KYC Documents. Values are reported as the text the workbook holds. Only columns the return labels UTC are converted; other times carry no zone and stay as produced. Unknown columns, Account Balance blocks and sheets are kept, and anything the module cannot place is listed in Parsing Notes. Verified against the three returns by row count against an independent structure scan; no values from them are in this change. The generator builds a fabricated return for the test cases. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
One case, SYNTH001, built from gen_binance_synth.py: an 18-sheet and an 8-sheet workbook plus a decoy .xlsx, with baselines for all 29 artifacts. Every value is fabricated; the fixture's values were checked against the three returns the module was written from and share none beyond headers, block titles, generic vocabulary and round amounts. One invented amount that happened to coincide with a real one was changed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
check_artifact_output.py run on the three observed returns flagged empty, constant and identical columns. Each was checked against the source cells: none is a parsing defect. Margin Cross Total Balance and Order History Type hold a single space on every row, which is trimmed to blank; the Margin Isolated balance columns are equal in the source itself. The notes now name each column and the observation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
- Tabler icon names for the four artifacts that used Feather names (layout-grid, stack-2, login, device-mobile). - A UTC column whose value cannot be read is None, not an empty string, and the conversion uses convert_ts_human_to_utc from ilapfuncs. - A small helper replaces a lambda assigned inside a loop. The Access Logs baseline is re-recorded: its unreadable timestamp is now null. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
A Binance return produced in 2024 has 30 sheets where the 2022 returns had 8 or 18. The module now reads both layouts: - Customer Information: the KYC Approved Info, Address Validation and Sub-accounts blocks get their own artifacts, and an unrecognised block is reported cell for cell under Customer Information - Other Blocks. Before, such blocks were only named in Parsing Notes and their rows reached no table. Basic Information reads First Name, Last Name, Tax ID and TnC. - Assets Overview, which replaces Account Balance, is read with the same block layouts, plus Overview, Asset Positions and Earn Products. A layout is now matched on the columns every observed header holds, so the added USDT Equivalent column does not stop 2022 blocks matching. - New sheets: Spot and Funding Asset Log, P2P, Attempted Withdrawal History, Margin Order, Fiat payment methods, OTC Payment ID History, Gift Card Creation and Transfer, Loan Order and Repayment History. - The camel-case Fiat layout of the 2024 return (Fiat Deposit History, Fiat Withdrawal History and Fiat Trades) is reported under Fiat Orders; a Fiat sheet whose header matches neither layout goes to Other Sheets. - Columns added in 2024 to sheets the 2022 layout had (Account Type, USDT, Port Number, USDT equivalent and others) are reported in their own columns. Times the 2024 sheets label UTC+8, or carry a zone inside the value, are reported as produced and not converted. The three 2022 returns used to write the module give the same row counts as before. The synthetic case gains a workbook in the 2024 layout. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
Account Balance, Assets Overview and Current Assets & Wallets list a row for every asset or pair whether or not the account holds any. In the 2022 returns compared cell by cell, more than 90% of the Futures Positions, Futures Balances and Margin rows, and 96% of the Current Assets rows, held nothing. Those rows are no longer listed: - A balance row is listed when one of its amounts is not zero (blank, '-' and any number equal to zero count as zero) or it carries a column the artifact does not name. Block Index gains Rows Not Listed, per block. - A Current Assets row is also kept for a deposit address, a label or memo, or an extra column. Parsing Notes gives how many rows were left out. Related artifacts are merged, 47 to 38, each with a Sheet or Block column saying where the row came from: - Spot and the 2024 Funding, staking and Autoinvest blocks: Holdings - Margin - Cross and Margin - Isolated: Margin - Order History and Margin Order: Order History - the 2022 Fiat Deposit and Fiat Withdrawal History: Fiat History - Gift Card Creation and Transfer: Gift Cards - Loan Order and Repayment History: Loans - KYC Approved Info, Address Validation and Sub-accounts: Customer Information - KYC and Address - the two Other Blocks artifacts: Other Blocks Checked against the three 2022 returns: every source cell is either in the report or in a row left out for holding no position, and the synthetic case now has zero rows to leave out beside zero rows kept for an address or memo. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
After the merge, six functions kept the name of one of the artifacts folded into them. The function name is also the LAVA table name, so it should match the artifact. Nothing has shipped under the old names. - binanceBalanceSpot -> binanceBalanceHoldings - binanceBalanceMarginCross -> binanceBalanceMargin - binanceFiatDeposits -> binanceFiatHistory - binanceGiftCardCreation -> binanceGiftCards - binanceLoanOrders -> binanceLoans - binanceBalanceOther -> binanceOtherBlocks (it also carries Customer Information blocks) Test data and baselines regenerated; the rows are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
check_artifact_output.py, run on the report from the four returns tested (three in the 2022 layout, one in the 2024 layout), reported 70 empty, constant and identical columns across 20 artifacts. Each is now named in that artifact's notes, in a sentence saying what was observed in the returns tested, so the checker reads it as documented. None is a parsing defect: the verifier that compares every source cell with the report found every cell in place. Other Columns (as produced) is empty where no return added an unnamed column, and Sheet and Block are constant where every listed row came from one sheet or block. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc
Maxitelmo
marked this pull request as ready for review
November 12, 2026 00:59
The module matches every .xlsx, so a run over another provider's return put a Binance Returns category in the report, with a Parsing Notes row for each workbook that was not a Binance return. Those workbooks, and ones that cannot be opened, are now named in the run log and produce no row. The Parsing Notes baseline is re-recorded: the decoy workbook's row is gone, the other 12 match. A header that repeats an earlier column's name lost the first column's value, since records are keyed by header name. The repeat now carries its column letter, so it is reported under Other Columns and listed in Parsing Notes. Each workbook is read once per run however many are matched. The cache held 16 and did not keep a failed open, so a return of 17 or more workbooks was reread by each of the 38 artifacts, and an unreadable one was retried by each. The module docstring said nothing in a recognised workbook is dropped; it now names the zero-amount rows that are left out and where they are counted. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qmjfBRpcweABqm9Epc
The pattern was *.xlsx, which off Windows does not match a workbook whose extension is in upper case; the module lower-cased the name only after the seeker had already left the file out. The extension is now matched with one bracket class per letter. Checked with fnmatch.fnmatchcase: .xlsx, .XLSX and .Xlsx match, .xls, .xlsm and .xlsx.bak do not. The case file records the new pattern; the case zips and baselines are unchanged and all 38 units match. A block's 'Note:' row was read as its note only when it stood in place of the header, as in every return observed. Under a header row it became a record. It is now the block's note in both positions, before any record. The second position has only been exercised on synthetic rows. The misplaced indentation of seven "notes" keys and the lines over 120 characters are fixed; the notes and descriptions read the same as before. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01Krp9qmjfBRpcweABqm9Epc
Maxitelmo
force-pushed
the
feat/binance-returns
branch
from
November 12, 2026 02:51
0424767 to
ab9244a
Compare
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.
What this changes
Adds
scripts/artifacts/binanceReturns.py, which parses the .xlsx workbook Binance produces in response to legal process. It reads both layouts seen so far: the 2022 one, with 8 or 18 sheets and an Account Balance sheet, and the 2024 one, with 30 sheets and an Assets Overview sheet. It produces 38 artifacts under the Binance Returns category. A workbook is recognised by its content, a Customer Information sheet plus an Access Logs sheet, not by its file name. It usesopenpyxl, which is already inrequirements.txt.What it covers:
check_in_embedded_media, and the format is sniffed from the bytes rather than the extension.Nothing in a workbook is dropped silently:
Rows a balance block lists for an asset or pair the account holds nothing of are not listed. A row counts as empty when every amount is zero, blank or
-and it carries no column the artifact does not name. Current Assets keeps such a row if it has a deposit address or a label/memo. Block Index gives the number of rows left out per block, in Rows Not Listed, and Parsing Notes gives the count for Current Assets. In the 2022 returns, compared cell by cell, more than 90% of the futures and margin rows and 96% of the Current Assets rows were empty this way.For a new or changed artifact
media/byte for byte, and all 865 device attribute pairs are present.python admin/scripts/check_artifact_output.py <report folder>on that report and fixed or documented every finding. Each empty, constant or identical column was checked against the source cells; none is a parsing defect. Each one is named in that artifact'snotes, and the checker now reports nothing to look at.notesanddescriptionsay only what the data shows, and the numbers were re-derived from the finished run. The module has nosample_datablock.Anything reviewers should know
caseSYNTH001) is built byadmin/test/scripts/gen_binance_synth.py, and every value in it is invented: documentation IP ranges, example.com addresses,SYNTHidentifiers and plain colour images. Before pushing, I searched every committed file, the cells and XML inside the test zips, and the commit messages for every value in the real returns. Only generic words and round amounts matched.🤖 Generated with Claude Code
https://claude.ai/code/session_01Krp9qn6BCzbC9Y1p1oUTAc