System Architecture
Directory Structure
Each Condor Trading Agent (CTA) is a directory containing structured files:Two Memory Files
| File | Scope | Purpose |
|---|---|---|
journal.md | Per-session | Short-term memory for the current trading session |
learnings.md | Cross-session | Long-term memory that persists across all sessions |
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:Tick Loop
Each tick (TickEngine._tick) executes:
- Resolve API client for the configured server
- Run providers —
executorsandpositions, filtered bycontroller_id - Read journal context — learnings, summary, last 3 decisions
- Get risk state — exposure, drawdown, open count. If blocked, skip LLM
- Build prompt — system prompt + strategy + provider summaries + journal
- Spawn ACP session with MCP servers (Hummingbot tools, market data)
- 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_quotedrawdown_pct > max_drawdown_pctdaily_cost > max_cost_per_day_usd
Per-executor Validation
Blocks executor creation if:executor_count >= max_open_executorsorder_amount > max_single_order_quotetotal_exposure + new_amount > max_position_size_quote
Providers
Providers fetch deterministic data before each tick:| Provider | Output |
|---|---|
executors | Active executors filtered by controller_id, with status and P&L |
positions | Held positions from closed executors, with breakeven and unrealized P&L |
data: Structured data for internal trackingsummary: Human-readable string included in the LLM prompt
Routines
Custom Python helpers in theroutines/ directory:
Inspecting Activity
| Location | Content |
|---|---|
sessions/session_N/journal.md | Chronological summary, decisions, tick log |
sessions/session_N/snapshots/snapshot_K.md | Full tick: prompt, response, tool calls |
learnings.md | Lessons the agent chose to keep |
dry_runs/experiment_N.md | Dry-run results |
Injecting Information
You can manually add tolearnings.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
trading_agents/my_strategy/learnings.md directly
