//define a trigger event private void Submit_Click(object sender, RoutedEventArgs e) { //catch the exception try { SO = Convert.ToDouble(this.So.Text); K = Convert.ToDouble(this.k.Text); sigma = Convert.ToDouble(this.Sigma.Text); r = Convert.ToDouble(this.R.Text); T = Convert.ToDouble(this.Tenor.Text); TrailNum = Convert.ToInt32(this.Trail.Text); StepNum = Convert.ToInt32(this.Step.Text); double[,] Randoms = RandomNum.RandomSet(TrailNum, StepNum); double[] EurpCall = EuropOption.PriceEurp(SO, K, sigma, r, T, StepNum, TrailNum, Randoms); double[] GreekValue = Greek.Greeks(SO, K, sigma, r, T, StepNum, TrailNum, Randoms); string OutPut; //output the results OutPut = Convert.ToString("EurCallprice : " + EurpCall[0] + "\n" + "EurPutprice : " + EurpCall[1] + "\n" + "EurCallStdEr : " + EurpCall[2] + "\n" + "EurPutStdEr : " + EurpCall[3] + "\n" + "EurCallDelta : " + GreekValue[0] + "\n" + "EurPutDelta : " + GreekValue[1] + "\n" + "EurCallGamma : " + GreekValue[2] + "\n" + "EurPutGamma : " + GreekValue[3] + "\n" + "EurCallVega : " + GreekValue[4] + "\n" + "EurPutVega : " + GreekValue[5] + "\n" + "EurCallTheta : " + GreekValue[6] + "\n" + "EurPutTheta : " + GreekValue[7] + "\n" + "EurCallRho : " + GreekValue[8] + "\n" + "EurPutRho : " + GreekValue[9]); MessageBox.Show(OutPut); } catch (Exception) { MessageBox.Show("All the inputs need to be numbers."); } }
//define a trigger event private void Submit_Click(object sender, RoutedEventArgs e) { watch.Start(); //catch the exception try { SO = Convert.ToDouble(this.So.Text); K = Convert.ToDouble(this.k.Text); sigma = Convert.ToDouble(this.Sigma.Text); r = Convert.ToDouble(this.R.Text); T = Convert.ToDouble(this.Tenor.Text); TrailNum = Convert.ToInt32(this.Trail.Text); StepNum = Convert.ToInt32(this.Step.Text); Anti = Convert.ToInt32(this.AntiOrNot.Text); Divident = Convert.ToDouble(this.Div.Text); DeltaBase = Convert.ToInt32(this.deltabased.Text); MultiThread = Convert.ToInt32(this.Multithread.Text); double[,] Randoms; if (MultiThread == 1) { Randoms = RandomNum.RandomSetMulti(TrailNum, StepNum); } else { Randoms = RandomNum.RandomSetMulti1(TrailNum, StepNum); } increase(1); double[] EurpCall = EuropOption.PriceEurp(SO, K, sigma, r, T, StepNum, TrailNum, Randoms, Anti, Divident, DeltaBase, MultiThread); double[] GreekValue = Greek.Greeks(SO, K, sigma, r, T, StepNum, TrailNum, Randoms, Anti, Divident, DeltaBase, MultiThread); string OutPut; //output the results watch.Stop(); OutPut = Convert.ToString("EurCallprice : " + EurpCall[0] + "\n" + "EurPutprice : " + EurpCall[1] + "\n" + "EurCallStdEr : " + EurpCall[2] + "\n" + "EurPutStdEr : " + EurpCall[3] + "\n" + "EurCallDelta : " + GreekValue[0] + "\n" + "EurPutDelta : " + GreekValue[1] + "\n" + "EurCallGamma : " + GreekValue[2] + "\n" + "EurPutGamma : " + GreekValue[3] + "\n" + "EurCallVega : " + GreekValue[4] + "\n" + "EurPutVega : " + GreekValue[5] + "\n" + "EurCallTheta : " + GreekValue[6] + "\n" + "EurPutTheta : " + GreekValue[7] + "\n" + "EurCallRho : " + GreekValue[8] + "\n" + "EurPutRho : " + GreekValue[9] + "\n" + "Timer : " + watch.Elapsed.TotalSeconds.ToString() + "\n" + "Cores : " + cores); MessageBox.Show(OutPut); } catch (Exception) { MessageBox.Show("All the inputs need to be numbers."); } }