Fast Trade is an open-source Python backtesting library built around portable strategy definitions, CLI workflows, local market archives, terminal views, and an MCP server. The FXMacroData integration gives that stack a macro-context layer for currency-pair research.
FXMacroDataClient or build_macro_context() from fast_trade.fxmacrodata to fetch pair-level catalogue, calendar, announcement, and forex context before a Fast Trade run. Agents can call the same path through the Fast Trade MCP tool fxmacrodata_macro_context.
The useful pattern is not to call macro APIs from inside every trade decision. Fetch the context once, attach it to the research run, and let the strategy or agent decide how to use it.
Prerequisites
- Use a current Fast Trade checkout or package version that includes
fast_trade.fxmacrodata. - Set
FXMACRODATA_API_KEYorFXMD_API_KEYin the same environment that runs Fast Trade when requesting protected pair, COT, commodity, session, or sentiment data. - Keep the macro context outside the strategy loop so repeated backtests use a stable input snapshot.
Fit
Use this for
Adding macro context to currency-pair backtests, strategy screens, agent prompts, and post-run diagnostics.
Choose Fast Trade when
You want a Python CLI and MCP-enabled research loop where backtests, saved runs, and agent tools share the same project surface.
Avoid
Treating macro context as an automatic buy or sell signal. It is an input for filtering, explaining, or stress-testing strategy output.
Why Fast Trade Works for Macro Context
Fast Trade already treats a strategy as a repeatable research object: data in, strategy rules, output summary, saved artifacts. FXMacroData fits beside that loop by giving the run currency-aware context before the backtest starts.
| Fast Trade piece | FXMacroData role | How to use it |
|---|---|---|
FXMacroDataClient |
Small REST client for macro, FX, COT, commodities, sessions, and sentiment endpoints. | Use it when you want explicit calls from a notebook or script. |
build_macro_context() |
Collects base and quote catalogue, calendar, announcement, and forex payloads for a pair. | Use it as the standard context bundle for EUR/USD, GBP/USD, or another pair. |
fxmacrodata_macro_context |
Exposes the same helper through the Fast Trade MCP server. | Use it when an agent needs macro context before running a screen, inspecting a strategy, or summarizing a backtest. |
Visual Check: Macro Context Flow
Before the strategy runs, build a stable context bundle. The same bundle can be saved with the run, inspected in a notebook, or passed to an agent.
Macro context bundle
Collect context before the Fast Trade run
FXMacroData supplies the macro inputs; Fast Trade keeps the strategy and result artifacts reproducible.
Pair
EUR/USD
Focus
policy_rate
Output
JSON context
Takeaway: macro context should be a declared input to the research run, not a hidden side effect buried inside the trading loop.
Integration Surface Map
Fast Trade exposes FXMacroData in two practical ways: direct Python calls for notebooks and scripts, and an MCP tool for agent workflows.
REST client
Use FXMacroDataClient when your script needs explicit endpoint calls.
Context helper
Use build_macro_context() when the research unit is a currency pair.
MCP tool
Use fxmacrodata_macro_context when an agent needs the same context.
Step 1: Install or Update Fast Trade
Install Fast Trade from PyPI, or use the open-source repository when you want the latest integration files:
pip install fast-trade
For a source checkout:
git clone https://github.com/jrmeier/fast-trade.git
cd fast-trade
python -m venv venv
source venv/bin/activate
pip install -e .
On Windows, activate with venv\Scripts\activate. If you already use Fast Trade in a strategy workspace, update the checkout before using the FXMacroData helper.
Step 2: Build Pair-Level Macro Context
For most pair research, start with build_macro_context(). It asks for a base currency, quote currency, indicator focus, and row limit, then returns a dictionary with the pair's macro and FX context.
For protected currency-pair data such as EUR/USD, set FXMACRODATA_API_KEY or FXMD_API_KEY before running the helper. Fast Trade reads either variable automatically, so the key stays out of notebooks, strategy files, and saved backtest artifacts.
from fast_trade.fxmacrodata import build_macro_context
context = build_macro_context(
base="eur",
quote="usd",
indicator="policy_rate",
limit=10,
)
print(context.keys())
print(context.get("forex", {}).get("data", [])[:2])
The helper is intentionally useful before a strategy run: it can collect the base catalogue, quote catalogue, filtered calendars, recent announcements, and FX data in one context object. Save that object beside the backtest output if the run depends on it.
Use FXMacroDataClient directly inside Fast Trade when you want a narrower call, such as a release calendar check or a COT snapshot.
Step 3: Use the MCP Tool
Fast Trade also exposes the macro-context helper through its MCP server. Start the local server from the same environment that has Fast Trade installed:
python -m fast_trade.mcp_server
An MCP-capable agent can then call fxmacrodata_macro_context with the same arguments:
{
"base": "eur",
"quote": "usd",
"indicator": "policy_rate",
"limit": 10
}
This is useful when an agent is reviewing a saved strategy, comparing a screen result against upcoming macro events, or explaining why a currency-pair backtest behaved differently around policy decisions.
Backtest Guardrails
Macro context can improve a research workflow only if it stays reproducible. Keep the context stable and auditable.
| Guardrail | Reason |
|---|---|
| Fetch context before the run | Repeated parameter tests should use the same macro snapshot. |
| Save the context with results | A reviewer should be able to see which release and FX rows informed the run. |
| Separate alpha from explanation | Macro context can filter or explain strategy output without becoming an untested signal. |
| Use the right currency pair | For cross pairs, build context for both legs rather than assuming USD-only behavior. |
If the strategy depends on exact release timing, pair the context helper with the FXMacroData release calendar and make the blackout or event-window rule explicit. If the strategy depends on daily FX direction, inspect the EUR/USD dashboard or the relevant pair dashboard before encoding the rule.
Common Questions
Can Fast Trade use FXMacroData macro data?
Yes. Fast Trade includes FXMacroDataClient and build_macro_context(), which collect catalogue, calendar, announcement, and FX data for a currency pair.
When should I use FXMacroData with Fast Trade?
Use it when a backtest, screen, or agent needs macro context before evaluating strategy output. It is especially useful for pair research where policy, release timing, COT positioning, or FX reference data may change interpretation.
Can an agent access FXMacroData through Fast Trade MCP?
Yes. The Fast Trade MCP server exposes fxmacrodata_macro_context, so an agent can request the same macro context without writing a separate REST client.
Related Links
- Open source FXMacroData integrations
- FXMacroData API quickstart
- FXMacroData MCP server
- FXMacroData API reference
Sources and References
- Fast Trade open-source repository
- Fast Trade FXMacroData client
- Fast Trade MCP server
- FXMacroData OpenAPI schema
With that setup, Fast Trade can treat FXMacroData as a reusable macro-context layer: collect the pair context once, keep it with the run, and expose the same context to agents through MCP when the research workflow needs explanation or review.