Python scraper for SEC N-MFP2 filings.
Project description
SEC N-MFP2 Money Market Fund Holdings Data
- Author: Yangjue Han
- Date: May 2020
Introduction
This repository contains code that enables the user to parse and download money market fund holdings information in N-MFP2 filings from SEC EDGAR system. At the end of every month, all U.S. money market funds are required to report their securities holdings to SEC, including identification, maturity, market value, yield to maturity, issuer information, and other features. For repurchase agreement contracts, money market funds also have to report information on collateral securities. The granularity of this dataset provides an unparallel opportunity for financial economists to study questions related to the shadow banking system.
Installation
pip install secmmf
Usage
Initial setup
The module secmmf contains a set of functions that parse and download the information in N-MFP2 filings. The user should first specify the path of a directory to store the downloaded data to data_dir and the storage of data_dir should be at least 20GBs. Note that the package can only be used to download N-MFP2 filings, but could be extended to download other filings with a similar format. The package does not provide any data cleaning function.
import secmmf
data_dir = ## YOUR DIRECTORY HERE ##
pathfile = 'xmlpath.csv' # no need to change this
Build index of filings
First we download and extract the paths of filings from SEC EDGAR system using method download_sec_index().
- By specifying
start_dateandend_date, the user will limit the time range to [start_date,end_date]. The default start date is 2016-10 and end date is the current month. - The method will output a csv file named
index_file.csvindata_dir. We then usegenerate_index()to create a file of urls linked to XML files that can be easily parsed, namedpathfile.
secmmf.download_sec_index(data_dir, form_name = 'N-MFP2', start_date = '2016-10', end_date = '2020-05')
generate_index(data_dir, pathfile)
Download raw files
Next, we download XML files from pathfile and parse them into un-modified csv files using scrape().
- Depending on the number of files to download and internet connection, this step might take up to 4 hours.
- Paths contained in
pathfileare divided into 20 blocks and the corresponding csv files will be saved into 20 different subfolders. - If the program is interrupted at any block, the user can specify
start_blockorend_blockto modify the exact portion of files to download.
scrape(data_dir, pathfile, N_blocks=20, start_block=1, end_block=20)
Generate fund-level and holdings-level tables
Raw csv files contain unstructure data that combine both fund-level information and asset holdings. We can use gen_table_fund() and gen_table_holdings() to generate tables with ready-to-use data on fund-level information and asset holdings. Finally, wrap() method combines all formatted tables into a single table for each level of information and clean up the data folder.
gen_table_fund(data_dir, pathfile)
gen_table_holdings(data_dir, pathfile)
wrap(data_dir)
# Done!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secmmf-1.0.2.tar.gz.
File metadata
- Download URL: secmmf-1.0.2.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.45.0 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d35e77972a85408401992f25addd17a024a14b452b574266411b3a9a66761b6
|
|
| MD5 |
867f520b5b3a27b90e574703b392a03c
|
|
| BLAKE2b-256 |
c361fa2bf0bd7b3ca954d27087ab38e9137e100e262b2ded69d1f542fbb05789
|
File details
Details for the file secmmf-1.0.2-py3-none-any.whl.
File metadata
- Download URL: secmmf-1.0.2-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.45.0 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0028ff88cfa56c1a7b55f1f52e35af5c900b14262b1c030c8d3468b67d2fbdf6
|
|
| MD5 |
41cec33fbed5cbb1f40e38416283671d
|
|
| BLAKE2b-256 |
4d6635ad262bbb65db898d4bc8225d2e32b09109d7f5523a0dccea001cdf4066
|