Skip to main content

FXMacroData for Prefect

Bring your FXMacroData subscription into scheduled Prefect research workflows: cross-currency indicators, complete available histories, FX reference rates, commodities, positioning and release analysis. Store your API key in a Prefect Credentials Block and pass its name to native tasks.

Subscribe to FXMacroData for subscriber coverage and deeper available history. Public USD catalogue, recent indicator history and calendar access let you evaluate the workflow before subscribing without an API key. Availability varies by dataset.

Install and connect

Use Python 3.10���3.14 and Prefect 3.9.1 or later within version 3. From the release artifacts directory, install the adapter wheel into the environment that runs your flows. Its pinned FXMacroData public client is available on PyPI and resolves automatically:

python -m pip install ./prefect_fxmacrodata-0.1.0-py3-none-any.whl
prefect block register -m prefect_fxmacrodata

The adapter uses the supplied release artifact; its public-client dependency comes from PyPI. Configure your Prefect server or Cloud workspace through Prefect's normal setup. In Blocks, create an FXMacroData Credentials block, enter your subscription API key and save it as fxmacrodata-research. The key uses Prefect's secret-field storage. The timeout controls each HTTP request, in seconds.

To create the same block interactively without putting a key in source code:

from getpass import getpass
from pydantic import SecretStr
from prefect_fxmacrodata import FXMacroDataCredentials

FXMacroDataCredentials(
    api_key=SecretStr(getpass("FXMacroData API key: ")),
).save("fxmacrodata-research")

Create the block during setup, outside a flow. Flows and tasks take only its name; do not put keys in flow parameters, operation arguments or logs. Omitting credentials_block explicitly uses public evaluation access, even if an API-key environment variable is set.

Build a research flow

macro_snapshot is a Prefect subflow that collects every available history page for the selected series and retrieves its release calendar. Pass the typed snapshot to your own downstream task:

import asyncio
from prefect import flow, task
from prefect_fxmacrodata import MacroSnapshot, macro_snapshot


@task(persist_result=False)
def count_observations(snapshot: MacroSnapshot) -> int:
    return len(snapshot.history.records())


@flow(persist_result=False)
async def research_run():
    snapshot = await macro_snapshot(
        "EUR",
        "policy_rate",
        credentials_block="fxmacrodata-research",
        start_date="2020-01-01",
        end_date="2026-01-01",
    )
    return count_observations(snapshot)


if __name__ == "__main__":
    asyncio.run(research_run())

To evaluate with USD, omit the credentials and historical date range:

snapshot = await macro_snapshot("USD", "policy_rate")

Subscriber history can extend beyond the public evaluation window where the series supports it. Deploy or schedule this flow with your normal Prefect work pool and deployment process. The date filters select indicator history. The calendar uses the API's current release-calendar window for the currency; it is not filtered to the historical range or one indicator. Use the release_calendar task directly for different calendar filters.

Use individual operations

Every packaged operation is a named Prefect task, with normal task states, dependencies, with_options, retries and scheduling through its enclosing flow. Both REST and hosted MCP operations are available:

from prefect_fxmacrodata import operation_schemas
from prefect_fxmacrodata.tasks import indicator_history, mcp_macro_briefing_task


async def inspect_series():
    page = await indicator_history(
        {"currency": "GBP", "indicator": "inflation", "limit": 100},
        credentials_block="fxmacrodata-research",
    )
    briefing = await mcp_macro_briefing_task(
        {"currency": "GBP"},
        credentials_block="fxmacrodata-research",
    )
    return page, briefing


schemas = {operation.name: operation.input_schema for operation in operation_schemas()}

See CAPABILITIES.md for the exact operation inventory. The original input schemas are available through operation_schemas() or the native discover_operations task. OPERATION_TASKS[name] supports configuration-driven flows without losing operation-specific task names.

Results are FXMacroDataResult models. payload retains the entire service response, including original units, provenance, unavailable values and MCP content; source_url records the source endpoint. records() adds a convenient row view without replacing the payload. No publication timestamps or missing observations are inferred.

History and failure behavior

Individual operation tasks return a single response using the API's pagination rules. Use complete_history("indicator_history", arguments, credentials_block) for a complete available dataset within the requested filters. It starts at offset zero, verifies contiguous pages and dataset versions when supplied, and fails if completion cannot be established. Its payload retains every page's metadata and returns rows in chronological order. max_pages is an explicit safety budget; an error never passes an incomplete history off as complete. Applications that need resumable storage can persist individual page responses and control offset and dataset_version through the named operation tasks.

Event streaming is a bounded capture using max_events and max_seconds. The response retains the original completion flag and reason. Cancellation finishes the current bounded HTTP request, closes the client, and stops before the next history page. MCP sessions are closed after each task.

Tasks disable result persistence and caching by default. Opt in only when the destination and access controls suit your data licence. Task errors omit raw responses, authenticated URLs and credentials. Transient retries are opt-in with Prefect's with_options(retries=..., retry_delay_seconds=...).

FXMacroData API reference describes access requirements and supported arguments for each dataset.

Metadata

Release files for prefect-fxmacrodata 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prefect-fxmacrodata 0.1.0
File Size Uploaded Provenance Actions
prefect_fxmacrodata-0.1.0.tar.gz 17.8 kB Without provenance Details for prefect_fxmacrodata-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prefect-fxmacrodata 0.1.0
File Interpreter ABI Platform Actions
prefect_fxmacrodata-0.1.0-py3-none-any.whl Python 3 none any Details for prefect_fxmacrodata-0.1.0-py3-none-any.whl

Total release size: 29.4 kB

Release files / prefect_fxmacrodata-0.1.0.tar.gz

Download URL prefect_fxmacrodata-0.1.0.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
89764f02c2b4bcef19a4191253e4ede92064eca19b98ba7ef31254bdd7d9682e
BLAKE2b-256 checksum
How to use checksums
436a354ab1c25878d32cb3f384fc6de3b5563f4f2ffdfff9ba94e86e60ee299d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via FXMacroData-PackagePublisher/1.0

Release files / prefect_fxmacrodata-0.1.0-py3-none-any.whl

Download URL prefect_fxmacrodata-0.1.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e2c14a898984bbe2aeb6f437766ecdf7ce7bb1e907dc7f0025fe1a436bf4ebf
BLAKE2b-256 checksum
How to use checksums
4a3bd4f5ba1c483578e54daad23d8ed5a8ebc4067f8321d9933a71429394c352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via FXMacroData-PackagePublisher/1.0

Security for prefect-fxmacrodata 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page