How mingyuj666/stockagent works
StockAgent is a simulated stock-trading environment in which LLM-driven trader agents respond to market information, place orders, and interact through a daily forum. The principal workflow is launched by main.py: initialize the simulation, apply scheduled events and loan handling, collect agent decisions, match orders, update prices, and record results. Agent prompts and response validation support those decisions; stock state and agent portfolios represent market state. The README also describes initial, trading, post-trading, and specific-event phases. The graph follows the sampled code and README; some phase details and the implementation of Secretary were not sampled.
Main entry points: main.py Simulation Runner · agent.py Trader Agent · stock.py Stock State · util.py Simulation Configuration
Components 15
Simulation Control
- Simulation Runner
main.py - Initial Phase
main.py - Trading Phase
main.py - Post-Trading Phase
main.py - Special Events
main.py
Trading Domain
- Order Matching
main.py - Stock State
stock.py
Agent Decisions
- Trader Agent
agent.py - Decision Prompts
prompt/agent_prompt.py - Decision Validation
secretary.py
Configuration and Records
- Simulation Configuration
util.py - Simulation Records
record.py - Logging
log/custom_logger.py
Other components
- Simulation User
- LLM Provider
Connections 18
- Simulation User → Simulation Runner: starts run
README.md - Simulation Runner → Initial Phase: initializes
main.py - Simulation Runner → Trading Phase: runs sessions
main.py - Simulation Runner → Post-Trading Phase: runs post-day
README.md - Simulation Runner → Special Events: applies events
main.py - Simulation Runner → Order Matching: dispatches orders
main.py - Order Matching → Trader Agent: updates holdings
main.py - Order Matching → Stock State: adds deals
main.py - Trading Phase → Trader Agent: requests plans
main.py - Trading Phase → Stock State: updates prices
main.py - Trading Phase → Simulation Records: writes records
main.py - Post-Trading Phase → Trader Agent: requests posts
README.md - Trader Agent → Decision Prompts: formats decisions
agent.py - Trader Agent → Decision Validation: checks responses
agent.py - Trader Agent → LLM Provider: sends prompts
agent.py - Initial Phase → Simulation Configuration: loads settings
main.py - Stock State → Simulation Configuration: reads reports
stock.py - Trading Phase → Logging: logs activity
main.py