Hedging API Reference¶
Delta Hedging¶
delta
¶
Classical delta hedging.
Simulates dynamic delta-hedging of a European call option under GBM, rebalancing at discrete intervals using the Black-Scholes delta.
HedgeResult
dataclass
¶
Result of a discrete delta-hedging simulation.
Attributes¶
pnl : float Final hedging P&L (hedge portfolio value minus option payoff). hedging_error : float Absolute hedging error at expiry. rebalance_dates : NDArray Array of rebalance times (fractions of T). deltas : NDArray Delta held at each rebalance date. spot_path : NDArray Simulated spot path at rebalance dates (length n_rebalances + 1). option_price : float Initial Black-Scholes call price used to set up the hedge.
DeltaHedger
¶
Discrete delta-hedging simulator for a European call under GBM.
Parameters¶
is_call : bool
Hedge a call (True) or put (False).
hedge(spot, strike, r, sigma, T, n_rebalances=100, seed=42)
¶
Run a single-path discrete delta-hedging simulation.
Parameters¶
spot : float Initial spot price. strike : float Strike price. r : float Risk-free rate. sigma : float Volatility. T : float Time to expiry (years). n_rebalances : int Number of rebalance steps. seed : int | None Random seed.
Returns¶
HedgeResult
bs_delta(spot, strike, r, sigma, T, is_call=True)
¶
Black-Scholes delta for a European option.
Parameters¶
spot : float
Current spot price.
strike : float
Strike price.
r : float
Risk-free rate (annualised).
sigma : float
Volatility (annualised).
T : float
Time to expiry in years. Must be > 0.
is_call : bool
True for call, False for put.
Deep Hedging¶
deep_hedging
¶
Deep hedging (Buhler-Gonon-Teichmann-Wood, Quantitative Finance 2019).
A minimal numpy-only implementation of deep hedging. A small feedforward network learns a hedging strategy that minimises P&L variance over simulated GBM paths. No PyTorch or TensorFlow dependency is required.
DeepHedgingConfig
dataclass
¶
Hyper-parameters for the deep-hedging network.
Attributes¶
n_layers : int Number of hidden layers. hidden_dim : int Width of each hidden layer. n_epochs : int Training epochs. lr : float Learning rate for vanilla SGD. n_paths : int Number of GBM paths per training batch. n_steps : int Number of hedging time-steps.
DeepHedger
¶
Numpy-only deep hedging agent.
Parameters¶
config : DeepHedgingConfig Network / training configuration. s0 : float Initial spot price. strike : float Option strike price. r : float Risk-free rate. sigma : float Volatility. T : float Time to expiry (years). seed : int | None Random seed.
Quantum Deep Hedging¶
quantum_deep_hedging
¶
Quantum deep hedging (Cherrat et al., arXiv:2303.16585).
Revival of jpmorganchase/jpmc-qcware-deephedging (archived March 2023). Modernized to Qiskit Primitives and PennyLane TorchLayer.
This module provides a circuit builder and evaluator for variational quantum hedging networks. It does not include a full training loop (which would require PyTorch or JAX) but exposes all the building blocks needed to plug the circuit into an external optimiser.
QuantumDeepHedgingConfig
dataclass
¶
Configuration for the quantum deep-hedging ansatz.
Attributes¶
n_qubits : int
Number of qubits in the variational circuit.
n_layers : int
Number of variational layers.
entanglement : str
Entanglement topology: "linear", "full", or "circular".
QuantumDeepHedger
¶
build_circuit(n_qubits, n_layers, entanglement='linear')
¶
forward(params, features, n_qubits, n_layers, entanglement='linear', shots=1024, backend=None)
¶
Evaluate the parametrised circuit and return expectation values.
Parameters¶
params : NDArray
Flat array of variational parameters.
features : NDArray
1-D feature vector for angle encoding.
n_qubits, n_layers, entanglement
Ansatz configuration.
shots : int
Number of measurement shots.
backend : object or None
A Qiskit-compatible backend. If None the Qiskit
StatevectorSimulator is used via Statevector.
Returns¶
NDArray Array of per-qubit Z expectation values (length n_qubits).
RL-Quantum Hedging¶
rl_quantum
¶
Quantum RL policy networks for hedging.
Provides a parametrised quantum circuit acting as a stochastic policy for REINFORCE-style reinforcement learning. The circuit maps a classical state (encoded via angle embedding) to action probabilities derived from measurement outcome distributions.
QuantumPolicyConfig
dataclass
¶
Configuration for the quantum policy circuit.
Attributes¶
n_qubits : int Number of qubits in the policy circuit. n_layers : int Number of variational layers. n_actions : int Size of the discrete action space.
QuantumPolicy
¶
Parametrised quantum circuit as a discrete-action policy.
Parameters¶
config : QuantumPolicyConfig Policy configuration.
select_action(state, params, backend=None)
¶
Return action probabilities for the given state.
Parameters¶
state : NDArray
1-D classical state vector (length <= n_qubits).
params : NDArray
Flat variational parameter vector.
backend : object or None
Qiskit backend; None uses exact statevector simulation.
Returns¶
NDArray Action probability vector of length n_actions.
log_prob(state, action, params, backend=None)
¶
build_policy_circuit(n_qubits, n_layers, n_actions)
¶
Build a variational policy circuit.
The circuit consists of:
1. A placeholder for angle-encoded state features (applied at runtime).
2. An EfficientSU2-style trainable ansatz.
3. Measurement on the first ceil(log2(n_actions)) qubits.
Parameters¶
n_qubits : int Total qubits. n_layers : int Variational reps. n_actions : int Number of discrete actions.
Returns¶
qiskit.circuit.QuantumCircuit Parametrised circuit (without measurements; those are handled at evaluation time).