def get_futures_daily(self, start_date, end_date, market, index_bar): ''' 名称 类型 必选 描述 start_date str Y start_date="20200701" end_date str Y end_date="20200716" market str Y market="DCE"; choice of {"CFFEX", "INE", "CZCE", "DCE", "SHFE"} index_bar str Y index_bar=False; 是否合成指数 out 名称 类型 默认显示 描述 symbol str Y 合约 date str Y 交易日 open float Y 开盘价 high float Y 最高价 low float Y 最低价 close str Y 收盘价 volume str Y 成交量 open_interest str Y 持仓量 turnover float Y 成交额 settle float Y 结算价 pre_settle float Y 前结算价 variety str Y 品种 ''' futures_daily_df = ak.get_futures_daily(start_date=start_date, end_date=end_date, market=market, index_bar=index_bar) return futures_daily_df
def get_get_futures_daily(self, start_date, end_date, market): ''' :param start_date: start_date="20190107" :param end_date:end_date="20190108" :param market: 可以添为四个交易所的简称, 即 “DCE” 代表大商所; “INE” 代表能源所; “SHFE” 代表上期所; “CZCE” 代表郑商所, :return: ''' futures_daily_df = ak.get_futures_daily(start_date=start_date, end_date=end_date, market=market, index_bar=True) return futures_daily_df
def test(): print('测试及功能展示: ') # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n一个品种在时间轴上的展期收益率') df = akshare.get_roll_yield_bar(type_method='date', var='RB', start_day='20181206', end_day='20181210', plot=False) print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n一个品种在不同交割标的上的价格比较') df = akshare.get_roll_yield_bar(type_method='symbol', var='RB', date='20181210', plot=False) print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n多个品种在某天的展期收益率横截面比较') df = akshare.get_roll_yield_bar(type_method='var', date='20181210', plot=False) print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n特定两个标的的展期收益率') df = akshare.get_roll_yield(date='20181210', var='IF', symbol1='IF1812', symbol2='IF1901') print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n特定品种、特定时段的交易所注册仓单') df = akshare.get_receipt(start_day='20181207', end_day='20181210', vars_list=['CU', 'NI']) print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n特定日期的现货价格及基差') df = akshare.futures_spot_price('20181210') print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n特定品种、特定时段的现货价格及基差') df = akshare.futures_spot_price_daily(start_day='20181210', end_day='20181210', vars_list=['CU', 'RB']) print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n特定品种、特定时段的会员持仓排名求和') df = akshare.get_rank_sum_daily(start_day='20181210', end_day='20181210', vars_list=['IF', 'C']) print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n大商所会员持仓排名细节;郑商所、上期所、中金所分别改成get_czce_rank_table、get_shfe_rank_table、get_cffex_rank_table') df = akshare.get_dce_rank_table('20181210') print(df) # ---------------------------------------------------------------------- print('\n' + '-' * 80 + '\n日线行情获取') df = akshare.get_futures_daily(start_date='20181210', end_date='20181210', market='DCE', index_bar=True) print(df)
__author__ = 'zoulida' import akshare as ak get_futures_daily_df = ak.get_futures_daily(start_date="20200701", end_date="20200716", market="cffex", index_bar=True) print(get_futures_daily_df)
import akshare as ak get_futures_daily_df = ak.get_futures_daily(start_date="20201220", end_date="20201225", market="SHFE", index_bar=True) import time import akshare as ak dce_text = ak.match_main_contract(exchange="dce") czce_text = ak.match_main_contract(exchange="czce") shfe_text = ak.match_main_contract(exchange="shfe") while True: time.sleep(3) data = ak.futures_zh_spot(subscribe_list=",".join( [dce_text, czce_text, shfe_text]), market="CF", adjust=False) print(data)