How the-swarm-corporation/autohedge works
1. Overall shape
AutoHedge is a Python package centered on an autonomous trading pipeline. The runtime entrypoints are autohedge/__main__.py, autohedge/cli.py, and autohedge/main.py, which likely bootstrap the system, load configuration, assemble agents, and start the trading loop.
2. Core trading pipeline
The README describes the main architecture as a staged agent flow: Director Agent → Quant Agent → Risk Management Agent → Execution Agent. This is the primary control path for turning market context into trade decisions and then into executable orders.
3. Agent responsibilities
The system is intentionally split by function:
- Director: generates the strategy / thesis
- Quant: performs technical and statistical analysis
- Risk: sizes positions and applies constraints
- Execution: converts approved decisions into orders and sends them to the venue
This separation is the main architectural boundary and is important for any diagram.
4. Market/data access layer
autohedge/tools/ contains provider-specific connectors used by the agents:
- jupiter_price.py, jupiter_search.py for Solana/Jupiter-related data and discovery
- polygon_api.py and yahoo_api.py for market data
- exa_search_tool.py for external search
- ultra_tools.py and tools_registry.py for composing and exposing tools to agents
This layer isolates external APIs from the decision logic.
5. Tool registry boundary
tools_registry.py suggests a central place where agent-usable tools are registered and selected. Architecturally, this is the control point between “what the agents can do” and “how external services are called.”
6. Configuration and secrets
autohedge/env_loader.py plus .env.example define the config boundary. The repository expects environment variables such as JUPITER_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, WORKSPACE_DIR, and WALLET_PRIVATE_KEY. This means runtime behavior is driven by external configuration rather than hard-coded credentials.
7. Execution and venue support
The README says full autonomous trading on Solana is supported, with Coinbase and other exchanges planned. In architecture terms, Solana is the current execution venue boundary, and wallet/private-key handling is part of the execution subsystem.
8. Prompting and agent behavior
autohedge/prompts.py likely contains the system prompts / instructions that shape agent behavior. In an architecture diagram, this sits alongside the orchestration layer as a policy/behavior input rather than a data source.
9. Workers and concurrency
autohedge/workers.py implies background workers or task execution helpers for running analysis, polling markets, or coordinating agent steps. This is the most likely place where the sequential agent pipeline becomes asynchronous or scheduled work.
10. Logging and audit trail
The logs/ directory contains trade CSV files, showing that the system produces persistent execution records. This is an important operational boundary: decisions are not just made, they are recorded for audit, debugging, and performance review.
11. Experimental sandbox
experimental/ contains btc_agent.py, crypto_agent_wrapper.py, and market_making.py. These appear to be prototypes or alternate strategies outside the main production path, so they should be drawn as a separate experimentation lane rather than part of the core execution flow.
12. Packaging, quality, and delivery
The repo is a standard Python distributable with pyproject.toml, requirements.txt, and GitHub Actions workflows for linting, testing, docs, and publishing. These are supporting infrastructure, not part of the trading runtime, but they show the project has CI/CD and release automation around the core package.
Main entry points: tools_registry.py Tool registry · main.py App core · cli.py CLI · __main__.py Main entry
Components 20
Runtime
Package entrypoints and orchestration
- Main entry · Package and CLI startup paths for the application
autohedge/__main__.py - CLI · Command-line interface for launching and controlling runs
autohedge/cli.py - App core · Bootstraps configuration, agents, and the trading loop
autohedge/main.py - Workers · Background task and coordination helpers for agent work
autohedge/workers.py
Agents
Core autonomous trading pipeline
- Director · Creates the trading thesis and high-level intent
- Quant · Performs technical and statistical market analysis
- Risk · Applies sizing, constraints, and approval logic
- Execution · Converts approved decisions into venue orders
- Prompts · System instructions that shape agent behavior
autohedge/prompts.py
Tools
External data and execution connectors
- Tool registry · Registers and exposes tools available to agents
autohedge/tools/tools_registry.py - Jupiter price · Solana/Jupiter price and routing data access
autohedge/tools/jupiter_price.py - Jupiter search · Jupiter-related search and discovery helper
autohedge/tools/jupiter_search.py - Polygon API · Equity/market data connector
autohedge/tools/polygon_api.py - Yahoo API · Market data and lookup connector
autohedge/tools/yahoo_api.py - Exa search · Web/external research connector
autohedge/tools/exa_search_tool.py - Ultra tools · Higher-level composition of agent-facing tools
autohedge/tools/ultra_tools.py
Ops
Configuration, logging, and delivery
- Env loader · Loads runtime settings and secrets from environment variables
autohedge/env_loader.py - Trade logs · Persistent CSV records of executed trades
logs/trades_20250305_193100.csv - Experiments · Prototype and alternate strategy implementations
experimental/market_making.py - CI/CD · Automation for linting, testing, documentation, and publishing
.github/workflows/test.yml
Connections 21
- Main entry → CLI: launches · Startup flows into command handling
- CLI → App core: bootstraps · CLI hands off to application orchestration
- App core → Env loader: loads config · Runtime settings and secrets are loaded before execution
- App core → Prompts: applies · Agent behavior is shaped by prompt policy
- App core → Workers: delegates · Long-running or scheduled work is coordinated through workers
- App core → Director: runs · Trading loop begins with strategy generation
- Director → Quant: hands off · Strategy is refined by market analysis
- Quant → Risk: submits · Analytical output is constrained by risk logic
- Risk → Execution: approves · Approved decisions move into order generation
- Execution → Tool registry: uses · Execution and analysis access tools through the registry boundary
- Director → Tool registry: uses · Strategy generation can query external tools
- Quant → Tool registry: uses · Quant analysis pulls market and search data via tools
- Tool registry → Jupiter price: exposes · Registry makes Jupiter price data available
- Tool registry → Jupiter search: exposes · Registry makes Jupiter discovery tools available
- Tool registry → Polygon API: exposes · Registry makes Polygon data available
- Tool registry → Yahoo API: exposes · Registry makes Yahoo data available
- Tool registry → Exa search: exposes · Registry makes external search available
- Tool registry → Ultra tools: composes · Bundled tool surface is assembled here
- Execution → Trade logs: records · Executed trades are written to persistent CSV logs
- App core → Experiments: separates · Prototype strategies are kept outside the main production path
- App core → CI/CD: shipped by · Package delivery is supported by workflow automation