Skip to main content

A unified interface for market data APIs

Project description

MarketQuery

A unified interface for market data APIs, providing a simple way to download historical market data from multiple providers.

Features

  • Support for multiple data providers:
    • Yahoo Finance (default)
    • Stooq
    • Tiingo
    • Alpha Vantage
    • Polygon.io
  • Built-in caching system
  • Consistent data format across providers
  • Easy-to-use interface
  • Support for multiple tickers
  • Progress bars for long downloads

Installation

pip install marketquery

Quick Start

import marketquery as mq

# Download data for a single ticker
data = mq.download('AAPL', start='2024-01-01', end='2024-01-31')

# Download data for multiple tickers
data = mq.download(['AAPL', 'GOOGL', 'MSFT'], start='2024-01-01', end='2024-01-31')

# Use a different provider
data = mq.download('AAPL', provider='tiingo', api_key='your_api_key')

Environment Variables

MarketQuery supports configuration through environment variables. To use them:

  1. Create a .env file in your project directory:
# Set default provider
MARKETQUERY_DEFAULT_PROVIDER=tiingo

# API keys for different providers
TIINGO_API_KEY=your_tiingo_api_key
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key
ALPHA_VANTAGE_PREMIUM_API_KEY=your_alpha_vantage_premium_api_key
  1. Load the environment variables in your code:
from dotenv import load_dotenv
load_dotenv()  # Load environment variables from .env file

import marketquery as mq
data = mq.download('AAPL')  # Will use settings from .env file

Available environment variables:

  • MARKETQUERY_DEFAULT_PROVIDER: Set default provider (e.g., 'yahoo', 'tiingo', 'alpha_vantage')
  • TIINGO_API_KEY: API key for Tiingo
  • ALPHA_VANTAGE_API_KEY: API key for Alpha Vantage
  • ALPHA_VANTAGE_PREMIUM_API_KEY: Premium API key for Alpha Vantage

Documentation

For detailed documentation, run:

import marketquery as mq
mq.help()

Cache Management

MarketQuery includes a built-in caching system to improve performance and reduce API calls. The cache is stored in your system's cache directory:

  • macOS: ~/Library/Caches/marketquery
  • Linux: ~/.cache/marketquery
  • Windows: %LOCALAPPDATA%\marketquery\Cache

You can control caching behavior with the following parameters:

  • load=True/False: Enable/disable loading from cache
  • save=True/False: Enable/disable saving to cache
  • cache_dir: Specify a custom cache directory

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

marketquery-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

marketquery-0.1.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file marketquery-0.1.0.tar.gz.

File metadata

  • Download URL: marketquery-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for marketquery-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ed4513896ce3ff65ea1debf5f97aafcad033e196bfb6e0fa0d8375fba20312f
MD5 8d89270c3f919dc062b15872ca5a2b7d
BLAKE2b-256 bdd614b1d0c709ba17249cbc986a9d9d1f77b4194c9ed40548e9a2f05a4efe49

See more details on using hashes here.

File details

Details for the file marketquery-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: marketquery-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for marketquery-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a98a1df2aa771ec58e2bc0f8d87dd2ef334321f99fc52bd37c1f583156bfd472
MD5 f3547eff482af0c5f78f0fa0f9fa572c
BLAKE2b-256 e0db86a13896d16e0bfd11abcce9ef020ef058be5e37c02cc3c85f5e6ca9e942

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