Skip to content

BaseTechnique#

Bases: ABC

Abstract base class for all pricing methodologies.

A technique defines the algorithm used to compute a price from the core 'atoms' (Option, Stock, Rate) and a given financial 'Model'.

Source code in src/quantfin/techniques/base/base_technique.py
class BaseTechnique(ABC):
    """
    Abstract base class for all pricing methodologies.

    A technique defines the algorithm used to compute a price from the core
    'atoms' (Option, Stock, Rate) and a given financial 'Model'.
    """

    @abstractmethod
    def price(
        self,
        option: Option | np.ndarray,
        stock: Stock,
        model: BaseModel,
        rate: Rate,
        **kwargs,
    ) -> PricingResult | np.ndarray:
        """
        Calculate the price of an option.

        Parameters
        ----------
        option : Option | np.ndarray
            The option contract(s) to be priced.
        stock : Stock
            The underlying asset's properties.
        model : BaseModel
            The financial model to use for the calculation.
        rate : Rate
            The risk-free rate structure.
        **kwargs : Any
            Additional keyword arguments required by specific techniques or models.

        Returns
        -------
        PricingResult
            An object containing the calculated price and potentially other metrics.
        """
        raise NotImplementedError

price(option: Option | np.ndarray, stock: Stock, model: BaseModel, rate: Rate, **kwargs) -> PricingResult | np.ndarray abstractmethod #

Calculate the price of an option.

Parameters:

Name Type Description Default
option Option | ndarray

The option contract(s) to be priced.

required
stock Stock

The underlying asset's properties.

required
model BaseModel

The financial model to use for the calculation.

required
rate Rate

The risk-free rate structure.

required
**kwargs Any

Additional keyword arguments required by specific techniques or models.

{}

Returns:

Type Description
PricingResult

An object containing the calculated price and potentially other metrics.

Source code in src/quantfin/techniques/base/base_technique.py
@abstractmethod
def price(
    self,
    option: Option | np.ndarray,
    stock: Stock,
    model: BaseModel,
    rate: Rate,
    **kwargs,
) -> PricingResult | np.ndarray:
    """
    Calculate the price of an option.

    Parameters
    ----------
    option : Option | np.ndarray
        The option contract(s) to be priced.
    stock : Stock
        The underlying asset's properties.
    model : BaseModel
        The financial model to use for the calculation.
    rate : Rate
        The risk-free rate structure.
    **kwargs : Any
        Additional keyword arguments required by specific techniques or models.

    Returns
    -------
    PricingResult
        An object containing the calculated price and potentially other metrics.
    """
    raise NotImplementedError