use super::OptionContract;
use crate::Payoff;
#[derive(Debug, Clone)]
pub struct LogMoneynessContract {
pub contract: OptionContract,
pub strike: f64,
}
#[derive(Debug, Clone)]
pub struct LogUnderlyingContract {
pub contract: OptionContract,
pub strike: f64,
}
#[derive(Debug, Clone)]
pub struct LogOption {
pub contract: OptionContract,
pub strike: f64,
}
impl Payoff for LogMoneynessContract {
type Underlying = f64;
fn payoff(&self, underlying: Self::Underlying) -> f64 {
(underlying / self.strike).ln()
}
}
impl Payoff for LogUnderlyingContract {
type Underlying = f64;
fn payoff(&self, underlying: Self::Underlying) -> f64 {
underlying.ln()
}
}
impl Payoff for LogOption {
type Underlying = f64;
fn payoff(&self, underlying: Self::Underlying) -> f64 {
(underlying / self.strike).ln().max(0.0)
}
}