var BondValues = from s in Scenario
select new { Name = s.Name, BondPx = CalcBondPx(s.RateValue) };
BondValues.Print("\nBond Prices in different scenarios");
// 5) Calculate the differences in bond prices in different scenarios, with
// respect to "flat" scenario
var PricesDelta = from s in BondValues
select new
{
Name = s.Name,
Delta = s.BondPx - BondValues.Single
(p => p.Name == "Flat").BondPx
};
PricesDelta.Print("\nDeltas in bond prices with respect 'Flat'
scenario");
The output from this code is:
Scenarios
{ Name = Flat, RateValue = 0.05 },
{ Name = +1bp, RateValue = 0.0501 },
{ Name = +100bp, RateValue = 0.06 },
{ Name = -1bp, RateValue = 0.0499 },
{ Name = -100bp, RateValue = 0.04 },
Bond Prices in different scenarios
{ Name = Flat, BondPx = 91.5043472804292 },
{ Name = +1bp, BondPx = 91.4774614314561 },
{ Name = +100bp, BondPx = 88.8549315045526 },
{ Name = -1bp, BondPx = 91.5312411221132 },
{ Name = -100bp, BondPx = 94.233696116228 },
Deltas in bond prices with respect 'Flat' scenario
{ Name = Flat, Delta = 0 },
{ Name = +1bp, Delta = -0.0268858489730945 },
{ Name = +100bp, Delta = -2.64941577587669 },
{ Name = -1bp, Delta = 0.0268938416839575 },
{ Name = -100bp, Delta = 2.72934883579873 },
It is possible to generalise this design to cases in