Question: As we have seen, any two runs generated from the same set of parameters might vary considerably from one-another. You might be asking how

As we have seen, any two runs generated from the same set

As we have seen, any two runs generated from the same set of parameters might vary considerably from one-another. You might be asking how simulation is useful if I get very different results every time we run a simulation. The answer is that we do not expect simulation to be able to tell us exactly what will occur, we use it to get an idea of the range of possible outcomes that might occur. In order to perform that sort of analysis, we need to perform many simulations, and then look at the range of outcomes occurring in this simulations. The process of performing several simulations to estimate probabilities relating to the outcome of a certain event is called Monte Carlo Simulation. Create a markdown cell that displays a level 2 header that reads: "Part D: Monte Carlo Simulation". Also add some text briefly describing the purpose of your code in this part. Write a function named monte_carlo. The function should accept five parameters: start, rate, vol, days, and num_runs. The function should use a loop to generate a number of simulated stock runs equal to num_runs. The characteristics of the runs are provided by the parameters start, rate, vol, and days. A detailed description of this function is provided below. Each time you loop executes, the following steps should be performed: 1. Simulate a run using the supplied parameters. Store the resulting array in a variable. 2. Determine the final simulated price of the stock and append it into a list called final_prices. 3. Determine the annual yield for the simulated run and append it into a list called annual_yields. When the loop is done executing, convert the two lists you have constructed to numpy arrays and return both of them. Create a markdown cell to explain that you are about to test the function by running a Monte Carlo simulation with a specific seed. Set a seed of 1, and run a Monte Carlo simulation consisting of 10,000 simulated runs for a stock with a current price of 200, an expected annual return of 10 %, and a volatility of 0.4. Each run should be over a period of 500 days. Create a histogram of the final prices. Use bins=np.arange(0, 1600, 50), and set the edgecolor to black. Set the size of the figure to be [10,5]. If your code is correct, your histogram should have a peak around 200 and should have a long tail trailing off to the right. This shows that the majority of the simulated final prices are near 200, but there are some very large outliers. Create a markdown cell to explain that you are about to display the 10th, 25th, 50th, 75th, and 90th percentiles of the simulated final prices. Use np. percentile to calculate the 10th, 25th, 50th, 75th, and 90th percentiles for the final prices in the simulated runs generated for the stock. Display the results by creating five lines of output, with each line using the following format: __th percentile: Round the display percentiles to 2 decimal places. If done correctly, you should get a 10th percentile of 118.05 and a 90th percentile of 505.91.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets break down the instructions step by step and create the required Python code and Markdown cells to perform a Monte Carlo simulation and analyze t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!