Atoms¶
The atoms
package provides the fundamental data structures used throughout
the optpricing library, representing core financial concepts like options,
stocks, and interest rates.
ExerciseStyle ¶
Bases: Enum
Enumeration for the exercise style of an option.
Option
dataclass
¶
Option(
strike: float,
maturity: float,
option_type: OptionType,
exercise_style: ExerciseStyle = ExerciseStyle.EUROPEAN,
)
Immutable container representing a single vanilla option contract.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strike
|
float
|
The strike price of the option. |
required |
maturity
|
float
|
The time to maturity of the option, expressed in years. |
required |
option_type
|
OptionType
|
The type of the option, either CALL or PUT. |
required |
exercise_style
|
ExerciseStyle
|
The exercise style of the option, by default ExerciseStyle.EUROPEAN. |
EUROPEAN
|
parity_counterpart ¶
Create the put-call parity equivalent of this option.
A call is converted to a put, and a put is converted to a call, while keeping all other parameters the same.
Returns:
Type | Description |
---|---|
Option
|
A new Option instance with the opposite type. |
Source code in src/optpricing/atoms/option.py
OptionType ¶
Bases: Enum
Enumeration for the type of an option (Call or Put).
Rate
dataclass
¶
Represents the risk-free interest rate structure.
This can be a single constant rate or a full term structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate
|
float | Callable[[float], float]
|
|
required |
get_rate ¶
Get the interest rate for a specific maturity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
float
|
The time (maturity) for which to get the rate. This is only used if the rate is a term structure (callable). Default is 0. |
0
|
Returns:
Type | Description |
---|---|
float
|
The continuously compounded risk-free rate. |
Source code in src/optpricing/atoms/rate.py
Stock
dataclass
¶
Stock(
spot: float,
volatility: float | None = None,
dividend: float = 0.0,
discrete_dividends: list[float] | None = None,
ex_div_times: list[float] | None = None,
)
Immutable container representing the underlying asset's properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spot
|
float
|
The current price of the underlying asset. |
required |
volatility
|
float | None
|
The constant (implied or historical) volatility of the asset's returns.
Default is |
None
|
dividend
|
float
|
The continuously compounded dividend yield, by default 0.0. |
0.0
|
discrete_dividends
|
list[float] | None
|
A list of discrete dividend amounts. Default is |
None
|
ex_div_times
|
list[float] | None
|
A list of times (in years) for the discrete dividend payments.
Must correspond to |
None
|
ZeroCouponBond
dataclass
¶
Represents a zero-coupon bond contract.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
maturity
|
float
|
The time to maturity of the bond, in years. |
required |
face_value
|
float
|
The face value of the bond, paid at maturity. Defaults to 1.0. |
1.0
|