module Quant.Models.Black (
Black (..)
) where
import Quant.Types
import Quant.Time
import Quant.YieldCurve
import Data.Random
import Control.Monad.State
import Quant.MonteCarlo
data Black = forall a b . (YieldCurve a, YieldCurve b) => Black {
blackInit :: Double
, blackVol :: Double
, blackForwardGen :: a
, blackYieldCurve :: b }
instance Discretize Black Observables1 where
initialize (Black s _ _ _) = put (Observables1 s, Time 0)
evolve' b@(Black _ vol _ _) t2 anti = do
(Observables1 stateVal, t1) <- get
fwd <- forwardGen b t2
let t = timeDiff t1 t2
grwth = (fwd vol*vol/2) * t
resid <- lift stdNormal
let resid' = if anti then resid else resid
postVal = stateVal * exp (grwth + resid'*vol*sqrt t)
put (Observables1 postVal, t2)
discount (Black _ _ _ dsc) t = return $ disc dsc t
forwardGen (Black _ _ fg _) t2 = do
(_, t1) <- get
return $ forward fg t1 t2
maxStep _ = 100