参考:https://zhuanlan.zhihu.com/p/35360694
1.获取数据
#定义所需要的数据
gafataDict={"谷歌":"GOOG","亚马逊":"AMZN","Facebook":"FB","苹果":"AAPL","阿里巴巴":"BABA","腾讯":"0700.hk"}
定义需要的数据时间段
start_date="2017-1-1"
end_date="2018-1-1"
数据选择从雅虎财经抓取,所需要的包有pandas和pandas_datareader等。
import pandas as pd
from pandas_datareader import data as pdr
import datetime
import fix_yahoo_finance as yf
yf.pdr_override()
抓取数据
googDF=pdr.get_data_yahoo(gafataDict["谷歌"],start_date,end_date)
amznDF=pdr.get_data_yahoo(gafataDict["亚马逊"],start_date,end_date)
fbDF=pdr.get_data_yahoo(gafataDict["Facebook"],start_date,end_date)
aaplDF=pdr.get_data_yahoo(gafataDict["苹果"],start_date,end_date)
babaDF=pdr.get_data_yahoo(gafataDict["阿里巴巴"],start_date,end_date)
txDF=pdr.get_data_yahoo(gafataDict["腾讯"],start_date,end_date)
2.查看数据
查看各个股票的描述性分析数据
例:谷歌和腾讯