DEV Community

Cover image for Building a Multi-Agent Quant Backtesting System: Amazon Bedrock AgentCore + Strands Agents
Haowen Huang
Haowen Huang

Posted on

Building a Multi-Agent Quant Backtesting System: Amazon Bedrock AgentCore + Strands Agents

A hands-on walkthrough of building a multi-agent quantitative backtesting system on Amazon Bedrock AgentCore and the Strands Agents SDK. Three specialized AI agents collaborate to turn a plain-English trading strategy into a full performance report. This post is the introduction to an eight-lab, 90-minute workshop and the first in a multi-part series. It covers the architecture, the three foundation models, and the lab progression—and kicks off follow-up posts on collaboration (A2A), safe execution (sandboxing), governed actions (guardrails), and compounding memory.


The Problem

The success or failure of quantitative trading depends, to a large degree, on backtesting. Before any real money goes into the market, a strategy has to prove itself on historical data: Does it make money? What's the worst-case loss? Is this much return worth that much risk?

The hard part is that going from a trading idea to a credible backtest report spans several domains at once: trading domain knowledge, data engineering, Python coding, and statistical analysis. That is precisely the kind of multi-step, multi-skill problem where AI agents shine. The hands-on workshop explored in this post builds exactly such a system: multiple specialized agents collaborating to go from a one-sentence strategy description to a full performance analysis—automatically.

This post gives you a quick tour of what the workshop covers and why its design decisions are worth adopting in your own projects.

Disclaimer: This content is for learning and discussion purposes only. It does not constitute investment advice, recommendations, or solicitation. Any investment decisions and resulting gains or losses are solely the responsibility of the individual.


About This Series

This post is the opener of a multi-part series. It gives you the big picture; the follow-up posts each zoom into one design decision that turns this system from a demo into something production-ready:

  • Part 1 (this post) — The big picture: the architecture, the models, and the eight-lab progression.
  • Part 2 — Collaboration (A2A protocol): how agents discover and invoke each other across accounts, clouds, and frameworks using an open standard rather than a proprietary API.
  • Part 3 — Safe execution (Code Interpreter sandbox): why you should not run LLM-generated code directly, and how a sandbox contains it.
  • Part 4 — Governed actions (Cedar guardrails): how to impose a deterministic guardrail on a probabilistic agent—a boundary it can never cross, no matter what it decides.
  • Part 5 — Compounding memory: how giving the agent memory turns one-off backtests into a research companion that accumulates context and converses.

The through-line: big picture → collaboration → safety → accumulation. If any of those resonate, follow along.


What You'll Build

This is a hands-on workshop—roughly 90 minutes—at an intermediate (300) level. By the end you will have:

  • Three specialized AI agents deployed to Amazon Bedrock AgentCore
  • The ability to connect agents to external market data through an AgentCore MCP Gateway
  • A full-stack backtesting application that runs all the way from strategy input to performance analysis
  • An understanding of multi-agent orchestration patterns for complex financial workflows.

The bar is not high: basic Python and command-line familiarity, plus a general grasp of trading concepts such as buy, sell, and technical indicators. No prior experience with AI agents or backtesting frameworks is required. The workshop environment ships with a browser-based code editor (Code-OSS/VS Code Open Source), so there is nothing to install locally.


Three Foundation Models

A core idea of the workshop is matching the right model to the task. Rather than having one large model do everything, each agent uses the model best suited to its job:

Model Role Responsibility
Amazon Nova Lite 2.0 Result summarizer Analyze performance metrics and write a professional report
Anthropic Claude Sonnet 4 Quant agent (orchestrator) Coordinate the entire workflow and all sub-agents
Anthropic Claude Opus 4 Strategy generator Turn natural-language strategy into executable Backtrader Python code

Using a powerful model for code generation and a lighter, faster model for summarization is, in itself, a practical lesson in cost-and-latency optimization.


Why Backtesting, and Why Agents

Backtesting answers the questions that matter most before real capital is deployed: total and annualized return, maximum drawdown, Sharpe and Sortino ratios, win rate, profit/loss ratio, and how a strategy behaves in bull, bear, and sideways markets.

The traditional flow has five steps: define the strategy, gather historical data (OHLCV), implement it in code, run the simulation, and analyze the results. The problem is that each step demands a different skill.

The workshop uses Backtrader, a popular open-source Python backtesting framework with an event-driven engine, built-in technical indicators (SMA, EMA, RSI, MACD), order management, and performance analytics. In this system, the strategy generator writes the Backtrader code and the quant agent runs it against real market data—leaving the human free to focus on the strategy itself.


Why Multiple Agents Instead of One Big Agent

A single "do-everything" agent tends to struggle with complex, multi-step tasks. The workshop argues for a multi-agent architecture along four axes:

  • Specialization — each agent has a single responsibility, improving accuracy
  • Scalability — distributed processing scales elastically and independently
  • Cost efficiency — provision resources per agent, on demand
  • Maintainability — fine-grained control, independent health monitoring, isolated testing

Strands Agents supports four collaboration patterns:

  • Agent-as-Tool (the orchestrator invokes specialized agents as callable tools)
  • Swarm (agents collaborate through shared memory)
  • Graph (agents as nodes connected by explicit edges)
  • Workflow (structured, sequential collaboration)

Use Cases:

  • Loan approval processes — Sequential steps: identity verification → credit check → risk assessment → approval decision
  • CI/CD pipelines — Build → test → security scan → deploy, with defined dependencies between stages
  • Insurance claims — Document collection → damage assessment → policy validation → settlement calculation

The diagram below illustrates sample use cases for each pattern.

This workshop uses the Agent-as-Tool pattern, because a backtesting flow is naturally hierarchical:

User Request
↓
Quant Agent (Orchestrator)
├── invoke → Strategy Generator Agent → Backtrader code
├── invoke → Market Data MCP Tool → Historical OHLCV data
├── execute → Backtest (Backtrader engine)
└── invoke → Result Summarizer Agent → Performance analysis
↓
Consolidated Response → User

Enter fullscreen mode Exit fullscreen mode

Because each specialized agent runs independently, it can use a different model and its own configuration, and it can be tested, scaled, and updated in isolation.


What AgentCore Brings

Amazon Bedrock AgentCore provides managed infrastructure for deploying, running, and scaling agents in production. The workshop uses five of its services:

  • Runtime — a serverless compute environment that hosts each agent. No servers or containers to manage; it auto-scales with invocation load, supports secure environment variables, and enables agent-to-agent invocation. All three agents are deployed here.
  • Gateway — wraps a market-data Lambda function into a get_market_data MCP tool that any agent can invoke, with semantic routing and Cognito-based OAuth.
  • Identity — secure authentication integrated with an existing identity provider (in this case, Amazon Cognito), ensuring that only authorized agents can access the market-data tool.
  • Memory — short-term and long-term context storage, enabling the quant agent to handle follow-ups and iterative strategy refinement.
  • Observability — OpenTelemetry-compatible tracing of the full execution path—from orchestrator to sub-agents to Gateway tool calls—flowing into Amazon CloudWatch.

Deployment is straightforward: point the AgentCore CLI at your Python entry file, and it handles packaging, dependencies, container management, and scaling:

agentcore configure --entrypoint quant_agent.py --name quant_agent \
  --requirements-file requirements.txt --idle-timeout 900

agentcore launch --auto-update-on-conflict \
  --env AWS_REGION=$WORKSHOP_REGION \
  --env STRATEGY_GENERATOR_RUNTIME_ARN=arn:... \
  --env AGENTCORE_GATEWAY_URL=https://...

Enter fullscreen mode Exit fullscreen mode

System Architecture

Overall system architecture. Source: the "Agentic Backtesting for Quants" workshop (AWS).

The system has three layers:

  • Frontend (Next.js) — a strategy-input form, real-time workflow progress indicators, and a results dashboard with metrics and AI-generated analysis.
  • Orchestration layer (Bedrock AgentCore) — the quant agent receives the request, invokes the strategy generator for code, fetches data through the market-data Gateway, runs the Backtrader simulation locally, and then invokes the result summarizer.
  • Data layer — S3 Tables (in Apache Iceberg format) store historical daily OHLCV data sourced from Yahoo Finance (for educational use only); a Lambda function queries the data via PyIceberg; and the Gateway exposes that Lambda function as the get_market_data tool.

The Hands-On Labs

The labs build progressively, each adding one new AgentCore capability on top of the last. You start with a prompt-only agent and evolve it, step by step, into a full multi-agent system with observability and guardrails:

  • Lab 1 — Deploy the strategy generator (AgentCore Runtime): get a simple, prompt-only agent up and running.
  • Lab 2 — Build the quant agent with market data (AgentCore Gateway & Identity): connect the agent to external tools.
  • Lab 3 — Multi-agent orchestration (Agent-as-Tool): transition from a single agent to an "orchestrator + experts" structure.
  • Lab 4 — Run your first backtest (AgentCore Observability): make the black box transparent with traces and spans.
  • Lab 5 — Backtest memory and chat (AgentCore Memory): transition from stateless to stateful, enabling the agent to remember context.
  • Lab 6 (bonus) — Add guardrails (AgentCore Policy): transition from unconstrained to governed execution.
  • Lab 7 (bonus) — Sandboxed execution (AgentCore Code Interpreter): run code in a secure sandbox rather than locally.
  • Lab 8 (bonus) — A2A protocol (Agent-to-Agent): replace a proprietary API with an open, interoperable standard.

This evolution path is itself the payoff: each lab corresponds to a real capability gap you will encounter when pushing an agent from "toy" toward "production."


What You've Built

Component Technology Purpose
Strategy Generator Claude Opus 4 + AgentCore Converts natural language to Backtrader code
Quant Agent Claude Sonnet 4 + AgentCore Orchestrates the four-step workflow
Results Summarizer Nova Lite 2.0 + AgentCore Analyzes performance metrics
Market Data MCP Lambda + S3 Tables + AgentCore Gateway Serves historical OHLCV data
Frontend Next.js + TypeScript User interface for strategy input and results

Who It's For

This workshop is aimed at quant developers, data scientists, engineers, and engineering managers who are curious about how agentic AI can accelerate quantitative trading workflows. If you have been looking for a concrete demonstration of how multi-agent orchestration, MCP, and managed agent infrastructure fit together in an end-to-end project, this is a well-scoped place to start. It is free at AWS events; running it in your own account requires you to cover the cloud resource costs.

Finally, to repeat a reminder from the workshop itself: the market data here comes from Yahoo Finance, for educational use only, and is not investment advice. What is truly worth taking away is the overall architecture of this quant backtesting system and the multi-agent design patterns you can internalize and apply to your own systems.


References

  1. Agentic Backtesting for Quants with Bedrock AgentCore and Strands Agents: https://catalog.us-east-1.prod.workshops.aws/workshops/dcf31eb4-6479-48ed-acc5-e58fe1f53656/en-US?trk=7b33727f-f84b-453c-8f31-3d32f7b2a4e7&sc_channel=el
  2. Backtrader open-source backtesting framework: https://www.backtrader.com/
  3. Amazon Bedrock AgentCore docs: https://docs.aws.amazon.com/bedrock-agentcore/?trk=7b33727f-f84b-453c-8f31-3d32f7b2a4e7&sc_channel=el
  4. Strands Agents docs: https://strandsagents.com/?trk=7b33727f-f84b-453c-8f31-3d32f7b2a4e7&sc_channel=el

Top comments (0)