Question
Code the following in Python 2.x A simple model for daily stock prices is based on multiplicative random walks. The idea is simple, but provides
Code the following in Python 2.x A simple model for daily stock prices is based on multiplicative random walks. The idea is simple, but provides a reasonably realistic result. Assume that daily stock returns are randomly distributed, and further assume that they follow a normal (aka. Gaus- sian) distribution. Then, we could simulate the price xt of a given stock on day t (t = 0, 1, 2, . . .) with the following random walk: xt+1 = xt (1 + rt) where rt N(0, ) is a normal random variable, with zero mean and variance . Write a program that accepts three command-line arguments: the initial price x0 (float), the number of days N (integer), and the variance (float). It should then simulate the above multiplicative random walk, printing out the values of x0, x1, x2, . . . , xN one per line of output (i.e., your output should have N + 1 lines). You should use the random.normalvariate() library function to generate numbers following a normal distribution with the desired parameters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started