This comprehensive example demonstrates a sophisticated Multi-Agent Collaboration (MAC) system designed for hedge fund analysis using the Strands Agents SDK. The system implements a hierarchical architecture with specialized financial analysis agents that work together to provide comprehensive investment insights.
View the architecture diagram below that shows how you can build a mutli-agentic system using an agent-as-tools pattern, with meta-tooling, human-in-the-loop, observability, detailed traces and logging enabled for a financial system:
🚨**THIS AGENTIC SYSTEM USES CLAUDE 4 SONNET, released on 05/22
- Role: Meta-coordinator that uses specialized agents as tools
- Capabilities: Synthesizes insights from all sub-agents
- Features: Dynamic tool creation for custom analysis requirements
-
Fundamental Analyst Agent
- Model: Claude 3 Haiku
- Purpose: Performs fundamental financial statement analysis
- Capabilities:
- Income statement analysis
- Balance sheet examination
- Cash flow statement evaluation
- Financial ratio calculations
- Valuation metrics assessment
-
Technical Analyst Agent
- Model: Amazon Nova Lite
- Purpose: Conducts technical analysis of stock price movements
- Capabilities:
- Historical price data retrieval
- Technical indicator calculations (
RSI
,MACD
,SMA
,EMA
) - Chart pattern analysis
- Trading signal generation
-
Market Analyst Agent
- Model: Claude 3 Haiku
- Purpose: Provides market context and sentiment analysis
- Capabilities:
- Options chain analysis
- Insider trading information
- Market news aggregation
- Sentiment analysis
- Financial Data Integration:
The system integrates with comprehensive financial data APIs to access:
- Real-time and historical stock prices
- Financial statements (income, balance sheet, cash flow)
- Options chain data
- Insider trading transactions
- Market news and sentiment data
- Multi-Model Support for multiple agents as tools and code generation
Utilizes multiple foundation models through AWS Bedrock:
- Amazon Nova Lite for routing and technical analysis
- Claude 3 Haiku for fundamental and market analysis
- Configurable model parameters for each agent
- This repository uses Claude 4 Sonnet as the underlying model for the lead analyst agent. This agent makes decision for which agent to be used as a tool, if meta tooling is required, etc.
There are custom tools that are used across different agents in this ecosystem:
get_income_statements
: Retrieves company income statement dataget_balance_sheets
: Fetches balance sheet informationget_cash_flow_statements
: Obtains cash flow dataget_stock_prices
: Historical price data with date range filteringget_current_stock_price
: Real-time price informationget_technical_indicators
: Calculates RSI, MACD, SMA, EMA indicatorsget_options_chain
: Options contract data with filtering capabilitiesget_insider_trades
: Insider trading transaction informationget_news
: Financial news and market sentiment data
generate_and_execute_code
: Dynamic Python code generation and safe execution- Uses LiteLLM with AWS Bedrock for code generation
- Implements security measures and timeout controls
- Supports data visualization and custom analysis
This Agentic system uses pre-built tools offered by Strands agent tools along with the custom tools created. The pre-built tools that are used are as follows across the four different agents:
calculator
: Mathematical operationsfile_read
: File parsing capabilitiesmem0_memory
: Memory management for context retentionpython_repl
: Python code execution environmentcurrent_time
: Date and time utilitiesjournal
: Structured task and log management
Implements human approval mechanisms for sensitive operations. If there is a tool that is getting sensitive news for example, the tool execution will halt and ask the human for approval for calling the tool. There are several design patterns for adding a human in the loop, but this is one of them being reviewing tool calls. You can also use the HITL
workflow to edit the tool call context, ask for approval and more.
- Insider trading data requests require explicit approval
- News data access with human oversight
- Interactive approval prompts in Jupyter notebook environment
The Lead Analyst Agent features advanced meta-tooling abilities:
- Dynamic Tool Creation: Generates custom tools on-demand
- Tool Loading: Integrates newly created tools into the system
- Shell Access: Command execution for testing and validation
- Editor Integration: Code modification and tool development
Follow the steps below to get started with running this in your environment:
- Make sure you are in your AWS environment. To set up your AWS environment, view the steps here. Create
.env
file with required API keys and credentials. Copy the.env.template
to.env
and edit it:
# Copy the template into your .env file and edit the content below
cp .env.template .env
TAVILY_API_KEY=<your-tavily-api-key>
FINANCIAL_DATASET_API=<your-financial-dataset-api-key>
To get your API key for Tavily, view here. To get your API key for financialdatasets.ai
, view here.
- Install
uv
and Python dependencies:
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
- Restore Python virtual environment from the
pyproject.toml
file.
uv venv && source .venv/bin/activate && uv pip sync pyproject.toml
- Create a
conda
kernel. This is needed to run the notebook on your EC2 instance:
uv add zmq
python -m ipykernel install --user --name=.venv --display-name="Python (uv env)"
- Open the JupyterLab notebook to run and select the
Python (uv env)
if not selected automatically (if it is not, refresh the page or close the notebook and open it again and you should see it selected or be able to select it from the drop down).
All information to run this sample is fetched from a configuration file. This configuration file contains information about the model id information, inference parameters and other information for each agent in this multi agent system. View the file here.
general:
name: "Financial-multi-agentic-system"
description: "This agentic system shows multi-agent collaboration different financial agents"
# This contains the model information for various agents
# in our multi agentic system
model_information:
finance_agent_model_info:
model_id: us.amazon.nova-micro-v1:0
inference_parameters:
temperature: 0.1
technical_agent_model_info:
model_id: us.anthropic.claude-3-5-sonnet-20240620-v1:0
inference_parameters:
temperature: 0.1
max_tokens: 512
.
.
.
Next, to run the solution, open the multi-agentic-system-strands.ipynb
, select the Python (uv env)
environment and run all the cells to see the outputs.
View some of the results below:
- Human in the loop example: View how the tool execution pauses and asks for the human in the loop input before resuming:
- On the fly research journal creation: One of the agents has the capability to use built in tools and custom tools, and write a journal on the fly. View an example off a Journal created here:
View the traces in Langfuse
dashboard below: