AkShare
[toc]
# General
pip install akshare --upgrade
# China
pip install akshare -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com --upgrade
# Data
import akshare as ak
stock_us_daily_df = ak.stock_us_daily(symbol="AMZN") # Get U.S. stock Amazon's price info
print(stock_us_daily_df)
2
3
# Plot
import akshare as ak
import mplfinance as mpf # Please install mplfinance as follows: pip install mplfinance
stock_us_daily_df = ak.stock_us_daily(symbol="AAPL", adjust="qfq")
stock_us_daily_df = stock_us_daily_df[["open", "high", "low", "close", "volume"]]
stock_us_daily_df.columns = ["Open", "High", "Low", "Close", "Volume"]
stock_us_daily_df.index.name = "Date"
stock_us_daily_df = stock_us_daily_df["2020-04-01": "2020-04-29"]
mpf.plot(stock_us_daily_df, type='candle', mav=(3, 6, 9), volume=True, show_nontrading=False)
2
3
4
5
6
7
8
9
# Rollover rate
import akshare as ak
get_roll_yield_bar_df = ak.get_roll_yield_bar(type_method="date", var="RB", start_day="20180618", end_day="20180718", plot=True)
print(get_roll_yield_bar_df)
2
3
# Option
# 交易所商品期权数据
"option_dce_daily" # 提供大连商品交易所商品期权数据 "option_czce_daily" # 提供郑州商品交易所商品期权数据 "option_shfe_daily" # 提供上海期货交易所商品期权数据
# 交易所金融期权数据
"get_finance_option" # 提供上海证券交易所期权数据
# 金融期权
"option_finance_board" # 获取金融期权数据
# 金融期权-新浪
"option_sina_cffex_hs300_list" # 沪深300期权列表 "option_sina_cffex_hs300_spot" # 沪深300期权实时行情 "option_sina_cffex_hs300_daily" # 沪深300期权历史行情-日频 "option_sina_sse_list" # 上交所期权列表 "option_sina_sse_expire_day" # 上交所期权剩余到期日 "option_sina_sse_codes" # 上交所期权代码 "option_sina_sse_spot_price" # 上交所期权实时行情 "option_sina_sse_underlying_spot_price" # 上交所期权标的物实时行情 "option_sina_sse_greeks" # 上交所期权希腊字母 "option_sina_sse_minute" # 上交所期权分钟数据 "option_sina_sse_daily" # 上交所期权日频数据 "option_sina_finance_minute" # 股票期权分时数据
# 商品期权-新浪
"option_sina_option_commodity_dict" # 商品期权合约字典查询 "option_sina_option_commodity_contract_list" # 商品期权合约查询 "option_sina_option_commodity_hist" # 商品期权行情历史数据
# Futures
# 新浪财经-期货
"futures_zh_spot" # 获取新浪-国内期货实时行情数据 "futures_foreign_commodity_realtime" # 获取新浪-外盘期货实时行情数据 "futures_foreign_hist" # 获取新浪-外盘期货历史行情数据 "futures_foreign_detail" # 获取新浪-外盘期货合约详情
# 期货连续合约
"futures_main_sina" # 获取新浪期货连续合约的历史数据
# 期货合约详情
"futures_contract_detail" # 期货合约详情