Ubuntu安装matplotlib/pandas
sudo apt-get install python-matplotlib
sudo apt-get install python-pandas
获取雅虎财经网的可口可乐公司上一个的股票基本情况,包括日期/开盘价/收盘价/最高价/最低价和成交量。
from matplotlib.finance import quotes_historical_yahoo
from datetime import date
import pandas as pd
today = date.today()
start=(today.year,today.month-1,today.day)
quotes = quotes_historical_yahoo('CCE',start,today)
df=pd.DataFrame(quotes)
print df
运行结果
monica@monica-virtual-machine:~/Python$ python quotes.py
0 1 2 3 4 5
0 736052 50.049999 50.330002 50.410000 49.970001 1226000
1 736053 50.570000 51.090000 51.130001 50.410000 1071100
2 736054 51.209999 50.740002 51.820000 50.689999 2787400
3 736055 50.419998 51.480000 51.580002 50.380001 2404500
4 736058 51.590000 52.150002 52.160000 51.509998 3175200
5 736059 52.020000 52.020000 52.490002 51.910000 3506900
6 736060 51.840000 52.680000 52.779999 51.840000 2312600
7 736061 52.520000 52.400002 52.619999 52.150002 2369500
8 736062 52.630001 52.540001 52.860001 52.410000 1392800
9 736065 52.790001 52.630001 53.200001 52.549999 2297200
10 736066 52.799999 52.820000 53.049999 52.580002 2813400
11 736067 53.090000 52.970001 53.090000 52.639999 2267500
12 736068 53.939999 53.470001 54.540001 53.360001 4120200
13 736069 53.529999 53.669998 53.779999 53.310001 1518800
14 736072 53.580002 53.590000 53.799999 53.360001 1123200
15 736073 53.820000 53.779999 53.849998 53.560001 1226600
16 736074 53.290001 52.830002 53.290001 52.360001 3085300
17 736075 53.000000 51.740002 53.000000 51.680000 3051500
18 736076 51.770000 51.830002 52.029999 51.540001 1888300
19 736079 51.720001 51.939999 52.310001 51.700001 1907400
20 736080 51.939999 51.660000 52.299999 51.580002 2601300
21 736081 51.869999 51.959999 52.279999 51.669998 2619000
22 736082 53.340000 53.900002 54.220001 53.119999 3113700
23 736083 53.650002 52.480000 53.930000 52.369999 3061000
[24 rows x 6 columns]