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.3.tar.gz (6.1 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.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file market_calendar_tool-0.1.3.tar.gz.

File metadata

  • Download URL: market_calendar_tool-0.1.3.tar.gz
  • Upload date:
  • Size: 6.1 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.3.tar.gz
Algorithm Hash digest
SHA256 a6a3fc3bd8ce449bce5d0a4fa66672bbeadb72fe1b31f9dd8bc245c5fe17e88a
MD5 560e20d254bc73659b9304039e2d22bb
BLAKE2b-256 5594502208b149168dc74b6f60b26cda09fa8cb63619fbbeef895d2b64789358

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for market_calendar_tool-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8e96d56d2dbd2cc08743834eb42e2683cfa0d89fb9b4511d9001851b69067565
MD5 c1abe9850ad108ed225ced72aeb199a0
BLAKE2b-256 bb9f65b2ebc288d1ae7ac20ff67933398f493af15c71b2fd0378266dc7182d03

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