A plugin for ofxstatement that processes Fidelity Investments CSV files ("Activity & Orders") and converts them to OFX format. This allows you to import your Fidelity investment history into personal accounting software like GnuCash, HomeBank, or MoneyWiz.
- Robust Parsing: Handles standard Fidelity CSV exports, including US-style number formatting (e.g.,
"1,234.56"), Excel BOMs, and various date formats. - Stable IDs: Generates unique transaction IDs based on the date and chronological sorting. This ensures that
20250101-1is always the same transaction, preventing duplicates when you import the same date range twice. - Smart Mapping: Supports a wide range of transaction types:
- Buys/Sells: Stocks, ETFs, Mutual Funds.
- Income: Dividends (Cash or Reinvested), Interest.
- Transfers: EFT, Direct Deposit, Direct Debit.
- Fees: Commissions, Foreign Tax, ADRA Fees.
If you simply want to use the plugin, install it directly from the source:
pip3 install --user .
To set up a development environment to modify the code or run tests:
# Install in editable mode
pip3 install --user -e .
# Install build/test dependencies
pip3 install build pytest mypy
(Note: If you prefer pipenv, you can still use pipenv sync --dev and pipenv shell as configured in the Pipfile.)
After installation, configure ofxstatement to use this plugin. Add the following section to your configuration file (usually located at ~/.config/ofxstatement/config.ini):
[fidelity]
plugin = fidelity
currency = USD
account = fidelity
- Log in to Fidelity.com.
- Navigate to Accounts & Trade > Portfolio.
- Select the specific account you want to export.
- Click on the Activity & Orders tab.
- Select the Time Period (e.g., "Past 90 days" or "Custom").
- Click the Download link (usually at the top right of the transaction list).
- Save the file (e.g.,
History_for_Account_123456789.csv).
Run the ofxstatement tool:
ofxstatement convert -t fidelity History_for_Account_123456789.csv history.ofx
Import the resulting history.ofx file into GnuCash or your preferred finance software.
Fidelity does not provide ratio information for stock splits in their CSV export, which is required for the OFX <SPLIT> element. Additionally, GnuCash has limited support for importing OFX <SPLIT> elements.
To ensure data is at least imported, this plugin generates <TRANSFER> transactions for splits and spin-offs. You will likely see a warning or a generic transfer in your ledger.
Recommendation for GnuCash: A common approach is to manually edit the imported transaction:
- Treat a split (e.g., 4:1 on 100 shares) as a net 300 share transfer.
- Adjust the transaction to:
- -100 shares at a sale price of the remaining cost basis.
- +400 shares at a buy price of the remaining cost basis.
This preserves the per-share gain calculations, though the date may not perfectly align for long-term capital gain tax tracking.
This project uses pytest and a Makefile for convenience. The test suite includes an iterative runner that checks all CSV files found in the tests/ directory.
make test
To build a distributable wheel:
python3 -m build
If you encounter a transaction type that causes a crash or is not parsed correctly:
- Obfuscate your data: Do not upload raw financial statements to GitHub. Use the included tool to scrub personal data (Account IDs, Balances, Descriptions):
python3 tools/obfuscate.py ~/Downloads/History_for_Account_REAL.csv
This creates a safe version (e.g., History_for_Account_TEST1234.csv) with randomized values and sanitized strings.
2. Verify: Open the output file to ensure no PII remains.
3. Submit: Open an issue and attach the obfuscated CSV (or the specific line causing the error) so we can add the missing regex mapping.