예제 #1
0
        public async Task <IActionResult> CalcBlackSholesAsync(BlackSholesModel model)
        {
            try
            {
                double S0    = model.S0;
                double K     = model.K;
                double T     = model.T;
                double sigma = model.sigma / 100;
                double r     = model.r / 100;

                string json = $"{{\"S0\": {S0},\"K\": {K},\"T\": {T},\"sigma\": {sigma},\"r\": {r}}}";

                var content = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await client.PostAsync("http://localhost:8888/api/v1/blacksholes", content);

                var responseString = await response.Content.ReadAsStringAsync();

                var result = double.TryParse(responseString, out _);

                if (!result)
                {
                    responseString = "ERROR";
                }

                TempData["value"] = "Predicted Price is: " + responseString;
                return(RedirectToAction("BlackSholes"));
            }
            catch
            {
                TempData["value"] = "The error was occure";
                return(RedirectToAction("BlackSholes"));
            }
        }
예제 #2
0
        public IActionResult BlackSholes()
        {
            var model = new BlackSholesModel();

            return(View(model));
        }