# ENGR-25_HW-01_Solution.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.

## Presentation on theme: "ENGR-25_HW-01_Solution.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical."— Presentation transcript:

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering 25 Prob 7.18 Solution Stock Market Simulation: Buy? Sell? Hold?

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Scenario  Behavior of Certain Stock Price, P, is randomly set by NORMAL distribution –µ = \$100 –σ = \$5 Simulate Stock behavior over 250 days (1 trading year)  Trading Algorithm If P<100, → BUY 50 Shares If P>105 → SELL ALL shares If 100< P < 105 → HOLD Add to Profit the Value of Stock HELD at END of Year

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Key to Problem  The Critical Issue required to get close to the BOOK answer is to realize:  That at YEAR’S END we must Assess the Value of Any Shares NOT SOLD We will Very Likely (84.13% chance) have shares “Left Over” if P 250 < \$105  Add the Held-Over Value to the previous selling profit

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods MATLAB Code: Method-1

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-1 Results (1-Run) =Stock purchase Profit summary = SellDays = 38 BuyDays = 133 HoldDays = 79 NoSharesLeftInPortfolio = 50 YearEndPrice = 98.9097 YearEndValue = 4.9455e+003 DailyProfit = 6.4715e+004 TotalProfit = 6.9660e+004

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-1 Day-by-Day

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-1 Single Run

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods MATLAB Code: Method-2

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-2 Results mean_yearly_profit = 6.5054e+004 min_yearly_profit = 4.9024e+004 max_yearly_profit = 9.0948e+004 std_profit = 5.7442e+003 MEAN_YrEnd_Price = 99.8867 AVG_YrEnd_Shares = 154.4088 MIN_YrEnd_Shares = 0 MAX_YrEnd_Shares = 1250

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-2 Plots

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods MATLAB Code: Method-1 →MultiRun

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-1: 499 Runs = Stock purchase Profit summary = MAXProfit = 8.5555e+004 MINProfit = 4.6147e+004 AvgProfit = 6.4593e+004 StdPprofit = 5.7947e+003 AvgEndShares = 168.0361

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-1: 499 Runs