A library for generating OFX files.
Project description
OFX Generator
This repository provides a Python library for generating OFX (Open Financial Exchange) files. It includes data models, formatters, and a generator to create OFX 2.3 XML documents according to the OFX specification.
How to Use
Example: Generating an OFX File
-
Create a Bank Statement: Define the financial institution, bank account, transactions, balance, and settings.
from datetime import date from decimal import Decimal from ofx_generator.models import ( Balance, BankAccount, BankStatement, CreditCardAccount, FinancialInstitution, OFXSettings, Transaction ) from ofx_generator.standards import AccountType, Currency, Language, TransactionType fi = FinancialInstitution(org="Example Bank", fid="000") account = BankAccount( bank_id="000", branch_id="0000-0", account_id="000000000", account_type=AccountType.CHECKING, ) transactions = [ Transaction( transaction_type=TransactionType.PAYMENT, date_posted=date(2025, 1, 30), amount=Decimal("-100.00"), fit_id="202501300000", check_num="000", ref_num="000", memo="Payment to Vendor", ), Transaction( transaction_type=TransactionType.CREDIT, date_posted=date(2025, 1, 22), amount=Decimal("500.00"), fit_id="202501220000", check_num="000", ref_num="000", memo="Salary Payment", ), ] balance = Balance(amount=Decimal("1000.00"), date_as_of=date(2025, 1, 31)) settings = OFXSettings( language=Language.PORTUGUESE, currency=Currency.BRAZILIAN_REAL, version=211, ) credit_card_account = CreditCardAccount( cash_advance_available_amount=1000.00, cash_advance_credit_limit=5000.00 ) statement = BankStatement( financial_institution=fi, bank_account=account, transactions=transactions, balance=balance, start_date=date(2025, 1, 1), end_date=date(2025, 1, 31), settings=settings, credit_card_account=credit_card_account )
-
Generate the OFX File: Use the
OFXGeneratorto create the OFX content and write it to a file.from ofx_generator.generator import OFXGenerator generator = OFXGenerator() trnuid = "1001" ofx_content = generator.generate(statement, trnuid) with open("output.ofx", "w", encoding="utf-8") as f: f.write(ofx_content)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ofx_generator-0.1.0.tar.gz.
File metadata
- Download URL: ofx_generator-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3cd39c370bc794628b45501d2a85964278235e3fffdd984d022e76c7a369ff1
|
|
| MD5 |
48ac908bb4713c093481ee056461bbb8
|
|
| BLAKE2b-256 |
f940d90e68769e886e5000636a281d822e3845aa9bfd32a8c037133ca60068ab
|
File details
Details for the file ofx_generator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ofx_generator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea741a3359e3f2e3b3c1889622ea96ce8dc08ccdceb5c10bdf9c84e5d29a8449
|
|
| MD5 |
34dfa15c12e9d3a3b17dbda309efa5ab
|
|
| BLAKE2b-256 |
226d816ac6da902bdf098bbd29412f36579dd5da0543081328d083d89aea4d85
|