Skip to main content

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, and aiohttp.
    • These libraries will be automatically installed when you install the package.

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 is Site.FOREXFACTORY.
    • Options:
      • Site.FOREXFACTORY
      • Site.METALSMINE
      • Site.ENERGYEXCH
      • Site.CRYPTOCRAFT
  • 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 is False.

Return Values

  • When extended=False: Returns a pandas.DataFrame containing basic event data.
  • When extended=True: Returns a ScrapeResult object 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.FOREXFACTORY
  • Site.METALSMINE
  • Site.ENERGYEXCH
  • Site.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

market_calendar_tool-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

market_calendar_tool-0.1.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

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

Hashes for market_calendar_tool-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d3cfe9ddd98405d725e8d8e5030861f9ac07d295fa8399ed7424226e663e5c73
MD5 138150d44685fb19f54ac0492c67d5e2
BLAKE2b-256 731b6b5c80edc2409c3aa1c26d8560e51eb116f4ec18b6fb8b6f48807d5c37f4

See more details on using hashes here.

File details

Details for the file market_calendar_tool-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for market_calendar_tool-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e685bc7a1c0dd71a73336630e1f4e8861c1f075ee6e6232629f59b17e7438b45
MD5 c80c14dcb5fd850c60b37cec2e46e4ef
BLAKE2b-256 43c04de498673756400aff1b1acb196cdec56dbe0d738f0fd48932181c67e204

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page