Python代写:CSC521-MonteCarloSimulate

Problem1

Your have N servers behind a load balancer. When a request arrives it is automatically assigned to one of the available servers. Requests arrive at random intervals according with the exponential distribution with an average of 100 requests per second. When a server receives a request, it processes the request and this takes a random time described by the pareto distribution.

The minimum time is 2 seconds and the average time is 3 seconds. Each server can process only one request at the time. One server costs $2000/month. If a request arrives and all servers are busy the request is dropped. You earn $0.01 for every request you process and you pay $0.10 in penalties for every request you drop. What is the value of N that allows you to guarantee that 90% of the requests are processed? What is the value of N that maximizes profit? What is the value of N below which you would operate at a loss?

Write a short paper (10 pages), explaining the problem, your solution, answers to the above questions with explanations, and an appendix containing the code (commented and indented).
The paper should contain at least one graph of income vs time for one simulated scenario.

I recommend that each simulate once simulates one minute. Also each call to simulate many should run at least 100 simulate once.

Problem2

Consider the following stocks of the 5 Large-Cap hardware manufacturers in 2016: AAPL, EMC, HPQ, QCOM, STX. Download the historical daily closing prices for these stocks for the last 5 years. For each compute the average yearly return and yearly volatility (average over the past 5 years). You invest $1M in each of these stocks ($5M total).

Implement a Monte Carlo simulation to compute the value of the portfolio in one year. What is the average portfolio value in one year? What is the 5% VAR (defined as the amount such that in no more than 5% of the simulated scenarios, the portfolio value in one year is below said value). Perform the simulation computation in two ways:

  1. simulate each stock separately using a gaussian model for the logreturn.
  2. use resampling. Which is of the two methods is correct and why? What would be the price of a call option that pays you $1M if, after three months, 4 of the 5 stocks have a value below their current value?

Write a short paper (10 pages), explaining the problem, your solution, answers to the above questions with explanations, and an appendix containing the code (commented and indented).

The paper should contain at least one graph showing the simulated stock prices in one simulated scenario and one plot of the distribution from which the VAR is computed.