Thread: Need Help with BlackScholes program

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

    Need Help with BlackScholes program

    Hey guys, i am almost complete my program, i just keep getting the same
    Error 1 error C2059: syntax error : '{'
    Error 2 error C2334: unexpected token(s) preceding '{'; skipping apparent function body

    //My program is
    Code:
    #pragma endregion
    	private: System::Void btncalculate_Click(System::Object^  sender, System::EventArgs^  e)  {
    			 }
    			 {
    							//Declaring Variables
    	// The cumulative normal distribution function 
                    double CND;
    							//Defining Variable
    	 x = Convert::ToDouble(tbStrike_Price->Text);			
    	double L;
    	double K;
    	double const a1 = 0.31938153, a2 = -0.356563782; 			double const a3 = 1.781477937;
                    double const a4 = -1.821255978, a5 = 1.330274429;
    	double const Pi 3.141592653589793238462643; 
    	L = fabs(X);
    	K = 1.0 / (1.0 + 0.2316419 * L);
    	CND = 1.0 - 1.0 / sqrt(2 * Pi) * exp(-L *L / 2) * (a1 * K + a2 * K *K + a3 * pow(K,3) + a4 * pow(K,4) + a5 * pow(K,5));
    	if (X < 0 )(
    	CND= 1.0 - CND
    	)
    	return CND;
    							
    	//Time Difference
    	// Declare two variables
    							System::TimeSpan daysdiff;
                    double daysdiff = this->dtpExpiration_Date->Value - this->dtpCurrent_Date->Value;;
    							tbDays_To_Expiration->Text = daysdiff.ToString();
    	// The Black and Scholes (1973) Stock option formula
    							//Declaring Variables
    	double call;
    	double put;
    	double S;
    	double t;
    	double r;
    	double v;
    	double d1;
    	double d2;
    							//Defining Variables
    							
    	s = Convert::ToDouble(tbStock_Price->Text);
    	t = ((double daysdiff)/365);
    	r = (Convert::ToDouble(tbRisk_Free_Rate->Text)/100);
    	v = (Convert::ToDouble(tbVolatility->Text)/100);
    	d1 = (Log(S / X) + (r + v ^ 2 / 2) * T) / (v * Sqr(T));
    	d2 = d1 - v * Sqr(T);
    	call = S * CND(d1) - X * Exp(-r * T) * CND(d2);
    	put = X * Exp(-r * T) * CND(-d2) - S * CND(-d1);
    							tbCall_Price->Text = Convert::ToString(call.ToString((".00"));
    							tbPut_Price->Text = Convert::ToString(put.ToString(".00");
    			 }	
    							
    };
    }
    i am using visual studios 2010

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    you appear to have 4 of } and 2 of {
    hooch

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM