This framework is designed to scrape quarterly 13F-HR filings for fund managers from the website 13f.info. It processes the filings to infer stock transaction types (buy, sell, or hold) based on changes in shares between consecutive quarters. The system generates a final CSV that summarizes the data, including the inferred transaction type, stock symbols, shares, value, and more.
- Scrapes Fund Manager Data: Fetches data on fund managers from the 13f.info website.
- Processes Filings: Scrapes and processes quarterly 13F-HR filings, comparing share changes between quarters.
- Infers Transaction Types: Based on share changes (buy, sell, or hold).
- Generates CSV: Outputs the processed data as a structured CSV file with the required columns.
The project is structured as a Python package with the following components:
src/: Contains core logic, including data processing and transaction inference.sdk/: The main client interface for interacting with the scraper functionality.data_cleaning/: Contains logic for cleaning and saving scraped data.tests/: Unit tests for the various modules of the framework.common/: Utilities like logging.
-
Python 3.7 or above
-
The following Python libraries:
requestsbeautifulsoup4seleniumwebdriver-managerpandas
-
Clone the repository:
git clone https://github.com/mutugid/scrape-data-project.git cd scrape-data-project -
Install dependencies:
Use a virtual environment to manage dependencies:
python -m venv gomans source gomans/bin/activate #Windows .\gomans\Scripts\activate # use setup.py pip install .
-
Running the scraper, data fetching and cleaning:
To scrape data, simply run:
python main.py
You can customize certain parts of the scraping process by editing the scraper.py file located in the src/client/ directory.
The base URL for scraping fund managers is set to https://13f.info.
The project uses Python’s built-in logging module. Logs appear in the console by default; adjust settings in src/common/logging.py to log elsewhere or change levels.
The DataProcessor class (src/core/data_processor.py) calculates share changes and percentage changes for each stock between quarters.
The TransactionInference class (src/core/transaction_inference.py) infers “buy”, “sell”, or “hold” based on those share changes.
The final CSV contains:
fund_namefiling_datequarterstock_symbolcl(stock class, e.g.,COM)value_($000)shareschangepct_changeinferred_transaction_type(buy,sell,hold)
- Web Scraping Service
- Data Comparison & Inference Service
- Data Storage Service
- CSV Export Service
- Logging & Monitoring Service
The scraper retries failed pages (up to 3 times) and logs detailed errors for debugging.
Run unit tests with:
pytest tests/Build and run with Docker:
docker build -t scrape-data-project .
docker run -it scrape-data-projectGitHub Actions pipeline (.github/workflows/ci.yml) includes:
flake8lintingmypytype checkingpytesttest runs
MIT License
Feel free to open issues and submit pull requests!
- Uses BeautifulSoup for HTML parsing
- Uses Selenium for dynamic content
- Thanks to the open-source community for their contributions