Appendix A · Quick-reference formula sheet
Every formula in the course, checked against the primary literature, in a single reference.
How to use this formula sheet. This appendix condenses every operational formula in the course into two dense tables — one per area — using the exact notation of modules 7 through 9. Each row gives the concept, the formula, the symbols to fix before computing, and the usage caution; the most frequently consulted formulas also appear as display blocks, outside the table, so they can be copied at a glance. Global conventions: losses are positive unless stated otherwise; \(r_t\) = log return; \(\alpha\) = tail level (0.01 for 99% VaR); \(z_\alpha = \Phi^{-1}(1-\alpha)\); \(\varphi, \Phi\) = standard normal density and CDF; \(w\) = weights, \(\Sigma\) = covariances, \(\mathbf{1}\) = vector of ones. And the golden rule of the course: no formula is executed by the LLM — the LangChain agent orchestrates, explains, and alerts; the number is always produced by a deterministic tool.
13.1 Risk and performance
13.1.1 Formula table: delta-normal/historical/Monte Carlo VaR, ES/CVaR (Rockafellar-Uryasev), realized volatility, EWMA λ=0.94, GARCH(1,1), MDD, Sharpe/Sortino/Omega/Calmar/Sterling/Ulcer, beta, TE/IR + Grinold's law, skew/kurtosis, Cornish-Fisher, Component/Marginal VaR (Euler), Kupiec/Christoffersen LR, PSR/DSR
Key formulas for quick reference:
Table A.1 — Risk and performance formula sheet: formula, key symbols, and usage cautions
| Concept | Formula | Key symbols | Usage/caution |
|---|---|---|---|
| Delta-normal VaR (portfolio) | \(\mathrm{VaR}_{\alpha} = V\,z_{\alpha}\sqrt{w^{\top}\Sigma w}\); single asset: see block | \(V\) value, \(w\) weights, \(\mu,\sigma\) daily | Fast and aggregable; fails with fat tails, skewness, and non-linearities (options); the \(\sqrt{h}\) rule requires i.i.d. |
| Historical VaR (HS) | \(\mathrm{VaR}_{\alpha}^{\mathrm{HS}} = L_{(\lceil T(1-\alpha) \rceil)}\) | \(L_{(k)}\) = \(k\)-th worst loss out of \(T\) revalued P&L | No distributional assumptions; at 99% with \(T=250\) only ~2.5 tail observations; slow to react to regime changes |
| Monte Carlo VaR / FHS | \(\mathrm{VaR}_{\alpha}^{\mathrm{MC}} = \hat{F}^{-1}_{L,N}(1-\alpha)\) | \(\hat{F}_{L,N}\) = empirical CDF of \(N\) simulated losses | The risk shifts to the generator; FHS: resample residuals \(z_t = r_t/\sigma_t\) from a GARCH; Gaussian MC underestimates tails |
| ES / CVaR | See block; empirical: mean of the \(\lfloor T\alpha \rfloor\) worst losses | \(\alpha\) tail; \(p=1-\alpha\) confidence | Coherent and subadditive (VaR is not); FRTB: 97.5% ES \(= 2{,}338\sigma \approx\) 99% VaR \(= 2{,}326\sigma\) under normality |
| Rockafellar–Uryasev | \(\widehat{\mathrm{CVaR}}_{\beta} = \min_{c}\left\{ c + \frac{1}{1-\beta}\cdot\frac{1}{T}\sum_{t=1}^{T}(L_t - c)_{+} \right\}\) | \(c\) ≈ VaR; \((\cdot)_{+}\) positive part | Turns CVaR optimization into linear programming (ideal with cvxpy) |
| Realized volatility | \(RV_t = \sum_{i=1}^{M} r_{t,i}^{2}\), \(\mathrm{RVol}_t = \sqrt{RV_t}\) | \(M\) evenly spaced intraday observations | Consistent estimator of quadratic variation; with microstructure noise, sample at ~5 min |
| EWMA (RiskMetrics) | See block; expanded form \(\sigma_t^2 = (1-\lambda)\sum_{i\ge1}\lambda^{i-1}r_{t-i}^2\) | \(\lambda=0{,}94\) daily, \(0{,}97\) monthly | Effective memory \(\approx 1/(1-\lambda)\approx 17\) days; IGARCH with no mean reversion |
| GARCH(1,1) | See block; long run \(\bar\sigma^2 = \omega/(1-\alpha-\beta)\); forecast \(\mathbb{E}_t[\sigma_{t+k}^2] = \bar\sigma^2 + (\alpha+\beta)^{k-1}(\sigma_{t+1}^2-\bar\sigma^2)\) | \(\omega>0\), \(\alpha,\beta\ge0\), persistence \(\alpha+\beta\) | Requires \(\alpha+\beta<1\) for stationarity; EWMA is the limiting case \(\omega=0\), \(\alpha+\beta=1\) |
| Maximum drawdown | \(\mathrm{MDD}_T = \min_{0\le t\le T}\frac{V_t - \overline{V}_t}{\overline{V}_t}\) | \(\overline{V}_t = \max_{s\le t}V_s\) (high-water mark) | Asymmetric recovery: \(g = d/(1-d)\) (−50% ⇒ +100%); highly sensitive to the window |
| Sharpe | See block | \(R_f\) risk-free, \(\sigma_p\) of the excess | Annualize with \(\sqrt{252}\) only under i.i.d.; with autocorrelation it can be overstated by up to 65% (Lo 2002) (Alpha Vantage) |
| Sortino | \(\mathrm{Sortino} = \frac{R_p - \tau}{\sigma_d}\), \(\sigma_d = \sqrt{\frac{1}{N}\sum_{i=1}^{N}\min(R_i-\tau,\,0)^2}\) | \(\tau\) = MAR (0 or \(R_f\)) | Penalizes downside volatility only; sensitive to the choice of \(\tau\) |
| Omega | \(\Omega(\theta) = \frac{\mathbb{E}[(R-\theta)^{+}]}{\mathbb{E}[(\theta-R)^{+}]}\) | \(\theta\) threshold; \((x)^{+}=\max(x,0)\) | Uses the entire distribution with no moment assumptions; sanity check: \(\Omega(\bar R)=1\) |
| Calmar | \(\mathrm{Calmar} = \mathrm{CAGR}/\lvert\mathrm{MDD}\rvert\) | Typical window: 36 months | A crisis-free track record artificially inflates it; MAR variant over the full history |
| Sterling | \(\mathrm{Sterling} = \frac{APR}{ALD + 10\%}\) | \(APR\) annual return, \(ALD\) average of annual max DD | \(\pm 10\%\) convention ambiguous in the literature: state the one used (Alpha Vantage) ; modern variant: \((\mathrm{CAGR}-R_f)/\overline{\mathrm{MDD}}\) |
| Ulcer Index | \(R_i = 100\times\frac{P_i - \max_{j\le i}P_j}{\max_{j\le i}P_j}\), \(UI = \sqrt{\frac{1}{N}\sum_{i=1}^{N}R_i^2}\) | % drawdown from the prior peak | Penalizes depth and duration; UPI \(= (R_p - R_f)/UI\) |
| Beta | \(\beta_i = \frac{\mathrm{Cov}(R_i,R_m)}{\mathrm{Var}(R_m)} = \rho_{i,m}\,\frac{\sigma_i}{\sigma_m}\) | Slope of the regression against the market | Highly sensitive to window, benchmark, and data frequency |
| TE / IR + Grinold | \(TE = \sigma(R_p - R_b)\), \(IR = \frac{\mathbb{E}[R_p - R_b]}{TE}\), \(IR \approx IC\sqrt{BR}\) | \(IC\) information coefficient, \(BR\) breadth | Grinold's law assumes independent forecasts; constraints reduce the achievable IR |
| Skew / kurtosis | \(\hat{S} = \hat\mu_3/\hat\sigma^3\), \(\hat{K} = \hat\mu_4/\hat\sigma^4\), \(K_{\mathrm{exceso}} = \hat K - 3\) | 3rd and 4th standardized moments | Typical equity: \(S<0\) and \(K_{\mathrm{exceso}}>0\) — the direct reason normal VaR underestimates |
| Cornish–Fisher | See block; \(\mathrm{VaR}_{\mathrm{mod}} = V\left[z_{CF}\,\sigma\sqrt{h} - \mu h\right]\) | Sample \(S\), \(K_{\mathrm{exceso}}\) | Cheap non-Gaussian VaR; invalid if \(\lvert S\rvert\gtrsim 2\) or \(K\gtrsim 6\) (non-monotonic quantiles): verify before reporting |
| Marginal / Component VaR (Euler) | \(\mathrm{MVaR}_i = z_\alpha\,\frac{(\Sigma x)_i}{\sigma_p}\), \(\mathrm{CVaR}_i = x_i\,\mathrm{MVaR}_i = \mathrm{VaR}_i\,\rho_{i,p}\) | \(x_i\) monetary position, \(\rho_{i,p}\) correlation with the portfolio | Exact aggregation: \(\sum_i \mathrm{CVaR}_i = \mathrm{VaR}_p\); mathematical basis of narrative VaR attribution |
| Kupiec POF | See block | \(N\) exceptions in \(T\) days, \(p\) nominal rate | Unconditional frequency only; low power with small \(T\) (250 days ⇒ ~12.5 expected exceptions at 95%) |
| Christoffersen | \(LR_{cc} = LR_{uc} + LR_{ind} \sim \chi^2_2\) | \(\hat\pi_{01} = \frac{n_{01}}{n_{00}+n_{01}}\), \(\hat\pi_{11} = \frac{n_{11}}{n_{10}+n_{11}}\) | Detects exception clustering (independence); required in Basel internal-models frameworks |
| PSR / DSR | See block; \(\widehat{DSR} = \widehat{PSR}(SR_0)\) | Sample \(\hat\gamma_3,\hat\gamma_4\); \(\gamma_{EM}\approx 0{,}5772\); \(N\) trials | Operating rule: require DSR > 0.95 (PyPI) ; a backtest Sharpe without a declared number \(N\) of trials is not evidence |
Usage notes — risk and performance. When each formula fails: delta-normal VaR systematically underestimates risk under fat tails and negative skewness (\(S<0\), \(K_{\mathrm{exceso}}>0\) in equity) and does not capture derivative non-linearities; historical VaR relies on a single path and at 99% with 250 days has only ~2.5 tail observations; Monte Carlo shifts the risk to the stochastic generator — the comparative evidence shows that Gaussian MC underestimates tails relative to filtered historical simulation. The \(\sqrt{h}\) rule and Sharpe annualization with \(\sqrt{252}\) are valid only under i.i.d. returns: with serial autocorrelation, Lo (2002) documents annualized Sharpe ratios overstated by up to 65% (Alpha Vantage) . Fixed course conventions: \(\lambda=0{,}94\) daily (0.97 monthly; effective memory ≈ 17 days), per the RiskMetrics Technical Document (Godel Discount) ; EWMA does not revert to the mean — if reversion is needed, use GARCH(1,1) with \(\alpha+\beta<1\). Sterling is the least standardized formula in the literature: the original version adds 10% to the denominator, but variants with \(-10\%\) or with \(R_f\) circulate; always state the convention used (±10% tolerance) (Alpha Vantage) . Cornish-Fisher stops being monotonic for \(\lvert S\rvert\gtrsim 2\) or \(K\gtrsim 6\): verify the monotonicity of \(z_{CF}\) in \(\alpha\) before reporting. Kupiec has low power with small \(T\) and does not detect time clustering — which is why it is complemented with Christoffersen. Calmar and MDD depend on the window: a crisis-free history inflates them. And no backtest Sharpe is evidence without DSR > 0.95 after declaring the \(N\) trials (PyPI) .
13.2 Portfolios and execution
13.2.1 Formula table: Markowitz MVO + GMV + tangency, CAPM, FF3/FF5, Black-Litterman (π=δΣw, posterior, Idzorek ω), Kelly (discrete/continuous/fractional), ERC (Spinu), Ledoit-Wolf δ*, HRP, Almgren-Chriss (trajectory, κ, E(X), V(X)), square-root law, signal cross-sectional z-score
Key formulas for quick reference:
Table A.2 — Portfolio and execution formula sheet: formula, key symbols, and usage cautions
| Concept | Formula | Key symbols | Usage/caution |
|---|---|---|---|
| MVO (Markowitz) | \(\min_w w^{\top}\Sigma w\) s.a. \(w^{\top}\mu = \bar\mu\), \(w^{\top}\mathbf{1} = 1\); dual: \(\mathbf{w}^{*} = \frac{1}{\lambda}\Sigma^{-1}\mu\) | \(\lambda\) risk aversion | "Error maximizer" (Michaud): errors in \(\mu\) weigh ~11× those of variances; never with raw sample \(\Sigma\) |
| GMV | See block; \(\sigma_{\mathrm{GMV}}^2 = 1/(\mathbf{1}^{\top}\Sigma^{-1}\mathbf{1})\) | Does not use \(\mu\) | The most robust out of sample; long-only + bounds = implicit shrinkage (Jagannathan–Ma) |
| Tangency (max Sharpe) | See block; \(SR_{\mathrm{tan}} = \sqrt{(\mu - r_f\mathbf{1})^{\top}\Sigma^{-1}(\mu - r_f\mathbf{1})}\) | With \(r_f\); tangency point of the CML | Extremely sensitive to \(\hat\mu\); multivariate Kelly = unnormalized tangency (\(\lambda=1\)) |
| CAPM | \(\mathbb{E}[R_i] = r_f + \beta_i\big(\mathbb{E}[R_m] - r_f\big)\) | \(\beta_i\) from the previous row; equilibrium | Basis of the Black-Litterman prior; SML: assets above it are undervalued |
| FF3 / FF5 | \(R_{i,t} - r_{f,t} = \alpha_i + \beta_M MKT_t + \beta_{SMB}SMB_t + \beta_{HML}HML_t\,(+\beta_{RMW}RMW_t + \beta_{CMA}CMA_t) + \varepsilon_{i,t}\) | Size, value (+ profitability, investment) factors | Factor attribution of alpha; Carhart adds \(WML\) (momentum); data: Ken French Data Library |
| Black-Litterman | See block; Idzorek: \(\omega_k = \tau\,\mathbf{p}_k\,\Sigma\,\mathbf{p}_k^{\top}\); \(\Sigma_{BL} = \Sigma + M\) | \(\delta\approx 2{,}5\!-\!3{,}5\); \(\tau\) prior scale; \(P,\mathbf{q},\Omega\) views | \(\tau \in [0{,}025,\ 0{,}05]\) or \(\tau = 1/T\) (Github) ; views are the auditable entry point for signals (incl. LLM) |
| Discrete Kelly | See block | \(b\) net odds, \(p\) win probability, \(q=1-p\) | Growth-optimal capital fraction; at full Kelly the drawdowns are intolerable |
| Continuous / multivariate Kelly | See block | Maximizes \(\mathbb{E}[\ln W]\) (log utility) | \(\mathbf{f}^{*} = \Sigma^{-1}(\mu - r_f\mathbf{1})\) coincides with the unnormalized tangency portfolio |
| Fractional Kelly | \(\hat f = c\cdot f^{*}\), \(c\in(0,1)\) | \(c = 1/2\) or \(1/4\) in practice | 1/2-Kelly ≈ 75% of growth with ~50% of the volatility (Github) ; protects against overestimated edge |
| ERC (risk parity, Spinu) | See block; \(\mathbf{w}_{ERC} = \arg\min \sum_{i,j}\big(w_i(\Sigma w)_i - w_j(\Sigma w)_j\big)^2\) s.a. \(w^{\top}\mathbf{1}=1\), \(w_i\ge0\) | \(RC_i\) risk contribution | No general closed-form solution; sits between \(1/N\) and GMV on the diversification-risk spectrum |
| Ledoit–Wolf | \(\widehat{\Sigma}_{LW} = \delta^{*}F + (1-\delta^{*})S\), \(\delta^{*} = \frac{\sum_{i\ne j}\widehat{\mathrm{Var}}(s_{ij})}{\sum_{i\ne j}(s_{ij}-f_{ij})^2}\) | Sample \(S\); \(F\) target (constant correlation or \(\frac{\mathrm{Tr}(S)}{n}I\)) | Closed-form \(\delta^{*}\), no free parameters; mandatory standard before inverting \(\Sigma\) with 10+ assets |
| HRP | \(d_{ij} = \sqrt{\tfrac{1}{2}(1-\rho_{ij})}\); allocation \(\alpha_1 = 1 - \frac{V_1}{V_1+V_2}\), \(\alpha_2 = 1-\alpha_1\) | Clustering + seriation + recursive bisection; \(V_c\) intra-cluster variance | Diversifies without inverting \(\Sigma\): robust to ill-conditioning |
| Almgren–Chriss | See block; \(E(x) = \tfrac{1}{2}\gamma X^2 + \varepsilon\sum_j\lvert n_j\rvert + \frac{\tilde\eta}{\tau}\sum_j n_j^2\), \(\tilde\eta = \eta - \tfrac{1}{2}\gamma\tau\); \(V(x) = \sigma^2\tau\sum_j x_j^2\) | \(\gamma\) permanent impact, \(\eta\) temporary, \(\lambda\) aversion, \(\tau=T/N\) | \(\kappa T\ll1\) ⇒ ≈TWAP; \(\kappa T\gg1\) ⇒ front-loaded with half-life \(1/\kappa\); the naive strategy (\(\lambda=0\)) is never optimal (Blockchain News) |
| Square-root law | See block; practical: \(C_{\mathrm{impacto}} \approx 0{,}1\times\text{spread} + Y\sigma_D\sqrt{Q/V_D}\) | \(Q\) meta-order, \(V_D\) daily volume, \(\sigma_D\) daily vol. | Concave in \(Q\): defines the strategy's capacity; Almgren et al. propose a 3/5 exponent for blocks (🦜️🔗 LangChain) |
| Cross-sectional z-score | \(z_{i,t} = \dfrac{s_{i,t} - \bar{s}_t}{\sigma_t(s)}\) | \(s\) signal (e.g., LLM score), mean and standard deviation per date \(t\) | Winsorize before standardizing; the basis of long-short ranking and of weights \(\propto z\); handle the point mass at "neutral" |
Usage notes — portfolios and execution. The weak link of MVO is not the QP but \(\mu\): errors in means weigh ~11× those of variances (Chopra–Ziemba) and the optimizer systematically maximizes them (Michaud); that is why GMV, ERC, and HRP — which do not use \(\mu\) or do not invert \(\Sigma\) — tend to win out of sample, and long-only constraints with bounds act as implicit shrinkage (Jagannathan–Ma). In production, never feed the raw sample \(\Sigma\): Ledoit–Wolf with closed-form \(\delta^{*}\) is the standard before any \(\Sigma^{-1}\). In Black-Litterman, \(\tau\) scales the confidence in the equilibrium prior: institutional practice is \(\tau\in[0{,}025,\ 0{,}05]\) or \(\tau = 1/T\), with \(\Omega\) calibrated per Idzorek (Github) ; the views \((P,\mathbf{q},\Omega)\) are the auditable entry point for signals, including LLM-generated ones. Full Kelly maximizes growth but with intolerable drawdowns: in practice it is traded fractionally at 1/4–1/2 — half-Kelly retains ≈ 75% of the growth with ~50% of the volatility (Github) . In execution: \(\kappa T\ll1\) reproduces TWAP; \(\kappa T\gg1\) liquidates front-loaded with half-life \(1/\kappa\), and the naive strategy (\(\lambda=0\)) is never optimal for a risk-averse trader (Blockchain News) . The square-root law is concave in \(Q\) — "it costs ~1 day of volatility to move 1 day of volume" (🦜️🔗 LangChain) : liquidating \(X = 1{,}000{,}000\) shares with \(Q/V_D = 0{,}25\), \(\sigma_D = 2\%\) and \(Y=0{,}6\) costs \(\approx 0{,}6\times2\%\times0{,}5 = 60\) bp. The cross-sectional z-score requires winsorizing the signal by date before ranking; with LLM signals, explicitly handle the point mass in the neutral class.
Appendix A of 3 — LangChain for Quantitative Trading. Data and versions verified as of July 2026; prices and market figures subject to change. LangChain 1.3.14 / langchain-core 1.5.2.