Package: beancount-reds-importers
Beancount Red's ImportersSimple importers and tools forBeancount, software forplain text, double entry bookkeeping.More
importantly, a framework to allow you to easily write your own importers.IntroductionThis is a reference implementation of the principles expressed inThe Five Minute Ledger Update.Importers can be ugly and painful to write, yet are important in automating the grunt
work out of maintaining personal finance software. The philosophy is to make writing
sustainable, dependable importers easy. To achieve this, the design separates importers
in to three parts:file format reader (reusable)transaction builder (reusable)institution-specific declarations and code (minimal, institution specific) <-The
only one you have to writeThis design helps move most of the heavy-lifting common code into (1) and (2) above.
Writing new importers is made easier since one only has to write code to address the
institution-specific formatting and quirks for each bank/brokerage. See working examples
of anofx basedandcsvbased importers.ImportersFile format readers included are:.ofx.csv(single and multitable support).xlsx(single and multitable support) (pip3 install xlrdif you plan to use this)Transaction builders included are:Banking (for banks and credit cards, which benefit from a postings predictor likesmart_importer).Investments/brokerages (to handle the very many distinct cases of investment related
transactions).Paychecks (to handle paychecks, which typically contain very many mostly
pre-determined postings in a single entry).Input in.ofxformat (over.csv) is preferred,
when provided by the institution, as it minimizes data and coding errors, eliminates
format breaking changes in .csv files, and typically includes balances that are used to
generate balance assertions, and commodity prices.Seeherefor a list of institutions built-in. More investment, credit card, and banking
institutions will be added in the future. Contributions welcome.Tools and UtilitiesThese commands are installed as a part of the pip installation:ofx-summarize: Quick and dirty way to summarize a .ofx file, and peek inside itbean-download:Download account statements automatically(for supporting institutions), from your configuration of accounts. Multi-threaded.bean-download needs-updateis a configurable utility that shows you the last time
each account was updated, based on the latest balance assertion in your journal. Seethis articlefor more.The commands include shell auto-completion (tab-to-complete) viaclick.bean-download, in
particular, can complete the account or account groups you want to download, which can
be handy. To enable it in zsh, do
(see here for other shells):mkdir -p ~/.zcomplete
_OFX_SUMMARIZE_COMPLETE=zsh_source ofx-summarize > ~/.zcomplete/ofx-summarize-complete.zsh
_BEAN_DOWNLOAD_COMPLETE=zsh_source bean-download > ~/.zcomplete/bean-download-complete.zsh

# Place this in your shell's rc file (.zshrc or .bashrc or .fishrc):
for f in ~/.zcomplete/*; do source $f; doneFeaturessupportsBeancountoutput viabean-extractshould be easy to extend to ledger/hledger, etc. (contributions welcome)automatically generatesbalance assertionssupport for:investment accounts (brokerages including retirement accounts)handles sweep funds, money market funds, and all standard brokerage transactionsbanking and credit cardpaychecksfile format independent (ofx, csv, xlsx supported out of the box; single and
multitable for csv and xlsx; write your own reusable handler if needed)supports commodity-leaf accountsseeThe Five Minute Ledger Updatefor automating downloads viaofxclient, connecting tosmart_importerto
auto-classify transactions, and moreInstallationpip3 install beancount-reds-importersOr to install the bleeding edge version from git:pip3 install git+https://github.com/redstreet/beancount_reds_importersRunningRunning the included examples:cd <your pip installed dir>/example #eg: cd ~/.local/lib/python3.8/site-packages/beancount_reds_importers/example./import.sh OfxDownload.qfx# Imports investments./import.sh transactions.qfx# Import bank transactions; uses smart_importer to classify transactionsCreating and running your own config:Create your own my.import. An example my.import is provided. At the least, include your account numbersInclude fund information. Copy the includedfund_info.pyto start with.You can now runbean-identify,bean-extract, etc. See the included script: Run./import.sh <your_input_ofx>If identifier/cusip/isin info is missing, the importer will let you know. Add it to yourfund_info.pySeethis articlefor automating and managing identifier infoConfiguring balance assertion datesChoices for the date of the generated balance assertion can be specified as a key in
the importer config,balance_assertion_date_type, which can be set to:smart:            smart date (default; see below)ofx_date:         date specified in ofx filelast_transaction: max transaction datetoday:            today's dateIf you want something else, simply override this method in individual importersmartdates: Banks and credit cards typically have pending transactions that are not
included in downloads. When we download the next statement, new transactions may appear
prior to the balance assertion date that we generate for this statement. To attempt to
avoid this, we set the balance assertion date to either two days (fudge factor to
account for pending transactions) before the statement's end date or the last
transaction's date, whichever is later. To choose a different fudge factor, simply setbalance_assertion_date_fudgein your config.NoteDepending on the institution, thepayeeandnarrationfields in generated
transactions may appear to be switched. This is described bylibtransactionbuilder/banking.py,
and the fields can be swapped in acustom_init.TestingFirst:pip3 install xlrdSome importers are tested withregression_pytest.py.
Runpytest --generatethenpytest.Anonymized data to increase regression test coverage is most welcome. Please submit a
PR if you can. Seeherefor an example to follow.More broadly I run tests across hundreds of actual ofx and csv files, against reference
outputs that I know to be correct from my personal file. However, I'm unable to share
them since these are personal. Testing against real world files is best, so I recommend
you do this with your own input files.ContactFeel free to post questions/concerns in theBeancount groupsor onThe Five Minute Ledger Updatesite. For bugs, open an issue here on Github.ContributionsFeatures, fixes, and improvements welcome. New importers for institutions with test
input files appreciated. Sharing importers helps the community! Remember:Feel free to send send pull requests. Please include unit testsFor larger changes or changes that might need discussion, please reach out and discuss
first to save time (open an issue)Please squash your commits (reasonably)Useconventional commitsfor commit messagesThank you for contributing!