Skip to main content

A Python client for the marketdata.app API

Project description

MarketData API Client

This Python module provides a client for interacting with the marketdata.app API. It offers both synchronous and asynchronous methods to fetch various financial data, including stock candles, options chains, and options quotes.

Features

  • Synchronous and asynchronous API clients
  • Caching mechanism for efficient data retrieval
  • Parallel processing for bulk data requests
  • Support for various API endpoints:
    • Stock candles
    • Options chains
    • Options quotes
    • Index candles and quotes
    • Market status
    • Earnings data
    • Stock news

Configuration

Create a file named marketdata_api.key in the credentials directory and add your MarketData API key to it.

Usage

Basic Usage

from marketdata.manager import MarketDataManager
from datetime import date

mdm = MarketDataManager()

# Fetch stock candles
candles = mdm.get_stock_candles(["AAPL", "GOOGL"], "1D", from_date=date(2023, 1, 1), to_date=date(2023, 6, 1))

# Print the results
for symbol, df in candles.items():
    print(f"Candles for {symbol}:")
    print(df.head())
    print("\n")

Fetching Options Data

from marketdata.client_params import OptionsChainParams, OptionsQuoteParams

# Fetch options chains
chain_params = [
    OptionsChainParams(underlying="AAPL"),
    OptionsChainParams(underlying="GOOGL")
]
chains = mdm.get_options_chains(chain_params)

# Fetch options quotes
quote_params = [
    OptionsQuoteParams(option_symbol="AAPL230616C00150000"),
    OptionsQuoteParams(option_symbol="GOOGL230616P02000000")
]
quotes = mdm.get_options_quotes(quote_params)

Using BasicParams and FromToParams

The BasicParams and FromToParams classes are used to provide common parameters for API requests:

from marketdata.client_params import BasicParams, FromToParams
from datetime import date

# Basic parameters
basic_params = BasicParams(
    lookup_date=date(2023, 6, 1),
    dateformat="timestamp",
    limit=1000
)

# Date range parameters
from_to_params = FromToParams(
    from_date=date(2023, 1, 1),
    to_date=date(2023, 6, 1)
)

# Use these params in API calls
candles = mdm.get_stock_candles(
    ["AAPL"],
    "1D",
    basic_params=basic_params,
    from_to_params=from_to_params
)

BasicParams includes common options like date format and result limits, while FromToParams specifies date ranges for historical data queries.

Caching

The module implements caching to reduce API calls and improve performance. Cached data is stored in the ./data/cache directory.

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

marketdata_py-0.0.3.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

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

marketdata_py-0.0.3-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file marketdata_py-0.0.3.tar.gz.

File metadata

  • Download URL: marketdata_py-0.0.3.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for marketdata_py-0.0.3.tar.gz
Algorithm Hash digest
SHA256 44d99ef0efc8db4834d25807f674b09707bafd0b3886f3da84c4e70e4e9ddb6f
MD5 41d78bbf042410389b93162d98a602c6
BLAKE2b-256 193929217abe0d4b7b2478cafea2cc4c5bf22d504ef0ff753891f050bfac6a75

See more details on using hashes here.

File details

Details for the file marketdata_py-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: marketdata_py-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for marketdata_py-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5c8305ee89bf671939c33fd1ef62a2e3c45606fb707f82f6335da93b64fc9bdb
MD5 aac8c78679efa751431474af69dde2aa
BLAKE2b-256 de6cb077258dd15545ab41faf3197b06fbeb10e0d05d883f5c3b2fe27dc9dc55

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