예제 #1
0
        public string CacheFraTrade(ILogger logger, ICoreCache cache, string fraId, FraInputRange fraInputRange)
        {
            var fra   = ProductFactory.GetFpMLFra(fraInputRange);
            var trade = new Trade();

            XsdClassesFieldResolver.TradeSetFra(trade, fra);
            cache.SaveObject(trade, fraId, null);
            return(fraId);
        }
예제 #2
0
        private static double GetParRateFromRange(ILogger logger, ICoreCache cache, IRateCurve forwardCurve, IRateCurve discountCurve,
                                                  IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, FraInputRange fraInputRange, String nameSpace)
        {
            Fra fra = ProductFactory.GetFpMLFra(fraInputRange);
            //var forwardCurve = ObjectCacheHelper.GetPricingStructureFromSerialisable(fraInputRange.ForwardCurveId);
            //var discountCurve = (RateCurve)ObjectCacheHelper.GetPricingStructureFromSerialisable(fraInputRange.DiscountingCurveId);
            var market       = CreateMarket(discountCurve, forwardCurve);
            var priceInMoney = GetParRate(logger, cache, fixingCalendar, paymentCalendar, fra, fraInputRange.ValuationDate, market, nameSpace);

            return(priceInMoney);
        }
예제 #3
0
        public string CreateFraTradeValuation(ILogger logger, ICoreCache cache,
                                              IRateCurve forwardCurve, IRateCurve discountCurve,
                                              IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar,
                                              FraInputRange fraInputRange, string[] metrics,
                                              NamedValueSet properties, String nameSpace)
        {
            //get the balues reqired from the property bag.
            var valuationId       = new ValuationReportIdentifier(properties);
            var baseParty         = properties.GetString("BaseParty", true);
            var reportingCurrency = properties.GetString("ReportingCurrency", true);

            properties.Set("Function", "ValuationReport");
            properties.Set("Domain", "Orion.ValuationReport");
            //TODO add other properties
            //var fra = Cache.GetTrade(fraId);
            var fra = ProductFactory.GetFpMLFra(fraInputRange);
            //Get the curves and store.
            var marketFactory = new MarketFactory();
            var uniqueCurves  = new List <IRateCurve>();
            //var forwardCurve = (RateCurve)ObjectCacheHelper.GetPricingStructureFromSerialisable(fraInputRange.ForwardCurveId);
            //var discountCurve = (RateCurve)ObjectCacheHelper.GetPricingStructureFromSerialisable(fraInputRange.DiscountingCurveId);
            var market        = CreateMarket(discountCurve, forwardCurve);
            var agreement     = new FraPricer(logger, cache, null, null, fra, nameSpace);
            var modelData     = CreateInstrumentModelData(metrics, fraInputRange.ValuationDate, market, reportingCurrency);
            var asetValuation = agreement.Calculate(modelData);

            //  Add forward yield curve to the market environment ...
            //
            //var forwardCurve = (IRateCurve)ObjectCacheHelper.GetPricingStructureFromSerialisable(fraInputRange.ForwardCurveId);
            uniqueCurves.Add(forwardCurve);
            //  ... if discount curve is not the same as forward curve - add a discount curve too.
            //
            //if (fraInputRange.ForwardCurveId != fraInputRange.DiscountingCurveId)
            //{
            //    var discountingCurve = (IRateCurve)ObjectCacheHelper.GetPricingStructureFromSerialisable(fraInputRange.DiscountingCurveId);
            //    uniqueCurves.Add(discountingCurve);
            //}
            //TODO Add the FX curve if the reporting currency is different.
            foreach (var rateCurve in uniqueCurves)
            {
                // Add all unique curves into market
                //
                Pair <PricingStructure, PricingStructureValuation> pair = rateCurve.GetFpMLData();
                marketFactory.AddPricingStructure(pair);
            }
            var valuation = new Valuation();

            //  create ValuationReport and add it to in-memory collection.
            //
            valuation.CreateFraValuationReport(cache, nameSpace, valuationId.UniqueIdentifier, baseParty, fra, marketFactory.Create(), asetValuation, properties);
            return(valuationId.UniqueIdentifier);
        }
예제 #4
0
        public string CacheFraTradeWithProperties(ILogger logger, ICoreCache cache, FraInputRange fraInputRange, NamedValueSet properties)
        {
            var fra   = ProductFactory.GetFpMLFra(fraInputRange);
            var trade = new Trade();

            XsdClassesFieldResolver.TradeSetFra(trade, fra);
            //Get the id.
            ProductIdentifier = new FpML.V5r10.Reporting.Identifiers.TradeIdentifier(properties);
            var fraId = ProductIdentifier.UniqueIdentifier;

            //Cache the trade.
            cache.SaveObject(trade, fraId, properties);
            return(fraId);
        }