用python下载金融数据,现在我用的有yfinance
; Tushare
; akshare
; Investpy
。
但是可以下载到数据的有 Tushare
; akshare
。Tushare
下载一些数据需要积分。
Baostock
yfinance
- Yahoo : https://finance.yahoo.com/
import yfinance as yf
aapl= yf.Ticker("aapl")
aapl_historical = aapl.history(start="2020-06-02", end="2020-06-07", interval="1m")
Tushare
import tushare as ts
token = 'Your Token'
ts.set_token(token)
pro = ts.pro_api()
df = pro.index_basic(market='SW') # 查询信息
SZ_180 = pro.index_daily(ts_code='000010.SH', start_date='20180701', end_date='20190718') # 上证180
HuShen_300 = pro.index_daily(ts_code='000300.SH', start_date='20180701', end_date='20190718') # 沪深300
akshare
- akshare - 文档:https://www.akshare.xyz/
import akshare as ak
stock_zh_a_daily_qfq_df = ak.stock_zh_a_daily(symbol="sh000001", start_date="20201103", end_date="20201116", adjust="qfq")
Investpy
investing.com
可以手动下载一些数据,或者进行爬虫。
- Investpy 文档:https://investpy.readthedocs.io/
import investpy
df = investpy.get_stock_historical_data(stock='AAPL',
country='United States',
from_date='01/01/2010',
to_date='01/01/2020')
JointQuant
- API 文档:https://www.joinquant.com/help/api/help#name:api
- 金融数据分析| JoinQuant 量化策略: https://www.cnblogs.com/shengyang17/p/12764808.html