**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.

# Exercise Model

This section shows examples of exercise models implemented in ThetaML.

## Contents

# Exerciser Interface

This is a ThetaML interface model to impose some constraints on the `import` and `export` parameters for various implementations of the exercise strategy. The `IExerciser` interface model guarantees that the imported `ExcerciseValue_CUR` is uniformly named "ExcerciseValue_CUR" and has the description `"Excercise value"`. The exported parameter `ExerciseStrategy` in all the subsequent ThetaML models that compute an exercise strategy should be called "ExerciseStrategy".

interface IExerciser import ExcerciseValue_CUR "Excercise value" export ExerciseStrategy end

The advantage of using ThetaML `interface` is the flexibility to structure dynamic models where a given stochastic process can be imported from different simulation models.

The following ThetaML models compute exercise strategies based on the `ExcerciseValue_CUR` computed from the payoff description models in the examples given in Payoff Description Language.

# Risk Neutral Exerciser

The following ThetaML model computes the risk neutral exercise strategy and the option price. The exercise strategy is based on the ThetaML `E` function. The `E` function computes the conditional expectations of its argument using the least squares Monte Carlo regression method combined with the sparse grid type basis functions.

The ThetaML future operator `!` allows the possibility to use the a vairable at the model time when its values are not pre-assigned. This is base on forward algorithm. The finally compiled codes, however, record the commands into a computational order by forcing the final assignment of the variable to be evaluated first. The result is then overwritten by updated values when stepping backwards in time.

model RiskNeutralExerciserCash implements IExerciser import ExcerciseValue_CUR "Excercise value" import TimeGrid "Exercise time grid" export ExerciseStrategy "1 for exercise, 0 otherwise" export Price "Option price" %returns current price, the E function computes the expected values based on current information Price = E(value!) ExerciseStrategy = 0 loop t:TimeGrid if ExcerciseValue_CUR > 0 if E(value!) < ExcerciseValue_CUR value = ExcerciseValue_CUR ExerciseStrategy = 1 else ExerciseStrategy = 0 end else ExerciseStrategy = 0 end theta t-@time end if ExcerciseValue_CUR>0 value = ExcerciseValue_CUR ExerciseStrategy = 1 else ExerciseStrategy = 0 value = 0 end end

# Risk Neutral Exerciser with Variance Optimal Hedging

The following model computes a risk neutral exercise strategy based on a variance optimal hedge. The hedge ratio is computed using ThetaML `Beta` function. The `Beta` function returns a variance optimal hedge ratio between its two arguments, conditional on the current information available. The first argument is the explanatory variable, and the second argument is the dependent variable.

model RiskNeutralExerciserCashHedged implements IExerciser import ExcerciseValue_CUR "Excercise value" import HedgeInstruments "Discounted price process of hedge instrument(s)" import CUR "Discount process of currency cur" import TimeGrid "Time grid for exercise and rehedging" export ExerciseStrategy "1 for exercise, 0 otherwise" export Price "Option prices" Price = value! ExerciseStrategy = 0 hedgeInstruments_CUR = HedgeInstruments * CUR loop t:TimeGrid loop s,d : hedgeInstruments_CUR, delta value = value! - d! * (s!-s) end delta = Beta(hedgeInstruments_CUR!, value!) if ExcerciseValue_CUR>0 if E(value!) < ExcerciseValue_CUR value = ExcerciseValue_CUR ExerciseStrategy = 1 else ExerciseStrategy = 0 end else ExerciseStrategy = 0 end theta t-@time hedgeInstruments_CUR = HedgeInstruments * CUR end if ExcerciseValue_CUR>0 value = ExcerciseValue_CUR ExerciseStrategy = 1 else ExerciseStrategy = 0 value = 0 end end

# Better than Optimal: Perfect Hedging Knowing the Future

The following model computes a better than optimal exercise borrowing the forward access feature of the ThetaML future operator `!`. The future operator `!` allows the possibility to use a variable at the model time when its values are not pre-assigned. This is based on the forward algorithm. The ThetaML compiler compiles the codes into a computational order. Whenever it encounters the future operator `!`, it forces the final assignments of the `!`-referenced variable to be evaluated first. The results are then overwritten when stepping backwards in time.

model PerfectExerciserCash implements IExerciser import ExcerciseValue_CUR "Excercise value" import TimeGrid "Exercise time grid" export ExerciseStrategy "1 for exercise, 0 otherwise" export Price "Option prices" Price = value! ExerciseStrategy = 0 loop t:TimeGrid if ExcerciseValue_CUR > 0 if value! < ExcerciseValue_CUR value = ExcerciseValue_CUR ExerciseStrategy = 1 else ExerciseStrategy = 0 end else ExerciseStrategy = 0 end theta t-@time end if ExcerciseValue_CUR>0 value = ExcerciseValue_CUR ExerciseStrategy = 1 else ExerciseStrategy = 0 value = 0 end end