Build a personal finance tracker with Python

Personal finance can become tangled quickly when income, rent, groceries, transport and superannuation sit in different places. A Python-based tracker brings those movements into one calm view. Instead of guessing from a bank screen, you can see what arrived, what left, and which habits are shaping your week. The aim is not perfect bookkeeping; it is a dependable routine that answers basic questions without demanding constant admin.

A strong tracker starts small: a transaction list, a handful of categories, and a monthly summary. It should work for an Australian household, accept the formats your bank provides, and keep sensitive data under your control. Python suits the job because standard libraries can handle CSV files, dates, currency, reports and a local database without turning the project into an expensive software build.

Start with the life you actually live

Choose the decisions the tracker must support. Perhaps you want to check whether groceries are rising, confirm that a subscription was charged twice, or see how much remained after fixed bills. Write these down before choosing fields or charts. A tracker built around a real question is easier to maintain than one designed to imitate every feature of a commercial budgeting package.

Begin with a one-month boundary and simple categories such as housing, groceries, transport, utilities, health, fun and income. Separate transfers from spending so moving money to savings or superannuation does not look like an expense. Record refunds as positive amounts and keep uncertain entries in an “unclassified” group rather than forcing them into the wrong bucket.

Model money in Python

Represent each transaction as a small object with a posting date, description, amount, category and account label. Python's dataclass keeps the shape clear, while Decimal avoids the rounding surprises that appear when currency is stored as a floating-point number. The account field becomes useful once you compare a transaction account with a general spending category.

from dataclasses import dataclass
from datetime import date
from decimal import Decimal

@dataclass
class Transaction:
    posted: date
    description: str
    amount: Decimal
    category: str
    account: str

Use ISO dates for storage and Australian dollars for display. A dictionary can work for a prototype, but lists of transaction objects make later filtering and testing more dependable. If lists and dictionaries still feel abstract, the Python data structures guide offers a useful bridge from stored rows to reusable code.

Bring in transactions without losing control

Many Australian banks let customers download transaction histories as CSV, although each export may label columns differently. Build an import mapping that recognises the date, description, debit or credit amount, and balance fields you actually use. Treat every file as untrusted input: strip stray symbols, standardise dates and reject malformed rows instead of letting one bad record break the whole run.

Deduplication matters because downloaded files often overlap. A combination of account, posted date, amount and merchant description can form a stable key, while preserving genuine repeated purchases such as two $4.50 coffees. For live bank access, request read-only credentials through the institution's supported channel, store them outside source code and never hard-code a password in a script.

Calculate the numbers that matter

Derive spending from negative transaction amounts and income from positive ones, then group by category and month. Useful outputs include net cash flow, the savings rate, fixed-cost share and a comparison with the previous month. Keep transfer accounts visible in the overall balance but exclude internal transfers from category totals; otherwise a move to savings can appear to reduce spending and distort every report.

income = sum((t.amount for t in txns if t.amount > 0), Decimal("0"))
spend = sum((-t.amount for t in txns if t.amount < 0), Decimal("0"))
savings_rate = (income - spend) / income if income else Decimal("0")

Never divide by zero when calculating a savings rate, and decide whether refunds net against their original category or count as income. Charts should make one point clear at a time: bars for category totals, a line for month-to-month change, and a separate balance view. For interface inspiration, a look at the Rocketplay site can prompt the same design question: does each colour, block and label help the reader understand the next figure?

Make the tracker feel Australian

Local details should shape the data model rather than sit in a footnote. Amounts are in Australian dollars, many sales include 10% GST, and the personal financial year runs from 1 July to 30 June. Superannuation contributions and the Medicare levy can sit beside ordinary wages on a payslip, while a separate super transfer may reach your account.

Payment habits matter too. PayID, BSB-and-account-number transfers, BPAY and the big four banks—Commonwealth Bank, ANZ, NAB and Westpac—are familiar parts of household banking. Retain the original merchant description even after assigning a cleaner category, since a shortened label can erase useful context about what was purchased.

Place names and transport can also sharpen categories: a Myki top-up in Melbourne and an Opal fare in Sydney are not the same event. Australian users may say they are “sorting out” spending or “socking away” cash for a goal; those plain phrases can become friendly category labels. Natural language is less important than making every category recognisable at a glance.

Test the code and protect the data

Give the calculation functions tests before adding charts. Cover refunds, duplicate rows, salary timing, a month with no spending, an unclassified merchant and a transfer between tracked accounts. Property-based ideas can help, but ordinary unit tests for totals, filtering and percentage handling are enough for a small personal project. Keep sample transactions anonymous so a colleague or open-source project cannot identify your real financial life.

Store raw exports and the local database outside folders that a public repository might capture. On a shared computer, use operating-system permissions and disk encryption; if an API is unavoidable, keep access tokens in environment variables or a secret manager. Back up the encrypted database regularly, but test that a restore actually opens and contains the expected records.

Version the code and keep a short changelog whenever the import format changes. A monthly test run against a clean copy of one bank export will reveal whether a renamed column or changed date format has quietly broken the pipeline. These checks turn an improvised script into a tool that can be trusted when the figures matter.

Build a simple monthly rhythm

Automation is valuable only when its output is easy to check. Run the import after the relevant bank statements settle, generate a short Markdown or HTML report, and keep exceptions visible. A quiet layout with readable type, restrained colour and generous whitespace lets the numbers remain the focus.

During the week, use a three-item check:

At the end of each month, run a second review:

The result is a small, repeatable loop rather than a demanding accounting ritual. For an example of calm, presentation-led web design, the C9 Indian homepage uses nature-inspired imagery and clear visual hierarchy to reinforce that principle. Clear records and brief reviews keep the tracker useful long after the first month has passed.

Contact