HQu-0.0.0.0: src/Q/Options/ImpliedVol/SVI.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Q.Options.ImpliedVol.SVI where
import Q.Types (Forward (..), Strike (..), Vol (..),
YearFrac (..))
import Q.Options.ImpliedVol.TimeSlice
import GHC.Generics (Generic)
import Q.Greeks (Bump, Bumpable(..))
newtype Alpha = Alpha Double deriving (Generic, Eq, Show, Ord, Num, Fractional, Floating)
newtype Beta = Beta Double deriving (Generic, Eq, Show, Ord, Num, Fractional, Floating)
newtype Rho = Rho Double deriving (Generic, Eq, Show, Ord, Num, Fractional, Floating)
newtype M = M Double deriving (Generic, Eq, Show, Ord, Num, Fractional, Floating)
newtype Sigma = Sigma Double deriving (Generic, Eq, Show, Ord, Num, Fractional, Floating)
-- | Stochastic volatility inspired parameterization of the vol surface.
data SVI = RSVI -- ^ The original raw SVI representation from Gatheral
Alpha -- ^ Corresponds to a vertical translation of the smile.
Beta -- ^ Slope of call and put wings.
Rho -- ^ A counter clock wise rotation of the smile.
M -- ^ translate the smile to the right
Sigma -- ^ ATM curviture of the smile.
instance TimeSlice SVI LogRelStrike where
totalVar (RSVI (Alpha πΆ) (Beta π·) (Rho π) (M π¦) (Sigma π)) (LogRel π€) =
TotalVar $ πΆ + π· * (π * (π€ - π¦) + sqrt ((π€ - π¦) ** 2 + π * π))
isValidSVI (RSVI (Alpha πΆ) (Beta π·) (Rho π) (M π¦) (Sigma π)) =
π· >= 0
&& abs π < 1
&& π > 0
&& πΆ + π· * π * sqrt (1 -π*π) >= 0