Inspiration

The inspiration for this project comes from my personal experience with futures trading. After three months of paper trading before jumping into real trading, I've learned that trading is largely about psychology. There were days of revenge trading, careless entries, and risky sizing. Throughout my journey, I wished for a trading companion that could provide extra confidence and keep an eye on my decision-making process—not to make decisions for me, but to support them with structured analysis and guardrails. Like a weather reporter for surfers - when the weather is good, you surf; when the weather is bad, you don't. TraderPal helps you think better, but the decision is always yours.

What it does

AI Trading Plan Agent is a deterministic market snapshot generator and trading plan support system. Users input the instrument they're interested in trading, and the system:

  1. Captures a market snapshot using technical indicators (VWAP, EMA, ADX, ATR) from live market data
  2. Generates a Zoo Report that indicates market bias (bullish 🐂, bearish 🐻, or consolidation 🦀) with confidence levels
  3. Creates a structured trading plan with entry points, stop-losses, targets, and position sizing recommendations
  4. Supports stress testing with scenarios like fake breakouts, VWAP rejections, and ATR spikes
  5. Optional Critic pass for plan refinement and risk validation

The system uses Gemini 3 to generate validated, structured JSON plans that serve as decision support—helping traders stay disciplined and avoid emotional trading mistakes.

How we built it

  • Frontend: Next.js 16 with React 19, Tailwind CSS for a modern, responsive UI
  • Backend: Next.js API routes with Zod schema validation for type-safe request/response handling
  • AI Engine: Google Gemini 3 API with a multi-agent architecture:
    • Strategist Agent: Generates initial trading plans from market snapshots
    • Critic Agent: Reviews and refines plans for logic and risk management
    • Report Agent: Analyzes market bias and confidence levels
  • Market Data: Yahoo Finance API for live futures data (supports 30+ futures contracts)
  • Technical Indicators: Custom implementations of EMA, ATR, ADX, and VWAP calculations
  • PDF Export: jsPDF for generating downloadable trading plan reports

The architecture emphasizes separation of concerns: providers (data), indicators (calculations), LLM (AI), and plan orchestration layers work independently, making it easy to swap data sources or enhance AI capabilities.

Challenges we ran into

  1. Market Data Access: Futures trading is a relatively new market, and there aren't many live platforms that support APIs, and even fewer that are developer-friendly. We eventually found Yahoo Finance, though the trade-off is a 15-minute data delay. At this stage, this is acceptable because as a decision supporter (not a decision maker), the agent aims to show users a macro view of the market and potential direction.

  2. JSON Validation & Repair: Getting Gemini to return consistently valid JSON for complex trading plans was challenging. We implemented a repair mechanism that attempts to fix malformed JSON when validation fails, ensuring robust plan generation.

  3. PDF Generation: Initially tried using html2canvas to convert the UI to images, but encountered CSS parsing errors with modern Tailwind color functions. We pivoted to jsPDF for a more reliable, data-driven PDF generation approach.

  4. Multi-Agent Coordination: Orchestrating three different AI agents (Strategist, Critic, Report) while maintaining clear separation of concerns and error handling required careful design.

Accomplishments that we're proud of

  • Multi-agent AI system that generates structured, validated trading plans with optional refinement
  • Comprehensive symbol support for 30+ futures contracts across equity indices, energy, metals, rates, grains, and more
  • Stress testing capabilities that help traders understand how plans perform under adverse conditions
  • Beautiful, intuitive UI with toggleable cards, expandable descriptions, and professional PDF exports
  • Robust error handling with JSON repair mechanisms and graceful fallbacks
  • Type-safe architecture using Zod schemas throughout, catching errors at compile-time and runtime

What we learned

  • The power of structured AI outputs: Using Zod schemas to validate Gemini responses ensures reliability and catches errors early
  • Multi-agent design patterns: Separating concerns (Strategist, Critic, Report) makes the system more maintainable and allows for independent improvements
  • Market data realities: Free-tier APIs have limitations, and sometimes the best solution is finding the right trade-offs (15-min delay vs. paid subscriptions)
  • User experience matters: Even for technical tools, a polished UI with clear visual hierarchy and helpful descriptions significantly improves usability
  • Psychology in trading tools: Building a "trading companion" rather than an automated system respects the human decision-making process while providing guardrails

What's next for AI Trading Plan Agent

  • Real-time data integration: Upgrade to a premium data provider for lower-latency, more accurate market data
  • Historical backtesting: Allow users to test plans against historical market data to validate strategy effectiveness
  • Portfolio-level analysis: Extend beyond single-instrument plans to consider correlations and portfolio risk
  • Custom indicator support: Allow users to add their own technical indicators to the snapshot
  • Plan execution tracking: Help users track how well their executed trades align with generated plans
  • Mobile app: Bring the trading companion to mobile devices for on-the-go market analysis
  • Community features: Share and discuss plans with other traders (with appropriate disclaimers)

Built With

  • google-gemini-3-api
  • jspdf
  • next.js
  • react
  • tailwind-css
  • typescript
  • yahoo-finance-api
  • zod
Share this project:

Updates