#finance #cli #flex #reports #interactivebrokers

bin+lib ibflex

A library and a CLI for reading Interactive Brokers Flex reports and comparing to Ledger-cli transactions

19 releases (7 breaking)

0.8.0 Jan 25, 2023
0.7.1 Jan 25, 2023
0.6.2 Jan 20, 2023
0.5.1 Jan 17, 2023
0.1.0 Dec 26, 2022

#25 in Finance

Download history 31/week @ 2022-12-20 107/week @ 2022-12-27 107/week @ 2023-01-03 77/week @ 2023-01-10 117/week @ 2023-01-17 95/week @ 2023-01-24

396 downloads per month

GPL-3.0-or-later

57KB
1K SLoC

interactive-brokers-flex-rs

Tools to assist with IB Flex reports and Ledger-cli comparison

This crate contains a CLI application and is also a library which assists working with Flex Reports from Interactive Brokers. It simplifies the Flex Query download and compares the downloaded transactions (distributions and tax) to the records in Ledger, identifying missing ones.

There are several components in the package:

  • The command-line application (CLI) ibflex, provides all the features of the ibflex library
  • ibflex library exposes the following functionality:
    • downloads the IB Flex Query report
    • parses IB Flex Query report
    • runs Ledger-cli to retrieve the transactions in the last 60 days
    • compares the Cash Transactions from the downloaded Flex Query .xml report to the Ledger transactions
  • as-symbols crate provides the Symbol mapping between IB Flex report and Ledger. I.e. symbol VHYL in the report is VHYL_AS in Ledger.

The project started as a rewrite of my Python scripts and is intended to be expanded as needed, to parse Flex Queries.

Configuration

To view the current configuration, run

ibflex cfg

The config file will be created automatically if it does not exist.

To edit the values, use any text editor.

Symbols Configuration

See as-symbols crate for instructions on how to set up the symbols data file. At the moment this is required for the symbol mapping. The symbols in IB (i.e. VHYL) may be mapped to a different symbol in Ledger (i.e. VHYL_AS).

Usage

Downloading the Flex Query report requires Query Id and the Token. These can be passed in several ways:

  1. as parameters to the download (Dl) method. Use parameters --queryid and --token.
  2. as environment variables:

The application will read the values from environment variables:

  • IBFLEX_TOKEN
  • IBFLEX_QUERYID
  1. in the configuration file: The application will read the configuration file ibflex.toml, which is located in the current directory. See the section below.

Download

The required parameters for downloading the Flex report are:

  • flex_query_id
  • ib_token

Once this is set up, invoke the CLI:

ifblex dl

This will save the report in the current directory. The filename will contain today's date.

Comparison

To compare the transactions, run

ibflex cmp

This will compare the downloaded IB transactions to the transactions in Ledger. The new Dividend and Tax transactions will be reported as New. The other transactions will be reported as Skipped.

Changelog

See Changelog

Credits

License

See LICENSE file.

Dependencies

~11–20MB
~388K SLoC