金融數據獲取

最近研究金融數據,須要獲取大量的金融數據進行研究,在python中金融數據模塊進行了遷移,從之前的pandas到pandas_datareader模塊的遷移,折騰了挺久了,終於能夠成功的獲取數據,環境是基於python3html

安裝pandas_datareader模塊python

$pip3 install pandas
$pip3 install pandas-datareader

1.利用pandas_datareader模塊獲取數據web

1.1利用ipython,代碼以下所示:spa

ipython
In [1]: import pandas_datareader.data as web
#獲取蘋果 2014年1月1號至 2018年7月17日的股票數據
In [2]: web.get_data_yahoo('AAPL', '1/1/2014', '17/7/2018')     

獲取國內的股票數據方式「股票代碼」+「對應股市」code

上證股票代碼後面加上.sshtm

#獲取深市30048股票 2015年1月1號至2018年7月17號的數據
In [3]: web.get_data_yahoo('300481.sz', '1/1/2015','17/7/2018')   

上證股票:.ss      深證股票:.szblog

上證綜指:00001.ss      深證成指:399001.sz.      滬深300:000300.ss      香港: 0001.hkip

加拿大股指: cun.to      新西蘭股指:.nz      新加坡股指:.si      臺灣股指:.tw get

2.使用tusharepandas

#安裝tushare
$pip3 install tushare
#版本升級
$pip install tushare --upgrade

詳細狀況可參考官網信息:http://tushare.org/index.html

相關文章
相關標籤/搜索