**Welcome to THETAWIKI**. If you like to create or edit a page please make sure to login or register an account. All registered users please make sure to provide a valid email address.

# From European to American

This tutorial applies the ThetaML Language in the area of pricing financial derivatives.

ThetaML presents the definition of complex financial derivatives with unprecedented simplicity. The ThetaML language strictly separates the structural and stochastic part of a model. The structural part describes the product, that is, it defines the payment streams depending on observable market variables. The stochastic part models the stochastic behavior of these external variables. This is demonstrated by the following examples.

To start with, we first implement in ThetaML the stochastic processes underlying the financial options, then show how ThetaML combines the stochastic processes with the product descriptions to price the financial options. The pricing examples include a simple European option, a put option with Bermudan and American exercise features, and a compound option.

## Contents

## The Stochastic Processes

To price an option, we first define a stochastic process for the underlying. As there might be thousands of scenarios for the future values of the underlying, good modeling language and powerful simulation engine are essential for estimating accurate future values. This is where ThetaML comes into play.

For the simple purpose of this tutorial, we assume that a stochastic model for the stock price parameter `S` is given. To allow more convenient exposition, we assume that the stock price process is under the risk-neutral measure, such as the Geometric Brownian Motion process as in Black-Scholes Option Pricing.

The following ThetaML model simulates the stock prices `S` that follow the Geometric Brownian motion process.

model S_Process import S0 "Initial stock price" import r "Risk-free interest rate in currency CUR" import sigma "Volatility of stock prices" export S "Simulated GBM stock price process" % initial stock price S = S0 % an infinite loop; the loop length automatically extends to the % length of the lifetime of a pricing application loop inf % time passing of @dt units, the value(s) of @dt are % determined later when the simulated stock price % process is applied in pricing financial contracts theta @dt % update stock prices for the time step @dt S = S * exp( (r - 0.5*Sigma^2) * @dt + sigma * sqrt(@dt) * randn() ) end end

Since the cash flows in our pricing applications occur at future times, a process for the discount numeraire should be computed to obtain the present value of future cash flows. The discount numeraire in this example is a discount process with unit initial value in currency `EUR`. We assume that interest rates are constant throughout the option life time and set the constant interest rate to `r`, such that the value of the discount process decays at a constant interest rate `r`. When the future cash flows of an asset are multiplied by the discount process `EUR`, it serves two purposes: first, it discounts the future cash flows to current time; second, it translates the future cash flows into the currency unit `EUR`. This numeraire parameter represents the discount factor for payments conducted in a specific currency, `EUR` in our examples refer to the currency Euro.

model EUR_Process import r "Risk-free interest rate in currency EUR" export EUR "Simulated discount numeraire process" % initial values of the discount numeraire process; set to 1 % in currency ‘EUR’ EUR = 1 % an infinite loop; the loop length automatically extends to the % length of the lifetime of a pricing application loop inf % time passing of @dt units, the value(s) of @dt are % determined later when the simulated discount numeraire % process is applied in pricing financial contracts theta @dt % the value of the discount numeraire decays at a constant % rate of r EUR = EUR * exp( -r * @dt ) end end

## The Options

With the simulated processes `S` and `EUR`, we now proceed to price financial options with ThetaML.

### European Option

This little example shows the implementation of a European option in ThetaML.

model EuropeanPut % The stock prices 'S' and the discount numeraire 'EUR' are simulated respectively in the model % 'S_Process' and 'EUR_Process' import S "Underlying stock prices" import EUR "Discount numeraire" import K "Option strike price" import T "Option time to maturity" export P "European put option price" %at current time, set the option value to have the same expected discounted %value as the variable 'V'; the ThetaML future operator '!' accompanying the %variable 'V' acts like a function on 'V', such that the values of 'V'at %current time remain to be determined at a later instance when 'V' is assigned %some values P = E(V!) %the ThetaML command 'theta' passes time by 'T' years theta T %at option maturity time T, set the European put option payoffs; %the option payoffs are discounted to time 0 by the discount numeraire 'EUR'; %the values of the stock prices 'S' and the discount numeraire 'EUR' are evaluated %at the option's maturity time T V = max(K - S, 0) * EUR end

The first 'import' block defines the variables and processes that must be provided by the user. The exported variable `P` is the European put option price returned by the code generated by this model.

Following the 'import' and 'export' block, the body part of the model consists of three statements. At the initial time, the price `P` is defined as the expected value of the final payoff `V`. The second command advances the time by `T` units, using the ThetaML command `theta`. Finally, we reach maturity and assign `V` the European put option payoff values.

Note that the payoffs `max(K - S,0)` are multiplied with the discount numeraire `EUR`. In this way the option values are discounted to time 0 using the numeraire `EUR`, such that future cash flows are represented in present value terms.

The variables `S`, `EUR` and `V` are process variables with implicit scenario and time indexes. The imported processes `S` and `EUR` step forward in time along with the process `V`. The ThetaML future operator `!` allows the forward-in-time style process stepping. The ThetaML command `theta` advances time by `T` years, such that at the option's maturity time `T` the variables `S`, `EUR` and `V` all take their respective values evaluated at time `T`.

### Bermudan Option

We now extend the European option with an additional feature. Suppose that half the maturity time has passed, and we decide to exercise the option early. Let us adjust our model to reflect this new feature.

model BermudanPut % The stock prices 'S' and the discount numeraire 'EUR' are simulated respectively in the model % 'S_Process' and 'EUR_Process' import S "Underlying stock price" import EUR "Discount numeraire" import K "Option strike price" import T "Option time to maturity" export P "Bermudan put option price" %at current time, set the option value to have the same expected discounted %value as the variable 'V'; the ThetaML future operator '!' accompanying the %variable 'V' acts like a function on 'V', such that the values of 'V'at %current time remain to be determined at a later instance when 'V' is assigned %some values P = E(V!) %the ThetaML command 'theta' advances time by 'T/2' years theta T/2 %early exercise evaluation; the ThetaML function 'E' approximates the conditional %expected discounted option value, computed using the Least Squares Monte Carlo %method combined with the sparse grid basis functions if E(V!) < (K - S)*EUR %early exercise payoff V = (K - S)*EUR end %the ThetaML command 'theta' advances time by another 'T/2' years theta T/2 %at option maturity time T, set the Bermudan put option payoffs; %the option payoffs are discounted to time 0 by the discount numeraire 'EUR'; %here the values of the stock prices 'S' and the discount numeraire 'EUR' are evaluated %at the option's maturity time T V = max(K - S, 0) * EUR end

Again, we first define the price `P` as the expected value of `V`, and we wait for a time period of `T/2`. We then compare the expected value of continuation `E(V!)` with the intrinsic value, i.e., the payment received for an immediate exercise. In case this comparison turns out favorably, we assign the new value to `V`. We then wait another `T/2` and, finally, assign the payoff value.

At time `T/2`, the early exercise strategy is computed using the ThetaML function `E()`. The function `E()` uses the least squares Monte Carlo regression method combined with sparse grid type basis functions to obtain an optimal estimates of the expected option value conditional on the current values of `S`. To compute `E()`, the ThetaML compiler determines the smallest sigma field of the underlying state variables, by filtering out the set of state variables that are measurable at current model time.

The ThetaML future operator `!` allows the possibility to use the variable `V!` at the model time when the values of `V` are not known. This feature occurs a couple of times in our pricing models: at the initial time, when assigning the computed expected discounted values `E(V!)`; at the intermediate model times, when evaluating the early exercise strategies `E(V!) < (K - S)*EUR`. The ThetaML future operator `!` accompanying the variable `V` acts like a function on `V`, such that the values of `V` at this model time remain to be determined at a later instance when `V` is assigned some values. This happens at the option's maturity time, when `V` is assigned the option payoff values. The future operator `!` thus allows stepping the stochastic processes forward in time like what they would have behaved in real life financial markets.

The compiled code will record the commands into a computable order. This forces the final assignment to `V` to be evaluated first. This value is then overwritten when stepping backwards in time if the option is exercised.

### American Option

An American option goes even further than the Bermudan option in that it can be exercised continuously. To implement this in ThetaML, we formulate a Bermudan approximate with finite step size between possible exercises. The following ThetaML model implements such an approximation with daily exercise intervals, i.e. assuming 252 trading days per year.

model AmericanPut % The stock prices 'S' and the discount numeraire 'EUR' are simulated respectively in the model % 'S_Process' and 'EUR_Process' import S "Underlying stock prices" import EUR "Discount numeraire" import K "Option strike price" import T "Option time to maturity" export P "American put option price" %at current time, set the option value to have the same expected discounted %value as the variable 'V'; the ThetaML future operator '!' accompanying the %variable 'V' acts like a function on 'V', such that the values of 'V' at %current time remain to be determined at a later instance when 'V' is assigned %some values P = E(V!) %loop 'T*252' times loop T*252 %early exercise evaluation; the ThetaML function 'E' approximates the conditional %expected discounted option value, computed using the Least Squares Monte Carlo %method combined with the sparse grid basis functions %'(K - S)*EUR' is the discounted exercise value evaluated at this exercise time if E(V!) < (K - S)*EUR V = (K - S)*EUR end %the ThetaML command 'theta' advances time by '1/252' years theta 1/252 end %at option maturity time T, set the American put option payoffs; %the option payoffs are discounted to time 0 by the discount numeraire 'EUR'; %here the values of 'S' and 'EUR' are evaluated at the option's maturity time T V = max(K - S, 0) * EUR end

In the model `AmericanPut`, the stock prices `S` and the discount numeraire `EUR` are imported processes simulated respectively in the models `S_Process` and `EUR_Process`. When imported into the option pricing model `AmericanPut`, the two processes `S` and `EUR` step forward in model time along with other processes such as `V` in the importing model. As such, at a given model time, the three processes `S`, `EUR` and `V` take their respective values evaluated at that particular model time.

The early exercise evaluation use a ThetaML function `E` to compute the expected discounted option values. The function `E` uses the least squares Monte Carlo regression method combined with sparse grid type basis functions to approximate the conditional expected value. The ThetaML compiler optimally selects the conditioning state variables that are measurable at current model time and takes care of the numerical evaluations of the function `E`.

Futures cash flows in the option pricing models are normalized by the discount numeraire `EUR`. At the option maturity time `T`, the option payoffs `V` are discounted by `EUR` maturing at time `T`. At the early exercise times, the exercise values are discounted by the `EUR`s maturing at the exercise times.

### Compound Option

The compound option is an option on an option. Let us assume the outer option is a European option and the inner option is an American option, i.e. a European option with an American option as its underlying.

Based on the above models for European and American options, our pricing model is extended as follows:

model CompoundOption % The stock prices 'S' and the discount numeraire 'EUR' are simulated respectively in the model % 'S_Process' and 'EUR_Process' import S "Underlying stock prices" import EUR "Discount numeraire" import K1 "Strike price of the outer option" import K2 "Strike price of the inner option" import T1 "Time to maturity of the outer option" import T2 "Time to maturity of the inner option" export P "Compound option price" %at current time, set the option value to have the same expected discounted %value as the variable 'V'; the ThetaML future operator '!' accompanying the %variable 'V' acts like a function on 'V', such that the values of 'V' at %current time remain to be determined at a later instance when 'V' is assigned %some values P = E(V!) %outer option %the ThetaML command 'theta' advances time by 'T1' years theta T1 %early exercise evaluation; the ThetaML function 'E' approximates the conditional %expected option value, computed using the Least Squares Monte Carlo method combined %with the sparse grid basis functions; %the values of 'V!' at this model time wait to be determined; the ThetaML future %operator '!' allows the possibility to use the variable 'V!' here even if the values %of 'V!' are not known at this model time if E(V!) - K1*EUR > 0 V = V! - K1*EUR else V = 0 end %inner option %loop 'T2*252' times loop T2*252 %early exercise evaluation; the ThetaML function 'E' approximates the conditional %expected option value, computed using the Least Squares Monte Carlo method combined %with the sparse grid basis functions; %the values of 'V!' here waits to be determined if E(V!) < (K2 - S)*EUR V = (K2 - S)*EUR end %the ThetaML command 'theta' advances time by '1/252' years theta 1/252 end %at option maturity time T1+T2, set the compound option payoffs; %the option payoffs are discounted to time 0 by the discount numeraire 'EUR' %note that the variable 'V' is now assigned the payoff values V = max(K2 - S, 0)*EUR end

In the above model, we import two strike prices `K1` and `K2` as well as two maturity times `T1` and `T2` for the outer and inner option, respectively.

The ThetaML future operator `!` allows the possibility to use the variable `V!` at the model time when the values of `V` are not known. This feature occurs a couple of times in our pricing models: at the initial time, when assigning the computed expected discounted values `E(V!)`; at the intermediate model times, when evaluating the outer option payoffs `E(V!) - K1*EUR` and the early exercise strategies `E(V!) < (K2 - S)*EUR`. The ThetaML future operator `!` accompanying the variable `V` allows the values of `V` at this model time to be determined at a later instance when `V` is assigned some values. This happens at the inner option's maturity time, when `V` is assigned the option payoff values. The future operator `!` thus allows stepping the stochastic processes forward in time like what they would have behaved in real life financial markets.

The compiled codes record the command sequences into a computational order. This forces the final assignment of `V` to be evaluated first. The result is then overwritten by optimized option values when stepping backwards in time.

### Hedged American Option

With the above setting as our background, it is easy to introduce variance optimal hedges. The ThetaML command `Beta(S,V)` computes the optimal fraction $ d $ of `S`, which minimizes the variance of a portfolio with one option `V` and $ d $ number of assets with price `S`. As a result, the model `Hedged_American` returns option values of higher precision than the model `American` as a result of using the `Beta` function.

Our model for the hedged American option is as follows:

model Hedged_American % The stock prices 'S' and the discount numeraire 'EUR' are simulated respectively in the model % 'S_Process' and 'EUR_Process' import S "Underlying stock prices" import EUR "Discount numeraire" import K "Strike price of the option" import T "Time to maturity of the option" export P "Hedged American put option price" export V "Process of the option hedge" %at current time, set the option value to have the same expected discounted %value as the variable 'V' P = E(V!) %loop 'T*252' times loop T*252 %at this model time step, the values of 'V' are hedged with the ThetaML function %'Beta'; the term 'Beta(S,V)' computes a optimal hedge ratio between 'S' and 'V'; %note that 'S', 'EUR' and 'V' take values at this model time, while 'S!', 'EUR!' %and 'V!' take values at the next model time V = V! - Beta(S,V)*(S!*EUR! - S*EUR) %early exercise evaluation; the ThetaML function 'E' approximates the conditional %expected discounted option value, computed using the Least Squares Monte Carlo %method combined with the sparse grid basis functions if E(V!) < (K - S)*EUR V = (K - S)*EUR end %the ThetaML command 'theta' advances time by '1/252' years theta 1/252 end %at option maturity time T, set the American put option payoffs; %the option payoffs are discounted to time 0 by the discount numeraire 'EUR' V = max(K - S, 0)*EUR end

In the model `Hedged_American`, the ThetaML `Beta(S, V)` function takes two arguments and computes the beta factor(s) between these two arguments, conditional on the information at current model time. The first argument `S` is the explanatory variable and the second argument `V` is the dependent variable for the conditional regression.

With this, we complete the introductory tutorial 'From European to American'. More detailed descriptions of the ThetaML language can be found at ThetaML. A new method for massively accelerating Monte Carlo simulation-based pricing in ThetaML can be found in the reference Dirnstorfer and Grau (2008) ^{[1]}.

## References

- ↑ Dirnstorfer,Stefan, Andreas J. Grau, 2008, Accelerated Option Pricing in Multiple Scenarios, Computational Engineering, Finance, and Science (cs.CE). URL: http://arxiv.org/abs/0807.5120