This project is an AI Stock Research Assistant, a web application powered by Streamlit, designed to help novice investors with stock research and portfolio generation. It provides an interactive, user-friendly interface to access functionalities that were previously command-line based. Users can dynamically generate investment portfolios and perform technical analysis on individual stocks.
The application offers two main modes accessible via a sidebar navigation:
- Portfolio Generator:
- Allows users to specify an investment amount.
- Select preferences for investing in high-dividend stocks, growth stocks, and index funds.
- Generates a diversified stock portfolio based on these inputs and historical price data.
- Displays the suggested portfolio, including number of shares, mean prices, current prices, and total portfolio value.
- Stock Analyzer:
- Enables users to input a stock ticker and a start date for analysis.
- Performs technical analysis, including Moving Average (MA) strategies and Relative Strength Index (RSI) calculations.
- Visualizes stock performance with charts for price, MAs, buy/sell signals, MA strategy wealth simulation vs. Buy & Hold, and RSI.
- Provides a summary of backtesting results, comparing MA strategy wealth against a Buy & Hold strategy.
- Customizable Stock Lists: Stock choices for portfolio generation can be easily modified by editing the
config.jsonfile. - Modular Codebase: The underlying logic is organized into reusable Python modules.
- Ensure you have Python 3.x installed.
- Clone the repository (if you haven't already).
- Install the required dependencies. This includes
streamlit,yfinance,pandas,matplotlib, andnumpy.pip install -r requirements.txt
To run the AI Stock Research Assistant web application:
- Navigate to the root directory of the project in your terminal.
- Execute the following command:
streamlit run app.py
- Your default web browser should automatically open to the application's UI.
Once the application is running, you can interact with it through the web interface:
-
Mode Selection: Use the sidebar navigation menu to choose between "Portfolio Generator" and "Stock Analyzer" modes.
-
Portfolio Generator Mode:
- Inputs:
- Enter the total amount of money you wish to invest.
- Select checkboxes for your preferred investment categories (high dividend, growth, index funds).
- Click the "Generate Portfolio" button.
- Outputs:
- A table displaying the generated portfolio (Stock, Shares, Mean Price, Current Price).
- Metrics showing the total portfolio value based on mean prices and current prices.
- Inputs:
-
Stock Analyzer Mode:
- Inputs:
- Enter the stock ticker symbol you want to analyze (e.g., "AAPL", "GOOG").
- Select the start date for the historical data analysis.
- Click the "Analyze Stock" button.
- Outputs:
- Charts visualizing:
- Stock closing prices with moving averages and buy/sell signals.
- Comparison of wealth generated by the MA strategy versus a Buy & Hold strategy.
- Relative Strength Index (RSI) with overbought/oversold indicators.
- A summary of backtesting results, including final wealth and total profit for both strategies.
- Charts visualizing:
- Inputs:
(Note: The original command-line scripts main.py and research_stock.py are still present but the primary way to use this tool is now through the Streamlit application app.py.)
The stock lists used by the "Portfolio Generator" mode are managed in the config.json file located in the root directory. This allows you to customize the universe of stocks considered for investment without modifying the Python code.
The config.json file contains three main keys:
"dividend_stocks": A list of stock tickers considered high-dividend."growth_stocks": A list of stock tickers considered growth stocks."index_funds": A list of tickers for index funds.
To customize these lists:
- Open
config.jsonin a text editor. - Modify the lists by adding or removing stock tickers (strings) as desired.
- Save the file. The changes will be reflected the next time you use the Portfolio Generator feature in the web application.
Example config.json structure:
{
"dividend_stocks": ["TICKER1", "TICKER2", ...],
"growth_stocks": ["TICKER3", "TICKER4", ...],
"index_funds": ["TICKER5", "TICKER6", ...]
}Unit tests are included to ensure the reliability of the underlying utility functions. To run the tests:
- Navigate to the root directory of the project in your terminal.
- Run the following command:
This will automatically discover and run all tests within the
python -m unittest discover tests
testsdirectory.
(As an AI Worker, I am unable to generate or embed screenshots directly into this README.md. When running the application, you will see an interactive interface with input fields, buttons, and data/chart displays for each mode.)
Disclaimer: Investing in the stock market involves risk. This tool is for informational and educational purposes only and should not be considered financial advice.