January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to find the Efficient Frontier using Monte Carlo simulations.
import yfinance as yfimport numpy as npimport pandas as pd
N_PORTFOLIOS = 10 ** 5N_DAYS = 252RISKY_ASSETS = ['FB', 'TSLA', 'TWTR', 'MSFT']RISKY_ASSETS.sort()START_DATE = '2018-01-01'END_DATE = '2018-12-31'n_assets = len(RISKY_ASSETS)
prices_df = yf.download(RISKY_ASSETS, start=START_DATE, end=END_DATE, adjusted=True)
returns_df = prices_df['Adj Close'].pct_change().dropna()avg_returns = returns_df.mean() * N_DAYScov_mat = returns_df.cov() * N_DAYS
Read now
Unlock full access