OptionMixin

class pfhedge.instruments.OptionMixin[source]

Mixin class for options.

log_moneyness(time_step=None)[source]

Returns log-moneyness of self.

Log-moneyness reads \(\log(S / K)\) where \(S\) is the spot price of the underlying instrument and \(K\) is the strike of the derivative.

Returns

torch.Tensor

max_log_moneyness(time_step=None)[source]

Returns self.max_moneyness(time_step).log().

Returns

torch.Tensor

max_moneyness(time_step=None, log=False)[source]

Returns the cumulative maximum of the moneyness.

Parameters
  • time_step (int, optional) – The time step to calculate the time to maturity. If None (default), the time to maturity is calculated at all time steps.

  • log (bool, default=False) – If True, returns the cumulative maximum of the log moneyness.

Shape:
  • Output: \((N, T)\) where \(N\) is the number of paths and \(T\) is the number of time steps. If time_step is given, the shape is \((N, 1)\).

Returns

torch.Tensor

moneyness(time_step=None, log=False)[source]

Returns the moneyness of self.

Moneyness reads \(S / K\) where \(S\) is the spot price of the underlying instrument and \(K\) is the strike of the derivative.

Parameters
  • time_step (int, optional) – The time step to calculate the moneyness. If None (default), the moneyness is calculated at all time steps.

  • log (bool, default=False) – If True, returns log moneyness.

Shape:
  • Output: \((N, T)\) where \(N\) is the number of paths and \(T\) is the number of time steps. If time_step is given, the shape is \((N, 1)\).

Returns

torch.Tensor

time_to_maturity(time_step=None)[source]

Returns the time to maturity of self.

Parameters

time_step (int, optional) – The time step to calculate the time to maturity. If None (default), the time to maturity is calculated at all time steps.

Shape:
  • Output: \((N, T)\) where \(N\) is the number of paths and \(T\) is the number of time steps. If time_step is given, the shape is \((N, 1)\).

Returns

torch.Tensor