• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Problem with american options C++

Joined
9/23/10
Messages
1
Points
11
I am currently programming up a binomial tree to price both euro and american options. I am stuck and cannot figure out how to alter the european code to allow for early exercise of the option. I've looked at many other examples and tried many things and can't get it to work. Here's my european put code, any help would be awesome I've been stuck for hours.


if (indicator1 == 'd')
{
if (indicator2 == 'a')
{
nper = npers;
tinc = ttm/nper;
sqrtt = sqrt(tinc);
up = exp(sigma*sqrtt);
down = exp(-sigma*sqrtt);
R = exp(r*tinc);
prup = (R-down)/(up-down);
prdn = 1-prup;
int i,j;


for(i=0;i<=nper;i++)
{
Sprice = S0*pow(up,(double) i)*pow(down,(double) (nper-i));
val = MAX(X-Sprice,0);
}
for(j=0;j<nper;j++)><nper;i++)
{
for(i=0;i<nper-j;i++) <nper-j;i++)>
{
val = (prdn * val + prup * val[i+1])/R;
}
}
return(val[0]);
}</nper-j;i++)></nper;j++)>
 
Back
Top