BaseInstrument¶
- class pfhedge.instruments.BaseInstrument[source]¶
Base class for all financial instruments.
- bfloat16()[source]¶
Casts all floating point parameters and buffers to
torch.bfloat16datatype.Note
This method modifies the instrument in-place.
- Returns
self
- cpu()[source]¶
Moves all buffers of this instrument and its underlier to the CPU.
Note
This method modifies the instrument in-place.
- Returns
self
- cuda(device=None)[source]¶
Moves all buffers of this instrument and its underlier to the GPU.
Note
This method modifies the instrument in-place.
- Parameters
device (int, optional) – If specified, all buffers will be copied to that device.
- Returns
self
- double()[source]¶
Casts all floating point parameters and buffers to
torch.float64datatype.Note
This method modifies the instrument in-place.
- Returns
self
- extra_repr()[source]¶
Set the extra representation of the instrument.
To print customized extra information, you should re-implement this method in your own instruments. Both single-line and multi-line strings are acceptable.
- float()[source]¶
Casts all floating point parameters and buffers to
torch.float32datatype.Note
This method modifies the instrument in-place.
- Returns
self
- half()[source]¶
Casts all floating point parameters and buffers to
torch.float16datatype.Note
This method modifies the instrument in-place.
- Returns
self
- abstract property is_listed¶
Returns whether it is listed or not.
- abstract simulate(n_paths, time_horizon, **kwargs)[source]¶
Simulate time series associated with the instrument itself (for a primary instrument) or its underlier (for a derivative) and add them as buffers.
- abstract property spot¶
Returns the spot price of self.
- abstract to(*args, **kwargs)[source]¶
Moves and/or casts the buffers of the instrument.
This can be called as
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
- 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