In [1]:
import numpy as np
import pandas as pd
from pandas_datareader import data as wb
import matplotlib.pyplot as plt
In [2]:
weights = np.array([32.94, 30.26, 11.77, 13.02, 9.00, 3.00])
In [3]:
tickers = ['ITSA3', 'GRND3', 'HGTX3', 'PSSA3', 'WEGE3', 'BVMF3']
sec_data = pd.DataFrame()
for t in tickers:
sec_data[t] = wb.DataReader(t, data_source='google', start='2010-1-1')['Close']
In [8]:
sec_data.tail()
Out[8]:
In [16]:
(sec_data / sec_data.iloc[0] * 100).plot(figsize = (15, 6))
plt.show()
Diversifiable Risk
In [10]:
sec_returns = np.log(sec_data / sec_data.shift(1))
In [17]:
ITSA3_var_a = sec_returns[['ITSA3']].var() * 250
GRDN3_var_a = sec_returns[['GRND3']].var() * 250
PSSA3_var_a = sec_returns[['PSSA3']].var() * 250
HGTX3_var_a = sec_returns[['HGTX3']].var() * 250
WEGE3_var_a = sec_returns[['WEGE3']].var() * 250
BVMF3_var_a = sec_returns[['BVMF3']].var() * 250
print(ITSA3_var_a, GRDN3_var_a, PSSA3_var_a, HGTX3_var_a, WEGE3_var_a, BVMF3_var_a)
In [ ]: