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 and forex price history 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:
    • Policy Rates
    • Inflation & CPI
    • GDP
    • Unemployment
    • Balance of Trade
    • Government Bond Yields
  • 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)

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", "cpi")
        print(data)

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

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", etc.
  • indicator: "policy_rate", "cpi", "inflation", "gdp", "unemployment", "trade_balance", "current_account", etc.
  • API key required for non-USD.

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

Fetches historical FX prices between two currencies. No API key needed for USD-based queries.


๐Ÿ’น 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.0.0.tar.gz (5.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.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fxmacrodata-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6227516c93a06501a6c807a2b739c38bbee9c966a2ca6ff8c7a1ed31d6be42ac
MD5 777ce899297ec0ab550a138950774d85
BLAKE2b-256 464919acfe1a48a99322dccfc42ffa960c9bd1aa5b9f1ade9cc4ecf0e78f47ba

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fxmacrodata-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e29fd8896ed37c12eaff4ae2ed2e969f0948fd88f5a00e843aad7da45634f8d
MD5 bf1db1134ba4b56e1d92699431a656d8
BLAKE2b-256 e12cdb42135e300fe588254f6d17055cdb30e9bea29eeb24cf8ac89e8b43a2cf

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