quant.data¶
quant.data.wind¶
-
class
quant.data.wind.
WindDB
[源代码]¶ 万得金融数据库接口
Methods
add_wind_columns get_all_columns get_fetched_columns get_unfetched_columns get_wind_connection sql_select update_last_update_time update_wind_table
-
class
quant.data.wind.
WindData
[源代码]¶ 万得金融数据库接口
Methods
arrange_entry_table
(table, …)把带有entry_dt, remove_dt的表重新整理成以股票为列、日期为行的透视表 get_consensus_data
(field, est_years)A股盈利预测汇总 get_data
(table, field, index, columns)获取万得交易数据 get_index_weight
(table, s_info_windcode)从指定的表中获得指数权重 get_stock_basics
()从AShareDescription表中获取每个股票的基本信息 get_stock_industries
(table, level)从指定的表中获取股票行业表 get_stock_st
()This method is deprecated in favor of arrange_entry_table. get_table
(table_name, columns, str] = None)万得数据库原始表 get_wind_data
(*args, **kwargs)This method is deprecated in favor of get_data. get_wind_table
(*args, **kwargs)This method is deprecated in favor of get_table. -
arrange_entry_table
(table: Union[str, pandas.core.frame.DataFrame], field: str = '', columns: str = None)[源代码]¶ 把带有entry_dt, remove_dt的表重新整理成以股票为列、日期为行的透视表
原数据表样例:
s_info_windcode entry_dt remove_dt XXXXX1.SH 20150101 20150201 XXXXX2.SH 20150130 20150307 … … … 转换后数据样例:
trade_dt XXXXX1.SH XXXXX2.SH … … … 2014-12-30 False False 2014-12-30 False False 2015-01-01 True False 2015-01-02 True False … … … 2015-01-29 True False 2015-01-30 True True 2015-01-31 True True 2015-02-01 True True 2015-02-02 False True … … … Parameters: - table: str
要查询的表名,或DataFrame数据框
- field: str
以某字段为内容。如果为空,则生成的数据只含有True,False
- columns: str
指定要作为列名的字段,默认为s_info_windcode
Examples
# AShareST表示通过entry_dt和remove_dt来维护股票进入ST和离开ST的时间的 # arrange_entry_table把该信息重新整理成以交易日为行、股票为列的“交易日”表 # 最后把剩下的NA用False填充 wind.arrange_entry_table("AShareST").fillna(False)
-
get_consensus_data
(field: str, est_years: int = 1) → pandas.core.frame.DataFrame[源代码]¶ A股盈利预测汇总
Parameters: - field: str
分析师预测数据字段
- est_years: {1, 2, 3}
预测周期(年)
Examples
# 获取预测一年的平均每股收益 wind.get_consensus_data('eps_avg', 1)
-
get_data
(table: str, field: str, index: str = None, columns: str = None) → pandas.core.frame.DataFrame[源代码]¶ 获取万得交易数据
Parameters: - table: str
数据库中数据表的名称
- field: str
要查询的字段名
- index: str
要作为行的字段名,默认为trade_dt
- column: str
要作为列的字段名,默认为s_info_windcode
Examples
wind.get_data("AShareEODPrices", "s_dq_pctchange")
-
get_index_weight
(table: str, s_info_windcode: str) → pandas.core.frame.DataFrame[源代码]¶ 从指定的表中获得指数权重
Parameters: - table
要取权重的数据表,例如AIndexHS300FreeWeight
- s_info_windcode
要取权重的指数的万得代码,中证500为000905.SH,沪深300为399300.SZ。
Examples
# 获取中证500指数的免费权重 wind.get_index_weight("AIndexHS300FreeWeight", "000905.SH")
-
get_stock_industries
(table: str, level: int = 1) → pandas.core.frame.DataFrame[源代码]¶ 从指定的表中获取股票行业表
Parameters: - table: str
AShareIndustriesClass 中国A股行业分类
AShareSECNIndustriesClass 中国A股证监会新版行业分类
AShareSECIndustriesClass 中国A股证监会行业分类
AShareIndustriesClassCITICS 中国A股中信行业分类
- level: {1, 2, 3}
行业等级
Examples
# 获取中国A股中信行业分类 (一级分类) wind.get_stock_industries("AShareIndustriesClassCITICS", 1)
-
get_stock_st
() → pandas.core.frame.DataFrame[源代码]¶ This method is deprecated in favor of arrange_entry_table. Use wind.arrange_entry_table(‘AShareST’).fillna(False)
-
get_table
(table_name: str, columns: Union[List[str], str] = None, format='table') → pandas.core.frame.DataFrame[源代码]¶ 万得数据库原始表
Parameters: - table_name: str
数据库中数据表的名称
- columns: List[str], 可选
要查询的数据字段,如果为None则查询所有字段
Returns: - pd.DataFrame
Examples
wind.get_table("AShareEODPrices", ["s_info_windcode", "trade_dt", "s_dq_adjclose", "s_dq_adjopen"])
-