+
Skip to content

📊 A data-driven analyzer for both ETFs (0050, 0056, VOO, QQQ, VT, etc.) and stocks (TSLA, AAPL, …). It fetches real-time market data from authoritative sources, generates performance reports with charts, and links historical returns & drawdowns to major events — helping investors evaluate long-term holding strategies.

Notifications You must be signed in to change notification settings

Chihuah/stock-etf-analyzer

Repository files navigation

AI Investment Report Generator Banner

📊 AI Investment Report Generator (AI 投資報告生成器)

An advanced, AI-powered application that generates in-depth comparative analysis reports for a curated list of popular ETFs (0050, 0056, VOO, QQQ, VT) and stocks (TSLA, AAPL). Leveraging the power of the Google Gemini API, this tool provides quantitative metrics, qualitative insights, and tailored investment advice based on a user-defined time period.

中文簡介:
這是一款由 AI 驅動的進階投資分析工具,專為比較多個熱門 ETF (0050、0056、VOO、QQQ、VT) 與股票 (TSLA、AAPL) 而設計。它利用 Google Gemini API 的強大能力,根據用戶指定的日期區間,生成包含量化數據、質化分析以及個人化投資建議的深度報告。


🚀 Features

  • 🤖 AI-Powered Analysis: Utilizes the Google Gemini API (gemini-2.5-flash) to generate sophisticated financial analysis, ensuring high-quality and context-aware insights.
  • 📅 Custom Date Ranges: Allows users to select any historical date range for analysis, with convenient presets for "This Year," "Past 3/5/10 Years," and more.
  • 📈 Comparative Metrics: Visualizes key performance indicators like Annualized Return, Max Drawdown, and the latest price range (current price, interval high, interval low) using clear, interactive charts powered by Recharts.
  • 🌍 Event-Driven Context: Identifies and analyzes the impact of major historical events on each asset's performance within the selected timeframe.
  • 💡 Tailored Recommendations: Delivers a structured conclusion with specific, actionable advice for Conservative, Balanced, and Aggressive investor profiles.
  • ✨ Modern UI: A clean, responsive, and aesthetically pleasing interface built with React, TypeScript, and Tailwind CSS.

🧠 How It Works

  1. Date Selection: The user selects a start and end date for the analysis.
  2. Prompt Engineering: The application constructs a detailed prompt for the Gemini API. This prompt includes the list of assets to analyze, the precise date range, and instructions to perform calculations and qualitative analysis.
  3. Structured Output: A strict JSON schema is sent along with the prompt to instruct the AI to return data in a predictable, well-structured format, including annualized return, drawdown, current price, and in-range high/low values for every asset. This eliminates unreliable text parsing and ensures data integrity.
  4. AI Generation: The Gemini model processes the request, performing complex analysis to calculate financial metrics, research key historical events, and formulate a comprehensive conclusion.
  5. Dynamic Rendering: The application receives the structured JSON from the API and dynamically renders the complete report, populating the UI with a title, introduction, comparison charts, detailed asset breakdowns, and styled conclusion cards.

🛠️ Tech Stack

  • Frontend: React, TypeScript, Tailwind CSS
  • AI Model: Google Gemini API (@google/genai)
  • Charting: Recharts
  • Environment: Runs entirely in the browser using modern ES modules and an importmap. No Node.js backend or local build step is required.

🔑 Configuration

This application requires a Google Gemini API key to function.

  • The API key is accessed from the environment variable process.env.API_KEY.
  • When running in a supported environment like Google AI Studio, you must configure this key as a secret or environment variable in the project's settings. The application code will automatically pick it up.

📌 Roadmap

  • Allow users to input their own custom stock/ETF tickers for analysis.
  • Fix known issue: current/high/low price retrieval is unreliable; investigate calling a trusted execution runner to fetch authoritative quotes.
  • Implement a feature to export the generated report as a PDF document.
  • Add more performance metrics, such as Sharpe Ratio and Volatility.
  • Cache results to reduce API calls for identical requests.

🧩 Build Prompt

This project was originally built in Google AI Studio using the following prompt:

請幫我即時抓取 0050 、0056與 VT、VOO、QQQ 、AAPL、TSLA的各項數據,所有數據必須來自網路上的權威來源,嚴禁自行模擬或假設生成。重點包含:歷史年化報酬率、最大回撤,並整理成一份報告書,要有圖表且以圖像為主,同時結合實際數據與重大事件,佐證哪一個更適合長期持有。

To reproduce:

  • Open Google AI Studio
  • Click Build
  • Paste the above prompt
  • View the live app in AI Studio.

🧑‍💻 Contributor Guide

Originally built in Google AI Studio and now iterated on with OpenAI Codex support. Refer to AGENTS.md for repository guidelines covering structure, commands, style, testing, and PR expectations.


📜 License

This project is licensed under the MIT License – feel free to use, modify, and distribute.

About

📊 A data-driven analyzer for both ETFs (0050, 0056, VOO, QQQ, VT, etc.) and stocks (TSLA, AAPL, …). It fetches real-time market data from authoritative sources, generates performance reports with charts, and links historical returns & drawdowns to major events — helping investors evaluate long-term holding strategies.

Topics

Resources

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载