Skip to main content
Each Trading Agent is a folder-based entity with structured files that define its behavior, track state, and accumulate learnings.

System Architecture

Directory Structure

Each Condor Trading Agent (CTA) is a directory containing structured files:

Two Memory Files

Journal: What the agent did in this sessionβ€”tick log, decisions, executor states. Learnings: Lessons that apply to all sessionsβ€”common errors, configuration tips, market insights.

agent.md

The strategy definition uses YAML frontmatter for configuration and Markdown for instructions:

Configs vs Limits

Configs

Agent-suggestible parameters that control trading behavior:
  • The agent can suggest changes based on learnings
  • User must approve before changes take effect
  • Examples: trading_pair, spread_percentage, tick_interval, grid_levels

Limits

User-only guardrails enforced by the Risk Engine:
  • Safety boundaries the agent cannot exceed
  • Only modifiable by the user, never by the agent
  • Examples: max_position_size_quote, max_daily_loss_quote, max_drawdown_pct

learnings.md

Persists across sessions, accumulating insights:
Maximum 20 entries to prevent context bloat. New insights replace older ones.

Tick Loop

Each tick (TickEngine._tick) executes:
  1. Resolve API client for the configured server
  2. Run providers β€” executors and positions, filtered by controller_id
  3. Read journal context β€” learnings, summary, last 3 decisions
  4. Get risk state β€” exposure, drawdown, open count. If blocked, skip LLM
  5. Build prompt β€” system prompt + strategy + provider summaries + journal
  6. Spawn ACP session with MCP servers (Hummingbot tools, market data)
  7. Persist β€” write snapshot, append tick to journal, update summary

Risk Engine

The Risk Engine (condor/trading_agent/risk.py) tracks state and enforces limits:

Pre-tick Validation

Blocks the entire tick if:
  • daily_pnl < -max_daily_loss_quote
  • drawdown_pct > max_drawdown_pct
  • daily_cost > max_cost_per_day_usd

Per-executor Validation

Blocks executor creation if:
  • executor_count >= max_open_executors
  • order_amount > max_single_order_quote
  • total_exposure + new_amount > max_position_size_quote

Providers

Providers fetch deterministic data before each tick: Provider output has two parts:
  • data: Structured data for internal tracking
  • summary: Human-readable string included in the LLM prompt

Routines

Custom Python helpers in the routines/ directory:
Routines are deterministicβ€”same input always produces same output.

Inspecting Activity

Injecting Information

You can manually add to learnings.mdβ€”the agent doesn’t know whether it wrote the entry or you did. Useful for:
  • Pre-seeding knowledge before deployment
  • Adding market context the agent can’t observe
  • Correcting agent behavior
Via web dashboard: Trading Agents β†’ Select agent β†’ Learnings β†’ Edit Via file: Edit trading_agents/my_strategy/learnings.md directly