Skip to content

ethan-tsai-tsai/AI-Stock-Analysis-Dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Powered Stock Technical Analysis Dashboard

This is an interactive web application built with Streamlit that provides technical analysis for stocks from US and Taiwan markets. It leverages a Large Language Model (LLM) to generate detailed analyses and recommendations based on a variety of technical indicators.

Disclaimer

This program is for educational and demonstrational purposes only. It showcases the application of Large Language Models (LLMs) in financial technical analysis and does not constitute any investment advice. Financial markets are complex and volatile; LLMs can make mistakes. All analysis results are for reference only. Please conduct your own thorough research or consult with a qualified financial advisor before making any investment decisions.

Features

  • Multi-Market Support: Analyze stocks from both the US (e.g., AAPL, MSFT) and Taiwan (e.g., 2330, 2317) markets.
  • Rich Technical Indicators: Visualize and analyze a wide range of indicators:
    • Trend Indicators: SMA, EMA, Bollinger Bands, VWAP
    • Momentum Indicators: RSI, MACD, ROC, CCI
  • Customizable Analysis: Freely add, remove, and customize the parameters for each technical indicator.
  • AI-Powered Analysis: Get detailed, human-like analysis and actionable recommendations (from 'Strong Buy' to 'Strong Sell') generated by an LLM.
  • Interactive Charts: Explore stock data with interactive candlestick charts powered by Plotly.
  • Multilingual Interface: The UI supports English, Traditional Chinese (繁體中文), Simplified Chinese (简体中文), and Japanese (日本語).

How It Works

The application follows a simple yet powerful workflow:

  1. Data Fetching: Stock data is fetched from Yahoo Finance for the user-specified tickers and date range.
  2. Indicator Calculation: The selected technical indicators are calculated using the retrieved stock data.
  3. Visualization: A Plotly-based interactive candlestick chart is generated, overlaying the calculated indicators.
  4. LLM Analysis: A detailed prompt, including the indicator data, is sent to the LLM via the OpenRouter API. The model provides a structured JSON response containing a recommendation and a detailed justification.
  5. UI Rendering: The entire interface, including charts and AI-generated text, is rendered using Streamlit.

Technology Stack

  • Framework: Streamlit
  • Data Source: yfinance for stock data
  • Charting: plotly for interactive visualizations
  • LLM Integration: openai client library connecting to OpenRouter.ai
  • LLM Model: deepseek/deepseek-chat-v3-0324:free (by default)
  • Configuration: python-dotenv for environment variable management

Installation and Setup

It is recommended to use a Python version manager like pyenv to install Python 3.11.5, as specified in the .python-version file.

Prerequisites

  • Python 3.11.5
  • Poetry (recommended for dependency management)

Steps

  1. Clone the repository:

    git clone https://github.com/your-username/AI-Stock-Analysis-Dashboard.git
    cd AI-Stock-Analysis-Dashboard
  2. Install dependencies using Poetry:

    poetry install

    Alternatively, if you are not using Poetry, you can install dependencies using pip:

    pip install -r requirements.txt
  3. Set up your environment variables: Create a .env file by copying the example file:

    cp .env-example .env

    Next, obtain an API key from OpenRouter.ai and add it to your .env file:

    OPENROUTER_API_KEY="your-openrouter-api-key"
    
  4. Run the application: Using Poetry:

    poetry run streamlit run main.py

    Using pip:

    streamlit run main.py

    The application will open in your web browser.

Usage Guide

  1. Configure Settings: Use the sidebar to configure your analysis.
    • Language: Select your preferred language for the UI.
    • Market Type: Choose between "US Stocks" and "TW Stocks".
    • Stock Tickers: Enter one or more stock tickers, separated by commas.
    • Date Range: Select the start and end dates for the analysis.
  2. Add Indicators:
    • Click the "+ Add Indicator" button in the sidebar.
    • Select an indicator from the dropdown menu.
    • Adjust its parameters (e.g., period, fast/slow period) as needed and click "Add Indicator".
    • You can add multiple indicators. They will appear in the "Selected Indicators" list.
  3. Generate AI Analysis:
    • Once the stock data and charts are loaded, click the "Generate AI Analysis for [Ticker]" button below each chart.
    • The application will display the AI's detailed justification and recommendation.
  4. Review Summary:
    • Go to the "Overall Summary" tab to see a consolidated table of recommendations for all analyzed stocks.

Project Structure

/
├── .env-example          # Example environment variables file
├── .gitignore            # Git ignore file
├── .python-version       # Specifies the recommended Python version
├── main.py               # Main application entry point
├── pyproject.toml        # Project metadata and dependencies for Poetry
├── README.md             # This file
├── requirements.txt      # Project dependencies for pip
└── src/
    ├── analysis.py       # Handles LLM API calls and analysis logic
    ├── config.py         # Manages configuration and API keys
    ├── data_fetcher.py   # Fetches stock data from yfinance
    ├── indicators.py     # Calculates technical indicators and creates charts
    ├── translations.py   # Contains UI translations for multiple languages
    └── ui.py             # Defines the Streamlit user interface

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

AI Stock Analysis Dashboard - A Streamlit web app for technical stock analysis with AI-powered recommendations. Supports US/TW markets, multiple technical indicators, and multilingual interface (EN/ZH/JP).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages