如何通过SEC API高效获取罗素3000成分股的10-K文件?
问题:如何高效获取罗素3000指数成分股的2020年10-K文件?
我尝试用以下代码通过SEC API直接按指数代码RUA(罗素3000)筛选10-K文件,但不确定是否可行:
from sec_api import QueryApi query_api = QueryApi(api_key='YOUR_API_KEY') # 定义搜索参数 index_ticker = 'RUA' # 罗素3000指数代码 filing_type = '10-K' start_date = '2020-01-01' end_date = '2020-12-31' # 构建查询语句 query = { 'query': { 'bool': { 'must': [ {'match': {'indexTic': index_ticker}}, {'match': {'formType': filing_type}}, {'range': {'filedAt': {'gte': start_date, 'lte': end_date}}} ] } }, 'size': 10 } # 发送查询并获取结果 results = query_api.get_filings(query)
查看SEC API的响应格式后,我没找到与指数相关的字段,因此怀疑上述代码无法生效。目前想到的替代方案是:
- 获取罗素3000指数的成分股列表
- 逐个遍历成分股,用以下代码单独获取每个股票的10-K文件:
from sec_api import QueryApi query_api = QueryApi(api_key='YOUR_API_KEY') # 定义搜索参数 ticker = 'AAPL' filing_type = '10-K' start_date = '2020-01-01' end_date = '2020-12-31' # 构建查询语句 query = { 'query': { 'bool': { 'must': [ {'match': {'ticker': ticker}}, {'match': {'formType': filing_type}}, {'range': {'filedAt': {'gte': start_date, 'lte': end_date}}} ] } }, 'size': 10 } # 发送查询并获取结果 results = query_api.get_filings(query)
但这个逐个查询的方案效率很低,有没有更高效的解决办法?
内容的提问来源于stack exchange,提问作者Ayodele Ashad
相关产品推荐
相关产品推荐

