Skip to main content

bankstatementparser-writer-ofx logo

bankstatementparser-writer-ofx

Writes bankstatementparser transactions as OFX 1.02 bank statements that accounting and personal-finance software can import.

Build Registry Docs OpenSSF Scorecard License: Apache-2.0 OR MIT Python 3.10+

A terminal printing the installed version, 0.0.36, then the two examples: two transactions written as OFX statement blocks, and a CSV statement converted to an OFX file and parsed back into four transactions


Contents

Getting started

The bankstatementparser-writer-ofx ecosystem

Library reference

Operational


Install

As a Python library

pip install bankstatementparser-writer-ofx

That installs the writer, bankstatementparser >= 0.0.35 and pandas.

Channel Command Notes
PyPI pip install bankstatementparser-writer-ofx Pulls in bankstatementparser >= 0.0.35
Source git clone https://github.com/sebastienrousseau/bankstatementparser-writer-ofx && cd bankstatementparser-writer-ofx && poetry install For local development

Verify the installation:

python -c "import bankstatementparser_writer_ofx as w; print(w.__version__)"
# -> 0.0.36

An isolated virtual environment keeps its dependencies apart:

python -m venv venv
source venv/bin/activate        # macOS/Linux
venv\Scripts\activate           # Windows
python -m pip install -U bankstatementparser-writer-ofx

Requirements

  • Python 3.10 or later. CI tests CPython 3.10, 3.11, 3.12, 3.13 and 3.14 on Linux, macOS and Windows; docs/POLICIES.md says when the floor moves.
  • bankstatementparser 0.0.35 or later, for the Transaction model and the parsers that feed the writer, and pandas, which it brings.

Quick Start

from bankstatementparser import create_parser

from bankstatementparser_writer_ofx import write_ofx

# 1. Parse a statement in any format the core supports
parser = create_parser("statement.csv")

# 2. Write it as an OFX 1.02 bank statement
write_ofx(
    parser,
    "statement.ofx",
    bank_id="123456789",
    account_id="987654321",
    currency="EUR",
)

write_ofx accepts the parser itself (it calls parse()), the DataFrame parse() returns, a list of Transaction objects or a list of dicts, and returns the Path it wrote. to_ofx takes the same arguments without the destination and returns the document as a string.


The bankstatementparser-writer-ofx ecosystem

bankstatementparser is a modular suite whose packages ship one version together. This package is its OFX writer; the full table, with every loader, writer and server, is in The suite.

Component Purpose Use case
bankstatementparser The parser core: CAMT, pain.001, CSV, OFX, QFX, MT940 and PDF statements Parsing statements from Python or the CLI
bankstatementparser-writer-ofx Transactions to OFX 1.02 Importing statements into accounting tools
Other writers XLSX, QIF and SWIFT MT940/MT942 Other export formats
Loaders BAI2, MT942, CFONB, CAMT.054, SEPA and BACS Formats beyond the core
bankstatementparser-transport-ebics, bankstatementparser-mcp, bankstatementparser-lsp EBICS data, Model Context Protocol and Language Server Protocol Bank downloads, AI agents and editors

Capabilities at a glance

Area Capability Status
Input list[Transaction], pandas.DataFrame, list[dict], or a core parser object Shipped
OFX structure <SIGNONMSGSRSV1>, <BANKMSGSRSV1>, <STMTRS>, <BANKTRANLIST> and <LEDGERBAL> Shipped
Transactions <TRNTYPE> (CREDIT, DEBIT), <DTPOSTED>, <TRNAMT>, <FITID>, <NAME>, <MEMO> Shipped
Escaping &, < and > in every value; newlines removed Shipped
OFX 1.02 SGML The format written Shipped
OFX 2.x XML Not written Not implemented

Ecosystem comparison

The choice is between this one-call writer for parsed statements and a full OFX library. Every cell comes from this repository or the other project's PyPI description.

Project OFX 1.x OFX 2.x Writes from
bankstatementparser-writer-ofx Yes (1.02) No bankstatementparser transactions
ofxtools Yes Yes Its own OFX object model

See docs/COMPARISON.md for the evidence and complete matrix.


Benchmarks

benches/bench_to_ofx.py times one to_ofx call for each input shape as the statement grows. Cost is linear: about 5 us per transaction from dicts, 12 us from Transaction objects and 20 us from a DataFrame.

Scenario Result Environment
1,000 Transaction objects 11.4 ms Apple M1 Pro, macOS 27.2.1, CPython 3.12.16
10,000 Transaction objects (1.4 MiB of OFX) 116 ms Apple M1 Pro, macOS 27.2.1, CPython 3.12.16
10,000-row DataFrame 197 ms Apple M1 Pro, macOS 27.2.1, CPython 3.12.16

See docs/BENCHMARKS.md for methodology and full results.


Features

  • to_ofx(data, bank_id="123456789", account_id=None, account_type="CHECKING", currency="EUR") -> str: serialises transactions to an OFX 1.02 document.
  • write_ofx(data, destination, bank_id="123456789", account_id=None, account_type="CHECKING", currency="EUR") -> Path: writes that document to destination as UTF-8, creating missing parent directories.

Each record becomes one <STMTTRN>: <TRNAMT> from the amount (two decimals), <TRNTYPE> CREDIT for a positive amount and DEBIT otherwise, <DTPOSTED> from the date, <FITID> from the transaction ID or reference, <NAME> from the payee or description and <MEMO> from the memo or reference. <DTSTART> and <DTEND> span the record dates and <BALAMT> is the sum of the amounts. The Usage page has the full mapping and fallbacks.


Configuration

There is no configuration file or environment variable; the writer's arguments are the configuration:

Argument Default Meaning
bank_id "123456789" <BANKID>
account_id None <ACCTID>; when None, the first record's account, else 0000000000
account_type "CHECKING" <ACCTTYPE>, e.g. SAVINGS or CREDITLINE
currency "EUR" <CURDEF>; while it is EUR, the last record's currency wins

Examples

examples/ holds two runnable scripts, each run in CI:

Example Demonstrates
01_basic_usage.py Two Transaction objects written with to_ofx
02_advanced_workflow.py A CSV statement (examples/data/statement.csv) converted to an OFX file with write_ofx and parsed back

When not to use bankstatementparser-writer-ofx

  • You need OFX 2.x (XML). Only OFX 1.02 SGML is written.
  • Your names are not ASCII and your importer is strict. The header declares ENCODING:USASCII and CHARSET:1252, but write_ofx writes UTF-8.
  • You need a bank-reported balance. <LEDGERBAL> is the sum of the written transactions.
  • You need bad input reported. An unparseable, NaN, infinite or out-of-range amount is written as 0.00 and a missing date as the current time, without an error.
  • You need transaction types beyond credit and debit (CHECK, FEE, PAYMENT and the like).
  • You need to read OFX. Use the core bankstatementparser, which parses OFX and QFX.

Development

git clone https://github.com/sebastienrousseau/bankstatementparser-writer-ofx.git
cd bankstatementparser-writer-ofx
poetry install
make check

make check runs the local gates: ruff lint and format, mypy --strict, Bandit, the complexity baseline (scripts/check_complexity.py), pytest with a 100% line and branch coverage floor, interrogate at 100% docstring coverage, the examples and the README template check. Other targets: make bench, make fuzz (Atheris, 60 s, Linux x86_64 with Python 3.12+), make docs (the MkDocs manual, --strict), make audit (pip-audit on the locked sets) and make demo (re-renders the GIF above with VHS from .github/demo.tape). CI adds the OS by Python matrix, the fuzz job, CodeQL and the Docs Lint gates. CONTRIBUTING.md covers the workflow and commit rules.


Security

  • No network and no reads. The writer opens no connection and reads no file; write_ofx writes only to the path you give.
  • Escaping. Every value from the records or the arguments has &, < and > escaped and newlines removed, so record text cannot open or close an OFX element.
  • Fuzzing. fuzz/fuzz_to_ofx.py drives to_ofx with Atheris in CI and fails on any exception, a lost record, a malformed amount or markup in an element value. It found the unescaped dates and currency and the out-of-range amounts fixed in 0.0.36.
  • Supply chain. Dependencies are locked in poetry.lock, CI installs hash-pinned exports of it, and pip-audit, Bandit and CodeQL run on every change. Releases publish to PyPI through OIDC trusted publishing and carry cosign signatures, SLSA provenance and SBOMs; every workflow action is pinned by commit SHA except the SLSA generator, which must be referenced by tag.

Report vulnerabilities according to SECURITY.md.


Documentation


Stability guarantees

  • Versioning. Releases stay on the 0.0.x line and step by exactly 0.0.1, in lockstep with the rest of the bankstatementparser suite. Under SemVer a 0.0.x release may break anything; this project names each break in the CHANGELOG instead.
  • The breaking axis is the output: the OFX the writer produces for a given input. A change to an element, its value or its fallback is called out in the CHANGELOG as breaking, even when no Python signature moves.
  • Python API. to_ofx and write_ofx keep their names and arguments; names starting with _ are internal.
  • Minimum toolchain. Python 3.10 is the floor; it moves only in a release, for the whole suite at once, with the reason in the CHANGELOG (docs/POLICIES.md).

License

Dual-licensed under Apache License, Version 2.0 or MIT, at your option (SPDX-License-Identifier: Apache-2.0 OR MIT). Any contribution submitted for inclusion in the work shall be dual-licensed as above, without additional terms or conditions.

Metadata

Release files for bankstatementparser-writer-ofx 0.0.36

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bankstatementparser-writer-ofx 0.0.36
File Size Uploaded Provenance Actions
bankstatementparser_writer_ofx-0.0.36.tar.gz 19.0 kB With provenance Details for bankstatementparser_writer_ofx-0.0.36.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bankstatementparser-writer-ofx 0.0.36
File Interpreter ABI Platform Actions
bankstatementparser_writer_ofx-0.0.36-py3-none-any.whl Python 3 none any Details for bankstatementparser_writer_ofx-0.0.36-py3-none-any.whl

Total release size: 35.1 kB

Release files / bankstatementparser_writer_ofx-0.0.36.tar.gz

Download URL bankstatementparser_writer_ofx-0.0.36.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b5871bb4d75ad039eee3bcdbf0245fb667840045948227f8df15d4692c6615a1
BLAKE2b-256 checksum
How to use checksums
3e53de72b157b8f3fe2939c86c4c6eb7873b5fa22ed9207a14473a7f93e9936e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / bankstatementparser_writer_ofx-0.0.36-py3-none-any.whl

Download URL bankstatementparser_writer_ofx-0.0.36-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1124a4c96928b8b60028ddb68f05878910bb8c64a77897b5e9ce7cb887aaee42
BLAKE2b-256 checksum
How to use checksums
319b68a3824e962327cfb5223148ee70ac7704fc5fbfa2f16e07cc79ff973bf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for bankstatementparser-writer-ofx 0.0.36

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bankstatementparser_writer_ofx-0.0.36.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page