Skip to content

๐Ÿ“Š Portfolio Analytics Lab: A professional-grade performance and risk engine for JSE equities. Built with Python & Streamlit.

Notifications You must be signed in to change notification settings

Dame-Sky/Portfolio-Analytics-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

44 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ŠAbout Portfolio-Lab โ€” Portfolio Analytics Dashboard

Overview

Portfolio-Lab is a web-based portfolio analytics application built with Streamlit. GitHub Repo

It is designed to help investors reconstruct, evaluate, and understand their portfolios through a professional-grade performance and risk analytics pipeline.

This version of the platform focuses on Jamaica Stock Exchange (JSE) listed equities.

Users manually input transactions, and the system rebuilds holdings, valuations, performance, attribution, and risk metrics from first principles.

At this stage, Portfolio-Lab does not persist user data and is intended as an analytics laboratory rather than a brokerage or trading platform.


Purpose

Portfolio-Lab was built to explore how institutional-grade portfolio analytics can be made transparent, interpretable, and accessible.

Rather than emphasizing trading, the app is centered on:

  • understanding portfolio construction
  • measuring performance correctly
  • identifying sources of return (alpha)
  • evaluating portfolio risk and diversification
  • diagnosing exposure to market, currency, and structural factors
  • building financial intuition through structure

This project treats portfolios not as tickers, but as evolving financial systems.


Core Capabilities

๐Ÿ” Portfolio Reconstruction Engine

  • Transaction-based holdings reconstruction
  • Corporate-action aware quantity roll-forward
  • Cost basis tracking
  • Multi-currency normalization into JMD
  • Historical valuation snapshots

๐Ÿ“ˆ Performance Engine

  • Simple returns
  • Time-Weighted Rate of Return (TWRR)
  • Money-Weighted Rate of Return (MWRR / IRR)
  • CFA-aligned TWRR logic (non-annualized sub-year periods)
  • Portfolio valuation history builder

๐Ÿงฎ Attribution Engine

  • Asset-level attribution
  • Sector-level attribution
  • Brinson-Hood-Beebower (BHB) model
  • Brinson-Fachler (BF) model
  • Allocation, selection, and interaction effects

Designed to evaluate where returns came from โ€” not only how much.


โš–๏ธ Risk Lab

  • Volatility analysis
  • Correlation heatmap
  • Diversification ratio
  • Sharpe ratio
  • Value-at-Risk (95% and 99%)
  • Marginal, incremental, and component VaR
  • Asset and sector risk attribution

Built to explore how portfolio structure influences risk.

๐ŸŒ Market Exposure & Factor Diagnostics

  • Excess return regression against market indices
  • FX sensitivity analysis (USD/JMD)
  • Index-relative beta estimation
  • Portfolio alpha diagnostics
  • Statistical significance testing (t-stats, p-values)
  • Model integrity checks (Rยฒ, Durbinโ€“Watson, condition number)
  • Residual analysis and attribution reconciliation

This module is designed to explore why a portfolio behaves the way it does relative to the market, not to optimize or predict returns.

Architectural Design

Portfolio-Lab is structured as a set of independent but connected financial engines:

  • valuation_engine.py โ†’ portfolio valuation logic
  • holdings_engine.py โ†’ transaction โ†’ holdings reconstruction
  • returns_engine.py โ†’ TWRR / MWRR / performance metrics
  • sector_engine.py โ†’ sector aggregation & attribution
  • attribution_engine.py โ†’ BF / BHB performance attribution
  • risk_engine.py โ†’ risk & VaR analytics
  • exposure_engine.py โ†’ market, FX, and factor exposure modeling
  • ui_components.py โ†’ shared UI primitives, tables, charts, and diagnostics

The Streamlit app orchestrates these engines into interactive workflows:

  1. 1_Transactions.py
  2. 2_Holdings.py
  3. 3_Performance_Attribution.py
  4. 4_Risk_Attribution.py
  5. 5_Market_Exposure.py

This modular structure allows each financial problem domain to remain isolated, testable, and extensible.


Distinctiveness

Portfolio-Lab differs from typical โ€œportfolio trackersโ€ in that it is built as a multi-engine financial infrastructure rather than a dashboard wrapper.

It reconstructs portfolios from raw transactions and evaluates them across:

  • valuation
  • performance
  • attribution
  • risk
  • and market exposure

using academically grounded and industry-standard models.

The emphasis is not on visualizing prices, but on explaining portfolio behavior.


Complexity Statement

This project addresses several technically and conceptually complex domains:

  • transaction-driven portfolio reconstruction
  • cash-flow-neutral performance measurement
  • benchmark-relative attribution modeling
  • historical valuation pipelines
  • decomposed portfolio risk
  • and market exposure

Each engine required aligning financial theory, accounting identities, and software design into a consistent system.

Portfolio-Lab represents an applied attempt to translate institutional portfolio analytics into an interpretable, user-facing platform.


Project Structure

portfolio-analytics-dashboard/
โ”‚
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ pages/
โ”‚ โ”œโ”€โ”€ 1_Transactions.py
โ”‚ โ”œโ”€โ”€ 2_Holdings.py
โ”‚ โ”œโ”€โ”€ 3_Performance_Attribution.py
โ”‚ โ”œโ”€โ”€ 4_Risk_Attribution.py
โ”‚ โ””โ”€โ”€ 5_Market_Exposure.py
โ”‚
โ”œโ”€โ”€ attribution_engine.py
โ”œโ”€โ”€ holdings_engine.py
โ”œโ”€โ”€ returns_engine.py
โ”œโ”€โ”€ risk_engine.py
โ”œโ”€โ”€ sector_engine.py
โ”œโ”€โ”€ valuation_engine.py
โ”œโ”€โ”€ exposure_engine.py
โ”œโ”€โ”€ simulation_engine.py
โ”œโ”€โ”€ ui_components.py
โ”œโ”€โ”€  docs/
โ”‚ โ”œโ”€โ”€  app_screenshots/
โ”‚ โ”œโ”€โ”€ documentation.md
โ”‚ โ”œโ”€โ”€ howtouse.md
โ”‚ โ”œโ”€โ”€ howtoreadmarketexposure.md
โ”‚ โ”œโ”€โ”€ glossaryofterms.md
โ”‚ โ””โ”€โ”€ security.md
โ””โ”€โ”€

Access

This application is deployed via Streamlit Cloud and is not distributed as open-source software.

Authorized users can access the live dashboard here:

Streamlit App

No local installation is required.


Reproducibility

The mathematical framework underlying this system is documented in the /docs directory.

Source code is private, but the computational methodology is fully documented for academic transparency.


Current Limitations

  • No user authentication

  • No persistent database

  • Manual transaction input only

  • JSE equity focus

  • Not intended for live trading or investment advice

  • Brinson Attribution Sensitivity: The Brinson-Fachler (BF) and Brinson-Hood-Beebower (BHB) models in this lab assume fixed beginning-of-period weights.

      Note: Large intra-period capital flows (buys/sells) can distort attribution results. If significant trading occurs mid-period, the attribution effects may not fully reconcile with the Portfolio's total return.
    
  • Portfolio-Lab is currently an analytics sandbox and research platform.

Out-of-Scope (Planned)

  • Portfolio simulation engine
  • Optimization framework
  • Automated data ingestion
  • User profiles and storage
  • Scenario and stress-testing modules
  • Development Philosophy

This project is not positioned as a finished financial product.

๐Ÿ›ก๏ธ Security & Privacy

Reference data is stored in an AES-256 encrypted volume and decrypted in-memory during session initialization to ensure data integrity. We take data privacy seriously. Portfolio-Lab does not persist user data. * All uploaded transactions are processed in-memory and destroyed when the session ends.

It is an evolving collaboration between human design, financial theory, and artificial intelligence โ€” built to explore how portfolio intelligence tools can be constructed, validated, and eventually democratized.

Portfolio-Lab is an experiment in learning, architecture, and applied finance.

Additional Documentation

GitHub Repo

๐Ÿ“˜ User Guide
๐Ÿง  Technical Docs

๐Ÿค Get Involved

About

๐Ÿ“Š Portfolio Analytics Lab: A professional-grade performance and risk engine for JSE equities. Built with Python & Streamlit.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published