#[derive(Clone, Debug)]
pub struct GreekPnL {
pub delta: f64,
pub gamma: f64,
pub vega: f64,
pub theta: f64,
}
impl GreekPnL {
pub fn new(delta: f64, gamma: f64, vega: f64, theta: f64) -> Self {
Self {
delta,
gamma,
vega,
theta,
}
}
#[must_use]
pub fn calculate(&self, d_s: f64, d_sigma: f64, dt: f64) -> f64 {
self.delta * d_s + 0.5 * self.gamma * d_s * d_s + self.vega * d_sigma + self.theta * dt
}
}
#[derive(Clone, Debug)]
pub struct DiscretePnL {
pub quantity: f64,
pub p0: f64,
}
impl DiscretePnL {
pub fn new(quantity: f64, p0: f64) -> Self {
Self { quantity, p0 }
}
#[must_use]
pub fn calculate(&self, p1: f64) -> f64 {
self.quantity * (p1 - self.p0)
}
}
#[derive(Clone, Debug)]
pub struct DeltaHedgedPnL {
pub theta: f64,
pub gamma: f64,
pub sigma: f64,
pub s: f64,
}
impl DeltaHedgedPnL {
pub fn new(theta: f64, gamma: f64, sigma: f64, s: f64) -> Self {
Self {
theta,
gamma,
sigma,
s,
}
}
#[must_use]
pub fn calculate(&self, dt: f64) -> f64 {
self.theta * dt + 0.5 * self.gamma * self.sigma * self.sigma * self.s * self.s * dt
}
}