Esempio n. 1
0
        public void RoundTripViaProtoBuf()
        {
            var aModel = GetModel();
            var to     = aModel.ToTransportObject();
            var ms     = new MemoryStream();

            ProtoBuf.Serializer.Serialize(ms, to);
            //ms.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            var to2     = ProtoBuf.Serializer.Deserialize <TO_AssetFxModel>(ms);
            var aModel2 = new AssetFxModel(to2, TestProviderHelper.CurrencyProvider, TestProviderHelper.CalendarProvider);

            Assert.Equal(aModel.GetPriceCurve("OIL").GetPriceForDate(ValDate.AddDays(100)), aModel2.GetPriceCurve("OIL").GetPriceForDate(ValDate.AddDays(100)));
            Assert.Equal(aModel.GetPriceCurve("OIL", zar).GetPriceForDate(ValDate.AddDays(100)), aModel2.GetPriceCurve("OIL", zar).GetPriceForDate(ValDate.AddDays(100)));
            Assert.Equal(aModel.GetCompositeVolForStrikeAndDate("OIL", ValDate.AddDays(100), 1000, zar), aModel2.GetCompositeVolForStrikeAndDate("OIL", ValDate.AddDays(100), 1000, zar));
        }
Esempio n. 2
0
        public void RoundTrip()
        {
            var aModel  = GetModel();
            var to      = aModel.ToTransportObject();
            var aModel2 = new AssetFxModel(to, TestProviderHelper.CurrencyProvider, TestProviderHelper.CalendarProvider);

            Assert.Equal(aModel.GetPriceCurve("OIL").GetPriceForDate(ValDate.AddDays(100)), aModel2.GetPriceCurve("OIL").GetPriceForDate(ValDate.AddDays(100)));
            Assert.Equal(aModel.GetPriceCurve("OIL", zar).GetPriceForDate(ValDate.AddDays(100)), aModel2.GetPriceCurve("OIL", zar).GetPriceForDate(ValDate.AddDays(100)));
            Assert.Equal(aModel.GetCompositeVolForStrikeAndDate("OIL", ValDate.AddDays(100), 1000, zar), aModel2.GetCompositeVolForStrikeAndDate("OIL", ValDate.AddDays(100), 1000, zar));
        }