Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer this using Matlaba Code. Thank you. determine % the maximum possible profit (on a $1000 investment) that could be gained % from a

Please answer this using Matlaba Code. Thank you.

determine % the maximum possible profit (on a $1000 investment) that could be gained % from a perfectly timed buy and subsequent sell. You will need to do this % for each stock independently and then compare the values to determine % which would have resulted in the biggest gain. Recall that one cannot % sell a stock that one does not own, so the purchase must come before the % sale. % % % Using good practices for formatting output, not the echo, report back to % the user: % (1) the max possible profit of the perfectly timed buy and sell within % each stock and the associated week of purchase and of sale % corresponding to that max profit % (2) the overall max profit among the results of (1)

Additional info that could be helpful to answer this:

sminvestment = [1000 , Taiwan_Semiconductor_Manufacturing + 1000]; shinvestment = [1000 , Royal_Dutch_Shell + 1000]; Alinvestment = [1000 , Alphabet + 1000]; Inminvestment = [1000 , Intel + 1000]; w = 1:numel(sminvestment); w1 = 1:numel(shinvestment); w2 = 1:numel(Alinvestment); w3 = 1:numel(Inminvestment);

data_investment=[shinvestment; sminvestment; Alinvestment; Inminvestment];

total_val=shinvestment(end)+sminvestment(end)+Alinvestment(end)+Inminvestment(end); fprintf('The total value of portfolio in week 53: $%3.4f. ',total_val)

% calculate stock performance perf(1)=((shinvestment(end)-shinvestment(1))/shinvestment(1))*100; perf(2)=((sminvestment(end)-sminvestment(1))/sminvestment(1))*100; perf(3)=((Alinvestment(end)-Alinvestment(1))/Alinvestment(1))*100; perf(4)=((Inminvestment(end)-Inminvestment(1))/Inminvestment(1))*100;

[~, best_perf]=max(perf); [~, worst_perf]=min(perf);

fprintf('The US$ value of my original $1000 investment at week 53 in the best performing year-to-date stock is $ %3.4f. ',data_investment(best_perf,end)); fprintf('The US$ value of my original $1000 investment at week 53 in the worst performing year-to-date stock is $ %3.4f. ',data_investment(worst_perf,end));

image text in transcribed

Thank you.

Taiwan Semiconductor Manufacturing= [ 31.959999 32.009998 32.73 34.279999 35.18 30.49 30.120001 28.5 28.459999 32.75 32.630001 33.630001 3.650002 41.209999 45.799999 20.389999 27.99 20.03 32.360001 34.299999 34.080002 33.669998 31.120001 31.450001 32.830002 35.869999 27.309999 28.43 29.950001 33.09 25.41 23.66 24.27 25.92 31.51 33.060001 32.66 33 35.349998 35.580002 31.030001 29.01 28.1 28.76 31.91 29 31.040001 45.880001 43.669998 46.650002 44.490002 43.419998 34.119999]: Alphabet= [ 9.85 9.25 9.12 8.64 8.5 8.98 9.38 9.38 9.05 11.06 10.98 10.56 9.93 10.04 9.74 9.55 9.68 9.48 9.27 9.45 9.13 9.41 8.82 .52 8.05 7.81 8.08 8.67 11.08 11.18 11.28 10.82 11.49 11.36 11.19 11.33 11.51 11.11 12.1 11.88 11.65 11.07 13.23 12 11.65 10.71 10.53 10.61 10.7 10.4 10.73 11.15 10.56 Intel- [ 39.400002 37.529999 37.73 36.59 36.380001 35.950001 36.049999 33.91 34.630001 35.32 33.669998 37.939999 35.169998 36.34 37.68 38.73 37.610001 37.650002 36.709999 36.889999 34.119999 31.790001 31.200001 32.650002 36.029999 35.700001 35.75 35.93 7.950001 34.689999 35.099998 32.98 33.919998 33.330002 34.73 44.07 43.150002 43.490002 41 41.459999 41.09 40.91 37.43 37.84 7-790001 38.299999 43.200001 44.25 43.91 41.25 39.400002 39.16 39.360001] Royal Dutch Shell- 159.389999 159.789993 157.199997 164.520004 166.279999 173.58999 176.610001 173.800003 174.649994 175.729996 163.039993 162.320007 162.929993 164.460007 140.610001 137.419998 144.059998 124.949997 133.199997 137.949997 144.199997 179.369995 181.289993 190 190.279999 176.110001 177.360001 183.289993 176.619995 185.229996 185.089996 186.990005 182.679993 184.919998 193.990005 189.100006 195.950006 201.740005 194.320007 203.229996 207.320007 209.940002 174.989999 177.779999 180.259995 157.330002 153.740005 154.050003 145.369995 150.350006 144.960007 139.529999 131.729996]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions