pfhedge.stochastic.generate_merton_jump

pfhedge.stochastic.generate_merton_jump(n_paths, n_steps, init_state=(1.0, ), mu=0.0, sigma=0.2, jump_per_year=68.2, jump_mean=0.0, jump_std=0.02, dt=0.004, dtype=None, device=None, engine=<built-in method randn of type object>)[source]

Returns time series following the Merton’s Jump Diffusion Model.

The time evolution of the process is given by:

\[\frac{dS(t)}{S(t)} = (\mu - \lambda k) dt + \sigma dW(t) + dJ(t) .\]
Reference:
  • Merton, R.C., Option pricing when underlying stock returns are discontinuous, Journal of Financial Economics, 3 (1976), 125-144.

  • Gugole, N. (2016). Merton jump-diffusion model versus the black and scholes approach for the log-returns and volatility smile fitting. International Journal of Pure and Applied Mathematics, 109(3), 719-736. (Especially p.730 for parameter calibulation.)

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

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

  • init_state (tuple[torch.Tensor | float], default=(1.0,)) – The initial state of the time series. This is specified by a tuple \((S(0),)\). It also accepts a torch.Tensor or a float.

  • mu (float, default=0.0) – The parameter \(\mu\), which stands for the dirft coefficient of the time series.

  • sigma (float, default=0.2) – The parameter \(\sigma\), which stands for the volatility of the time series.

  • jump_per_year (float, default=68.2) – The average number of jumps per year.

  • jump_mean (float, default=0.0) – The mean of jump sizes.

  • jump_std (float, default=0.02) – The standard deviation of jump sizes.

  • dt (float, default=1/250) – The time step interval.

  • 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.

  • engine (callable, default=torch.randn) – The desired generator of random numbers from a standard normal distribution. A function call engine(size, dtype=None, device=None) should return a tensor filled with random numbers from a standard normal distribution.

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

Returns

torch.Tensor

Examples

>>> from pfhedge.stochastic import generate_merton_jump
>>>
>>> _ = torch.manual_seed(42)
>>> generate_merton_jump(2, 5)
tensor([[1.0000, 0.9904, 1.0074, 1.0160, 1.0117],
        [1.0000, 1.0034, 1.0040, 1.0490, 1.0457]])