Ejemplo n.º 1
0
        public void Actual(DataTestCase testCase)
        {
            Data.InitMarketData(testCase.Vol,
                                testCase.Rate,
                                testCase.EvalDate);

            var            pricingCfg      = new PricingConfiguration(testCase.GreekTypes);
            var            pricer          = new Pricer();
            PricingResults expectedResults = null;
            var            actualResults   = pricer.Results(testCase.Option, pricingCfg);
            var            error           = string.Empty;

            try
            {
                using (StreamReader file = File.OpenText(@"C:\Users\AHMED\source\repos\ConsoleApp1\ResultPricing.text"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    expectedResults = (PricingResults)serializer.Deserialize(file, typeof(PricingResults));
                }
            }
            catch (Exception e)
            {
                Assert.Fail(error = string.Format("Not Deserialize result: {0}", e.Message));
            }

            if (actualResults.CompareResult(expectedResults))
            {
                Assert.Pass("No regression detected");
            }
            else
            {
                // save ecart
                Assert.Fail("regression detected");
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            DateTime expirationDate = DateTime.Parse("01/05/2019");
            DateTime riskFactorDate = DateTime.Parse("01/09/2019");
            DateTime paramDate      = DateTime.Parse("01/04/2019");
            var      option         = new OptionInstrument(60, expirationDate, OptionType.Put,
                                                           Way.Sell, Underlying.Petrol, riskFactorDate);

            Data.InitMarketData(0.25, 0.05, paramDate);

            var pricingcfg = new PricingConfiguration(
                new List <GreekType>
            {
                GreekType.Delta,
                GreekType.Gamma,
                GreekType.Vega,
                GreekType.Rho,
                GreekType.Tetha
            });
            var pricer  = new Pricer();
            var results = pricer.Results(option, pricingcfg);

            Console.WriteLine("Le prix de l'option :" + results.Mtm);
            foreach (var result in results.Results)
            {
                Console.WriteLine("La valeur de " + result.Key.ToString() + " : " + result.Value);
            }


            /*// prcing europeene option
             * var maturity = DateTime.Parse("01/05/2019");
             * var paramDate = DateTime.Parse("01/04/2019");
             * var riskFctorDate = DateTime.Parse("01/09/2019");
             * var diif = (paramDate-maturity).TotalDays;
             * var option = new OptionInstrument(60, maturity);
             * var interpolator = new InterpolatorFuturePrice("CL", riskFctorDate);
             * var riskFator = interpolator.InterpolationBackStepProcess();
             * var optionData = new OptionMarketData(riskFator, paramDate, 0.05, 0.25);
             *
             * var pricer = new OptionPricer(option, optionData,"call");
             *
             *
             * var listGreeks = new List<string>()
             * {
             * "Delta",
             * "Vega",
             * "Theta",
             * "Rho",
             * "Gamma"
             * };
             *
             * PrintResult print = new PrintResult(pricer,true,true,listGreeks);
             * print.Print();
             */

            // InitMarketData
            // Construction of Product + PricingConfiguration
            // Call the method Price
        }
Ejemplo n.º 3
0
        public ProductProfile(PricingConfiguration config)
        {
            CreateMap <Product, ProductSummaryItem>()
            .ForMember(dest => dest.UnitPrice, opt => opt.MapFrom(src => src.UnitPrice * config.MarkUp));

            CreateMap <Product, GetProductDetailsResponse>()
            .ForMember(dest => dest.UnitPrice, opt => opt.MapFrom(src => src.UnitPrice * config.MarkUp));

            CreateMap <PostProductRequest, Product>()
            .ForMember(dest => dest.UnitPrice, opt => opt.MapFrom(s => s.UnitPrice.Value))
            .ForMember(dest => dest.InInventory, opt => opt.MapFrom(_ => true));
        }
Ejemplo n.º 4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            GetData(out vol, out strikeValue, out interestRate, out valueDate, out maturityDate, out riskfacorDate);

            way        = (Way)System.Enum.Parse(typeof(Way), Way.SelectedItem.ToString());
            optionType = (OptionType)System.Enum.Parse(typeof(OptionType), TypeOption.SelectedItem.ToString());
            sousJacent = (Underlying)System.Enum.Parse(typeof(Underlying), sousjacent.SelectedItem.ToString());

            var x = MyGreeks.SelectedItems;
            var z = MyGreeks.SelectedItem;

            listGreeks = MyGreeks.SelectedItems.Cast <GreekType>().ToList();

            Data.InitMarketData(vol, interestRate, valueDate);
            var option = new OptionInstrument(strikeValue, maturityDate, optionType, way, sousJacent, riskfacorDate);

            var pricingcfg = new PricingConfiguration(listGreeks);
            var pricer     = new Pricer();

            Result.Text = pricer.Results(option, pricingcfg).Mtm.ToString();

            var resultGreek = pricer.Results(option, pricingcfg).Results;

            if (resultGreek.Count != 0)
            {
                foreach (var result in resultGreek)
                {
                    switch (result.Key)
                    {
                    case GreekType.Delta:
                        ValueDelta.Text = result.Value.ToString("");
                        break;

                    case GreekType.Vega:
                        ValueVega.Text = result.Value.ToString();
                        break;

                    case GreekType.Gamma:
                        ValueGamma.Text = result.Value.ToString();
                        break;

                    case GreekType.Rho:
                        ValueRho.Text = result.Value.ToString();
                        break;

                    case GreekType.Tetha:
                        ValueTetha.Text = result.Value.ToString();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            var items = new List <Item>()
            {
                new Ipad(), new MacBookPro(), new AppleTv(), new Vga()
            };

            AvailableItems.ItemsSource = items;

            var pricingRules = new PricingConfiguration().PricingRules;

            _checkOut = new Checkout.Core.Checkout(pricingRules);
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.IgnoreNullValues = true;
            });

            services.AddDbContext <ShoppingDataContext>(options =>
                                                        options.UseSqlServer(Configuration.GetConnectionString("shopping"))
                                                        );

            services.AddScoped <ILookupProducts, EfSqlShopping>();
            services.AddScoped <IProductCommands, EfSqlShopping>();

            var pricingConfig = new PricingConfiguration();

            Configuration.GetSection(pricingConfig.SectionName).Bind(pricingConfig);
            // Makes this injectable into services using IOptions<T>
            services.Configure <PricingConfiguration>(Configuration.GetSection(pricingConfig.SectionName));

            var pickupConfig = new PickupEstimatorConfiguration();

            Configuration.GetSection(pickupConfig.SectionName).Bind(pickupConfig);
            services.Configure <PickupEstimatorConfiguration>(Configuration.GetSection(pickupConfig.SectionName));

            var mapperConfig = new MapperConfiguration(opt =>
            {
                opt.AddProfile(new ProductProfile(pricingConfig));
            });

            IMapper mapper = mapperConfig.CreateMapper();

            services.AddSingleton <IMapper>(mapper);
            services.AddSingleton <MapperConfiguration>(mapperConfig);

            services.AddScoped <ICurbsideCommands, EfSqlAsyncCurbside>();
            services.AddScoped <ICurbsideLookups, EfSqlAsyncCurbside>();

            services.AddSingleton <CurbsideChannel>();

            services.AddScoped <IGenerateCurbsidePickupTimes, GrpcPickupEstimator>();

            services.AddHostedService <CurbsideOrderProcessor>();
        }
Ejemplo n.º 7
0
        public void Reference(DataTestCase testCase)
        {
            Data.InitMarketData(testCase.Vol,
                                testCase.Rate,
                                testCase.EvalDate);

            var pricingCfg  = new PricingConfiguration(testCase.GreekTypes);
            var pricer      = new Pricer();
            var results     = pricer.Results(testCase.Option, pricingCfg);
            var json        = JsonConvert.SerializeObject(results, Formatting.Indented);
            var msg         = "The reference is generated";
            var isGenereted = true;

            try
            {
                using (StreamWriter file =
                           File.CreateText(@"C:\Users\AHMED\source\repos\ConsoleApp1\ResultPricing.text"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, results);
                }
            }
            catch (Exception e)
            {
                isGenereted = false;
                msg         = string.Format("The reference cannot be generated:{0}", e.Message);
            }
            finally
            {
                if (isGenereted == false)
                {
                    Assert.Fail(msg);
                }
                else
                {
                    Assert.Pass(msg);
                }
            }
        }
Ejemplo n.º 8
0
        public void Initialize()
        {
            var pricingRules = new PricingConfiguration().PricingRules;

            _checkOut = new Checkout(pricingRules);
        }