Where Are the Prompt Templates in AutoHedge and How to Use Them

AutoHedge stores all LLM prompt definitions in autohedge/prompts.py and consumes them through autohedge/workers.py to configure autonomous trading agents.

The AutoHedge project by The-Swarm-Corporation orchestrates multiple AI agents for algorithmic trading using the swarms framework. Understanding how to locate and manipulate these AutoHedge prompt templates is essential for customizing agent behavior and injecting dynamic market data into the trading pipeline.

Locating the Prompt Templates in AutoHedge

All prompt definitions live in a single module: autohedge/prompts.py. This file contains the complete corpus of system instructions and dynamic templates used by the Director, Quant, Sentiment, Risk, and Execution agents.

According to the AutoHedge source code, this centralization allows consistent prompt versioning across the autonomous hedge fund architecture. The file defines both static system prompts that establish agent identity and templated prompts containing {placeholder} tokens for runtime formatting.

System Prompts vs. Template Prompts

AutoHedge distinguishes between two prompt categories:

System Prompts

System prompts define the role, objectives, and operational constraints for each autonomous agent. These are plain Python string constants imported by autohedge/workers.py and passed directly to the swarms.Agent constructor.

For example, the DIRECTOR_PROMPT configures the orchestration layer that manages trade flow between specialized workers.

Template Prompts

Template prompts contain variable placeholders like {stock}, {thesis}, and {quant_analysis}. These strings are designed for Python’s str.format() method, allowing agents to inject real-time market data and previous analysis results into new requests.

Key templates include RISK_ASSESSMENT_PROMPT and EXECUTION_ORDER_PROMPT, which require dynamic values to generate actionable trading instructions.

How to Use AutoHedge Prompt Templates

Assigning System Prompts to Agents

Import constants from autohedge/prompts.py and pass them to the system_prompt parameter when instantiating agents in autohedge/workers.py or your custom scripts:

from autohedge.prompts import DIRECTOR_PROMPT
from swarms import Agent

director = Agent(
    agent_name="Trading-Director",
    system_prompt=DIRECTOR_PROMPT + "\nCurrent date: 2024-01-15",
    model_name="gpt-4.1",
    max_loops=1,
)

This pattern, as implemented in autohedge/workers.py, establishes the foundational identity of each agent in the pipeline.

Formatting Dynamic Template Prompts

For prompts requiring runtime data, use the format() method to populate placeholders. The RISK_ASSESSMENT_PROMPT expects variables like stock, thesis, and quant_analysis:

from autohedge.prompts import RISK_ASSESSMENT_PROMPT

stock = "AAPL"
thesis = "Long on AAPL due to strong earnings."
quant_analysis = """{
    "technical_score": 0.85,
    "volume_score": 0.72,
    "trend_strength": 0.78,
    "volatility": 0.12,
    "probability_score": 0.81,
    "key_levels": {"support": 150.0, "resistance": 165.0, "pivot": 157.5}
}"""

prompt = RISK_ASSESSMENT_PROMPT.format(
    stock=stock,
    thesis=thesis,
    quant_analysis=quant_analysis,
)

The resulting prompt contains fully populated risk analysis instructions ready for agent consumption.

Chaining Agents with Formatted Prompts

After formatting, pass the prompt to specialized agents imported from autohedge/workers.py:

from autohedge.workers import risk_agent

risk_result = risk_agent.run(prompt)
print(risk_result)

This workflow enables the Director agent to coordinate multi-stage analysis where quantitative output feeds into risk assessment through dynamically formatted AutoHedge prompt templates.

Summary

  • AutoHedge prompt templates reside exclusively in autohedge/prompts.py, serving as the single source of truth for all agent instructions.
  • System prompts establish agent roles and are assigned via the system_prompt parameter in swarms.Agent constructors within autohedge/workers.py.
  • Template prompts utilize Python str.format() to inject real-time variables like stock tickers and technical analysis data.
  • The architecture separates prompt definition (prompts.py) from agent instantiation (workers.py), enabling modular customization of the trading pipeline.

Frequently Asked Questions

What file contains all the prompt definitions in AutoHedge?

All prompt definitions are centralized in autohedge/prompts.py. This module exports string constants for both system prompts and dynamic templates used across the Director, Quant, Risk, and Execution agents.

How do I customize a system prompt for a specific agent?

Import the desired constant from autohedge.prompts and modify it before passing to the Agent constructor. For example, append context-specific instructions to DIRECTOR_PROMPT when initializing the agent in autohedge/workers.py or your implementation.

Can I add new variables to existing template prompts?

Yes. Modify the string in autohedge/prompts.py to include new {placeholder} tokens, then supply corresponding keyword arguments to the format() method when generating prompts. Ensure downstream agents in autohedge/workers.py are updated to provide the new data fields.

Which agents use template prompts versus static system prompts?

According to the source code, all agents receive static system prompts during initialization in workers.py. Template prompts are typically used for inter-agent communication where the Director or Quant agents generate formatted requests containing RISK_ASSESSMENT_PROMPT or EXECUTION_ORDER_PROMPT populated with current market data.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →