Skip to main content

Python client for the FXMacroData API, providing forex macroeconomic data for traders, quants, and analysts.

Project description

FXMacroData Python SDK ๐Ÿ๐Ÿ“Š

PyPI Version Python Versions License Build

The FXMacroData Python SDK provides a simple and efficient interface for fetching macroeconomic indicators, forex prices, release calendars, COT positioning, and commodity prices from FXMacroData.

It includes both synchronous and asynchronous clients, supports free USD endpoints, and offers a free Forex Price API for exchange rate data.


๐ŸŒŸ Features

  • Fetch:
    • Macroeconomic indicators โ€” policy rates, inflation, GDP, unemployment, bond yields, and 100+ more
    • FX spot rates with optional technical indicators (SMA, RSI, MACD, Bollinger Bands)
    • Release calendars โ€” upcoming economic data release dates
    • Data catalogue โ€” discover available indicators per currency
    • COT data โ€” CFTC Commitment of Traders positioning
    • Commodity prices โ€” gold, silver, platinum
  • Free access to USD macro data.
  • Free Forex Price API (get_fx_price).
  • API key required only for non-USD indicators.
  • Full support for:
    • Synchronous client
    • Asynchronous client
  • Lightweight: depends only on requests and aiohttp.

๐Ÿ“ฆ Installation

Install from PyPI:

pip install fxmacrodata

Or install the latest version from GitHub:

pip install git+https://github.com/fxmacrodata/fxmacrodata.git

๐Ÿ”ง Usage

Synchronous

from fxmacrodata import Client

client = Client(api_key="YOUR_API_KEY")

# Fetch macroeconomic indicators
data = client.get_indicator(
    "aud", "policy_rate",
    start_date="2023-01-01",
    end_date="2023-11-01"
)
print(data)

# Free Forex Price Endpoint
fx = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
print(fx)

# Forex with technical indicators
fx = client.get_fx_price("eur", "usd", indicators="sma_20,rsi_14,macd")
print(fx)

# Release calendar
calendar = client.get_calendar("usd")
print(calendar)

# Data catalogue โ€” discover available indicators
catalogue = client.get_data_catalogue("usd")
print(catalogue)

# COT positioning data
cot = client.get_cot("eur", start_date="2025-01-01")
print(cot)

# Commodity prices
gold = client.get_commodities("gold", start_date="2026-01-01")
print(gold)

Asynchronous

import asyncio
from fxmacrodata import AsyncClient

async def main():
    async with AsyncClient(api_key="YOUR_API_KEY") as client:
        # Fetch macroeconomic indicators
        data = await client.get_indicator("eur", "inflation")
        print(data)

        # Free Forex Price Endpoint
        fx = await client.get_fx_price("usd", "jpy")
        print(fx)

        # Release calendar
        calendar = await client.get_calendar("usd")
        print(calendar)

        # Data catalogue
        catalogue = await client.get_data_catalogue("usd")
        print(catalogue)

        # COT positioning
        cot = await client.get_cot("jpy")
        print(cot)

        # Commodity prices
        gold = await client.get_commodities("gold")
        print(gold)

asyncio.run(main())

๐Ÿ“˜ API Overview

get_indicator(currency, indicator, start_date=None, end_date=None)

Fetches macroeconomic indicator time series data.

  • currency: "usd", "aud", "eur", "gbp", "cad", "nok", "nzd", "jpy", "brl", "cny", "dkk", "pln", "sek", "sgd", etc.
  • indicator: "policy_rate", "inflation", "gdp", "unemployment", "trade_balance", "current_account_balance", "gov_bond_10y", etc.
  • API key required for non-USD.

get_fx_price(base, quote, start_date=None, end_date=None, indicators=None)

Fetches daily FX spot rates (ECB reference rates) between two currencies.

  • indicators: Optional comma-separated technical indicators โ€” "sma_20", "sma_50", "sma_200", "rsi_14", "macd", "ema_12", "ema_26", "bollinger_bands", or "all".
  • No API key needed.

get_calendar(currency, indicator=None)

Fetches upcoming economic data release dates for a currency.

  • indicator: Optional filter to a specific indicator slug.
  • Returns announcement_datetime (Unix timestamp) and release (indicator slug).

get_data_catalogue(currency, include_capabilities=False, include_coverage=False, indicator=None)

Discovers available macroeconomic indicators for a given currency.

  • Returns a dict keyed by indicator slug with name, unit, frequency, and has_official_forecast.
  • API key required for non-USD.

get_cot(currency, start_date=None, end_date=None)

Fetches CFTC Commitment of Traders (COT) positioning data.

  • Supported currencies: AUD, CAD, CHF, EUR, GBP, JPY, NZD, USD.
  • API key required for non-USD.

get_commodities(indicator, start_date=None, end_date=None)

Fetches commodity price time series.

  • indicator: "gold", "silver", or "platinum".
  • API key required.

๐Ÿ’น Supported Currencies & Indicators

Category Metric USD EUR AUD GBP
Economy GDP Growth โœ“ โœ“ โœ“ โœ“
Inflation Rate โœ“ โœ“ โœ“ โœ“
Trade Balance โœ“ โœ“ โœ“ โœ“
Current Account Balance โœ“ โœ“ โœ“ โœ“
Labor Market Unemployment Rate โœ“ โœ“ โœ“ โœ“
Employment Level โœ“ โ€” โœ“ โœ“
Full-Time Employment โœ“ โ€” โœ“ โ€”
Part-Time Employment โœ“ โ€” โœ“ โ€”
Participation Rate โœ“ โ€” โœ“ โœ“
Non-Farm Payrolls โœ“ โ€” โ€” โ€”
Monetary Policy Policy Rate โœ“ โœ“ โœ“ โœ“
Interbank Rate โœ“ โœ“ โœ“ โœ“
Government Bond Yields 2-Year Govt Bond โœ“ โœ“ โœ“ โ€”
3-Year Govt Bond โœ“ โœ“ โœ“ โ€”
5-Year Govt Bond โœ“ โœ“ โœ“ โœ“
10-Year Govt Bond โœ“ โœ“ โœ“ โœ“
Inflation-Linked Bond โœ“ โ€” โœ“ โœ“

๐Ÿ“„ License

MIT License ยฉ FXMacroData


๐ŸŒ Links

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

fxmacrodata-1.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

fxmacrodata-1.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file fxmacrodata-1.1.0.tar.gz.

File metadata

  • Download URL: fxmacrodata-1.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for fxmacrodata-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6fc3fa5a08e3d151986f869370881a3e8492fa8977baba32f45990b55f278ae0
MD5 7138315d3f456075994e5bb11416952a
BLAKE2b-256 cae976d7fc12fb7a8e81c53defaada63e2c6354e2bdf70938251a9dce2531afa

See more details on using hashes here.

File details

Details for the file fxmacrodata-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: fxmacrodata-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for fxmacrodata-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1826810f1268fecea1c765e40df4b910d94dbc7b398a930ac8366390215a14c5
MD5 52b1c7d924d77a66d4757136b6213fca
BLAKE2b-256 c8f8f4a4ccf9d9b3bbcb02c3d03a3d2b786b96e682c93525d1c891825f39ffa6

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