历史专业财务数据 pytdx.crawler
参考
issue from @datochan https://github.com/rainx/pytdx/issues/133
财务指标的名称含义,参考 issue #163 https://github.com/QUANTAXIS/QUANTAXIS/blob/master/QUANTAXIS/QAData/financial_mean.py
pytdx.crawler
crawler 其实本来想叫做downloader或者fetcher, 专门来处理 http 协议的数据的下载和解析,分为两个阶段,下载阶段我们会使用 urllib 来下载数据,数据可以下载到临时文件(不传入path_to_download参数)或者下载到指定的位置(提供path_to_download参数),也支持指定 chunk 的分段下载进度的提示(使用reporthook传入处理函数), 下面是一个 reporthook 函数的例子
def demo_reporthook(downloaded, total_size):
print("Downloaded {}, Total is {}".format(downloaded, total_size))获取历史专业财务数据列表 pytdx.crawler.HistoryFinancialListCrawler
实现了历史财务数据列表的读取,使用方式
from pytdx.crawler.history_financial_crawler import HistoryFinancialListCrawler
crawler = HistoryFinancialListCrawler()
list_data = crawler.fetch_and_parse()
print(pd.DataFrame(data=list_data))结果
其中,filename 字段为具体的财务数据文件地址, 后面的分别是哈希值和文件大小,在同步到本地时,可以作为是否需要更新本地数据的参考
获取历史专业财务数据内容 pytdx.crawler.HistoryFinancialCrawler
获取历史专业财务数据内容
使用上面返回的filename字段作为参数即可
通过 reader 读取数据
如果您自己管理文件的下载或者本地已经有对应的数据文件,可以使用我们的 HistoryFinancialReader来读取本地数据,使用方法和其它的 Reader 是类似的, 我们的 reader 同时支持.zip和解压后的.dat文件
通过命令行工具hq_reader读取并保存到 csv 文件
hq_reader读取并保存到 csv 文件Last updated
Was this helpful?