コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: TradePricer.cs プロジェクト: zhangz/Highlander.Net
 ///<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!");
 }