Skip to content

Commit 5e21f24

Browse files
jenshnielsenstory645
authored andcommitted
Make longshort python3 compatible
1 parent 877d90a commit 5e21f24

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/misc/longshort.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
csv file, computing the daily returns, appending the results to the
44
record arrays, joining on date
55
"""
6-
import urllib
6+
from six.moves import urllib
77
import numpy as np
88
import matplotlib.pyplot as plt
99
import 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
2020
gains1 = np.zeros_like(r1.adj_close)

0 commit comments

Comments
 (0)