Ahmer Nadeem Khan
Return to research

Personal Quant Research & Trading Engine

A systematic equity research and execution platform built from scratch in Python, designed to take trading strategies from hypothesis through backtesting to paper (and eventually live) execution on US equities via Alpaca.

Paper Trading

Portfolio Dashboard

89.8% Annualized return Compound annual growth rate (CAGR). Measures the geometric average yearly return over the full period.
1.55 Sharpe ratio Excess return per unit of total volatility, annualized. Higher is better; above 1.0 is generally considered good.
-36.9% Max drawdown Largest peak-to-trough decline on the equity curve. Measures worst-case loss from a high point.
54.7% Win rate Fraction of trading periods with positive returns. Context-dependent — a low win rate can still be profitable with large winners.
1.59 Sortino ratio Like Sharpe, but only penalizes downside volatility. Better for asymmetric return distributions.
2.43 Calmar ratio Annualized return divided by max drawdown. Measures return per unit of tail risk.
49.2% Annualized volatility Standard deviation of returns, annualized. Measures total dispersion of returns around the mean.
1.31 Profit factor Gross profits divided by gross losses. Above 1.0 means the strategy is net profitable.
NVDA equity curve showing growth of $1 from Jan 2024
NVDA daily returns equity curve (Jan 2024 – May 2026). Red shading indicates drawdown periods.
Last updated: 16 May 2026
How these metrics are computed

All metrics are computed on simple (not log) returns, indexed by trading day. Risk-free rates are compounded per-period rather than linearly approximated. Default annualization assumes 252 trading days per year.

Sharpe ratio. Measures excess return per unit of total volatility: $$\text{SR} = \frac{\bar{r} - r_f}{\sigma} \cdot \sqrt{N}$$ where $\bar{r}$ is the mean period return, $r_f$ is the per-period risk-free rate computed as $(1 + R_f)^{1/N} - 1$, and $N = 252$.
Sortino ratio. Penalizes only downside volatility, using the root-mean-square of negative excess returns: $$\text{Sortino} = \frac{\bar{r} - r_f}{\sigma_d} \cdot \sqrt{N}, \qquad \sigma_d = \sqrt{\frac{1}{n^-} \sum_{r_i < r_f} (r_i - r_f)^2}$$ where $n^-$ counts only periods with returns below the risk-free rate.
Maximum drawdown. The largest peak-to-trough decline on the cumulative equity curve: $$\text{MDD} = \min_t \left( \frac{V_t - \max_{\tau \leq t} V_\tau}{\max_{\tau \leq t} V_\tau} \right), \qquad V_t = \prod_{i=1}^{t}(1 + r_i)$$
Calmar ratio. Annualized return per unit of tail risk: $$\text{Calmar} = \frac{\text{CAGR}}{|\text{MDD}|}$$
Annualized return. Compound annual growth rate (CAGR): $$\text{CAGR} = \left(\prod_{i=1}^{n}(1 + r_i)\right)^{N/n} - 1$$ where $n$ is the number of observed periods and $N = 252$.
Annualized volatility. Standard deviation of returns, scaled to annual: $$\sigma_{\text{ann}} = \sigma(r) \cdot \sqrt{N}$$
Win rate. Fraction of periods with positive returns: $$\text{WR} = \frac{|\{i : r_i > 0\}|}{n}$$
Profit factor. Ratio of gross gains to gross losses: $$\text{PF} = \frac{\sum_{r_i > 0} r_i}{\left|\sum_{r_i < 0} r_i\right|}$$

Pipeline

Data
Alpaca API ingestion, Parquet storage with incremental updates
Alpha
Factor research, signal generation, composite scoring
Strategy
Signal combination, target weight computation
Portfolio
Position sizing, risk constraints, rebalancing
Execution
Order routing, fill handling, slippage modeling
Analytics
22 metrics, IC analysis, tearsheet, vectorized backtester

Solid border indicates implemented modules. Dashed border indicates modules under development.

Progress

May 2026

Benchmark-relative & distribution metrics

Added beta, alpha (Jensen's), tracking error, information ratio, up/down capture, VaR, CVaR, skewness, kurtosis, tail ratio, and expected tail ratio. Full tearsheet redesign with 22-metric dashboard. 119 unit tests.

May 2026

Alpha framework & vectorized backtester

Built abstract alpha base class with four factors (momentum, cross-sectional momentum, RSI, Bollinger z-score). Implemented vectorized backtester with dollar-neutral positioning, transaction cost modeling, and IC analysis module.

May 2026

Performance analytics suite & data exploration

Implemented Sharpe, Sortino, Calmar, max drawdown, win rate, profit factor with full edge-case handling. Published data exploration notebook covering return distributions, cross-sector correlations, and volatility dynamics.

Apr 2026

Historical data pipeline

Built Alpaca market data client and Parquet-based storage with smart incremental fetching, deduplication, and multi-timeframe support (1min to daily).

Apr 2026

Core domain model

Designed type-safe data structures (Bar, Signal, Order, Fill, Position) using frozen dataclasses and enums. Established project scaffold with strict typing and linting.

Tooling & Quality

Language
Python 3.13
Type checking
mypy (strict mode)
Linting
ruff
Testing
pytest
Packaging
pyproject.toml + hatchling
Data format
Apache Parquet (columnar, compressed)
Libraries
Pandas, NumPy, Pydantic, Alpaca SDK, PyArrow

Attributes

Status
Active development (paper trading)
Period
2026 – present
Affiliation
Independent research
Market
US Equities
Broker
Alpaca (paper + live)
Repository
GitHub