Skip to main content

Tools for working with the OFX (Open Financial Exchange) file format

Project description

ofxparse

ofxparse is a parser for Open Financial Exchange (.ofx) format files. OFX files are available from almost any online banking site, so they work well if you want to pull together your finances from multiple sources. Online trading accounts also provide account statements in OFX files.

There are three different types of OFX files, called BankAccount, CreditAccount and InvestmentAccount files. This library has been tested with real-world samples of all three types. If you find a file that does not work with this library, please consider contributing the file so ofxparse can be improved. See the Help! section below for directions on how to do this.

Example Usage

Here’s a sample program

from ofxparse import OfxParser
with codecs.open('file.ofx') as fileobj:
    ofx = OfxParser.parse(fileobj)

# The OFX object

ofx.account               # An Account object

# AccountType
# (Unknown, Bank, CreditCard, Investment)

# Account

account = ofx.occount
account.account_id        # The account number
account.number            # The account number (deprecated -- returns account_id)
account.routing_number    # The bank routing number
account.branch_id         # Transit ID / branch number
account.type              # An AccountType object
account.statement         # A Statement object
account.institution       # An Institution object

# InvestmentAccount(Account)

account.brokerid          # Investment broker ID
account.statement         # An InvestmentStatement object

# Institution

institution = account.institution
institution.organization
institution.fid

# Statement

statement = account.statement
statement.start_date          # The start date of the transactions
statement.end_date            # The end date of the transactions
statement.balance             # The money in the account as of the statement date
statement.available_balance   # The money available from the account as of the statement date
statement.transactions        # A list of Transaction objects

# InvestmentStatement

statement = account.statement
statement.positions           # A list of Position objects
statement.transactions        # A list of InvestmentTransaction objects

# Transaction

for transaction in statement.transactions:
  transaction.payee
  transaction.type
  transaction.date
  transaction.amount
  transaction.id
  transaction.memo
  transaction.sic
  transaction.mcc
  transaction.checknum

# InvestmentTransaction

for transaction in statement.transactions:
  transaction.type
  transaction.tradeDate
  transaction.settleDate
  transaction.memo
  transaction.security      # A Security object
  transaction.income_type
  transaction.units
  transaction.unit_price
  transaction.comission
  transaction.fees
  transaction.total
  transaction.tferaction

# Positions

for position in statement.positions:
  position.security       # A Security object
  position.units
  position.unit_price
  position.market_value

# Security

security = transaction.security
# or
security = position.security
security.uniqueid
security.name
security.ticker
security.memo

Help!

Sample .ofx and .qfx files are very useful. If you want to help us out, please edit all identifying information from the file and then email it to jseutter dot ofxparse at gmail dot com.

Development

Prerequisites::

# Ubuntu sudo apt-get install python-beautifulsoup python-nose python-coverage-test-runner # Python 3 (pip) pip install BeautifulSoup4 six lxml nose coverage # Python 2 (pip) pip install BeautifulSoup six nose coverage

The six package is required for python 2.X compatibility

Tests: Simply running the nosetests command should run the tests.

nosetests

If you don’t have nose installed, the following might also work:

python -m unittest tests.test_parse

Test Coverage Report:

coverage run -m unittest tests.test_parse

# text report
coverage report

# html report
coverage html
firefox htmlcov/index.html

Homepage

License

ofxparse is released under an MIT license. See the LICENSE file for the actual license text. The basic idea is that if you can use Python to do what you are doing, you can also use this library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ofxparse-0.20.tar.gz (53.2 kB view details)

Uploaded Source

Built Distributions

ofxparse-0.20-py3.6.egg (70.2 kB view details)

Uploaded Egg

ofxparse-0.20-py2.7.egg (74.5 kB view details)

Uploaded Egg

File details

Details for the file ofxparse-0.20.tar.gz.

File metadata

  • Download URL: ofxparse-0.20.tar.gz
  • Upload date:
  • Size: 53.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14

File hashes

Hashes for ofxparse-0.20.tar.gz
Algorithm Hash digest
SHA256 eb45db5802938ac0ab3664418ca564619cc9e7ec6d301c1063ffc16e587ec37e
MD5 a3daf82edc5fd1ebee560264a7cdf5e7
BLAKE2b-256 07ab22faf6348652e9ac662b594c35ee9de1dba76b5adcad94a143d317377138

See more details on using hashes here.

File details

Details for the file ofxparse-0.20-py3.6.egg.

File metadata

  • Download URL: ofxparse-0.20-py3.6.egg
  • Upload date:
  • Size: 70.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for ofxparse-0.20-py3.6.egg
Algorithm Hash digest
SHA256 2c0f8bed7eed5ac7b1a8168e3b848f59004db5e16fa89a5df0f3cd9ca9f6b613
MD5 93ebc87678b20362d323ea908b13190b
BLAKE2b-256 5d3be877def34e581ddc5f1847cfc5cb424af67cfdffbf6c8c73bc3469f7d077

See more details on using hashes here.

File details

Details for the file ofxparse-0.20-py2.7.egg.

File metadata

  • Download URL: ofxparse-0.20-py2.7.egg
  • Upload date:
  • Size: 74.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for ofxparse-0.20-py2.7.egg
Algorithm Hash digest
SHA256 12210ec47616b13aaf34de99ff52ff51637b1cb204fb30cd1235e7457ca9e692
MD5 3639bb868735c03a8e8c0c6f88531b88
BLAKE2b-256 0d1afdf95328bae8e9e39f32e9f078241cb8831500f7ff22639bd7e17abcbee6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page