public static double BSPricing(EuropeanOptionProb prob) { double s = prob.SpotPrice; double k = prob.StrikePrice; double t = prob.Maturity; double r = prob.InterestRate; double sigma = prob.Volatility; OptionTypeEnum optionType = prob.OptionType; return(BSPricing(s, k, t, r, sigma, optionType)); }
private void DoCalculation() { IsCalculateEnabled = false; RaisePropertyChanged("IsCalculateEnabled"); ErrorCode errcode = FirstValidation(); if (errcode != ErrorCode.OK) { Result = Utility.getErrorMsg(errcode); } else { var prob = new EuropeanOptionProb( _spotPrice, _volatility, _interestRate, _maturity, _strikePrice, _optionType ); errcode = prob.validate(); if (errcode != ErrorCode.OK) { Result = Utility.getErrorMsg(errcode); } else { Result = Math.Round(prob.calculate(), 4).ToString(); } } RaisePropertyChanged("Result"); IsCalculateEnabled = true; RaisePropertyChanged("IsCalculateEnabled"); }