pfhedge.nn

pfhedge.nn provides torch.nn.Module that are useful for Deep Hedging.

See PyTorch Documentation for general usage of torch.nn.Module.

Hedger Module

nn.Hedger

Module to hedge and price derivatives.

Black-Scholes Layers

nn.BlackScholes

Creates Black-Scholes formula module from a derivative.

nn.BSAmericanBinaryOption

Black-Scholes formula for an American binary option.

nn.BSEuropeanOption

Black-Scholes formula for a European option.

nn.BSEuropeanBinaryOption

Black-Scholes formula for a European binary option.

nn.BSLookbackOption

Black-Scholes formula for a lookback option with a fixed strike.

Whalley-Wilmott Layers

nn.WhalleyWilmott

Creates a module for Whalley-Wilmott's hedging strategy.

Nonlinear Activations

nn.Clamp

Clamp all elements in input into the range \([\min, \max]\).

nn.LeakyClamp

Leakily clamp all elements in input into the range \([\min, \max]\).

Loss Functions

nn.HedgeLoss

Base class for hedging criteria.

nn.EntropicLoss

Creates a criterion that measures the expected exponential utility.

nn.EntropicRiskMeasure

Creates a criterion that measures the entropic risk measure.

nn.ExpectedShortfall

Creates a criterion that measures the expected shortfall.

nn.QuadraticCVaR

Creates a criterion that measures the QuadraticCVaR.

nn.IsoelasticLoss

Creates a criterion that measures the expected isoelastic utility.

Multi Layer Perceptron

nn.MultiLayerPerceptron

Creates a multilayer perceptron.

Other Modules

nn.Naked

Returns a tensor filled with the scalar value zero.

nn.SVIVariance

Returns total variance in the SVI model.