EuropeanForwardStartOption

class pfhedge.instruments.EuropeanForwardStartOption(underlier, strike=1.0, maturity=0.08, start=0.04)[source]

European forward start option.

The payoff is given by

\[\mathrm{payoff} = \max(S_T / S_{T'} - K, 0) ,\]

where \(S_T\) is the underlier’s spot price at maturity, \(S_{T'}\) is the underlier’s spot price at start, and \(K\) is the strike.

Note

If start is not divisible by the interval of the time step, it is rounded off so that the start time is the largest value that is divisible by the interval and less than start.

Parameters
  • underlier (BasePrimary) – The underlying instrument of the option.

  • strike (float, default=1.0) – The strike value of the option.

  • maturity (float, default=20/250) – The maturity of the option.

  • start (float, default=10/250) – The start of the option.

dtype

The dtype with which the simulated time-series are represented.

Type

torch.dtype

device

The device where the simulated time-series are.

Type

torch.device

Examples

>>> import torch
>>> from pfhedge.instruments import BrownianStock
>>> from pfhedge.instruments import EuropeanForwardStartOption
>>>
>>> _ = torch.manual_seed(42)
>>> derivative = EuropeanForwardStartOption(BrownianStock(), maturity=5/250, start=2/250)
>>> derivative.simulate(n_paths=2)
>>> derivative.underlier.spot
tensor([[1.0000, 1.0016, 1.0044, 1.0073, 0.9930, 0.9906],
        [1.0000, 0.9919, 0.9976, 1.0009, 1.0076, 1.0179]])
>>> derivative.underlier.spot[:, -1] / derivative.underlier.spot[:, 2]
tensor([0.9862, 1.0203])
>>> derivative.payoff()
tensor([0.0000, 0.0203])
list(pricer, cost=0.0)

Make self a listed derivative.

After this method self will be a exchange-traded derivative which can be transacted at any time with the spot price given by self.spot.

See an example in EuropeanOption for a usage.

Parameters
  • pricer (Callable[[BaseDerivative], Tensor]]) – A function that takes self and returns the spot price tensor of self.

  • cost (float, optional) – The transaction cost rate.

simulate(n_paths=1, init_state=None)

Simulate time series associated with the underlier.

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

  • init_state (tuple[torch.Tensor | float], optional) – The initial state of the underlier.

  • **kwargs – Other parameters passed to self.underlier.simulate().

to(*args, **kwargs)

Moves and/or casts the buffers of the instrument.

This can be called as

to(device=None, dtype=None)
to(tensor)
to(instrument)

Its signature is similar to torch.nn.Module.to(). It only accepts floating point dtypes. See Instrument dtype and device for details.

Note

This method modifies the instrument in-place.

See also

  • float(): Cast to torch.float32.

  • double(): Cast to torch.float64.

  • half(): Cast to torch.float16.

  • bfloat16(): Cast to torch.bfloat16.

  • cuda(): Move to CUDA memory.

  • cpu(): Move to CPU memory.

Parameters
  • dtype (torch.dtype) – The desired floating point dtype of the buffers in this instrument.

  • device (torch.device) – The desired device of the buffers in this instrument.

  • tensor (torch.Tensor) – Tensor whose dtype and device are the desired dtype and device of the buffers in this instrument.

  • instrument (BaseInstrument) – Instrument whose dtype and device are the desired dtype and device of the buffers in this instrument.

Returns

self

ul(index=0)

Alias for self.underlier.