| 1. | Introduction |
| 2. | Binomial model |
| 3. | Options |
| 4. | American puts |
| 5. | Systems of equations |
| 6. | Matrix operations |
| 7. | Matrix inverse |
American Put Options with C++ Tables
1. American put options
The buyer of the European put option has the right, but not the obligation, to sell one share of the underlying asset at the expiration time for the strike price \(K\). The buyer of the American put has the right to exercise the option at any time prior to and including the expiration \(T\).
The price of the American put is calculated by constructing the put price tree. The tree is constructed backwards. The last, payoff, column is constructed first. Then we move backwards. Every time we evaluate two prices. The first price to calculate is the price that can be gained by exercising the put. The second price, the holding value is the value of the option if the exercising were not allowed. This holding price is obtained using the formula \begin{eqnarray*}\mbox{Price}&=& \frac1{1+r}\cdot \mathbb E_*\left[\mbox{Payoff}(S_n)\right]. \end{eqnarray*}
2. Code that constructs the option price tree
The code is obtained by taking the program made in the section Option Pricing with C++ Tables and applying the changes described in the previous paragraph.
double S, u, d;
S=A[0][1]; u=A[0][2]; d=A[0][3];
int n;
n=A[0][0];
std::vector<std::vector<double> > stockTree;
stockTree.resize(n+1);
int i;
i=0;
while(i<=n){
stockTree[i].resize(i+1);
i=i+1;
}
stockTree[0][0]=S;
int j;
i=1;
while(i<=n){
stockTree[i][0]=stockTree[i-1][0]*u;
j=1;
while(j<=i){
stockTree[i][j]=stockTree[i-1][j-1]*d;
j=j+1;
}
i=i+1;
}
double r,K;
r=A[0][4]; K=A[0][5];
std::vector<std::vector<double> > optionTree=stockTree;
i=0;
while(i<=n){
if(stockTree[n][i]<K){
optionTree[n][i]=K-stockTree[n][i];
}
else{
optionTree[n][i]=0;
}
i=i+1;
}
double pStar,qStar;
pStar=(1.0+r-d)/(u-d); qStar=1.0-pStar;
i=n-1;
double exerciseValue, holdingValue;
while(i>=0){
j=0;
while(j<=i){
exerciseValue=0;
if(stockTree[i][j]<K){
exerciseValue=K-stockTree[i][j];
}
holdingValue=(1.0/(1.0+r))
* (pStar*optionTree[i+1][j]
+ qStar*optionTree[i+1][j+1]);
if(exerciseValue>holdingValue){
optionTree[i][j]=exerciseValue;
}
else{
optionTree[i][j]=holdingValue;
}
j=j+1;
}
i=i-1;
}
i=0;
while(i<=n){
j=i;
while(j<=n){
B[i][j]=optionTree[j][i];
j=j+1;
}
i=i+1;
}