A simple task of portfolio simulation with and without the prerequisites of stock correlation.

Assumptions

Source of data: Yahoo Finance. Stocks: Amazon, Cisco, IBM, Intel and Take-Two Interactive

data.rar

Для генерации случайных скоррелированных чисел используется разложение Холецкого для матрицы ковариации.

self.L = sl.cholesky(self.cov_matrix, lower=True)

Portfolio generation

For simplicity, all portfolios are equal-weighted..

# Portfolio with correlated stocks
np.random.seed(42)
o = Basket(1, 10)        
o.prepare_data()
o.monte_carlo()

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/121e46df-c7ba-4bcc-b9ce-5fcc3fcc1fb6/correlated.png

Correlated portfolios

Correlation table

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7294839a-1626-492a-ae6b-d6eb31b8535a/corr_matrix.png

As you can see, the vast majority of stocks are positively correlated with each other. In the case of uncorrelated stocks, the performance of the portfolio is noticeably sagging, because of high standard deviations of individual stocks.

np.random.seed(42)
o = Basket(1, 10, correlated=False)        
o.prepare_data()
o.monte_carlo()

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2b695738-084d-4289-8d18-c7b75bb792be/uncorrelated.png

Uncorrelated