module Quant.YieldCurve (
YieldCurve (..)
, FlatCurve (..)
, NetYC (..)
) where
class YieldCurve a where
disc :: YieldCurve a => a -> Double -> Double
forward :: YieldCurve a => a -> Double -> Double -> Double
forward yc t1 t2 = (/(t2t1)) $ log $ disc yc t1 / disc yc t2
spot :: YieldCurve a => a -> Double -> Double
spot yc t = forward yc 0 t
data FlatCurve = FlatCurve Double
instance YieldCurve FlatCurve where
disc (FlatCurve r) t = exp (r*t)
data NetYC a = NetYC a a
instance YieldCurve a => YieldCurve (NetYC a) where
disc (NetYC yc1 yc2) t = disc yc1 t / disc yc2 t