在股票市场的金融数据方面,可以利用以下组件获得数据来源
1.国内需要利用akshare组件包来处理,官方网址
https://www.akshare.xyz
简单实例如下
import akshare as ak stock_us_daily_df = ak.stock_us_daily(symbol="AAPL", adjust="") print(stock_us_daily_df)
2.利用pandas组件包
官方网址
https://pandas.pydata.org/
这个组件在境外比较好用,国内读取股市信息可能需要VPN
import investpy import matplotlib as mp import pandas as pd a=pd.Series(['1a','2a','3a','4a','5a'],index=[1,2,3,4,5]) ### ''' df = investpy.get_stock_historical_data(stock='AAPL', country='United States', from_date='01/01/2010', to_date='01/01/2020') print(df.head()) ### ''' print(a)
3.
官方网址
https://www.tushare.pro/
实例如下:
import tushare as ts ts.set_token('28d80dc9f7e55b29af68e245c8f68ce1a7a163ca05691b12c04d00aa') pro = ts.pro_api('28d80dc9f7e55b29af68e245c8f68ce1a7a163ca05691b12c04d00aa') df = pro.query('trade_cal', exchange='', start_date='20180901', end_date='20181001', fields='exchange,cal_date,is_open,pretrade_date', is_open='0') df = pro.trade_cal(exchange='', start_date='20180901', end_date='20181001', fields='exchange,cal_date,is_open,pretrade_date', is_open='0') df = pro.stock_basic(**{ "ts_code": '000100.SZ', "name": "TCL", "exchange": "SZSE", "market": "", "is_hs": "", "list_status": "", "limit": "", "offset": "" }, fields=[ "ts_code", "symbol", "name", "area", "industry", "market", "list_date", "fullname", "enname", "cnspell", "exchange", "curr_type", "list_status", "delist_date", "is_hs" ]) print(df)