Example #1
0
 /// <summary>
 /// Prices the trade.
 /// </summary>
 /// <param name="modelData"></param>
 /// <param name="reportType"></param>
 /// <returns></returns>
 public abstract List <ValuationReport> Price(List <IInstrumentControllerData> modelData, ValuationReportType reportType);
Example #2
0
 ///<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!");
 }
Example #3
0
 ///<summary>
 /// Prices the trade.
 ///</summary>
 ///<returns></returns>
 public abstract ValuationReport Price(IInstrumentControllerData modelData,
                                       ValuationReportType reportType);
Example #4
0
        ///<summary>
        /// Prices the trade.
        ///</summary>
        ///<returns></returns>
        public override List <ValuationReport> Price(List <IInstrumentControllerData> modelData, ValuationReportType reportType)
        {
            switch (reportType)
            {
            //Creates a valuation report for each market
            case ValuationReportType.Full: return(modelData.Select(element => Price(element, reportType)).ToList());

            //
            //Creates a single valuation report with sensitivities populated.///TODO
            case ValuationReportType.Summary: return(modelData.Select(element => Price(element, reportType)).ToList());

            //TODO Convert all the individual reports into a single summary report.
            //The default
            default: return(modelData.Select(element => Price(element, reportType)).ToList());
            }
        }