module Quant.YieldCurve (
YieldCurve (..)
, FlatCurve (..)
, NetYC (..)
) where
import Quant.Time
class YieldCurve a where
disc :: YieldCurve a => a -> Time -> Double
forward :: YieldCurve a => a -> Time -> Time -> Double
forward yc t1 t2 = (/(timeFromZero t2timeFromZero t1)) $ log $ disc yc t1 / disc yc t2
spot :: YieldCurve a => a -> Time -> Double
spot yc t = forward yc (Time 0) t
data FlatCurve = FlatCurve Double
instance YieldCurve FlatCurve where
disc (FlatCurve r) t = exp (r*timeFromZero 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