File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 3
3
csv file, computing the daily returns, appending the results to the
4
4
record arrays, joining on date
5
5
"""
6
- import urllib
6
+ from six . moves import urllib
7
7
import numpy as np
8
8
import matplotlib .pyplot as plt
9
9
import matplotlib .mlab as mlab
10
10
11
11
# 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' )
14
14
15
15
# 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 ]))
18
18
19
19
# compute the daily returns and add these columns to the arrays
20
20
gains1 = np .zeros_like (r1 .adj_close )
You can’t perform that action at this time.
0 commit comments