RustQuant_instruments/options/
log.rs1use super::OptionContract;
11use crate::Payoff;
12
13#[derive(Debug, Clone)]
15pub struct LogMoneynessContract {
16 pub contract: OptionContract,
18
19 pub strike: f64,
21}
22
23#[derive(Debug, Clone)]
25pub struct LogUnderlyingContract {
26 pub contract: OptionContract,
28
29 pub strike: f64,
31}
32
33#[derive(Debug, Clone)]
35pub struct LogOption {
36 pub contract: OptionContract,
38
39 pub strike: f64,
41}
42
43impl Payoff for LogMoneynessContract {
44 type Underlying = f64;
45
46 fn payoff(&self, underlying: Self::Underlying) -> f64 {
47 (underlying / self.strike).ln()
48 }
49}
50
51impl Payoff for LogUnderlyingContract {
52 type Underlying = f64;
53
54 fn payoff(&self, underlying: Self::Underlying) -> f64 {
55 underlying.ln()
56 }
57}
58
59impl Payoff for LogOption {
60 type Underlying = f64;
61
62 fn payoff(&self, underlying: Self::Underlying) -> f64 {
63 (underlying / self.strike).ln().max(0.0)
64 }
65}