In [2]:
import pandas as pd
from os import listdir
import plotly.graph_objects as go
In [3]:
#read csv files with stocks time series
stockfiles = [f for f in listdir('.') if f[-3:] == 'csv']
In [4]:
#read stocks description and symbols
stocks_description = pd.read_csv('stocks.description')
stocks_description
Out[4]:
Name Description
0 vwigx Vanguard International Growth Fund
1 vfwax Vanguard FTSE All-World ex-US Index Fund Admir...
2 vxus Vanguard Total International Stock ETF
3 vbtlx Vanguard Total Bond Market Index Fund Admiral ...
4 vihax Vanguard International High Dividend Yield Ind...
5 vthrx Vanguard Target Retirement 2030 Fund
6 vghcx Vanguard Health Care Fund
7 vpadx Vanguard Pacific Stock Index Fund Admiral Shares
8 vtsax Vanguard Total Stock Market Index Fund
9 viaax Vanguard International Dividend Appreciation ...
10 veusx Vanguard European Stock Index Fund Admiral Shares
11 vffvx Vanguard Target Retirement 2055 Fund
12 pogrx PRIMECAP Odyssey Growth Fund
13 vti Vanguard Total Stock Market ETF
14 88160RAD3 Tesla Motors, Inc. Bond 2.375% Due 3/15/2022
In [5]:
#create dictionary with stocks names and data
stocks={}
for s in stockfiles:
    df = pd.read_csv(s)
    df['Date'] = df.Date.astype('M')
    stocks[s.split('.')[0].lower()] = df.copy()
In [6]:
# Create plotly figure and add traces
fig = go.Figure()
for stock in stocks.keys():
    fig.add_trace(go.Scatter(x=stocks[stock]['Date'], y=stocks[stock]['Close'],
                        mode='lines',
                        name=stock))
fig.show()
In [7]:
stocks_description
Out[7]:
Name Description
0 vwigx Vanguard International Growth Fund
1 vfwax Vanguard FTSE All-World ex-US Index Fund Admir...
2 vxus Vanguard Total International Stock ETF
3 vbtlx Vanguard Total Bond Market Index Fund Admiral ...
4 vihax Vanguard International High Dividend Yield Ind...
5 vthrx Vanguard Target Retirement 2030 Fund
6 vghcx Vanguard Health Care Fund
7 vpadx Vanguard Pacific Stock Index Fund Admiral Shares
8 vtsax Vanguard Total Stock Market Index Fund
9 viaax Vanguard International Dividend Appreciation ...
10 veusx Vanguard European Stock Index Fund Admiral Shares
11 vffvx Vanguard Target Retirement 2055 Fund
12 pogrx PRIMECAP Odyssey Growth Fund
13 vti Vanguard Total Stock Market ETF
14 88160RAD3 Tesla Motors, Inc. Bond 2.375% Due 3/15/2022
In [ ]: