File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33csv file, computing the daily returns, appending the results to the
44record arrays, joining on date
55"""
6- import urllib
6+ from six . moves import urllib
77import numpy as np
88import matplotlib .pyplot as plt
99import matplotlib .mlab as mlab
1010
1111# grab the price data off yahoo
12- u1 = urllib .urlretrieve ('http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv' )
13- u2 = urllib .urlretrieve ('http://ichart.finance.yahoo.com/table.csv?s=GOOG&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv' )
12+ u1 = urllib .request . urlretrieve ('http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv' )
13+ u2 = urllib .request . urlretrieve ('http://ichart.finance.yahoo.com/table.csv?s=GOOG&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv' )
1414
1515# load the CSV files into record arrays
16- r1 = mlab .csv2rec (file (u1 [0 ]))
17- r2 = mlab .csv2rec (file (u2 [0 ]))
16+ r1 = mlab .csv2rec (open (u1 [0 ]))
17+ r2 = mlab .csv2rec (open (u2 [0 ]))
1818
1919# compute the daily returns and add these columns to the arrays
2020gains1 = np .zeros_like (r1 .adj_close )
You can’t perform that action at this time.
0 commit comments