How hummingbot/condor works
Purpose and entry points
Condor is a Python trading-control client for Hummingbot API: it monitors portfolios/bots, executes CEX/DEX actions through Hummingbot and Gateway, runs routines, and hosts LLM-driven trading agents. main.py is the process entry point, registering Telegram and application services; condor/web/app.py exposes the browser dashboard/API, consumed by the React entry point frontend/src/main.tsx. It supports explicit Telegram and local-dashboard modes.
Interaction surfaces and access boundary
Telegram command handling is organized by product domain under handlers/, while the web surface is a FastAPI-style route layer under condor/web/routes/. Both surfaces should converge on shared Condor services rather than independently implementing trading logic.
• handlers/trading/router.py
• handlers/dex/router.py
• condor/web/routes/chat_ws.py
• condor/web/routes/portfolio.py
Authentication, user ownership, server access, and local-mode behavior are material safety boundaries. Runtime confirmation and danger controls protect consequential agent/tool actions.
• condor/web/auth.py
• utils/auth.py
• condor/runtime/confirmations.py
• condor/runtime/danger.py
Hummingbot and market-data integration
The primary external control plane is Hummingbot API, accessed through typed fetchers for bots, executors, orders, positions, portfolios, connectors, and market data. Gateway is the DEX-facing boundary for wallets, tokens, pools, swaps, and CLMM positions. These modules isolate upstream API formats, pagination, validation, and error behavior from handlers and web routes.
• condor/fetchers/market_data.py
• condor/fetchers/executors.py
• condor/fetchers/portfolio.py
• condor/fetchers/gateway_tokens.py
• condor/server_data_service.py
Supporting upstreams include DEX candle/pool sources and Orca integration:
• condor/dex_candles.py
• condor/pool_data.py
• condor/orca_api.py
Agent runtime and LLM orchestration
The agent subsystem turns user requests into bounded sessions with prompts, strategy context, toolsets, streamed events, delegation, journals, risk checks, and shutdown behavior. Agent definitions are filesystem content: each domain agent supplies instructions, strategies, routines, and skills, while shared skills establish reusable operating procedures.
• condor/agents/engine.py
• condor/agents/agent.py
• condor/runtime/sessions.py
• condor/runtime/events.py
• agents/directional_trader/AGENT.md
• agents/_shared/skills/strategy_builder/SKILL.md
LLM providers support configured OpenAI-compatible endpoints and OpenRouter models:
• condor/llm/custom_models.py
• condor/llm/openrouter_models.py
• condor/runtime/llm_client.py
Automation, research, and reporting
Routines are discovered and scheduled Python workloads; they can run standalone or be initiated from an agent/chat context. Results can become persisted reports rendered by the backend and displayed in Telegram/web. Backtesting and code-running are adjacent controlled execution paths.
• condor/routine_store.py
• condor/routine_hooks.py
• routines/base.py
• condor/reports/builder.py
• condor/backtesting.py
• condor/code_runner.py
MCP integration boundary
Two MCP servers expose Condor’s agent, memory, routine, notification, and trading capabilities to external AI clients. The Hummingbot MCP server separately presents Hummingbot API operations with schemas and response formatters. This is an integration boundary requiring the same permissions and confirmation guarantees as native agent calls.
• mcp_servers/condor/server.py
• mcp_servers/condor/tools/trading_agent.py
• mcp_servers/hummingbot_api/server.py
• mcp_servers/hummingbot_api/tools/trading.py
State, deployment, and runtime infrastructure
Persistent local state covers configuration/preferences, agent memory, sessions, routine/report artifacts, caches, and telemetry outbox. The frontend is a Vite/React SPA using HTTP plus WebSockets/SSE for live chat, candles, bot, and market updates.
• config_manager.py
• condor/persistence.py
• condor/memory/store.py
• condor/runtime/state.py
• condor/web/ws_manager.py
• frontend/src/App.tsx
Production depends on Python, Telegram, Hummingbot API (typically Docker-hosted), Gateway/DEX connectors, optional LLM providers, and recommended Tailscale private networking. Telemetry is consent-controlled:
• condor/telemetry/consent.py
• condor/telemetry/emitter.py
Main entry points: engine.py Agent engine · server_data_service.py Trading data service · chat_ws.py Web routes · persistence.py Local persistence
Components 20
Interaction Surfaces
- Telegram handlers
handlers/trading/router.py - Web application
condor/web/app.py - Web routes
condor/web/routes/chat_ws.py - React SPA · Consumes dashboard HTTP and live-update endpoints.
frontend/src/main.tsx
Condor Runtime
- Process entry · Registers application and Telegram services.
main.py - Access control · Enforces authentication, ownership, server access, and local mode.
condor/web/auth.py - Agent engine · Builds bounded agent sessions, tools, delegation, and strategy context.
condor/agents/engine.py - Runtime sessions · Streams lifecycle events and maintains agent session state.
condor/runtime/sessions.py - Action safety · Gates consequential agent and tool actions.
condor/runtime/confirmations.py - Agent definitions · Domain instructions, strategies, routines, and reusable skills.
agents/directional_trader/AGENT.md - Routine automation · Schedules standalone or agent-initiated Python workloads.
condor/routine_store.py - Reports and controlled execution · Builds persisted reports alongside backtesting and code-running paths.
condor/reports/builder.py - Trading data service · Normalizes bots, orders, positions, portfolios, connectors, and market data.
condor/server_data_service.py
External Integrations
- LLM client · Uses configured OpenAI-compatible and OpenRouter models.
condor/runtime/llm_client.py - Hummingbot API
- Gateway and DEX · Provides wallets, tokens, pools, swaps, and CLMM positions.
condor/fetchers/gateway_tokens.py - MCP servers · Exposes Condor and Hummingbot trading capabilities to AI clients.
mcp_servers/condor/server.py
State & Observability
- Local persistence · Stores preferences, memory, sessions, routine/report artifacts, and caches.
condor/persistence.py - Live updates · Publishes chat, candle, bot, and market updates.
condor/web/ws_manager.py - Consent telemetry · Emits telemetry only under user consent.
condor/telemetry/emitter.py
Connections 27
- Process entry → Telegram handlers: registers
- Process entry → Web application: starts
- Telegram handlers → Access control: authorizes
- Web application → Web routes: mounts
- Web routes → Access control: authorizes
- React SPA → Web application: HTTP
- React SPA → Live updates: WebSocket/SSE
- Telegram handlers → Agent engine: requests
- Web routes → Agent engine: chat requests
- Agent engine → Runtime sessions: creates
- Agent engine → Agent definitions: loads
- Agent engine → LLM client: invokes
- Agent engine → Action safety: gates tools
- Agent engine → Routine automation: initiates
- Routine automation → Reports and controlled execution: produces
- Agent engine → Trading data service: uses tools
- Web routes → Trading data service: portfolio data
- Trading data service → Hummingbot API: typed API calls
- Trading data service → Gateway and DEX: DEX operations
- MCP servers → Agent engine: agent capabilities
- MCP servers → Trading data service: trading schemas
- MCP servers → Action safety: same safeguards
- Runtime sessions → Local persistence: stores state
- Routine automation → Local persistence: stores artifacts
- Reports and controlled execution → Local persistence: persists reports
- Runtime sessions → Live updates: streams events
- Consent telemetry → Local persistence: consent and outbox