pfhedge.nn.functional.realized_variance

pfhedge.nn.functional.realized_variance(input, dt)[source]

Returns the realized variance of the price.

Realized variance \(\sigma^2\) of the stock price \(S\) is defined as:

\[\sigma^2 = \frac{1}{T - 1} \sum_{i = 1}^{T - 1} \frac{1}{dt} \log(S_{i + 1} / S_i)^2\]

where \(T\) is the number of time steps.

Note

The mean of log return is assumed to be zero.

Parameters
Shape:
  • input: \((*, T)\) where \(T\) stands for the number of time steps and \(*\) means any number of additional dimensions.

  • output: \((*)\)

Returns

torch.Tensor