/// <summary> /// Returns the npv. /// </summary> /// <param name="reportingParty"></param> /// <param name="baseCurrency"></param> /// <param name="valuationDate"></param> /// <param name="market"></param> /// <returns></returns> public double GetNPV(string reportingParty, string baseCurrency, DateTime valuationDate, IMarketEnvironment market) { var modelData = CreateInstrumentModelData(new List <string> { InstrumentMetrics.NPV.ToString() }, valuationDate, market, baseCurrency, reportingParty); var av = PriceableProduct.Calculate(modelData); return((double)av.quote[0].value); }
/// <summary> /// Prices the product. /// </summary> /// <param name="reportingParty"></param> /// <param name="valuationDate"></param> /// <param name="market"></param> /// <returns></returns> public double GetParRate(string reportingParty, DateTime valuationDate, IMarketEnvironment market) { var modelData = CreateInstrumentModelData(new List <string> { InstrumentMetrics.ImpliedQuote.ToString() }, valuationDate, market, PriceableProduct.PaymentCurrencies[0], reportingParty); var av = PriceableProduct.Calculate(modelData); return((double)av.quote[0].value); }
/// <summary> /// Builds the product with the calculated data. /// </summary> /// <returns></returns> public override Product BuildTheProduct() { return(PriceableProduct.BuildTheProduct()); }
///<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!"); }