Metadata-Version: 2.5
Name: personal-finance-etl
Version: 12.3.0
Summary: Local-first personal financial systems platform for investment accounting, reconciliation, tax evidence, wealth analytics, FIRE planning, and BI.
Project-URL: Homepage, https://github.com/tks18/personal-finance-etl
Project-URL: Documentation, https://github.com/tks18/personal-finance-etl
Project-URL: Repository, https://github.com/tks18/personal-finance-etl
Project-URL: Issues, https://github.com/tks18/personal-finance-etl/issues
Project-URL: Changelog, https://github.com/tks18/personal-finance-etl/blob/master/CHANGELOG.md
Author-email: Shan <tksudharshan@gmail.com>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Keywords: analytics-engineering,data-engineering,data-lineage,duckdb,etl,fifo,financial-analytics,financial-data-engineering,fire,investment-analytics,local-first,monte-carlo,personal-finance,polars,portfolio-analytics,power-bi,quantitative-finance,reconciliation,sqlite,tax-analytics
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.13
Requires-Dist: customtkinter>=6.0.0
Requires-Dist: duckdb>=1.5.5
Requires-Dist: fastexcel>=0.20.2
Requires-Dist: filelock>=4.0.3
Requires-Dist: numba>=0.66.0
Requires-Dist: openpyxl>=3.1.5
Requires-Dist: pillow>=12.3.0
Requires-Dist: polars>=1.42.1
Requires-Dist: psutil>=7.2.2
Requires-Dist: pyarrow>=25.0.0
Requires-Dist: pydantic>=2.13.4
Requires-Dist: python-dateutil>=2.9.0.post0
Requires-Dist: pyxirr>=0.10.8
Requires-Dist: rich>=15.0.0
Requires-Dist: tkcalendar>=1.6.1
Requires-Dist: tomlkit>=0.15.2
Requires-Dist: types-psutil>=7.2.2.20260518
Requires-Dist: types-python-dateutil>=2.9.0.20260716
Requires-Dist: uuid>=1.30
Requires-Dist: yfinance>=1.5.1
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/tks18/personal-finance-etl/master/src/personal_finance_etl/presentation/assets/logo.png" width="145" alt="Personal Finance ETL logo">
</p>

# Personal Finance ETL

<p align="center">
  <strong>Local-first personal finance engine — raw statements in, reconciled DuckDB truth out. Zero cloud.</strong>
</p>

<p align="center">
  <a href="https://pypi.org/project/personal-finance-etl/"><img src="https://img.shields.io/pypi/v/personal-finance-etl?label=PyPI" alt="PyPI"></a>
  <img src="https://img.shields.io/badge/Python-3.13%2B-3776AB?logo=python&amp;logoColor=white" alt="Python">
  <a href="https://www.gnu.org/licenses/gpl-3.0"><img src="https://img.shields.io/badge/License-GPL--3.0-blue.svg" alt="GPL-3.0-or-later"></a>
  <img src="https://img.shields.io/badge/Compute-Polars-CD792C" alt="Polars">
  <img src="https://img.shields.io/badge/Warehouse-DuckDB-FFF000?logo=duckdb&amp;logoColor=000" alt="DuckDB">
  <img src="https://img.shields.io/badge/Control%20Plane-SQLite-003B57?logo=sqlite&logoColor=white" alt="SQLite">
  <img src="https://img.shields.io/badge/Desktop-CustomTkinter-1E293B" alt="CustomTkinter">
</p>

---

## What's the vibe?

**Personal Finance ETL (PFETL Core)** is the local-first data & accounting engine that turns messy household records, broker statements, market prices, and FX rates into a clean, reconciled **DuckDB** warehouse (`Bronze` → `Silver` → `Gold`).

No spreadsheets held together by vibes, and no third-party cloud tracking your money. Everything runs on your machine, keeps a full audit trail in a **SQLite Control Plane**, and publishes Gold marts ready for dashboards, SQL, or BI tools.

### Two-part ecosystem

PFETL is split into two separate repos that work together cleanly:

- **PFETL Core** _(this repo)_ — ingests evidence, runs FIFO lot accounting, XIRR, tax classification, FX attribution, reconciliation, and FIRE Monte Carlo simulations, and writes the outputs.
- **[PFETL Analytics Studio](https://github.com/tks18/pfetl-analytics-studio)** ([PyPI](https://pypi.org/project/pfetl-analytics-studio/)) — the read-only NiceGUI + Plotly web/desktop UI that reads Core's outputs for interactive charts, drill-downs, read-only SQL, and PDF/PPTX/XLSX/CSV exports.

---

## How it all connects

```mermaid
flowchart LR
    subgraph EVIDENCE["Your Files & Market Data"]
        HH["Household SQLite"]
        INV["Broker / Investment Statements"]
        REF["Reference Data"]
        MKT["Market / Benchmark / FX (yfinance)"]
    end

    subgraph CORE["PFETL Core (this repo)"]
        CP[("Control Plane SQLite")]
        WH[("DuckDB · Bronze / Silver / Gold")]
        FIN["Engines: FIFO · Tax · Wealth · FIRE"]
        LOGS["Forensic JSONL + pipeline.lock"]
    end

    subgraph CONSUMERS["Where You View It"]
        CLI["pfetl CLI"]
        GUI["CustomTkinter Operator UI"]
        STUDIO["PFETL Analytics Studio"]
        BI["Power BI / Any SQL Client"]
    end

    HH --> CP
    INV --> CP
    REF --> CP
    MKT --> WH
    CP --> WH
    WH --> FIN
    FIN --> WH
    CP --> LOGS

    WH --> CLI
    WH --> GUI
    WH --> STUDIO
    CP --> STUDIO
    LOGS --> STUDIO
    WH --> BI
```

### How Core & Analytics Studio talk

Core doesn't hard-couple to Studio's UI code, and Studio doesn't import `personal-finance-etl`. Instead, they share a clean local contract:

- **Outputs:** `Personal_Finance_DB.duckdb`, Control Plane SQLite, `Settings.toml`, `FinancialRules.toml`, Forensic JSONL logs, and `pipeline.lock` (so Studio never touches DuckDB mid-run).
- **Desktop launch:** The PFETL Core CustomTkinter app can launch and supervise **Analytics Studio** directly with your active `Settings.toml` + `FinancialRules.toml` and monitor it over `/healthz`.

---

## What Core actually computes

| Domain                 | What it does                                                                                                                                                                |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Household Finance**  | Income, expense, and transfer classification; active vs passive income; core vs non-core spend; operating/investing/financing cashflows; liquidity & runway                 |
| **Investments & FIFO** | Chronological FIFO lot matching, partial lot depletion, remaining cost basis, realized/unrealized P&L, broker quantity reconciliation, and concentration metrics            |
| **Performance & FX**   | Pre-tax & after-tax XIRR (`pyxirr`), CAGR, benchmark-relative alpha, drawdown, and asset vs FX return attribution                                                           |
| **Tax Evidence**       | Multi-FY tax events, indicative ledger + investment tax liability, TDS/tax credits, net payable, ledger-vs-quant reconciliation, and LTCG maturity / loss-harvesting flags  |
| **Wealth & FIRE**      | Market vs book net worth attribution, FI / Lean FI / Coast FI targets, savings velocity, and deterministic + Monte Carlo (P10/P50/P90) simulations accelerated with `numba` |
| **Ops & Provenance**   | Incremental file hashing, retained source payloads, provider retry/cache logs, Settings/Rules snapshots, `snapshot` / `restore` backups, and `doctor` diagnostics           |

---

## Install & Run

Requires **Python 3.13+**.

### Grab it

```bash
# From PyPI
pip install personal-finance-etl
pfetl

# Or from source with uv
git clone https://github.com/tks18/personal-finance-etl.git
cd personal-finance-etl
uv sync
uv run pfetl
```

### CLI commands

```bash
pfetl                                              # Launch desktop operator UI
pfetl --gui                                        # Explicit GUI mode
pfetl run --config config.toml --rules rules.toml  # Run full ETL pipeline
pfetl run --config config.toml --rules rules.toml --cron  # Unattended / scheduled run
pfetl status --config config.toml                  # Latest run & sync status
pfetl info --config config.toml                    # Warehouse & system info
pfetl doctor --config config.toml --rules rules.toml      # Run diagnostics
pfetl snapshot --config config.toml                # Create backup archive
pfetl restore backup_archive.zip --config config.toml     # Restore from backup
pfetl --version                                    # Show installed version
```

---

## Repo Layout & Stack

```text
src/personal_finance_etl/
├── application/       # Pipeline orchestration & use cases
├── bootstrap/         # Dependency wiring
├── config/            # Settings & FinancialRules TOML models
├── contracts/         # Typed cross-layer contracts
├── domain/            # Financial logic (FIFO, XIRR, tax, wealth, FIRE)
├── infrastructure/    # DuckDB, SQLite Control Plane, yfinance, recovery, Studio supervisor
└── presentation/      # CLI & CustomTkinter operator console
```

| Layer               | Libraries                                                   |
| ------------------- | ----------------------------------------------------------- |
| Compute & Warehouse | Polars, DuckDB, PyArrow, Numba, pyxirr                      |
| Storage & Config    | SQLite, Pydantic, tomlkit, fastexcel, openpyxl, filelock    |
| Market Data         | yfinance                                                    |
| UI & CLI            | CustomTkinter, Rich, Pillow, tkcalendar                     |
| Packaging & Quality | Hatchling, PyInstaller, Ruff, Mypy, Pyright, Pylint, Pytest |

---

## Dev & Vibe Checks

```bash
uv run pytest
uv run poe audit-fast
uv run poe audit-full
uv run pylint src tests
```

---

## Author & License

Built by **Shan TK (me)** — check out the companion UI at **[PFETL Analytics Studio](https://github.com/tks18/pfetl-analytics-studio)** ([PyPI](https://pypi.org/project/pfetl-analytics-studio/)).

Licensed under the **GNU General Public License v3.0 or later (GPL-3.0-or-later)**. See [LICENSE](LICENSE).
