Principle:HKUDS AI Trader System Prompt Construction
| Knowledge Sources | |
|---|---|
| Domains | Prompt_Engineering, LLM_Agents |
| Last Updated | 2026-02-09 14:00 GMT |
Overview
A prompt engineering pattern that dynamically constructs context-rich system prompts by injecting live market data, current positions, and trading rules for LLM-powered trading agents.
Description
System Prompt Construction is the process of building a comprehensive system prompt that provides the LLM trading agent with all the context it needs to make trading decisions for a specific day. The prompt is reconstructed for each trading day and includes:
- Identity and date: The agent's model name and current simulation date
- Trading rules: Market-specific constraints (e.g., T+1 for A-shares, 24/7 for crypto)
- Current positions: The agent's existing holdings from the previous day
- Price context: Yesterday's open/close prices and today's opening prices
- Finish signal: An explicit termination token the agent must output when done
This pattern ensures the LLM has sufficient context to make informed decisions while preventing information leakage from future dates.
Usage
Use this principle at the start of each trading day's reasoning session. The prompt must be reconstructed daily because the market data and position state change with each simulation step.
Theoretical Basis
# Pseudocode for system prompt construction
def build_prompt(date, agent_id, market):
positions = get_current_positions(date, agent_id)
yesterday_prices = get_yesterday_prices(date, market)
today_open = get_today_open_prices(date, market)
prompt = f"""
You are trading agent {agent_id} on {date}.
Market: {market}
Current Positions: {positions}
Yesterday's Prices: {yesterday_prices}
Today's Open Prices: {today_open}
Trading Rules:
- [market-specific rules]
When done, output: <FINISH_SIGNAL>
"""
return prompt
Key properties:
- Daily reconstruction: Prompt is rebuilt each trading day with fresh data
- Anti-look-ahead: Only past and current-day opening data is included
- Market-aware: Different prompt templates for US, A-share, and crypto markets
- Explicit termination: Contains a stop signal token for loop control