Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / The objective of this project is to estimate some basic statistics using time series of stock prices

The objective of this project is to estimate some basic statistics using time series of stock prices

Computer Science

The objective of this project is to estimate some basic statistics using time series of stock prices. We also look whether estimates are stable over time when new data are added to the estimation data set. Stability is important because if an investment decision (the purchase/sell of assets) & made based on the estimates, unstable estimates mean that your investment strategy will change from one day to the next making it useless in practice.

The answers for Exercise | should be provided in a folder that is zipped. The folder should contain:

1. A python code that performs the computations that is well organized. Try to display the results in a professional way

(i.¢., put titles and axis legends to graphs), Do not just print numbers. In particular, the code must have

« A sain function that is in a file whose name is Project!

« The answers must be provided in functions that are in a file that is imported in the file that contains the main

function. See ExampleCode.zip on Canvas.

© Graph, if any, should have legends on the axes.

« Whenever you print a number on the console, you should specify what it represents.

« The user (me) will execute the code that will produce the results. Do not use an absolute path if some data are uploaded.

« Use Spyder to develop your code (or your preferred IDE if you don't use Spyder).

2. The data used by the code to answer the questions.

The code should be in a folder whose name is YourIDnumberProject1 and it should be zipped and uploaded on Canvas.

Exercise |

(Total: 5 marks for presentation + 25 marks). Stock index and stocks.

We denote by 4)” the stock index value at time ¢ (im stands for the “market”), it is given by the S&:P500 (RIC .SPX). You

select § US. stocks. We denote by s/ the stock value at time t of the 1" stock with j= 15. O

i. Once a stock is selected, it can no longer be selected by another student. Then you download the daily prices for these 5 U.S. stocks and the S&P500 from 20/03/2016 to 20/03/2022 using Workspace.

1, (2 marks) For three assets, one of which is the S&P500, denoted «!, «7 and «\", plot (using matplotlib) the evolutions

(sty or, (92). op and (sf")), or. Check if you can identify the Covid-19 impact and other international events. B

2. (4 marks) Given a stock «?, we denote by

al =a

de t - toa q)

ed

the return from day { — | to day ¢. Similarly, the retumn of the stock index (i.e. the S&P500) is denoted

a — ai,

m= td 2

" | (2)

Notice that r}" and r] can be computed using the pandas method pct change.

We want to estimate the mean and standard deviation of the returns. More precisely, we suppose that

rh ~ N(yj.0;). for j = 1,....5 (3)

re ~ N (ptm. Om) « (4)

where j1, and o, are the mean and standard deviation of the return of the asset j whilst similar interpretation applies to

the stock index mm. N (je. 0) is a Gaussian distribution with mean j: and standard deviation o.

Using the functions

© mean

© std

and the entire sample, compute for each stock 1; and a, for j = 1,...,5 and for the stock index ji, and Oy.

We suggest to annualize j:,, and o,,, (and j, and a,), it means that once you have j1,, and o, from the daily returns, you annualize them by multiplying by 250 and 250, respectively.

3. (4 marks) Consider all the stocks along with the S&P500. The covariance matrix of the vector (r},r?,....r? ri" )r>o

is denoted £. Using the function cov compute £. B

4. (3 marks) For one of the stocks (of your choice), using the function plot hist plot the histogram of (re)... 7 where r,

is the return of the asset you selected. @

5. (2 marks) Using only 1 stock whose returns are denoted (r/),>0 and the stock index whose returns are denoted (r}")>0,

compute the correlation between (r}).>u and (r/");>u using a sliding window of size 250. It means that you take the first 250

observations (observations | to 250), compute the correlation, then take the observations 2 to 251, compute the correlation

etc... until you use all the data. You should use the function rolling. Plot the time series of correlations. BD

6. (4 marks) For a given stock of your choice and the stock index count the number of days for which the stock return is larger than the stock index return.

7. (3 marks) For a given stock of your choice denoted s;, let jz: be its mean daily return and o the standard deviation of the return. Count the number of days for which the daily return is larger than j: + 30 (.i.e.. the mean daily return plus three times the standard deviation). BB

8. (3 marks) For a given stock of your choice denoted «;, let j: be its mean daily return and « the standard deviation of the return. Using the method apply and a lambda function, replace all the negative returns with -O.l +.

Option 1

Low Cost Option
Download this past answer in few clicks

12 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE