MIT © 2025 Maria Westrin
A reproducible, bank-style analytics pipeline that goes from raw transaction rows (BUY/SELL/DIVIDEND) → clean panel data → risk metrics + exposures → shareable HTML report.
This project demonstrates an end-to-end workflow a data analyst/quant analyst would deliver:
- Data quality checks & validation (sanity checks, duplicates, missingness)
- Position building from transactions (signed volume/value, cumulative holdings)
- Daily portfolio panel construction (price/position/market value/exposure)
- Risk reporting (VaR, volatility, drawdown) + segment analyses
- Professional artifacts: HTML report + figures + CSV tables
- HTML report:
report/portfolio_risk_report.html - Figures:
report/figures/*.png - Tables:
report/*.csv
Tip: add 1–2 screenshots from the HTML report into
assets/and show them here.
- Reads
financial_raw_data.csv - Type casting for
dateandtimestamp - Overview table of dtypes, missingness, and basic stats
- Duplicate checks (
transaction_id) - Consistency check:
price_per_share * volume ≈ transaction_value - Flags relative error and inspects worst rows
- Signed volume/value (BUY = +, SELL = −)
- Instrument key primarily from
ticker_symbol(fallbacks exist) - Cumulative
position_unitsper instrument over time
- Daily snapshot per instrument
- Daily price series from last trade per day + forward-fill
- Returns computed from price (and optional comparison vs
daily_returnif present)
- Computes portfolio return via P&L / Gross Exposure: [ r_t = \frac{\sum_i pos_{t-1,i}(P_{t,i}-P_{t-1,i})}{\sum_i |pos_{t-1,i}P_{t-1,i}|} ]
- Stable even if net exposure is near zero (gross-based denominator)
- Historical VaR 95% (daily)
- Daily + annualized volatility
- Max drawdown on equity curve
- Exposures by sector and risk rating
- Optional signal check:
analyst_rating(t)→next-day return(t+1)and robust regression outputs (HC3)
This repo does not need to publish your private dataset. The notebook expects a CSV with transaction rows.
transaction_iddate,timestampticker_symbol(or equivalent identifier)transaction_type(BUY/SELL/DIVIDEND)price_per_share,volume,transaction_valuecurrency
company_name,sectorrisk_rating,liquidity_score,spread_pctanalyst_ratingdaily_return(if present, used for QC comparison)
- Open
Financial_Analysis.ipynb(orfinancial_analysis_maria_westrin.ipynb) - Restart Kernel → Run All
- Open
report/portfolio_risk_report.html
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
jupyter notebook