Technical Overview
The system automates the processing of Finansinspektionen’s (FI) quarterly zipped XML reports, converting raw asset filings into normalized, structured datasets. It consolidates portfolio holdings by sector, market capitalization, and performance metrics across historical reporting periods.
Operating as a dual-mode solution, it functions both as an automated background ETL pipeline for recurring quarterly ingestion and as a self-hosted FastAPI + HTMX financial terminal for sub-10ms portfolio queries and filtering.
Core Features & Architecture
Automated Quarterly ETL (Extract–Transform–Load):
- Extract: Detects and downloads FI’s newly published quarterly zipped XML files (e.g.
Fondinnehav 2024Q4 ... .zip). - Transform: Cleans and validates data (ISINs, currencies, duplicates), categorizes securities by sector and market cap, and computes derived metrics (fund performance, AUM growth, QoQ deltas).
- Load: Persists results into PostgreSQL with materialized views (
analytics.mv_holdings_by_quarter) and B-tree indexes on ISINs and fund names.
- Extract: Detects and downloads FI’s newly published quarterly zipped XML files (e.g.
Real-time Financial Terminal (FastAPI + HTMX):
- Sub-10ms server-side filtering and search across millions of holdings.
- Instant sector exposure, market-cap breakdowns, and fund-level analytics without heavy client-side JavaScript.
Schema & Scale:
- ~1.79 million holdings records
- 941 Swedish index funds (active + historical)
- 12-table analytical schema (holdings, sector allocation, market cap breakdown, performance, QoQ deltas, country exposure, asset pricing, ETL logs, etc.)
Infrastructure: Fully containerized via Docker and Docker Compose for reproducible deployment and database setup.
Automated Quarterly Execution (FI Reports)
The pipeline is designed around FI’s quarterly reporting cycle and handles new releases automatically.
- Detection & Extraction: A background/scheduled task checks FI’s public register for newly published quarterly zipped XML reports.
- Ingestion & Validation: Parses XML payloads, standardizes currencies, verifies asset identifiers (ISINs), and updates
control.etl_logwith run metadata and checksums. - Materialized View Refresh: Automatically refreshes
analytics.mv_holdings_by_quarterto reflect the latest quarter end (quarter_end = MAX(quarter_end)). - Dashboard Auto-Update: The FastAPI/HTMX terminal immediately serves the newly published quarter data on the next page refresh or search query.
Real-World Scale & Validation
- Data Volume: ~1.79M holdings records processed and stored.
- Fund Coverage: 941 Swedish index funds (active + historical).
- Analytical Output: 12 structured tables/views enabling sector/market-cap breakdowns, country exposure, asset pricing, fund performance metrics, and QoQ deltas.
Tech Stack & Specs
- Backend Framework: Python 3.11+, FastAPI, Uvicorn
- Frontend / UI: HTMX, HTML5, Jinja2 Templates, CSS
- Database & ORM: PostgreSQL 15+, SQLAlchemy (with materialized views and indexing)
- Data Processing: Pandas, LXML (XML parsing), PyYAML (config)
- Deployment: Docker, Docker Compose; optional scheduler for automated quarterly runs
Live Product & Links
- GitHub Repository: github.com/Devjosef/index-funds-etl