public override object[,] DoXLReport(InstrumentControllerBase pricer) { if (pricer is VanillaEuropeanFxOptionPricer fxswap) { var result = new object[fxswap.GetChildren().Count, 5]; var index = 0; foreach (var cashflow in fxswap.GetChildren()) { var flow = (PriceableCashflow)cashflow; result[index, 0] = flow.CashflowType.Value; result[index, 1] = flow.PaymentDate; result[index, 2] = flow.PaymentAmount.currency.Value; if (flow.ForecastAmount != null) { result[index, 3] = flow.ForecastAmount.amount; } else { result[index, 3] = flow.PaymentAmount.amount; } result[index, 4] = flow.ProductType.ToString(); //result[index, 5] = flow.; index++; } return(result); } return(null); }
public override object[,] DoXLReport(InstrumentControllerBase instrument) { if (instrument is FraPricer forwardRateAgreement) { var result = new object[forwardRateAgreement.GetChildren().Count, 7]; var index = 0; foreach (var receiveRateCoupon in forwardRateAgreement.GetChildren()) { var flow = (PriceableRateCoupon)receiveRateCoupon; result[index, 0] = flow.CashflowType.Value; result[index, 1] = flow.PaymentDate; result[index, 2] = flow.AccrualStartDate; result[index, 3] = flow.AccrualEndDate; result[index, 4] = flow.NotionalAmount.amount; result[index, 5] = flow.Rate; if (flow.ForecastAmount != null) { result[index, 6] = flow.ForecastAmount.amount; } else { result[index, 6] = flow.PaymentAmount.amount; } index++; } return(result); } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is InterestRateSwaptionPricer interestRateSwaption) { Debug.Print("Number of legs : {0}", interestRateSwaption.GetChildren().Count); if (interestRateSwaption.Swap is InterestRateSwapPricer swap) { Debug.Print("Receive leg {0} coupons", swap.ReceiveLeg.Coupons.Count); foreach (var receiveRateCoupon in swap.ReceiveLeg.Coupons) { Debug.Print( "Coupon: coupon type: {0},payment date: {1}, notional amount : {2}, fixed rate : {3}, payment amount: {4}", receiveRateCoupon.CashflowType, receiveRateCoupon.PaymentDate, receiveRateCoupon.Notional, receiveRateCoupon.Rate, receiveRateCoupon.PaymentAmount); } Debug.Print("Pay leg {0} coupons", swap.PayLeg.Coupons.Count); foreach (var payRateCoupon in swap.PayLeg.Coupons) { Debug.Print( "Coupon: coupon type: {0},payment date: {1}, notional amount : {2}, fixed rate : {3}, payment amount: {4}", payRateCoupon.CashflowType, payRateCoupon.PaymentDate, payRateCoupon.Notional, payRateCoupon.Rate, payRateCoupon.PaymentAmount); } } } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is InterestRateSwapPricer interestRateSwap) { var fixedStream = new InterestRateStream { cashflows = new Cashflows { paymentCalculationPeriod = interestRateSwap.ReceiveLeg.Coupons.Select(fixedRateCoupon => fixedRateCoupon.Build()).ToArray() } }; var floatStream = new InterestRateStream { cashflows = new Cashflows { paymentCalculationPeriod = interestRateSwap.ReceiveLeg.Coupons.Select(payRateCoupon => payRateCoupon.Build()).ToArray() } }; var fpmlSwap = new Swap { swapStream = new[] { fixedStream, floatStream } }; return(fpmlSwap); } return(null); }
public override object[,] DoXLReport(InstrumentControllerBase pricer) { if (pricer is BondTransactionPricer bond) { var result = new object[bond.GetChildren().Count, 8]; var index = 0; foreach (var cashflow in bond.GetChildren()) { var flow = (PriceableCashflow)cashflow; result[index, 0] = flow.CashflowType.Value; result[index, 1] = flow.PaymentDate; result[index, 2] = flow.PaymentAmount.currency.Value; if (flow.ForecastAmount != null) { result[index, 3] = flow.ForecastAmount.amount; } else { result[index, 3] = flow.PaymentAmount.amount; } result[index, 4] = flow.ProductType.ToString(); result[index, 5] = flow.PayerIsBaseParty; result[index, 6] = flow.ReceiverPartyReference?.href; result[index, 7] = flow.PayerPartyReference?.href; index++; } return(result); } return(null); }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase pricer) { if (pricer is BulletPaymentPricer payment) { return((from PriceableCashflow flow in payment.GetChildren() select CashflowReportHelper.DoCashflowReport(pricer.Id, flow)).ToList()); } return(null); }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase pricer) { if (pricer is PropertyTransactionPricer bond) { return((from PriceableCashflow flow in bond.GetChildren() select CashflowReportHelper.DoCashflowReport(pricer.Id, flow)).ToList()); } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is FraPricer forwardRateAgreement) { Debug.Print("Fra leg {0} coupons", forwardRateAgreement.GetChildren().Count); foreach (var receiveRateCoupon in forwardRateAgreement.GetChildren()) { var flow = (PriceableRateCoupon)receiveRateCoupon; var forecast = flow.ForecastAmount ?? new Money(); Debug.Print("Cashflow type: {0}, payment date: {1}, payment amount: {2}, forecast amount: {3}", flow.CashflowType, flow.PaymentDate, flow.PaymentAmount, forecast); } } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is VanillaEuropeanFxOptionPricer fxswap) { Debug.Print("Payment {0} coupons", fxswap.GetChildren().Count); foreach (var cashflow in fxswap.GetChildren()) { var flow = (PriceableCashflow)cashflow; var forecast = flow.ForecastAmount ?? new Money(); Debug.Print("Cashflow type: {0}, payment date: {1}, payment amount: {2}, forecast amount: {3}", flow.CashflowType, flow.PaymentDate, flow.PaymentAmount, forecast); } } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is TermDepositPricer termDeposit) { Debug.Print("Number of coupons : {0}", termDeposit.GetChildren().Count); foreach (var receiveRateCoupon in termDeposit.GetChildren()) { var flow = (PriceableRateCoupon)receiveRateCoupon; var forecast = flow.ForecastAmount ?? new Money(); Debug.Print("Coupon: coupon type: {0},payment date: {1}, notional amount : {2}, fixed rate : {3}, payment amount: {4}, forecast amount: {5}", flow.CashflowType, flow.PaymentDate, flow.Notional, flow.Rate, flow.PaymentAmount, forecast); } } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is FutureTransactionPricer future) { Debug.Print("Futures {0} underlyer", future.GetChildren().Count); foreach (var cashflow in future.GetChildren()) { var flow = (PriceableCashflow)cashflow; var forecast = flow.ForecastAmount ?? new Money(); Debug.Print("Cashflow type: {0}, payment date: {1}, payment amount: {2}, forecast amount: {3}", flow.CashflowType, flow.PaymentDate, flow.PaymentAmount, forecast); } } return(null); }
public override object DoReport(InstrumentControllerBase priceable) { if (priceable is PropertyTransactionPricer equity) { Debug.Print("Equity {0} dividends", equity.GetChildren().Count); foreach (var cashflow in equity.GetChildren()) { var flow = (PriceableCashflow)cashflow; var forecast = flow.ForecastAmount ?? new Money(); Debug.Print("Cashflow type: {0}, payment date: {1}, payment amount: {2}, forecast amount: {3}", flow.CashflowType, flow.PaymentDate, flow.PaymentAmount, forecast); } } return(null); }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase pricer) { if (pricer is FraPricer payment) { var result = new List <object[]>(); foreach (var cashflow in payment.GetChildren()) { var flow = (PriceableCashflow)cashflow; var reportHelper = CashflowReportHelper.DoCashflowReport(pricer.Id, flow); reportHelper[0] = pricer.Id; result.Add(reportHelper); } return(result); } return(null); }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase pricer) { if (pricer is VanillaEuropeanFxOptionPricer payment) { var result = new List <object[]>(); var index = 0; foreach (var cashflow in payment.GetChildren()) { var flow = (PriceableCashflow)cashflow; var reportHelper = CashflowReportHelper.DoCashflowReport(pricer.Id, flow); reportHelper[0] = pricer.Id; result[index] = reportHelper; index++; } return(result); } return(null); }
static public void ProcessInstrumentControllerResultsEvolve(InstrumentControllerBase instrumentController, string[] metrics, DateTime baseDate, DateTime valuationDate) { Assert.IsNotNull(instrumentController); //Double[] times = { 0, 1, 2, 3, 4, 5 }; //Double[] dfs = { 1, 0.98, 0.96, 0.91, 0.88, 0.85}; ISwapLegEnvironment market = CreateInterestRateStreamTestEnvironment(baseDate); IInstrumentControllerData controllerData = CreateInstrumentModelData(metrics, valuationDate, market); Assert.IsNotNull(controllerData); var results = instrumentController.Calculate(controllerData); Debug.Print("Id : {0}", instrumentController.Id); foreach (var metric in results.quote) { Debug.Print("Id : {0} Metric Name : {1} Metric Value : {2}", instrumentController.Id, metric.measureType.Value, metric.value); } }
static public void ProcessFxLegResultsWithCurrency(InstrumentControllerBase instrumentController, string[] metrics, DateTime baseDate, string currency) { Assert.IsNotNull(instrumentController); //Double[] times = { 0, 1, 2, 3, 4, 5 }; //Double[] dfs = { 1, 0.98, 0.96, 0.91, 0.88, 0.85}; IMarketEnvironment market = CreateFxLegTestEnvironment(baseDate); IInstrumentControllerData controllerData = CreateInstrumentModelData(metrics, baseDate, market, currency); Assert.IsNotNull(controllerData); var results = instrumentController.Calculate(controllerData); Debug.Print("Id : {0}", instrumentController.Id); foreach (var metric in results.quote) { Debug.Print("Id : {0} Metric Name : {1} Metric Value : {2}", instrumentController.Id, metric.measureType.Value, metric.value); } }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase instrument) { var interestRateSwaption = instrument as InterestRateSwaptionPricer; List <object[]> result = new List <object[]>(); if (interestRateSwaption?.Swap != null) { var expectedCashFlows = new InterestRateSwapReporter().DoExpectedCashflowReport(interestRateSwaption.Swap); result.AddRange(expectedCashFlows); if (interestRateSwaption.PremiumPayments != null) { foreach (var pemium in interestRateSwaption.PremiumPayments) { var expectedCashFlow = CashflowReportHelper.DoCashflowReport(instrument.Id, pemium); expectedCashFlow[0] = instrument.Id; result.Add(expectedCashFlow); } } } return(result); }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase instrument) { var interestRateSwap = instrument as InterestRateSwapPricer; var result = new List <object[]>(); if (interestRateSwap != null) { foreach (var leg in interestRateSwap.Legs) { var expectedCashFlows = CashflowReportHelper.DoCashflowReport(instrument.Id, leg); result.AddRange(expectedCashFlows); } if (interestRateSwap.AdditionalPayments != null) { foreach (var payment in interestRateSwap.AdditionalPayments) { var pay = CashflowReportHelper.DoCashflowReport(instrument.Id, payment); pay[0] = instrument.Id; result.Add(pay); } } } return(result); }
/// <summary> /// REturns the report for that particluar product type. /// </summary> /// <returns></returns> public override object[,] DoXLReport(InstrumentControllerBase instrument) { return(ProductReporter.DoXLReport(instrument)); }
/// <summary> /// REturns the report for that particluar product type. /// </summary> /// <param name="instrument"></param> /// <returns></returns> public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase instrument) { return(ProductReporter.DoExpectedCashflowReport(instrument)); }
///<summary> /// Prices the trade. ///</summary> ///<returns></returns> public override ValuationReport Price(IInstrumentControllerData modelData, ValuationReportType reportType) { //Price. if (TradeHelper.IsImplementedProductType(ProductType)) { // A new valuationReport. var valuationReport = new ValuationReport(); //var valSet = new ValuationSet(); InstrumentControllerBase priceableProduct = PriceableProduct; if (priceableProduct == null) { throw new ApplicationException("PriceableProduct is null!"); } //This makes sure the marketenvironment has curves in it, otherwise the pricer will not function. if (modelData.MarketEnvironment == null) { throw new ApplicationException("MarketEnvironment is null!"); } //Set the appropriate Multiplier based on the reporting party var result = new AssetValuation(); var reportingParty = modelData.BaseCalculationParty.Id; if (BaseParty == TradeProp.Party1) { if (reportingParty == TradeProp.Party1) { result = priceableProduct.Calculate(modelData); } if (Parties[0].partyName.Value == reportingParty) { result = priceableProduct.Calculate(modelData); } if (Parties[1].partyName.Value == reportingParty || reportingParty == TradeProp.Party2) { priceableProduct.Multiplier = -1; result = priceableProduct.Calculate(modelData); priceableProduct.Multiplier = 1; } } if (BaseParty == TradeProp.Party2) { if (reportingParty == TradeProp.Party2) { result = priceableProduct.Calculate(modelData); } if (Parties[1].partyName.Value == reportingParty) { result = priceableProduct.Calculate(modelData); } if (Parties[0].partyName.Value == reportingParty || reportingParty == TradeProp.Party1) { priceableProduct.Multiplier = -1; result = priceableProduct.Calculate(modelData); priceableProduct.Multiplier = 1; } } if (modelData.IsReportingCounterpartyRequired) { priceableProduct.Multiplier = 0; result = priceableProduct.Calculate(modelData); priceableProduct.Multiplier = 1; } var valSet = new ValuationSet { assetValuation = new[] { result } }; //The tradevaluation item. var trade = new Trade { id = TradeIdentifier.UniqueIdentifier, tradeHeader = TradeHeader }; //Checks to see if the deatil data is required and if so builds the product.//TODO Add other ItemChoice types.e.g. Fra if (reportType == ValuationReportType.Full) { var item = PriceableProduct.BuildTheProduct(); trade.Item = item; trade.ItemElementName = trade.GetTradeTypeFromItem(); } var tradeValuationItem = new TradeValuationItem { Items = new object[] { trade }, valuationSet = valSet }; valuationReport.tradeValuationItem = new[] { tradeValuationItem }; return(valuationReport); } throw new NotSupportedException("Product pricing is not supported!"); }
public abstract List <object[]> DoExpectedCashflowReport(InstrumentControllerBase pricer);
public abstract object[,] DoXLReport(InstrumentControllerBase pricer);
public abstract object DoReport(InstrumentControllerBase priceable);
public override object[,] DoXLReport(InstrumentControllerBase instrument) { return(null); }
public override List <object[]> DoExpectedCashflowReport(InstrumentControllerBase pricer) { return(null); }
public override object[,] DoXLReport(InstrumentControllerBase instrument) { var interestRateSwap = instrument as InterestRateSwapPricer; object[,] result = null; if (interestRateSwap != null) { var receiveLegExchangesCount = 0; if (interestRateSwap.ReceiveLeg.PriceablePrincipalExchanges != null) { receiveLegExchangesCount = interestRateSwap.ReceiveLeg.PriceablePrincipalExchanges.Count; } var payLegExchangesCount = 0; if (interestRateSwap.PayLeg.PriceablePrincipalExchanges != null) { payLegExchangesCount = interestRateSwap.PayLeg.PriceablePrincipalExchanges.Count; } var rows = interestRateSwap.ReceiveLeg.Coupons.Count + interestRateSwap.PayLeg.Coupons.Count + 1 + receiveLegExchangesCount + payLegExchangesCount; result = new object[rows, 15]; var index = 1; //Headings First: result[0, 0] = "Leg"; result[0, 1] = "Coupon"; result[0, 2] = "PriceableCouponType"; //result[0, 3] = "PaymentDate"; result[0, 3] = "NotionalAmount"; result[0, 4] = "Rate"; result[0, 5] = "ForecastAmount"; result[0, 6] = "Currency"; result[0, 7] = "AccrualStartDate"; result[0, 8] = "AccrualEndDate"; result[0, 9] = "PaymentDate"; result[0, 10] = "PaymentDiscountFactor"; result[0, 11] = "NPV"; result[0, 12] = "CouponYearFraction"; result[0, 13] = "IsDiscounted"; result[0, 14] = "IsRealised"; foreach (var receiveRateCoupon in interestRateSwap.ReceiveLeg.Coupons) { result[index, 0] = "ReceiveLeg"; result[index, 1] = "Coupon_" + index; result[index, 2] = receiveRateCoupon.PriceableCouponType.ToString(); //result[index, 3] = receiveRateCoupon.PaymentDate; result[index, 3] = receiveRateCoupon.NotionalAmount.amount; result[index, 4] = receiveRateCoupon.Rate; result[index, 5] = receiveRateCoupon.ForecastAmount.amount; result[index, 6] = receiveRateCoupon.NotionalAmount.currency.Value; result[index, 7] = receiveRateCoupon.AccrualStartDate; result[index, 8] = receiveRateCoupon.AccrualEndDate; result[index, 9] = receiveRateCoupon.PaymentDate; result[index, 10] = receiveRateCoupon.PaymentDiscountFactor; result[index, 11] = receiveRateCoupon.NPV.amount; result[index, 12] = receiveRateCoupon.CouponYearFraction; result[index, 13] = receiveRateCoupon.IsDiscounted; result[index, 14] = receiveRateCoupon.IsRealised; index++; } var secondIndex = 1; foreach (var payRateCoupon in interestRateSwap.PayLeg.Coupons) { result[index, 0] = "PayLeg"; result[index, 1] = "Coupon_" + secondIndex; result[index, 2] = payRateCoupon.PriceableCouponType.ToString(); //result[index, 3] = payRateCoupon.PaymentDate; result[index, 3] = payRateCoupon.NotionalAmount.amount; result[index, 4] = payRateCoupon.Rate; result[index, 5] = payRateCoupon.ForecastAmount.amount; result[index, 6] = payRateCoupon.NotionalAmount.currency.Value; result[index, 7] = payRateCoupon.AccrualStartDate; result[index, 8] = payRateCoupon.AccrualEndDate; result[index, 9] = payRateCoupon.PaymentDate; result[index, 10] = payRateCoupon.PaymentDiscountFactor; result[index, 11] = payRateCoupon.NPV.amount; result[index, 12] = payRateCoupon.CouponYearFraction; result[index, 13] = payRateCoupon.IsDiscounted; result[index, 14] = payRateCoupon.IsRealised; index++; secondIndex++; } if (interestRateSwap.ReceiveLeg.Exchanges != null) { var thirdIndex = 1; foreach (var principal in interestRateSwap.ReceiveLeg.Exchanges) { result[index, 0] = "ReceiveLeg"; result[index, 1] = "Principal_" + thirdIndex; result[index, 2] = "PrincipalExchange"; //result[index, 3] = principal.RiskMaturityDate; result[index, 3] = principal.PaymentAmount.amount; result[index, 4] = 0.0m; result[index, 5] = principal.PaymentAmount.amount; result[index, 6] = principal.PaymentAmount.currency.Value; result[index, 7] = principal.PaymentDate; result[index, 8] = principal.PaymentDate; result[index, 9] = principal.PaymentDate; result[index, 10] = principal.PaymentDiscountFactor; var npv = 0.0m; if (principal.NPV != null) { npv = principal.NPV.amount; } result[index, 11] = npv; result[index, 12] = principal.YearFractionToCashFlowPayment; result[index, 13] = false; result[index, 14] = principal.IsRealised; index++; thirdIndex++; } } if (interestRateSwap.PayLeg.Exchanges != null) { var fourthIndex = 1; foreach (var principal in interestRateSwap.PayLeg.Exchanges) { result[index, 0] = "PayLeg"; result[index, 1] = "Principal_" + fourthIndex; result[index, 2] = "PrincipalExchange"; //result[index, 3] = principal.RiskMaturityDate; result[index, 3] = principal.PaymentAmount.amount; result[index, 4] = 0.0m; result[index, 5] = principal.PaymentAmount.amount; result[index, 6] = principal.PaymentAmount.currency.Value; result[index, 7] = principal.PaymentDate; result[index, 8] = principal.PaymentDate; result[index, 9] = principal.PaymentDate; result[index, 10] = principal.PaymentDiscountFactor; var npv = 0.0m; if (principal.NPV != null) { npv = principal.NPV.amount; } result[index, 11] = npv; result[index, 12] = principal.YearFractionToCashFlowPayment; result[index, 13] = false; result[index, 14] = principal.IsRealised; index++; fourthIndex++; } } } return(result); }