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.
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.
- 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 (日本語).
The application follows a simple yet powerful workflow:
- Data Fetching: Stock data is fetched from Yahoo Finance for the user-specified tickers and date range.
- Indicator Calculation: The selected technical indicators are calculated using the retrieved stock data.
- Visualization: A Plotly-based interactive candlestick chart is generated, overlaying the calculated indicators.
- 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.
- UI Rendering: The entire interface, including charts and AI-generated text, is rendered using Streamlit.
- Framework: Streamlit
- Data Source:
yfinancefor stock data - Charting:
plotlyfor interactive visualizations - LLM Integration:
openaiclient library connecting to OpenRouter.ai - LLM Model:
deepseek/deepseek-chat-v3-0324:free(by default) - Configuration:
python-dotenvfor environment variable management
It is recommended to use a Python version manager like pyenv to install Python 3.11.5, as specified in the .python-version file.
- Python 3.11.5
- Poetry (recommended for dependency management)
-
Clone the repository:
git clone https://github.com/your-username/AI-Stock-Analysis-Dashboard.git cd AI-Stock-Analysis-Dashboard -
Install dependencies using Poetry:
poetry install
Alternatively, if you are not using Poetry, you can install dependencies using pip:
pip install -r requirements.txt
-
Set up your environment variables: Create a
.envfile by copying the example file:cp .env-example .env
Next, obtain an API key from OpenRouter.ai and add it to your
.envfile:OPENROUTER_API_KEY="your-openrouter-api-key" -
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.
- 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.
- 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.
- 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.
- Review Summary:
- Go to the "Overall Summary" tab to see a consolidated table of recommendations for all analyzed stocks.
/
├── .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
This project is licensed under the MIT License. See the LICENSE file for details.