Skip to main content

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.

Metadata

Release files for marketquery 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marketquery 0.1.0
File Size Uploaded
marketquery-0.1.0.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for marketquery 0.1.0
File Interpreter ABI Platform
marketquery-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.9 kB

Release files / marketquery-0.1.0.tar.gz

Download URL marketquery-0.1.0.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4ed4513896ce3ff65ea1debf5f97aafcad033e196bfb6e0fa0d8375fba20312f
BLAKE2b-256 checksum
How to use checksums
bdd614b1d0c709ba17249cbc986a9d9d1f77b4194c9ed40548e9a2f05a4efe49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / marketquery-0.1.0-py3-none-any.whl

Download URL marketquery-0.1.0-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a98a1df2aa771ec58e2bc0f8d87dd2ef334321f99fc52bd37c1f583156bfd472
BLAKE2b-256 checksum
How to use checksums
e0db86a13896d16e0bfd11abcce9ef020ef058be5e37c02cc3c85f5e6ca9e942
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page