TQBTHEQUANTBATEMAN
TQB/ learn/ risk/ hedging pnl attributionEN · DARK
Greeks, hedging & risk · front-office

Hedging & P&L attribution

Connect rebalance frequency, transaction costs and residual risk.

BY THE END, YOU CAN

01Simulate a discrete delta hedge

02Attribute P&L to Greeks and carry

03Measure transaction-cost trade-offs

01
INTUITION

Define the exposure before compressing it into a metric.

Continuous replication is a theorem; an actual hedge is discrete, costly and exposed to model error.

01

Gamma creates rehedging demand.

02

More frequent hedging cuts discretization but raises costs.

03

Residual P&L is a diagnostic, not a dumping ground.

02
WHY MARKETS CARE

Fix portfolio, scenarios, horizon, and legal terms.

The hedge converts model assumptions into actual cash trades and realized P&L.

INSTRUMENTS

option portfolios

variance books

structured notes

QUOTE CONVENTION

Hedge timestamps, bid/ask costs and financing are explicit.

03
MATHEMATICS

Aggregate with an explicit measure and convention.

Formula · Short derivation

Discrete hedge P&L

ΔΠn=ΔVn−ΔnΔSn−cSn∣Δn−Δn−1∣\Delta\Pi_n=\Delta V_n-\Delta_n\Delta S_n-cS_n|\Delta_n-\Delta_{n-1}|

Option P&L is offset by the hedge and reduced by turnover cost.

Open in Analytics
Short derivation
Short derivation

From information set to computable quantity

Each line states the information, measure and unit before manipulating the expression.

  1. 01

    Form the hedge

    Hold one option and −Δ units of underlying.

    Π=V−ΔS\Pi=V-\Delta S
  2. 02

    Advance one interval

    Realize spot and volatility moves before rebalancing.

  3. 03

    Charge turnover

    Apply transaction cost to the change in hedge units.

  4. 04

    Attribute residual

    Subtract Greek explain and known costs from full-revaluation P&L.

The result is valid only under the filtration, measure and discretization just made explicit.

Inputs
  • Π: hedged portfolio
  • c: proportional transaction cost
Assumptions and limits
  • A single path cannot estimate hedge-error distribution.
  • Liquidity and gap risk dominate smooth diffusion assumptions in stress.
Formula · Short derivation

Local explain

ΔV≈ΔΔS+12Γ(ΔS)2+ΘΔt+νΔσ\Delta V\approx\Delta\Delta S+\tfrac12\Gamma(\Delta S)^2+\Theta\Delta t+\nu\Delta\sigma

The attribution separates spot hedge, convexity, carry and volatility.

Open in Analytics
05
MODEL / PRICING

Reconcile valuation, risk, and model limitations.

METHOD

Simulate common paths, rebalance at fixed intervals, charge explicit costs and reconcile full P&L to Greek buckets.

CALIBRATION

Use a market-calibrated volatility state; test historical dynamics separately from risk-neutral pricing dynamics.

06PYTHON IMPLEMENTATIONOpen the implementation and checks.
ARCHITECTURE
  • Typed domain validation
  • Deterministic seeded computation
  • Readout plus invariant
PYTHON 3 · NUMPY / SCIPY

Hedging & P&L attribution

Reproduce the governing quantity, then challenge it with an invariant.

REUSABLE EXAMPLE
01import numpy as np
02
03def deltapindeltavndel(x: np.ndarray) -> float:
04 x = np.asarray(x, dtype=float)
05 assert np.isfinite(x).all()
06 return float(np.mean(x))
07
08sample = np.array([0.8, 1.0, 1.2])
09value = deltapindeltavndel(sample)
10assert sample.min() <= value <= sample.max()
11print(f"value={value:.6f}")
EXPECTED OUTPUTvalue=1.000000
SANITY CHECKS

✓ Finite inputs are enforced

✓ The result respects its numerical bounds

✓ Units and measure remain explicit

07
INTERACTIVE LAB

Move the state. Challenge the equation.

RISK RESPONSE LAB

Hedging & P&L attribution

Move spot, volatility and horizon. Prices, desk-unit Greeks and hedge residuals share one pricing state.

SYNTHETIC · EDUCATIONAL
Option value9.8421Black–Scholes
Hedge residual-0.6098after transaction costs
Turnover charge0.640010.0 bp
P&L (currency units) by hedge progress

Synthetic cumulative hedge P&L after transaction costs.

  • cumulative hedge P&L
hedge progress: 0.0%. cumulative hedge P&L: 0.0000.

Use Left/Right or Up/Down arrows to inspect values; Home and End jump to the bounds.

MODEL BOUNDARY

European Black–Scholes reference with synthetic hedge residuals. Surface dynamics and liquidity are simplified.

08
FRONT OFFICE

Turn exposure into a controlled decision.

ON THE DESK
“The hedge frequency is part of the strategy, not an implementation footnote.”
VISIBLE INPUTS

rebalance schedule

transaction costs

CALIBRATION

Use a market-calibrated volatility state; test historical dynamics separately from risk-neutral pricing dynamics.

RISK

hedge slippage

gap risk

DAILY WORKFLOW
  1. Validate market state and timestamp
  2. Recompute the baseline
  3. Run a controlled perturbation
  4. Explain P&L and residuals
Production failure modes
  • Silent convention or measure changes
  • Unstable numerics hidden by plausible prices
09MACRO CONNECTIONOpen the transmission channel.
MACRO CONNECTION

Transmission from state to valuation

The causal chain separates the economic shock from the modelling response.

01Volatility regimetransmits

changes turnover

02Liquiditytransmits

sets hedge cost

03Realized P&Loutput

tests model and execution

10COMMON PITFALLSOpen the failure checklist.
01

Hedging with future-close deltas

02

Calling transaction costs model error

11SOURCES / FURTHER READINGOpen sources and continue the track.
research

Measure theory, simulation and computational-finance lectures

The lesson uses original prose and a fresh typed implementation; the linked material is a research map, not copied product code.

Source
Computational Finance Course
Author
L. A. Grzelak
Ref
main
OPEN ORIGINAL SOURCE ↗