# 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

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, the BUY 50 Shares If P>105 SELL ALL shares If 100< P < 105 → Do Nothing Sell ALL 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 Realization required to get close to the BOOK answer is to realize:  That at YEAR’S END we must SELL ALL shares remaining in out portfolio at the Year- End PRICE, even if this price is less than \$105 This amount is then “lump- added” to our day-to-day 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 Stock purchase Profit summary MAXProfit = 8.2830e+004 MINProfit = 4.8765e+004 AvgProfit = 6.4429e+004 StdPprofit = 5.6996e+003

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

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

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-2 Results Stock purchase Profit summary mean_yearly_profit = 6.5045e+004 min_yearly_profit = 4.9708e+004 max_yearly_profit = 8.7179e+004 std_profit = 5.7279e+003

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

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

BMayer@ChabotCollege.edu ENGR-25_HW-01_Solution.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Method-1 Single Run Stock purchase Profit summary YearEndIncome = 7.4515e+004 TotalProfit = 6.2847e+004 NoSharesLeftInPortfolio = 750 s = 33 b = 131 na = 86

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