byahmedali/stockmarketagent
A modern, AI-powered stock market dashboard and chat agent for real-time and historical analysis of S&P 500 stocks, built with Streamlit, LangGraph & Yahoo Finance.
Stock Market AI Agent / Dashboard
A modern, AI-powered stock market dashboard and chat agent for real-time and historical analysis of S&P 500 stocks, built with Streamlit, LangGraph & Yahoo Finance.
Features
- Real-time and historical stock data fetching using YFinance
- AI-powered stock analysis, chat, and recommendations
- Interactive Streamlit dashboards for S&P 500 and individual stocks
- Automated local data storage and updates
- Technical indicators, financial ratios, and analyst recommendations
- Latest news and sentiment integration
Project Structure
app.py— Streamlit app entry point and navigation.pages/— Chat agent, S&P 500 monitor, and symbol monitor dashboards.- Chat Agent: Uses
deepseek-r1-distill-llama-70bLLM, equipped with a few tools around Yahoo Finance API provided by Agno as well as some custom tools. - S&P 500 Monitor: Uses automated logic to rank stocks with most significant changes in stock prices for a specified period. Logic flow:
- Loading data from local files.
- Calculating various changes such as 1h, 6h, 12h, 2d.
- Ranking top n stock based on based on highest changes.
- Symbol Monitor: Can be used to explore trends in a single stock.
- Chat Agent: Uses
data_fetcher.py— Automated data download and update logic that keeps running in background. Currently, it only fetches last5 daysof data, with1 minuteof interval during open-market times.tools.py— LangChain tools for stock analysis, news, and calculating changes in stock prices.S&P.json— List of S&P 500 companies and tickers.data/— Local storage for stock data (organized by symbol).
Prerequisites
Installation
-
Clone this repository:
git clone https://github.com/byahmedali/stockmarketagent.git cd stockmarketagent -
Create a
.envfileGROQ_API_KEY=YOUR_GROQ_API_KEY SERPER_API_KEY=YOUR_SERPER_API_KEY -
Set up a virtual environment
a. Create a new virtual environment:
py -3.10 -m venv venvb. Activate the virtual environment:
Linux/macOS:source venv/bin/activateWindows:venv\Scripts\activate.batc. Confirm you're using the newly created environment:
If you see environment name
(venv)at the beginning of your command prompt, it confirms that you're using the newly created virtual environment. -
Install required dependencies:
pip install -r requirements.txt
Usage
- Run
data_fetcher.pyin background:python data_fetcher.py
Note: On first launch, data fetcher will take some time.
- Open a new terminal in the same environment and start the Streamlit app:
streamlit run app.py
- Open your browser and go to http://localhost:8501
Navigate between the Chat Agent, S&P 500 Monitor, and Symbol Monitor from the sidebar.
Running with Docker
-
Build the Docker image:
docker build -t stockagent . -
Run the container:
docker run -p 8501:8501 --env-file .env stockagentNote: It is essential to provide API keys when running the docker container.
-
Open your browser and go to http://localhost:8501
Contributing
New idea and feature contributions are always welcome!
Acknowledgments
- This work is a part of ATS's projects catalog.
- Yahoo Finance & Agno contributors
- Python & LangChain community
