{-# LANGUAGE BangPatterns #-}
module QuantLib.Methods.Pricer
( MaxMinClosePricer (..)
, LastPointPricer (..)
, LogLastPointPricer (..)
) where
import QuantLib.Methods.MonteCarlo (PathPricer (..))
import QuantLib.Stochastic.Process (Dot (..))
data MaxMinClosePricer = MMCP {
mmcpHigh :: Double,
mmcpLow :: Double,
mmcpClose :: Double
} deriving (Show)
instance PathPricer MaxMinClosePricer where
ppPrice _ path = MMCP high low close
where !close = last xs
!high = maximum xs
!low = minimum xs
xs = map getX path
newtype LastPointPricer = LastPointPricer Double
instance PathPricer LastPointPricer where
ppPrice _ = LastPointPricer <$> getX . last
newtype LogLastPointPricer = LogLastPointPricer Double
instance PathPricer LogLastPointPricer where
ppPrice _ path = LogLastPointPricer (log (lastX / firstX))
where
lastX = getX $ last path
firstX = getX $ head path