About This Project

PSX Analyzer is a quantitative analysis tool for the Pakistan Stock Exchange. It computes standard financial metrics and presents them in an interactive web interface backed by a static historical dataset.

Data Update Notice

Support ended in June 2026. Automated delayed PSX data updates have been discontinued. PSX does not permit delayed data usage in this context (including non-commercial and educational use). We believe this restriction should apply to live licensed feeds only, but we are complying with the current policy. The site remains available with a static, historical dataset and no automatic data refresh.

WhatStatus
Automated pipelineDisabled (June 2026)
Scheduled refresh jobsDisabled
Data modeStatic historical dataset
Site availabilityOnline for research and archival analysis
Data Sources
DataPrimary SourceFallback
Company listings & sectorsPSX Data Portal (dps.psx.com.pk)Internal PSX API Fetcher
Daily close & volumePSX /timeseries/eod/{SYMBOL}—
KSE-100 IndexPSX /timeseries/eod/KSE100 (2021–present)Yahoo Finance ^KSE (2010–2021)
USD/PKR exchange rateYahoo Finance (USDPKR=X)Bundled CSV
CPI / InflationWorld Bank API FRED → Bundled CSV
SBP Policy RateFRED APIBundled CSV
Fundamentals (P/E, EPS, etc.)PSX Data Portal company pages—
Metric Definitions
MetricDefinition
Total Return(Last Close − First Close) / First Close
CAGRCompound Annual Growth Rate: (Last/First)^(1/years) − 1
VolatilityStd. deviation of daily log returns, annualized (× √245 trading days)
Max DrawdownLargest peak-to-trough decline over the full history
Sharpe Ratio(CAGR − risk-free rate) / Volatility. Risk-free rate = avg SBP policy rate
BetaCov(stock, KSE-100) / Var(KSE-100), computed from daily log returns
CorrelationPearson correlation of daily log returns vs KSE-100
Real CAGRCAGR minus average annual CPI inflation
Volume Trend30-day avg volume / 90-day avg volume (above 1 = rising)
Disclosure & Limitations
CSV Data Files

master.csv

169.0 KB — 606 companies, 26 columns of summary metrics

sectors.csv

3.9 KB — 37 sectors with aggregate statistics

macro_kse100.csv

85.9 KB — KSE-100 daily close (2010–2026)

macro_usdpkr.csv

191.3 KB — USD/PKR daily rate (2010–2026)

macro_cpi.csv

0.3 KB — Annual CPI inflation (World Bank)

macro_tbill.csv

0.3 KB — SBP policy rate history

Source Code (Python)

The full pipeline and application code. Read these to understand exactly how every number was computed.

config.py

3.5 KB — Configuration, paths, API endpoints, constants

fetcher.py

22.3 KB — Stock data fetching from PSX Data Portal

macro.py

11.7 KB — Macro data: KSE-100, USD/PKR, CPI, T-bill

metrics.py

8.8 KB — Per-stock metric computation (CAGR, Sharpe, beta, etc.)

sectors.py

5.3 KB — Sector-level aggregation

fundamentals.py

5.8 KB — Fundamentals scraping (P/E, EPS, dividend yield)

export.py

3.7 KB — CSV export logic

run_pipeline.py

6.4 KB — Pipeline orchestrator

app.py

36.8 KB — Flask application, routes, chart generation

freeze.py

9.5 KB — Static site generator for Netlify deployment

run.py

4.0 KB — Main entry point (CLI)