How builderr-ai/builderr-trading-template works
Purpose and contract
This repository is a submission template and local validation kit for the Builderr Trading Agent Leaderboard. The deployable strategy entry point is agent.py, which must expose decide(market_state, portfolio_state, cash) -> list[orders]. It receives daily historical bars and current holdings, then emits long-only buy/sell orders. AGENT_BRIEF.md and ANATOMY.md define the fuller agent contract and strategy-design guidance.
Paths: agent.py, AGENT_BRIEF.md, ANATOMY.md
Submitted strategy
The checked-in agent is a forward-return rotation hybrid: it determines a risk regime from SPY/QQQ trend and QQQ volatility; selects defensive ETFs in risk-off periods; ranks broad, sector, semiconductor, and mega-cap instruments in risk-on periods; and conditionally uses modest 2x ETF exposure. Target sizing includes ticker, drift-rebalance, and beta-adjusted gross-exposure controls.
Paths: agent.py, strategy_selftest.py, universe.json
Decision data boundary
The strategy is designed to operate primarily on the supplied market_state bars, which are oldest-first daily OHLCV histories. portfolio_state supplies cash, open positions, and last prices for reconciliation and sizing. The returned order list is the hard boundary to the external execution/scoring engine; the repository does not contain that private engine.
Paths: agent.py, preview.py, selfcheck.py
Local evaluation stages
preview.py is the primary local preflight: it runs the agent over bundled public market windows and reports admission-like safety/performance results. selfcheck.py provides a faster synthetic smoke test for output shape and crash resistance. Strategy-specific assertions verify regime behavior and exposure caps before submission.
Paths: preview.py, selfcheck.py, strategy_selftest.py
Execution and safety model
The central platform enforces a long-only, finite-order contract, maximum trade rate, minimum hold interval, per-name concentration limit, and beta-adjusted gross limit. The local strategy proactively stays below those limits through capped target weights and beta-aware sizing. Its output may still be rejected or flattened by the external engine if constraints are breached.
Paths: agent.py, fairness_tests.py, endpoint_security.py
Submission modes and live integration
A repository submission is centrally evaluated on hidden historical regimes, then admitted agents run in a shared daily paper-trading sandbox and appear on a live leaderboard. Alternatively, an externally hosted HTTPS /decide endpoint can provide decisions; endpoint responses are captured before the market session and replayed for execution. Supporting scripts implement local endpoint replay/capture and leaderboard refresh/runner behavior.
Paths: endpoint_replay.py, capture_endpoint_orders.py, live_runner.py
Runtime and infrastructure
The project is Python-based, with dependencies declared in requirements.txt. GitHub Actions automation publishes or refreshes leaderboard-related artifacts. A macOS launchd plist and shell script support scheduled live leaderboard operation. Persistent local artifacts include the trade universe, historical/sample regimes, and leaderboard/result JSON files.
Paths: requirements.txt, .github/workflows/leaderboard.yml, com.builderr.live-leaderboard.plist
Main entry points: agent.py Strategy entry point · live_runner.py Live leaderboard runner · endpoint_replay.py Endpoint replay · capture_endpoint_orders.py Endpoint order capture
Components 20
Strategy
- Agent contract · Defines the required decide interface and order contract.
AGENT_BRIEF.md - Strategy guidance
ANATOMY.md - Strategy entry point · Exports decide(market_state, portfolio_state, cash).
agent.py - Regime detection · Uses SPY/QQQ trend and QQQ volatility.
agent.py - Rotation & sizing · Ranks risk-on assets or defensive ETFs and caps beta-adjusted exposure.
agent.py - Market history · Oldest-first daily OHLCV bars.
- Portfolio state · Positions, cash, and last prices for reconciliation.
- Order list · Long-only buy and sell orders.
- Trade universe
universe.json
Local Validation
- Preflight evaluation · Runs bundled public market windows and reports safety/performance.
preview.py - Synthetic smoke test · Checks output shape and crash resistance.
selfcheck.py - Strategy assertions · Verifies regime behavior and exposure caps.
strategy_selftest.py
Submission & Live
- Scoring & execution engine · Enforces trading constraints and may reject or flatten orders.
- Hosted /decide endpoint · Optional HTTPS decision provider.
- Endpoint replay
endpoint_replay.py - Endpoint order capture · Captures endpoint responses for later execution replay.
capture_endpoint_orders.py - Live leaderboard runner · Supports shared daily paper-trading and leaderboard refresh.
live_runner.py
Operations
- Leaderboard automation · Publishes or refreshes leaderboard artifacts.
.github/workflows/leaderboard.yml - macOS scheduler · Schedules local live leaderboard operation.
com.builderr.live-leaderboard.plist - Python dependencies
requirements.txt
Connections 19
- Agent contract → Strategy entry point: specifies
- Strategy guidance → Strategy entry point: guides
- Market history → Strategy entry point: daily bars
- Portfolio state → Strategy entry point: holdings and prices
- Trade universe → Rotation & sizing: tradable instruments
- Strategy entry point → Regime detection: derives
- Regime detection → Rotation & sizing: selects risk mode
- Rotation & sizing → Order list: target trades
- Order list → Scoring & execution engine: submitted decisions
- Strategy entry point → Preflight evaluation: evaluated by
- Strategy entry point → Synthetic smoke test: smoke tested by
- Strategy entry point → Strategy assertions: asserted by
- Hosted /decide endpoint → Endpoint order capture: responses
- Endpoint order capture → Endpoint replay: captured orders
- Endpoint replay → Scoring & execution engine: replayed decisions
- Scoring & execution engine → Live leaderboard runner: paper-trading results
- macOS scheduler → Live leaderboard runner: schedules
- Live leaderboard runner → Leaderboard automation: leaderboard artifacts
- Python dependencies → Strategy entry point: runtime packages