pfhedge.stochastic.generate_rough_bergomi

pfhedge.stochastic.generate_rough_bergomi(n_paths, n_steps, init_state=None, alpha=- 0.4, rho=- 0.9, eta=1.9, xi=0.04, dt=0.004, dtype=None, device=None)[source]

Returns time series following the rough Bergomi (rBergomi) model.

The time evolution of the process is given by:

\[\begin{split}S(t) &=& \exp{\left\{\int_0^t \sqrt{V(u)} dB(u) - \frac{1}{2} \int_0^t V(u) du \right\}}, \\ B(u) &=& \rho W_u^1 + \sqrt{1-\rho^2}W_u^2, \\ V(t) &=& \xi\exp{\left\{\eta Y^\alpha(t) - \frac{\eta^2}{2} t^{2\alpha + 1}\right\}}, \\ Y^\alpha(t) &=& \sqrt{1\alpha + 1}\int_0^t (t-u)^\alpha dW_u^1,\end{split}\]

\(dW^1\) and \(dW^2\) are the Brownian motion.

Time-series is generated by Ryan et al.’s Monte Carlo algorithm.

References

Parameters
  • n_paths (int) – The number of simulated paths.

  • n_steps (int) – The number of time steps.

  • init_state (tuple[torch.Tensor | float], optional) – The initial state of the time series. This is specified by a tuple \((S(0), V(0))\). If None (default), it uses \((1.0, \\xi)\).

  • alpha (float, default=-0.4) – The parameter \(\\alpha\).

  • rho (float, default=-0.9) – The parameter \(\\rho\).

  • eta (float, default=1.9) – The parameter \(\\eta\).

  • xi (float, default=0.04) – The parameter \(\\xi\).

  • dt (float, default=1 / 250) – The intervals of the time steps.

  • dtype (torch.dtype, optional) – The desired data type of returned tensor. Default: If None, uses a global default (see torch.set_default_tensor_type()).

  • device (torch.device, optional) – The desired device of returned tensor. Default: If None, uses the current device for the default tensor type (see torch.set_default_tensor_type()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.

Shape:
  • spot: \((N, T)\) where \(N\) is the number of paths and \(T\) is the number of time steps.

  • variance: \((N, T)\).

Returns

A namedtuple (spot, variance).

Return type

(torch.Tensor, torch.Tensor)

Examples

>>> from pfhedge.stochastic import generate_rough_bergomi
...
>>> _ = torch.manual_seed(42)
>>> outputs = generate_rough_bergomi(2, 5)
>>> outputs.spot
tensor([[1.0000, 0.9807, 0.9563, 0.9540, 0.9570],
        [1.0000, 1.0147, 1.0097, 1.0107, 1.0164]])
>>> outputs.variance
tensor([[0.0400, 0.3130, 0.0105, 0.0164, 0.0068],
        [0.0400, 0.0396, 0.0049, 0.0064, 0.0149]])