F#: Shocking The Forecast

As I sit here on the train I release that my late night coding meant that I missed shocking the forcast. The following code corrects last nights mistake:

    let valueDate = new DateTime(2010,1,1)
    let trade  = createIRSTwoLegTrade 101
    let npv =
        trade.SwapStream |> Seq.sumBy (fun x -> generateCashflow(x,trade, valueDate, curve, forcast))
    printfn "IRS NPV %A" npv

    let bumpCurve = curve |> List.map (fun x -> (fst x + 0.0001, snd x))
    let bumpForcast = forcast |> List.map (fun x -> (fst x + 0.0001, snd x))
    let shockedNpv =
        trade.SwapStream |> Seq.sumBy (fun x -> generateCashflow(x,trade, valueDate, bumpCurve, bumpForcast))
    printfn "IRS Shocked NPV %A" shockedNpv

    printfn "Parallel PV01 %A" (npv - shockedNpv)

~ by mdavey on March 12, 2010.

One Response to “F#: Shocking The Forecast”

  1. could you please post your code on a codeplex site or on github? so that it will be easier to follow?

Leave a Reply