Market Calendar Tool is a Python package that scrapes economic calendar data from multiple financial websites and returns it as pandas DataFrames for easy analysis.
Project description
Market Calendar Tool
A Python package for scraping economic calendar data from various financial websites.
Legal notice
Please note that scraping data from websites must comply with the site's terms of service and legal requirements. The robots.txt files of the supported sites do not explicitly restrict scraping, but users should ensure they comply with local regulations and the website's terms.
Features
-
Multi-Site Support: Scrape data from multiple sites:
-
Flexible Date Range: Specify custom date ranges for scraping.
-
Extended Data Retrieval: Option to retrieve extended data for each event.
-
Easy-to-Use API: Simple and intuitive function to get you started quickly.
-
DataFrame Output: Returns raw data scraped from the website as pandas DataFrame(s) for further processing.
Installation
Install the package via pip:
pip install market-calendar-tool
Requirements
- Python Version: Python 3.12 or higher is required.
- Dependencies:
- The package relies on several libraries such as
loguru,requests,pandas,asyncio, andaiohttp. - These libraries will be automatically installed when you install the package.
- The package relies on several libraries such as
Usage
Import the package and use the scrape_calendar function.
from market_calendar_tool import scrape_calendar, Site, ScrapeResult
# Basic usage: scrape data from today to one week ahead from ForexFactory
df = scrape_calendar()
# Specify a different site
df = scrape_calendar(site=Site.METALSMINE)
# Specify date range
df = scrape_calendar(date_from="2023-01-01", date_to="2023-01-07")
# Retrieve extended data
result = scrape_calendar(extended=True)
print(result.base) # Basic event data
print(result.specs) # Event specifications
print(result.history) # Historical data
print(result.news) # Related news articles
Parameters
site(optional): The website to scrape data from. Default isSite.FOREXFACTORY.- Options:
Site.FOREXFACTORYSite.METALSMINESite.ENERGYEXCHSite.CRYPTOCRAFT
- Options:
date_from(optional): Start date in "YYYY-MM-DD" format.date_to(optional): End date in "YYYY-MM-DD" format.extended(optional): Boolean flag to retrieve extended data. Default isFalse.
Return Values
- When
extended=False: Returns apandas.DataFramecontaining basic event data. - When
extended=True: Returns aScrapeResultobject with the following attributes:base: DataFrame with basic event data.specs: DataFrame with event specifications.history: DataFrame with historical data.news: DataFrame with related news articles.
API Reference
scrape_calendar
Function to scrape calendar data.
Signature:
def scrape_calendar(
site: Site = Site.FOREXFACTORY,
date_from: Optional[str] = None,
date_to: Optional[str] = None,
extended: bool = False,
) -> Union[pd.DataFrame, ScrapeResult]:
...
Site Enum
Enumeration of supported websites.
Site.FOREXFACTORYSite.METALSMINESite.ENERGYEXCHSite.CRYPTOCRAFT
ScrapeResult Data Class
Contains extended data when extended=True.
base: Basic event data (pd.DataFrame)specs: Event specifications (pd.DataFrame)history: Historical data (pd.DataFrame)news: Related news articles (pd.DataFrame)
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to customize this package to better suit your project's needs!
Project details
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 market_calendar_tool-0.1.2.tar.gz.
File metadata
- Download URL: market_calendar_tool-0.1.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3cfe9ddd98405d725e8d8e5030861f9ac07d295fa8399ed7424226e663e5c73
|
|
| MD5 |
138150d44685fb19f54ac0492c67d5e2
|
|
| BLAKE2b-256 |
731b6b5c80edc2409c3aa1c26d8560e51eb116f4ec18b6fb8b6f48807d5c37f4
|
File details
Details for the file market_calendar_tool-0.1.2-py3-none-any.whl.
File metadata
- Download URL: market_calendar_tool-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e685bc7a1c0dd71a73336630e1f4e8861c1f075ee6e6232629f59b17e7438b45
|
|
| MD5 |
c80c14dcb5fd850c60b37cec2e46e4ef
|
|
| BLAKE2b-256 |
43c04de498673756400aff1b1acb196cdec56dbe0d738f0fd48932181c67e204
|