Sardine: A stock market where AI agents trade in real time
hackernews
|
|
📦 오픈소스
#ai 서비스
#ai 에이전트
#mastra
#실시간 거래
#주식 시뮬레이션
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
Sardine는 Mastra, TanStack Start 등을 기반으로 구축된 AI 주도의 실시간 주식 시장 시뮬레이션 플랫폼으로, 사용자가 종목 수와 에이전트 수 등을 직접 설정하여 트레이딩 터미널과 같은 환경을 구동할 수 있습니다. 이 시스템은 매칭 엔진을 통해 호가창을 처리하고 포트폴리오를 조정하며, WebSocket을 활용해 체결 내역이나 가격 차트 등을 대시보드로 실시간 스트리밍합니다. 특히 챗봇과 상호작용하여 가상의 시장 이벤트를 주입하고 AI 에이전트들의 반응을 관찰하는 기능을 제공하며, 알파카(Alpaca) 시장 데이터 연동 또는 로컬 시드 데이터를 통해 오프라인 개발도 지원합니다.
본문
Sardine is an AI-driven market simulation platform built with Mastra, TanStack Start, and a live trading-style dashboard. Sardine combines a configurable market simulator, Mastra-powered trading and research agents, a what-if chatbot, and a multi-panel dashboard for watching price action, order flow, and agent behavior in real time. Sardine is designed for running market simulation sessions that feel closer to a trading terminal than a toy demo: - Launch a session with configurable symbol count, agent count, tick timing, and trader mix. - Run Mastra trading, research, and chatbot agents against a live simulation loop and typed tools. - Stream watchlists, candlesticks, order book depth, time and sales, research notes, and agent events to the dashboard. - Bootstrap from Alpaca market data when credentials are available, or fall back to local seed prices for offline development. - Explore a curated local dev profile today, while keeping full S&P 500 ticker metadata scaffolded in code for larger-scale experiments. - Session-based simulations: each run persists its own symbols, tick settings, agent roster, and runtime state. - Mastra agent stack: shared trading, research, and chatbot agents adapt behavior through request context and tool calls. - Matching-engine workflow: orders flow through a limit-order-book engine, then into portfolio reconciliation and persistence. - What-if interaction loop: the chat API can inject events into a live session and observe how the market reacts over time. - Realtime monitoring: a separate WebSocket server broadcasts market, runtime, and agent activity to the dashboard. flowchart LR subgraph UI["Frontend (TanStack Start)"] Landing["Routes: / and /dashboard"] Session["Session dashboard: /dashboard/$sessionId"] ChatUI["Chat panel and dashboard widgets"] end subgraph App["App server"] Loaders["Session loaders and route handlers"] ChatAPI["/api/chat"] end subgraph Runtime["Simulation runtime"] Runner["src/server/sim-runner.ts"] Orchestrator["SimOrchestrator + SimClock"] Registry["AgentRegistry + batch scheduler + autopilot"] Match["MatchingEngine + limit order books"] WS["WebSocket server (:3001)"] end subgraph Mastra["Mastra"] Trading["tradingAgent"] Research["researchAgent"] Chatbot["chatbotAgent"] Tools["Tools: market data, portfolio, order, event injection, sim query, firecrawl, wait-and-observe"] end subgraph Data["Persistence and external services"] PG["Postgres + Drizzle + Mastra storage"] Alpaca["Alpaca market bootstrap"] Firecrawl["Firecrawl research scraping"] end Landing --> Loaders Session --> Loaders ChatUI --> ChatAPI ChatAPI --> Chatbot Chatbot --> Tools Loaders --> PG Session |"ws://localhost:3001"| WS Runner --> Orchestrator Runner --> Registry Orchestrator --> Match Runner --> PG Runner --> WS Registry --> Trading Runner --> Research Trading --> Tools Research --> Tools Tools --> PG Tools --> Alpaca Tools --> Firecrawl - A session is created from the dashboard and stored in Postgres with its symbol set, timing, and trader distribution. bun run sim picks up pending sessions, bootstraps prices from Alpaca when available, and falls back to local seeded market state otherwise.- Bootstrap logic creates the initial books, bars, portfolios, and namespaced agent instances for the session. - On each tick, the orchestrator advances simulated time, runs the active LLM cohort, applies autopilot directives for the rest, and releases research into the market. - Orders are processed through the matching engine, portfolio state is reconciled, and the updated session state is persisted. - The WebSocket server broadcasts runtime state, price bars, order book snapshots, trades, and agent events back to the dashboard. - The chatbot can inject events and query session state through /api/chat , closing the loop between operator input and simulated market behavior. git clone https://github.com/lightbearco/sardine.git cd sardine bun install cp .env.example .env.local Start with the values in .env.example , then add the additional variables called out in Environment. Sardine uses Postgres via Drizzle and Mastra storage. A Neon database works well for local development. bun run db:push Run the frontend and simulation worker together: bun run dev:full Or run them in separate terminals: bun run dev bun run sim - App UI: http://localhost:3000 - Realtime WebSocket server: ws://localhost:3001 Open /dashboard , create a session, and launch the simulation from there. | Command | Description | |---|---| bun run dev | Start the TanStack Start app on :3000 | bun run dev:full | Start the app and simulation worker together | bun run sim | Start the simulation runner and WebSocket server | bun run build | Build the production app | bun run preview | Preview the production build | | Command | Description | |---|---| bun run test | Run the full Vitest suite | bun run test:trading:fast | Run fast trading-agent and tool tests | bun run test:trading:live | Run the live trading-agent smoke test with real mod
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유