public void TestCreateSwaptionValuationReport()
        {
            var      curves        = CreateInterestRateStreamTestEnvironment(DateTime.Now);
            Swaption swaption      = GenerateSwaptionParametricWithCashflows();
            var      marketFactory = new MarketFactory();

            marketFactory.AddYieldCurve(curves.GetForecastRateCurveFpML());
            Market       market           = marketFactory.Create();
            const string baseParty        = _NAB;
            var          assetValuation   = new AssetValuation();
            var          listOfQuotations = new List <Quotation>();
            IEnumerable <StringDoubleRangeItem> valuationSet = CreateValuationSetList(54321, 123.5);

            foreach (StringDoubleRangeItem item in valuationSet)
            {
                var quotation = new Quotation
                {
                    measureType    = AssetMeasureTypeHelper.Parse(item.StringValue),
                    value          = (decimal)item.DoubleValue,
                    valueSpecified = true
                };

                listOfQuotations.Add(quotation);
            }
            assetValuation.quote = listOfQuotations.ToArray();
            ValuationReport valuationReport = ValuationReportGenerator.Generate("some-valuation-Id", baseParty, "0001", DateTime.Now, swaption, market, assetValuation);

            Debug.WriteLine("ValuationReport:");
            Debug.WriteLine(XmlSerializerHelper.SerializeToString(typeof(Document), valuationReport));
            string s1 = XmlSerializerHelper.SerializeToString(typeof(Document), valuationReport);

            XmlSerializerHelper.DeserializeFromString <ValuationReport>(typeof(Document), s1);
            XmlSerializerHelper.SerializeToFile(typeof(Document), valuationReport, "some-valuation-Id");
            XmlSerializerHelper.DeserializeFromFile <ValuationReport>(typeof(Document), "some-valuation-Id");
        }
        public void TestCreateFraValuationReport1()
        {
            var rateCurve     = TestRateCurve(new DateTime(2009, 7, 15));
            var fra           = new Fra();
            var pair          = rateCurve.GetFpMLData();
            var marketFactory = new MarketFactory();

            marketFactory.AddPricingStructure(pair);
            Market       market           = marketFactory.Create();
            const string baseParty        = _NAB;
            var          assetValuation   = new AssetValuation();
            var          listOfQuotations = new List <Quotation>();
            IEnumerable <StringDoubleRangeItem> valuationSet = CreateValuationSetList(54321, 123.5);

            foreach (StringDoubleRangeItem item in valuationSet)
            {
                var quotation = new Quotation
                {
                    measureType    = AssetMeasureTypeHelper.Parse(item.StringValue),
                    value          = (decimal)item.DoubleValue,
                    valueSpecified = true
                };
                listOfQuotations.Add(quotation);
            }
            assetValuation.quote = listOfQuotations.ToArray();
            ValuationReport valuationReport = ValuationReportGenerator.Generate("some-valuation-Id", baseParty, fra, market, assetValuation);

            Debug.WriteLine("ValuationReport:");
            Debug.WriteLine(XmlSerializerHelper.SerializeToString(valuationReport));
        }
Ejemplo n.º 3
0
        public static AssetValuation CreateAssetValuationFromValuationSet(List <StringObjectRangeItem> valuationSet)
        {
            var assetValuation   = new AssetValuation();
            var listOfQuotations = new List <Quotation>();

            foreach (StringObjectRangeItem item in valuationSet)
            {
                var quotation = new Quotation
                {
                    measureType = AssetMeasureTypeHelper.Parse(item.StringValue)
                };
                if (item.ObjectValue is double | item.ObjectValue is decimal)
                {
                    quotation.value          = Convert.ToDecimal(item.ObjectValue);
                    quotation.valueSpecified = true;
                }
                else
                {
                    quotation.cashflowType = new CashflowType {
                        Value = item.ObjectValue.ToString()
                    };
                }
                listOfQuotations.Add(quotation);
            }
            assetValuation.quote = listOfQuotations.ToArray();
            return(assetValuation);
        }