ExpectedShortfall

class pfhedge.nn.ExpectedShortfall(p=0.1)[source]

Creates a criterion that measures the expected shortfall.

Parameters

p (float, default=0.1) – Quantile level. This parameter should satisfy \(0 < p \leq 1\).

Shape:
  • input: \((N, *)\) where

    \(*\) means any number of additional dimensions.

  • target: \((N, *)\)

  • output: \((*)\)

Examples

>>> from pfhedge.nn import ExpectedShortfall
...
>>> loss = ExpectedShortfall(0.5)
>>> input = -torch.arange(4.0)
>>> loss(input)
tensor(2.5000)
>>> loss.cash(input)
tensor(-2.5000)