# How AutoHedge Discovers Tickers Dynamically from a Task

> Learn how AutoHedge dynamically discovers stock tickers from tasks using an LLM prompt and Director Agent. Eliminate hard-coded lists for efficient trading.

- Repository: [Swarms/AutoHedge](https://github.com/The-Swarm-Corporation/AutoHedge)
- Tags: how-to-guide
- Published: 2026-09-09

---

**AutoHedge leverages a specialized LLM prompt called `DIRECTOR_TICKER_DISCOVERY_PROMPT` and a Director Agent to extract stock tickers as a JSON array from natural language tasks, eliminating the need for hard-coded symbol lists.**

The AutoHedge trading system implements a fully dynamic approach to ticker identification that enables task-driven workflows without manual configuration. Instead of relying on static symbol databases, the system analyzes textual task descriptions in real-time to determine which securities require analysis.

## The Director Agent Architecture

The dynamic discovery mechanism centers on the Director Agent, which orchestrates the entire pipeline from task ingestion to downstream analysis delegation.

### Prompt Engineering for Ticker Extraction

In [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py) (lines 195-202), the repository defines the `DIRECTOR_TICKER_DISCOVERY_PROMPT`. This system prompt explicitly instructs the language model: *"Given the following task, determine which stock tickers are relevant to analyze… Reply with ONLY a JSON array of ticker symbols."*

This strict output constraint ensures the response is machine-parseable, allowing the Director Agent to convert free-form text into a structured list of ticker symbols without additional regex or string processing.

### Agent Orchestration in workers.py

The `director_agent` is instantiated in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) at lines 80-86. When invoked, this agent executes a specific workflow:

- Receives the task string
- Calls the LLM with the ticker discovery prompt
- Parses the returned JSON array
- Spawns separate sub-tasks for **sentiment**, **quant**, **risk**, and **execution** agents for each discovered ticker

This architecture decouples ticker identification from analysis execution, enabling the system to handle arbitrary market scenarios dynamically.

## Dynamic Discovery in Practice

Because the LLM evaluates the prompt fresh for each task, AutoHedge can process vague or broad descriptions. For example, a task such as *"Analyze the impact of the latest Fed rate decision on technology stocks"* returns specific tickers like `["AAPL","MSFT","NVDA"]` without predefined mappings.

The following implementation demonstrates the Director Agent handling a natural language task:

```python
from autohedge.workers import director_agent

# Example task describing a market scenario

task = """
Analyze the recent earnings reports of Amazon, Tesla, and the semiconductor sector.
Identify the most relevant stocks to trade based on this information.
"""

# Run the Director Agent – it will first discover tickers, then

# hand off each ticker to the downstream agents.

result = director_agent.run(task)

print(result)   # → JSON containing the discovered tickers and downstream analysis

```

In this workflow, `director_agent.run()` first extracts the tickers using the discovery prompt defined in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py), then routes each symbol to specialized downstream agents for parallel processing.

## Summary

- **LLM-Driven Extraction**: AutoHedge uses the `DIRECTOR_TICKER_DISCOVERY_PROMPT` in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py) to parse natural language and extract tickers as a JSON array.
- **Director Agent Orchestration**: The `director_agent` in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) (lines 80-86) manages the discovery workflow and delegates to sentiment, quant, risk, and execution agents.
- **Dynamic Workflow**: The system accepts arbitrary textual task descriptions and returns relevant securities without hard-coded lists.
- **Structured Output**: The prompt enforces JSON-only responses to ensure reliable programmatic parsing.

## Frequently Asked Questions

### What prompt does AutoHedge use for ticker discovery?

AutoHedge uses the `DIRECTOR_TICKER_DISCOVERY_PROMPT` defined in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py) at lines 195-202. This system prompt instructs the language model to analyze the provided task and return only a JSON array of relevant ticker symbols.

### Which file contains the Director Agent implementation?

The `director_agent` is implemented and instantiated in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) specifically at lines 80-86. This agent serves as the central orchestrator that invokes the ticker discovery prompt and manages downstream agent delegation.

### How does AutoHedge ensure valid JSON output from the LLM?

The `DIRECTOR_TICKER_DISCOVERY_PROMPT` contains explicit instructions to *"Reply with ONLY a JSON array of ticker symbols"*, constraining the model output format. This allows the Director Agent to parse the response directly without complex error handling or extraction logic.

### Can AutoHedge discover tickers from vague sector descriptions?

Yes. Because the discovery mechanism relies on LLM comprehension rather than keyword matching or static databases, the system can interpret broad descriptions like *"technology stocks affected by Fed decisions"* and return specific relevant tickers such as `AAPL`, `MSFT`, and `NVDA`.