A CLI tool to categorize and analyze bank transaction exports (XLS/XLSX).
Project description
BankTamer
banktamer is a Python 3.13+ CLI utility designed to process bank transaction files (XLS/XLSX), categorize operations using regex-based pattern matching, and generate detailed financial reports.
Features
- Standardized Ingestion: Support for multiple bank formats via JSON schemas.
- Regex Categorization: Fully customizable category rules using YAML.
- Monthly Analytics: Automatic grouping by month with totals for income, expenses, and net balance.
- Visual Insights: Automatic generation of colorful terminal bar charts, financial distribution pie charts, and category evolution line charts (tracking Incomes/Expenses over time).
- Modern Reporting: Export options to professional PDF documents for easy sharing and record keeping.
- AI-Powered Insights: (Optional) Integrated financial advisor that analyzes your spending patterns and provides actionable saving suggestions using providers like OpenAI, Anthropic, Gemini, or local models via Ollama.
- Modern Tooling: Managed with
uvfor high performance and strict type safety. - CI/CD Ready: GitHub Actions pipeline for automated formatting, linting, and 100% test coverage verification.
User Guide
Prerequisites
- Python 3.10+
uv(installed viabrew install uv)
Clone the repository and install dependencies locally:
make install
Installation Options
1. Global Installation (via pipx)
To install banktamer as a global command on your system:
# From the local repository
pipx install .
# Or from Git directly
pipx install git+https://github.com/diegojromerolopez/banktamer.git
Configuration
banktamer looks for configuration in the following order:
- CLI Flags:
--config-dir,--schemas, or--rules-dir. - Local Folder:
./config/in your current directory. - User Home:
~/.banktamer/config/. - Package Defaults: Bundled internal configuration (fallback).
To set up your global configuration (optional), copy the bundled config to your home directory:
mkdir -p ~/.banktamer
cp -r banktamer/config ~/.banktamer/
Usage
Once installed, use the banktamer command:
# General usage
banktamer --bank <bank-name> --category <category-name> --files <path-to-excel> [path-to-other-excel ...]
# Example: Santander with common rules
banktamer --bank santander --category common --files downloads/extract_2024.xlsx
# Example: Multiple files from the same bank
banktamer --bank santander --category common --files extract_jan.xlsx extract_feb.xlsx extract_mar.xlsx
# Example: Using custom config directory
banktamer --bank santander --config-dir /path/to/my/config --files data.xlsx
# Example: Generating a professional PDF report
banktamer --bank santander --category common --files data.xlsx --report pdf --output report_2024.pdf
# Example: AI Analysis with local Ollama
banktamer --bank santander --category common --files data.xlsx --ai ollama
AI Financial Analysis
BankTamer includes an optional AI-powered financial advisor that can analyze your categorized data and provide:
- Detailed spending pattern summaries.
- Actionable money-saving suggestions.
- Identification of unusual category spikes or trends.
Supported Providers
| Provider | Requirement | Flag |
|---|---|---|
| Ollama | Running local instance | --ai ollama |
| OpenAI | API Key (OPENAI_API_KEY) |
--ai openai |
| Anthropic | API Key (ANTHROPIC_API_KEY) |
--ai anthropic |
| Gemini | API Key (GOOGLE_API_KEY) |
--ai gemini |
| Hugging Face | API Key (HUGGINGFACE_API_KEY) |
--ai huggingface |
Local AI (Ollama) Smart Selection
If you use --ai ollama without specifying a model, BankTamer performs intelligent auto-discovery:
- Llama 3 First: It prioritizes
llama3if it's installed on your system. - Resource Efficient: If
llama3is missing, it automatically picks the smallest available general-purpose model to save memory. - Privacy & Quality: It automatically skips remote "cloud" links and "coder" specialized models (like
deepseek-coder) to ensure you get high-quality financial advice strictly on your local machine.
To override the selection, use --ai-model <model_name>.
Customizing AI Prompts (ai_settings.yaml)
You can customize the AI's persona and instructions by creating an ai_settings.yaml file in your configuration directory (e.g., ~/.banktamer/config/ai_settings.yaml).
prompt_templates:
financial_analysis: |
You are a strictly frugal financial advisor.
Analyze the following data and be very critical of any non-essential spending.
{summary}
The {summary} placeholder is optional; if present, it will be replaced by the monthly financial data. If absent, the data will be appended to your custom prompt.
Running directly with uv
If you prefer not to use make, you can run the tool directly using uv run:
uv run python -m banktamer.cli --bank santander --category common --files path/to/file.xlsx
Configuration Details
Bank Schemas (config/schemas.json)
Defines column mappings and date formats.
date_col: Name of the date column.concept_col: Name of the transaction description column.amount_col: Single column for amount (positive/negative).income_col/expense_col: Separate columns for income and expenses.skiprows: Number of header rows to ignore in the Excel file.
Categorization rules (config/categories/<category>.yaml)
Add regex patterns to classify transactions. Categories are independent of the bank schema. Patterns are matched case-insensitively by default.
Default Rules (config/categories/.default.yaml)
If present, rules in .default.yaml are always applied. If a specific --category is provided, its rules are merged with the default ones.
Developer Guide
Project Structure
banktamer/
├── banktamer/ # Core source code
│ ├── analytics.py # Aggregation logic
│ ├── categorizer.py # Regex engine
│ ├── cli.py # Entry point & CLI logic
│ ├── config/ # Bundled JSON schemas & YAML rules (DEFAULTS)
│ ├── io.py # Excel ingestion
│ ├── report/ # Reporting engine
├── tests/
│ ├── unit/ # Unit tests (100% coverage mandatory)
│ └── integration/ # Integration tests (verifying banks & happy paths)
├── GEMINI.md # Critical AI/Developer coding rules
├── Makefile # Development automation
└── pyproject.toml # Dependencies & Config
Development Workflow
Use the provided Makefile for standard tasks:
- Format code:
make format - Lint code:
make lint(Ruff & Mypy) - Run all tests:
make test-all - Tag and push release:
make tag(triggers GitHub Release and PyPI publication)
Testing Strategy
banktamer follows a strict testing hierarchy to ensure reliability:
- Unit Tests (
tests/unit): Fast tests focusing on individual functions and classes. 100% code coverage is mandatory. - Integration Tests (
tests/integration):- Schema Verification: Every bank defined in
config/schemas.jsonis automatically verified against generated Excel files to ensure parsing logic is correct. - Happy Paths: End-to-end functional flows for different bank formats (unified vs. split amounts).
- Schema Verification: Every bank defined in
Run specific test suites:
make test # Unit tests only
make test-integration # Integration tests only
make test-all # All of the above
Adding a New Bank
- Add the column mapping to
config/schemas.json. - Assign an existing category file or create a new one in
config/categories/<category>.yaml. - Run integration tests:
make test-integration. The schema verification test will automatically pick up your new bank and verify it parses correctly.
Coding Standards
- Rules: See GEMINI.md for strict requirements (100% coverage, no relative imports, etc.).
- Line Length: 120 characters.
- Type Hints: Mandatory for all functions (verified via
mypy). NoAnyallowed. - Python Version: Strictly 3.10+ using native generics (e.g.,
list[str]).
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 banktamer-0.1.1.tar.gz.
File metadata
- Download URL: banktamer-0.1.1.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21155fb2f07abc9b3c944afd0ec7bd2803e3ada5ad71a403ef07a49170e009b0
|
|
| MD5 |
9006a8a65284eaf6579cfa0fd85df1b6
|
|
| BLAKE2b-256 |
a9ef22c6a6f905bf08fd83ab74216bb4c1ac90225793cdf99e49e57a01e79540
|
Provenance
The following attestation bundles were made for banktamer-0.1.1.tar.gz:
Publisher:
publish_on_pypi.yml on diegojromerolopez/banktamer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
banktamer-0.1.1.tar.gz -
Subject digest:
21155fb2f07abc9b3c944afd0ec7bd2803e3ada5ad71a403ef07a49170e009b0 - Sigstore transparency entry: 1311929496
- Sigstore integration time:
-
Permalink:
diegojromerolopez/banktamer@562e2332c41cc3db1b700d1670b850b01cc95887 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/diegojromerolopez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_on_pypi.yml@562e2332c41cc3db1b700d1670b850b01cc95887 -
Trigger Event:
release
-
Statement type:
File details
Details for the file banktamer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: banktamer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee3d480cc7e8336a9368e1addb7cb355ec38ca57b75c3e8300b8729e4ef117c0
|
|
| MD5 |
2de209ee0b178ed64b5b1036e0ee8749
|
|
| BLAKE2b-256 |
b6225abbcdc6c46208b512fa0fa74084ab59a63a4c27e1c8028516a8b1453f6e
|
Provenance
The following attestation bundles were made for banktamer-0.1.1-py3-none-any.whl:
Publisher:
publish_on_pypi.yml on diegojromerolopez/banktamer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
banktamer-0.1.1-py3-none-any.whl -
Subject digest:
ee3d480cc7e8336a9368e1addb7cb355ec38ca57b75c3e8300b8729e4ef117c0 - Sigstore transparency entry: 1311929544
- Sigstore integration time:
-
Permalink:
diegojromerolopez/banktamer@562e2332c41cc3db1b700d1670b850b01cc95887 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/diegojromerolopez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_on_pypi.yml@562e2332c41cc3db1b700d1670b850b01cc95887 -
Trigger Event:
release
-
Statement type: