[codex] Add CIB debit and IBKR providers#223
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60d2f98caa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a424e8247d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
感觉没毛病,但是这个pr好像没办法用新provider抽象,我后面看看怎么加比较好一些 |
Summary
This PR adds two provider workflows, refreshes related provider documentation, and includes the shared compiler support needed by the new workflows:
cib_debitprovider/analyser with multi-file CNY/HKD/USD statement support.ibkrprovider/analyser for Interactive Brokers Flex XML exports.CurrencyExchangeIR order type and Beancount/Ledger rendering for paired FX transactions.MultiFileInterfaceto translate multiple input files in one command.cib_debit.ibkr.cib_debit,ibkr, and the existingbocprovider.CIB Debit
The new CIB debit provider parses XLSX exports and supports combining multiple currency statement files in one translation run. The converter detects paired purchase-of-foreign-currency activity and emits one currency-exchange transaction instead of disconnected cash-flow rows.
The analyser supports matching rules over peer, item, type, peer bank, peer account, currency, and timestamps, then maps output to method/target accounts using the existing configuration style.
Included examples cover CNY, HKD, and USD input files plus expected Beancount and Ledger output.
Documentation added:
docs/docs/providers/banks/cib_debit.mddocs/docs/en/providers/banks/cib_debit.mdIBKR
The new IBKR provider parses Flex XML using streaming XML decoding and converts:
Traderows into securities trade IR orders,Traderows such asUSD.HKDinto currency exchange IR orders,CashTransactionrows such as deposits, dividends, withholding tax, interest, and fees into normal cash-flow orders.IBKR metadata such as account id, trade id, transaction id, exchange, ISIN, security id, report date, and settle date is preserved in generated output where present.
The included
example/ibkr/config.yamldemonstrates default IBKR cash/position/fee/PnL accounts and usesbookingMethod: FIFOso generated Beancount can resolve repeated-lot securities sells. This PR also addsexample/ibkr/example-ibkr-records.xmlplus expected Beancount and Ledger outputs, and registersibkrin the e2e provider matrix.Documentation added:
docs/docs/providers/securities/ibkr.mddocs/docs/en/providers/securities/ibkr.mdBOC Documentation
This PR also documents the existing
bocprovider for Bank of China debit and credit card statements. The new pages describe the provider key, supported matching fields, the existing debit-cardpeerbehavior that combines counterparty name and account/card number, and a basicdouble-entry-generator translate --provider boccommand.Documentation added:
docs/docs/providers/banks/boc.mddocs/docs/en/providers/banks/boc.mdThe README provider lists, provider index pages, and Chinese/English MkDocs navigation now include Bank of China.
Compiler And CLI Changes
This PR adds
OrderTypeCurrencyExchangeto the IR and compiler templates for both Beancount and Ledger. The Beancount securities renderer now uses the order currency when present, which is required for non-default-currency broker records.The translate command now accepts multiple input files when a provider implements
MultiFileInterface; providers without that interface still fail explicitly for multi-file input.A new optional global config field,
bookingMethod, writes Beancount'soption "booking_method"header when configured.Documentation Navigation
The provider index and MkDocs navigation now include:
Both Chinese and English navigation trees were updated.
Validation
Ran the following checks locally:
GOCACHE=/private/tmp/double-entry-generator-go-build go test ./... GOCACHE=/private/tmp/double-entry-generator-go-build make test-provider PROVIDER=cib_debit TARGET=beancount GOCACHE=/private/tmp/double-entry-generator-go-build make test-provider PROVIDER=cib_debit TARGET=ledger GOCACHE=/private/tmp/double-entry-generator-go-build make test-provider PROVIDER=ibkr TARGET=beancount GOCACHE=/private/tmp/double-entry-generator-go-build make test-provider PROVIDER=ibkr TARGET=ledger GOCACHE=/private/tmp/double-entry-generator-go-build make test-providers make -C docs buildResults:
38/38 passed.I also tested the newly added BOC config/docs path locally with the existing BOC debit example fixture:
The command completed successfully and produced Beancount output using the existing
bocprovider.I attempted to rerun the original real IBKR XML conversion, but
/Users/triplez/Downloads/last_365_days.xmlwas no longer present in the local environment. The IBKR parser behavior is covered by the new unit test and by the new XML e2e fixture.