Entwickelt in den 1960er Jahren von William F. Sharpe, John Lintner und Jan Mossin.
Auf der Portefeuilletheorie (Portfolio Selection) basierendes Modell des Kapitalmarktes
Harry Markowitz, 1927
Nobel Memorial Prize in Economic Sciences, 1990
Dabei ist:
Dabei ist:
import quandl
import pandas as pd # time series
import datetime
import numpy as np
import matplotlib.pyplot as plt # Import matplotlib
#quandl.ApiConfig.api_key = "..." - this is the personal Quandl API key
quandlList= [["Microsoft", "Close", "EOD/MSFT"],
["SAP", "Close", "FSE/SAP_X"],
["gold", "Value", "WGC/GOLD_DAILY_EUR"],
["oil", "Value", "EIA/PET_RWTC_D"],
["E.ON", "Close", "FSE/EON_X"],
["deutsche Bank", "Close", "FSE/DBK_X"],
["Allianz", "Close", "FSE/ALV_X"],
["Munich Re", "Close", "FSE/MUV2_X"],
["€/$", "Value", "ECB/EURUSD"]
]
# We look at stock prices over the past year
start = datetime.datetime(2018,1,2)
#start = datetime.datetime(2018,1,2)
end = datetime.date.today()
stocks = pd.DataFrame()
for s in quandlList: # this call includes the personal Quandl API key
tmp= quandl.get(s[2], start_date=start, end_date=end, authtoken="...")
stocks= pd.concat([stocks, pd.DataFrame({s[0]: tmp[s[1]]})], axis=1, sort=True)
stocks['Microsoft']= stocks['Microsoft']/ stocks['€/$']
stocks['€/$']=1/stocks['€/$']
stocks # stocks.head(); stocks
import plotly #import plotly.plotly as py
import plotly.graph_objs as go
# Must enable in order to use plotly off-line (vs. in the cloud... hate cloud)
plotly.offline.init_notebook_mode()
stock_return = stocks.apply(lambda x: (x / x[0] ))
data = [go.Scatter( x=stock_return.index, y=stock_return[x[0]], name= x[0]) for x in quandlList]
fig = go.Figure(data=data, layout = go.Layout(title=go.layout.Title(text='assets, S')))
plotly.offline.iplot(fig, filename='stock data')