public void CreateStructuredFloorTest() { #region Initialise QRLib.PricingStructures.ClearCache(); string rateCurveId = BuildMarket(_baseDate); IMarketEnvironment marketEnvironment = ObjectCacheHelper.GetMarket(_marketEnvironmentId); #endregion #region Define the Swap const string id = "TestStructuredFloor"; object[,] capFloorTerms = { { "DealReferenceIdentifier", id }, { "BasePartyBuySellsInd", "Sells" }, { "CounterpartyName", "ANZ" }, { "DealType", "Floor" }, }; object[,] streamTerms = { { "NotionalAmount", "1000000" }, { "Currency", "AUD" }, { "DayCountConvention", "ACT/365.FIXED" }, { "DiscountingType", "Standard" }, { "DiscountCurveReference", rateCurveId }, { "ForwardCurveReference", rateCurveId }, { "VolatilityCurveReference", _volatilityStructureId }, { "RateIndexName", "AUD-LIBOR-BBA" }, { "RateIndexTenor", "6m" }, { "StrikePrice", "0.07" }, }; const double notionalAmount = -1000000; object[,] couponMatrix = { { "StartDate", "EndDate", "NotionalAmount", "StrikePrice" }, { new DateTime(2009, 09, 04), new DateTime(2010, 03, 01), notionalAmount, "0.07"}, { new DateTime(2010, 03, 01), new DateTime(2010, 09, 01), notionalAmount, "0.07"}, { new DateTime(2010, 09, 01), new DateTime(2011, 03, 01), notionalAmount, "0.07"}, { new DateTime(2011, 03, 01), new DateTime(2011, 09, 05), notionalAmount, "0.07"}, }; #endregion #region Define the Valuation Criteria string[] requiredMetrics = { "NPV", "BreakEvenRate" }; #endregion #region Create & Value the Swap string returnedId = QRLib.Rates.InterestRateCapFloor.CreateStructured(capFloorTerms, streamTerms, couponMatrix); Assert.AreEqual(id, returnedId); InterestRateCapFloor capFloor = ProductHelper.Get <InterestRateCapFloor>(id); Assert.IsNotNull(capFloor); CreditSettings creditSettings = new CreditSettings(ServerStore.Client); IDictionary <string, object> valuation = capFloor.BasicValuation(_baseDate, marketEnvironment, requiredMetrics, creditSettings); #endregion #region Validate the Results Assert.AreEqual(CapBreakEvenRate, Convert.ToDouble(valuation["BreakEvenRate"]), 0.0000001); Assert.AreEqual(_pv, Convert.ToDouble(valuation["NPV"]), 3); #endregion #region Reset QRLib.PricingStructures.ClearCache(); #endregion }
public void CreateAmortisedFloorTest() { #region Initialise QRLib.PricingStructures.ClearCache(); string rateCurveId = BuildMarket(_baseDate); IMarketEnvironment marketEnvironment = ObjectCacheHelper.GetMarket(_marketEnvironmentId); #endregion #region Define the Swap const string id = "TestAmortisedFloor"; object[,] capFloorTerms = { { "DealReferenceIdentifier", id }, { "BasePartyBuySellsInd", "Sells" }, { "CounterpartyName", "ANZ" }, { "DealType", "Floor" }, { "EffectiveDate", _baseDate }, { "TerminationDate", _baseDate.AddYears(2) }, { "AdjustCalculationDates", true }, }; object[,] streamTerms = { { "NotionalAmount", "1000000" }, { "Currency", "AUD" }, { "ScheduleGeneration", "Forward" }, { "BusinessCenters", "Sydney" }, { "CouponPeriod", "6m" }, { "RollDay", "1" }, { "CouponDateAdjustment", "FOLLOWING" }, { "DayCountConvention", "ACT/365.FIXED" }, { "DiscountingType", "Standard" }, { "DiscountCurveReference", rateCurveId }, { "FixedOrObservedRate", "0.07" }, { "ObservedRateSpecified", "FALSE" }, { "ForwardCurveReference", rateCurveId }, { "FixingDateBusinessCenters", "Sydney" }, { "FixingDateResetInterval", "0D" }, { "FixingDateAdjustmentConvention", "NONE" }, { "RateIndexName", "AUD-LIBOR-BBA" }, { "RateIndexTenor", "6m" }, { "Spread", "0" }, { "VolatilityCurveReference", _volatilityStructureId }, { "StrikePrice", "0.07" }, }; #endregion #region Define the Valuation Criteria string[] requiredMetrics = { "NPV", "BreakEvenRate" }; #endregion #region Create & Value the Swap string returnedId = QRLib.Rates.InterestRateCapFloor.CreateAmortised(capFloorTerms, streamTerms, null); Assert.AreEqual(id, returnedId); InterestRateCapFloor capFloor = ProductHelper.Get <InterestRateCapFloor>(id); Assert.IsNotNull(capFloor); CreditSettings creditSettings = new CreditSettings(ServerStore.Client); IDictionary <string, object> valuation = capFloor.BasicValuation(_baseDate, marketEnvironment, requiredMetrics, creditSettings); #endregion #region Validate the Results Assert.AreEqual(CapBreakEvenRate, Convert.ToDouble(valuation["BreakEvenRate"]), 0.0000001); Assert.AreEqual(_pv, Convert.ToDouble(valuation["NPV"]), 3); #endregion #region Reset QRLib.PricingStructures.ClearCache(); #endregion }