An AI-powered investment analysis tool that leverages simple ReAct AI agent flow framework and financial analysis techniques to provide comprehensive portfolio insights. This intelligent agent helps investors make data-driven decisions by offering deep portfolio risk assessment, stock profiling, and personalized recommendations.
- Stock Risk Profiling: Detailed risk assessment for individual stocks, including volatility, market cap, and return potential.
- Portfolio Diversification Analysis: Breakdown of sector allocation and risk levels within a given portfolio.
- Expected Return Calculation: Estimation of annual returns based on historical stock performance.
- Intelligent Portfolio Adjustments: Personalized recommendations aligned with user's risk tolerance.
- Interactive Web Interface: User-friendly Streamlit application for easy interaction with the AI agent.
The Investment Portfolio Analysis AI Agent is built on the ReAct (Reasoning and Action) framework, which combines the strength of large language models with a structured approach to problem-solving. Here's the workflow:
- Thought: The agent analyzes the user's query and formulates a plan of action.
- Action: Based on the thought, the agent selects and executes an appropriate tool or API call.
- Observation: The agent observes and interprets the results of the action.
- Repeat: This cycle continues until the agent has gathered enough information to provide a comprehensive answer.
The ReAct framework can be extended to incorporate specialized tools:
- Tool Definition: Each tool (e.g., stock risk profiler, portfolio analyzer) is defined with clear inputs and outputs.
- Tool Selection: The agent learns to choose the most appropriate tool based on the current context and user query.
- Tool Execution: The selected tool is called with the necessary parameters.
- Result Integration: The agent incorporates tool outputs into its reasoning process for the final response.
This extension allows the agent to leverage specific financial analysis functions while maintaining a flexible, language-model-driven interaction flow.
- Backend: Python
- AI Model: Groq API
- Frontend: Streamlit
- Key Libraries:
- Groq
- python-dotenv
- Logging
- JSON processing
- Dataclasses
- Python 3.8+
- Groq API Key
- Clone the repository
git clone https://github.com/yourusername/investment-portfolio-ai.git
cd investment-portfolio-ai
- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install dependencies
pip install -r requirements.txt
- Set up environment variables
- Create a
.env
file - Add your Groq API key:
GROQ_API_KEY=your_groq_api_key
- Optionally you can add file paths to stock risk json file and system prompt
STOCK_DATA_PATH=your_stock_data_json_file_path
SYS_PROMPT_DATA_PATH=your_system_prompt_data_path
streamlit run streamlit_app.py
- "Get risk profile for NVDA stock"
- "Analyze a portfolio with 40% AAPL, 30% GOOGL, 30% SPY"
- "Calculate expected return for a portfolio"
- "Recommend adjustments for a portfolio with specific risk tolerance"
The AI agent uses a ReAct (Reasoning and Acting) framework to:
- Understand the user's investment query
- Choose appropriate financial analysis tools
- Generate data-driven insights and recommendations
- FinancialTools: Comprehensive analysis methods
- Agent: Intelligent interaction and tool selection
- Streamlit Interface: User-friendly web application
Investment involves risks. This tool provides insights and should not be considered definitive financial advice. Always consult with a financial professional before making investment decisions.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
file for more information.
- Groq for providing the API used in this project.
- Streamlit for the excellent web app framework.
- Contributors and maintainers of the open-source libraries used in this project.
Feel free to reach out for collaboration, questions, or potential opportunities! I'm always excited to discuss
- π§ Intelligent AI Agents
- π Risk Analysis & Financial Technology
- π€ Machine Learning Solutions
- π AI-Driven Decision Support Systems