PitchHut logo
FXMacroData Python SDK
Effortlessly access forex macroeconomic data with Python.
Pitch

The FXMacroData Python SDK offers traders, quants, and analysts a powerful yet straightforward way to access macroeconomic indicators and forex price history directly from the FXMacroData API. With both synchronous and asynchronous support, it simplifies the retrieval of essential financial data.

Description

FXMacroData Python SDK

The FXMacroData Python SDK is designed for traders, quantitative analysts, and data enthusiasts seeking straightforward access to macroeconomic indicators and foreign exchange price history through the FXMacroData API. This SDK offers both synchronous and asynchronous client support, empowering users to fetch necessary economic data efficiently.

Key Features

  • Retrieve a variety of macroeconomic indicators including:
    • Policy Rates
    • Inflation & CPI
    • GDP
    • Unemployment
    • Balance of Trade
    • Government Bond Yields
  • Free USD macro data available.
  • Access a complimentary Forex Price API for exchange rate data with the get_fx_price function.
  • API key required only for retrieving non-USD indicators.
  • Lightweight dependencies: Only uses requests and aiohttp for optimal performance.

Usage Examples

Synchronous Client

To use the synchronous client, the following example demonstrates fetching economic indicators and forex prices:

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 Client

For non-blocking operations, use the asynchronous client:

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 time series data for various macroeconomic indicators. Requires an API key for non-USD queries.
  • get_fx_price(base, quote, start_date=None, end_date=None): Retrieves historical foreign exchange prices between two currencies without an API key for USD-based requests.

Supported Currencies & Indicators

The SDK supports a wide range of currencies and economic metrics:

CategoryMetricUSDEURAUDGBP
EconomyGDP Growth
Inflation Rate
Trade Balance
Current Account Balance
Labor MarketUnemployment Rate
Employment Level
Monetary PolicyPolicy Rate

Useful Links

0 comments

No comments yet.

Sign in to be the first to comment.