4.11 Trading resistance levels |
Rather than showing a complete solution, the teacher decided here to give you his
own applet and guide you through a series of experiments illustrating the effect of
resistance / support levels. To complete this exercise, your task will be to implement
your own scheme in the applet and discuss what you observe.
First check assignment 2.03 for a description of a
market parametrized with a Drift=0.03, a Volatility=0.3, taking account
of the price dynamics with a resistance / support level at Barrier=10.0 and an
intensity UserDouble=0.02.
A Monte-Carlo sampling of the underlying can now be used to calculate the expected
value for a European put option with a StrikePrice=9.0 for up to 9 months or
RunTime=0.75 years before the expiry and is discounted back to prevent time
assuming a risk free SpotRate=0.03.
VMarket applet: press START/STOP
for execution.
double timeStep= runData.getParamValue("TimeStep"); // Run parameters
double mu = runData.getParamValue("Drift");
double sigma = runData.getParamValue("Volatility");
int type = runData.getParamValueInt("UserInteger");
if (type == 1) { // Log-normal walk for stock prices (no modification required)
for(int j=0; j<f.length; j++) {
for(int k=0; k<numberOfRealisations; k++){
currentState[k][j] += currentState[k][j] *
( mu*timeStep +
sigma*random.nextGaussian()*Math.sqrt(timeStep) );
} // (for realisations)
} // for (initial conditions)
} else if (type == 2) { // Simulate resistance/support levels (please modify)
double barrier = runData.getParamValue("Barrier"); // Extra parameters
double intensity = runData.getParamValue("UserDouble");
double width = 0.1*barrier;
double odds = 2*intensity-1;
// Examples of useful functions in Java
// double uniform01 = Math.random(); // random number in U(0,1)
// double gaussian01 = random.nextGaussian(); // random number in N(0,1)
// double e = Math.exp(1.);
// double one = Math.log(e);
// System.out.println("Debug: type="+type); // print to browser Java-console
for(int j=0; j<f.length; j++) {
// Insert her your code from assignment 2.03, substituting
// currentState[k][0] -> currentState[k][j]
} // for (initial conditions)
} // if (type)
![]() |
Copyright © Doc Andre Jaun & Lifelong-Learners/opt at 06:53:57, May 05th, 2004 |