In: Computer Science
One share of Global Core Development Systems, Inc (an imaginary company with the abbreviation: Go-CDS) stock was priced at $14.31 on January 1, 2015. Your tasking in this problem is to determine how long does it take for a stockholder to double their money who has invested in Go-CDS? In other words, how long until the price per share has doubled.
Here are some facts about Go-CDS:
Problem: Write a MATLAB program to solve the following questions:
Question 1:
In what month does the stock exceed 2 times the price of $14.31?
Question 2:
Prepare a plot of the stock's per-month price movement over the course starting from the first month of year 2017 until the price has exceeded 2 times the price of $14.31. (You plot should start from month 25, and should cover the month that is the answer to Question #1.) You will need to adjust the plot routine to ONLY show these months.
To limit the plot to these months, add the following command after your xlabel and ylabel commands:
axis ([25, 41, 20, 30]) |
xticks (0:4:length(P)) |
yticks (0:2:30) |
How do I code this is MATLAB?
% Global Core Develpment System
%stock pric variable sp_initial and variable t forc storing the month count from
%1/Jan/2015
sp_initial = 32.50;
t(1) = 1;
sp(1) = sp_initial;
monthly_rate = 0.001; % 0.1percent growth rate = 0.001
quarter_rate = 0.045; %4.5percent quaterly increase
%growth in first 16 month before merger on 17th month
for i = 2:16
t(i) = i;
sp(i) = sp(i-1)*(1 + monthly_rate);
if(mod(i,3) == 0)
sp(i) = sp(i) * (1 + quarter_rate);
end
end
%merger growth in 17th month to 24th month (end of year)
monthly_rate = 0.0115;
for i = 17:24
t(i) = i;
sp(i) = sp(i-1)*(1 + monthly_rate);
if(mod(i,3) == 0)
sp(i) = sp(i) * (1 + quarter_rate);
end
end
% from 25th month that is the new year monthly growth rate is 1.25%
monthly_rate = 0.0125;
for i = 25:34
t(i) = i;
sp(i) = sp(i-1)*(1 + monthly_rate);
if(mod(i,3) == 0)
sp(i) = sp(i) * (1 + quarter_rate);
end
end
%in 34th month CEO gets fired and stock price are by $15 and new monthly
%rate is 1.05 percent
sp(34) = sp(34) - 15;
monthly_rate = 0.0105;
for i = 35:60
t(i) = i;
sp(i) = sp(i-1)*(1 + monthly_rate);
if(mod(i,3) == 0)
sp(i) = sp(i) * (1 + quarter_rate);
end
end
figure
plot(t,sp)
axis([25,49,50,70])
text(40,52,'Note: Price as of 1st of the month')
xlabel('Months from Jan/2015')
ylabel('Stock Share Price($)')
%Answer 1 month when price dobles as of initial stock price
for i =1:50
if(sp(i) >= 2*sp_initial)
fprintf('The Month when the share price doubled is: %d \n', i);
break;
end
end