This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
# `ofxtools`

## Description

`ofxtools` is a Python library for working with Open Financial Exchange (OFX)
data - both OFXv1 (SGML) and OFXv2 (pure XML) - which is the standard format
for downloading financial information from banks and stockbrokers.

`ofxtools` has no external dependencies beyond stdlib, and is compatible with
Python version 2.7+ and 3.1+.

The primary facilities provided include:
- The `OFXClient` class; which dowloads OFX statements from the Internet
- The `OFXTree` class; which parses OFX data into a standard ElementTree
structure for further processing in Python.
- The `OFXResponse` class; which validates and converts OFX data parsed by
OFXParser into Python types and exposes them through more Pythonic
attribute access (e.g. `OFXResponse.statements[0].ledgerbal`).

Also included is the `ofxtools.ofxalchemy` subpackage, with versions of OFXTree
and OFXResponse that can parse OFX formatted data and persist it into an SQL
database.

`ofxalchemy` depends on [the SQLAlchemy package](http://www.sqlalchemy.org).
You'll need SQLAlchemy version 1.0 or higher.


# Installation

Use the Python user installation scheme:

python setup.py install --user

In addition to the Python package, this will also install a script `ofxget`
in `~/.local/bin`, and its sample configuration file in `~/.config/ofxtools`.

To use `ofxalchemy`, you'll need to install SQLAlchemy via:

pip install sqlalchemy

or

easy_install sqlalchemy

or download and install the package from [the SQLAlchemy
website](http://www.sqlalchemy.org) or from
[PyPI](https://pypi.python.org/pypi/SQLAlchemy)


# Basic Usage to Download OFX

- Copy `~/.config/ofxtools/ofxget_example.cfg` to
`~/.config/ofxtools/ofxget.cfg` and edit:
- Add a section for your financial institution, including URL, account
information, login, etc.
- See comments within.
- Execute `ofxget` with appropriate arguments, for example:

```
ofxget amex stmt -s 20140101 -e 20140630 > foobar.ofx
```

See the `--help` for explanation of the script options.


## Parser Usage Example

```python
>>> from ofxtools import OFXTree
>>> tree = OFXTree()
>>> tree.parse('stmtrs.ofx')
>>> response = tree.convert()
>>> response
<ofxresponse fid="1001" org="NCH" dtserver="2005-10-29 10:10:03" len(statements)="1" len(securities)="0">
>>> stmt = response.statements[0]
>>> stmt
<bankstatement account="&lt;BANKACCTFROM" acctid="999988" accttype="CHECKING" bankid="121099999"> currency=USD ledgerbal=<ledgerbal balamt="200.29" dtasof="2005-10-29 11:20:00"> availbal=<availbal balamt="200.29" dtasof="2005-10-29 11:20:00"> len(other_balances)=0 len(transactions)=2>
>>> stmt.transactions[-1]
<stmttrn dtposted="2005-10-20 00:00:00" trntype="ATM" trnamt="-300.00" fitid="00003" dtuser="2005-10-20 00:00:00">
```

## SQL Persistence Example

```python
>>> # SQLAlchemy housekeeping to set up database connection
>>> from ofxtools import ofxalchemy
>>> from sqlalchemy import create_engine
>>> engine = create_engine('sqlite://', echo=False)
>>> from sqlalchemy.orm import sessionmaker
>>> DBSession = sessionmaker(bind=engine)
>>> # Create tables in database
>>> ofxalchemy.Base.metadata.create_all(engine)

>>> # Parse and persist the OFX data
>>> parser = ofxalchemy.OFXParser() # a/k/a ofxalchemy.OFXTree
>>> parser.parse('invstmtrs.ofx')
>>> parser.instantiate(DBSession)
<ofxresponse len(statements)="1" len(securities)="3">
>>> DBSession.commit()
>>> # Besides the returned OFXResponse object, persisted data can now be
>>> # accessed by querying the database. The object model follows the OFX
>>> # specification fairly closely, with data elements represented as instance
>>> # attributes, subaggregate type nesting modeled by polymorphic inheritance,
>>> # and references to other data types replaced by foreign key relationships.
>>> #
>>> # N.B. There is no database structure representing account statements
>>> # (OFX *STMT aggregates); only the transactions, balances, etc. contained
>>> # within a statement are persisted.

>>> from ofxtools.ofxalchemy.models import *
>>> acct = DBSession.query(ACCTFROM).one()
>>> acct
<invacctfrom(brokerid='121099999', acctid="999988" ,="" id="1" )="">
>>> acct.invbals
[<invbal(availcash='200.00', marginbalance="-50.00" ,="" shortbalance="0" ,="" acctfrom_id="1" ,="" dtasof="2005-08-27 01:00:00" )="">]
>>> # The full range of SQLAlchemy query expressions is available.
>>> from datetime import datetime
>>> invtrans = DBSession.query(INVTRAN).filter_by(acctfrom=acct).filter(INVTRAN.dttrade >= datetime(2005,1,1)).filter(INVTRAN.dttrade <= datetime(2005,12,31)).order_by(INVTRAN.dttrade).all()
>>> invtrans
[<buystock(units='100', unitprice="50.00" ,="" commission="25.00" ,="" total="-5025.00" ,="" subacctsec="CASH" ,="" subacctfund="CASH" ,="" buytype="BUY" ,="" secinfo_id="1" ,="" id="1" )="">]
>>> # OFX text data has been validated and converted to Python types, so it
>>> # can be worked with directly.
>>> t = invtrans[0]
>>> assert -t.units * t.unitprice - t.commission == t.total
```

## Contributing

If you want to contribute with this project, create a virtualenv and install
all development requirements:

virtualenv .venv
source .venv/bin/activate
pip install -r requirements-development.txt


Then, run the tests with `make`:

make test

Or directly with `nosetests`:

nosetests -dsv --with-yanc --with-coverage --cover-package ofxtools

Feel free to [create pull
requests](https://help.github.com/articles/using-pull-requests/) on [ofxtools
repository on GitHub](https://github.com/csingley/ofxtools)
Release History

Release History

0.3.13

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.12

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.11

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.7.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.7.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ofxtools-0.3.13.tar.gz (42.9 kB) Copy SHA256 Checksum SHA256 Source Dec 6, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting