PSX Investor: A FastAPI Tool for Disciplined Stock Investing on the Pakistan Stock Exchange
Description and use
PSX Investor automates target‑weight calculations and share purchases on the Pakistan Stock Exchange, eliminating manual errors and saving time.
Problem
Manual arithmetic for target‑weight investing on the Pakistan Stock Exchange is error‑prone and time‑consuming, especially when dealing with whole‑share constraints, live intraday prices, multiple holdings, and monthly tracking.
Outcome
The tool reduces monthly investment preparation time from minutes of spreadsheet work to a single button click, ensures accurate whole‑share calculations, and keeps all personal data local, enhancing privacy and reliability.
Workflow
- Enter investment amount in the web UI
- FastAPI backend loads portfolio weights from local JSON
- Backend concurrently fetches live prices from dps.psx.com.pk using async HTTP requests
- Backend calculates target PKR per holding, floors to whole shares, computes cost and actual weight
- Backend returns JSON plan to frontend
- Frontend renders plan table for user review
- User records actual purchases via API
- Backend aggregates transaction history to compute average cost, market value, and unrealized P/L
- User reviews updated positions each month
Evidence
PSX Investor is the local tool I built to automate that workflow. It is a FastAPI backend plus a single self-contained HTML page: enter an amount, get a buy plan with live prices, record what you actually purchased, and track positions at cost and market value.
The hard part of disciplined investing is not picking stocks — it is doing the same correct arithmetic every month without letting friction erode the habit.
- Record date: 2026-09-05T15:31:59.503Z