Consider a naive mdoel for a stock that has a support level of $20. Suppose also that the stock price moves randomly with a downward bias when the price is above $20 and randomly with an upward bias when price is below $20.
Consider a naive mdoel for a stock that has a support level of $20. Suppose also that the stock price moves randomly with a downward bias when the price is above $20 and randomly with an upward bias when price is below $20.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online from Scribd
Consider a naive mdoel for a stock that has a support level of $20. Suppose also that the stock price moves randomly with a downward bias when the price is above $20 and randomly with an upward bias when price is below $20.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online from Scribd
Question: Consider a naive mdoel for a stock that has a support level of $20. Suppose also that the stock price moves randomly with a downward bias when the price is above $20 and randomly with and upward bias when the price is below $20. The probabilities for stock price movement is as follows: Price(t+1) = price(t) + 1 with probability of 1/3 if price > 20, 9/10 if price = 20, 2/3 if price < 20 Price(t+1) = price(t) - 1 with probability of 2/3 if price > 20, 1/10 if price = 20, 1/3 if price < 20 Calculate the expected time for the stock price to fall from $25 through the sup port level of $20 all the way down to $18 ******/ #include <iostream> #include <time.h> #include <vector> using namespace std; int main(){ unsigned int iter = 1000000; //amount of times to run simulation srand(unsigned int(time(NULL))); //seed the random generator int sum = 0; //summed total number of days for (iter) num of simulations . int startPrice = 25;//start simulation at this price int endPrice = 18; //stop simulation when price hits this double oneTenth = 1.0/10.0;//probabilities double twoThirds = 2.0/3.0;//probabilities //run the simulation iter times for (unsigned int i=0;i<iter;i++){ int price = startPrice; int days=0; //days counter, counts the number of days to acheive end price while(price>endPrice){//when not end price keep going double x = ((rand()%32767)/32766.0); //x is a random dou ble from 0 to 1 //price action above 20 if(price>20){ if(x<twoThirds){ price--; }else{ price++; } }else if(price==20){ //price action at 20 if(x<oneTenth){ price--; }else{ price++; } }else if(price<20){//price action under 20 if(x<twoThirds){ price++; }else{ price--; } } days++; }//end while, end price reached sum+=days;//add number of days to summed total }//end for, completed all the simulations cout<<double(sum)/double(iter);//avg number of days to achieve end price }