Inspiration

Most trading platforms are still “UI-first”: you click through menus, translate your intent into form fields, double-check tickers, and repeat. We wanted to flip that workflow: start with natural language, keep every decision grounded in real account context (positions, buying power, open orders), and then turn intent into safe, structured actions.

StonksGPT was inspired by a simple question: what if trading felt like talking to a copilot?
“Buy $50 of NVDA.” “Close 10% of my TSLA position.” “Compare AAPL vs MSFT and explain the move.” "Loop up the 3 most traded crypto by volume this month. Then place an order for $100 each." Instead of hunting for buttons, the assistant should resolve symbols, fetch market/account data, and execute the exact tool call (with guardrails!) like paper trading by default and constrained, auditable tool usage.

What it does

  • Natural-language -> trading: Chat with StonksGPT to place/inspect orders, view positions, check account balances, and manage watchlists using plain English.
  • Market charts + comparisons: Pull price bars and render interactive line/candlestick charts across timeframes, including multi-ticker comparisons.
  • Portfolio & account analytics: View positions, allocation breakdowns, and portfolio equity/P&L history.
  • Market news: Browse trending news, portfolio news, and watchlist news (with watchlist auto-sync based on your current positions).
  • Sessions: Create trading sessions and persist chat history per session.
  • Voice experience: Optional voice call overlay with real-time speech-to-text, plus text-to-speech playback and spoken session recaps.

How we built it

  • Frontend (React): Built a responsive dashboard in React (Vite) with TanStack Query for fetching/caching, Tailwind + shadcn/ui for UI, and lightweight-charts for fast, interactive market charts.
  • Backend (Express.js): Implemented an Express API that bridges the UI to the agent + tooling layer, with practical timeouts, caching, and predictable JSON responses.
  • MCP + Dedalus Labs (agentic tool-calling): We wrapped Alpaca functionality behind MCP tools and used the Dedalus Labs SDK (with the Dedalus Auth standard) to run an intent -> tool selection -> validated JSON args -> tool results -> response loop. We also deployed an MCP server to Dedalus Labs so tools can be accessed in a hosted, secure, consistent way.
  • News via API: Implemented a real news pipeline using the MarketAux News API (and merged/deduped results where needed), with endpoints for symbol, portfolio, and watchlist-based feeds.
  • Token cost efficiency (1M+ token prompts): As context grew (long sessions + tool outputs), prompts could explode to \(10^6+\) tokens if naïvely replayed. We used Gemini for token compression/summarization so the agent keeps only the decision-critical context while staying fast and cost-efficient.
  • Voice (ElevenLabs): Added ElevenLabs TTS for spoken playback and a WebSocket bridge to ElevenLabs realtime STT for voice calls.

Challenges we ran into

  • Safe execution: Turning casual language into trading actions requires strict boundaries—tools must be structured, arguments must be validated, and the assistant must stay grounded in real account state.
  • Token blow-ups + cost: Large histories and verbose tool outputs can create \(10^6+\) token prompts, which are slow and expensive. Compression helped, but required careful tuning so we didn’t lose critical constraints.
  • Latency & rate limits: LLM calls, web research, and news requests can be slow or rate-limited; we added caching, timeouts, and fallback behavior to keep the UX responsive.
  • Parsing tool outputs: Some tool results arrive as formatted text or JSON strings, so we had to robustly parse symbols, bars, watchlists, and portfolio history.
  • Voice streaming complexity: Real-time STT involves streaming audio chunks, handling partial vs final transcripts, and keeping UI state stable during calls.

Accomplishments that we're proud of

  • End-to-end natural-language trading with an agent that can safely call real tools (account/positions/orders/watchlists) instead of hallucinating actions.
  • A polished dashboard: charts, news, portfolio analytics, sessions, and voice, all working together as one product.
  • Performance wins: caching/prefetching for charts and token compression for the agent made the experience feel dramatically faster.
  • Hosted MCP on Dedalus Labs with Dedalus Auth for secure tool access in a deployable environment.

What we learned

  • LLMs are best when constrained: “Tools + schemas” beats free-form text when money is on the line.
  • Determinism matters: keep data pipelines (charts, transformations) structured and predictable; use LLMs for language tasks (summaries, explanations, compression).
  • Token efficiency is a product feature: compression and context hygiene directly impact speed, reliability, and cost.
  • Great UX needs systems thinking: agent logic, caching, API design, and UI all have to cooperate to feel seamless.

What's next for StonksGPT

  • Richer safety rails: pre-trade confirmations, spending limits, “dry-run” previews, and stricter validations around market status and order parameters.
  • Better long-term memory: move beyond localStorage to real persistence so sessions and preferences follow users across devices.
  • Smarter insights: portfolio-aware news ranking, impact summaries, and daily “what changed?” briefings.
  • Alerts & automation: guardrailed triggers (price/news/portfolio events) with human-in-the-loop approvals.
  • More coverage: deeper analytics (risk, diversification, scenario testing) and broader asset support while keeping the interface simple.

Built With

Share this project:

Updates