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.
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.
get_fx_price function.requests and aiohttp for optimal performance.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)
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())
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.The SDK supports a wide range of currencies and economic metrics:
| Category | Metric | USD | EUR | AUD | GBP |
|---|---|---|---|---|---|
| Economy | GDP Growth | ✓ | ✓ | ✓ | ✓ |
| Inflation Rate | ✓ | ✓ | ✓ | ✓ | |
| Trade Balance | ✓ | ✓ | ✓ | ✓ | |
| Current Account Balance | ✓ | ✓ | ✓ | ✓ | |
| Labor Market | Unemployment Rate | ✓ | ✓ | ✓ | ✓ |
| Employment Level | ✓ | — | ✓ | ✓ | |
| Monetary Policy | Policy Rate | ✓ | ✓ | ✓ | ✓ |
No comments yet.
Sign in to be the first to comment.