This tool uses Ollama with the deepseek-r1:7b model to analyze stocks and provide investment recommendations.
- Technical analysis: Evaluates price movements, trends, and technical indicators
- Market analysis: Analyzes sector performance, market cap, and other market factors
- News analysis: Examines recent news related to the stock
- Final recommendation: Combines all analyses to provide an investment recommendation
-
Make sure you have Python 3.8+ installed:
python3 --version
-
Run the installation script (creates a virtual environment automatically):
chmod +x install.sh ./install.sh
This script will:
- Create a Python virtual environment named
venv - Activate the virtual environment
- Install Ollama
- Install all required Python packages
- Create a Python virtual environment named
-
Start Ollama server in a separate terminal window:
# In a separate terminal or tab: ollama serve -
In another terminal window, pull the deepseek model:
# In another terminal or tab: ollama pull deepseek-r1:7b -
For future sessions, activate the virtual environment before running:
source venv/bin/activate
-
Make sure your virtual environment is activated:
source venv/bin/activate -
Ensure the Ollama server is running in a separate terminal:
# In a separate terminal window ollama serve -
Run the analysis:
python stock_analysis.py <STOCK_SYMBOL>
For example:
python stock_analysis.py AAPL # Analyze Apple Inc.
python stock_analysis.py MSFT # Analyze Microsoft
python stock_analysis.py GOOG # Analyze Google/AlphabetYou can use country-specific suffixes for non-US stocks:
python stock_analysis.py INFY.NS # Analyze Infosys (India)
python stock_analysis.py 9984.T # Analyze SoftBank (Japan)The tool uses a workflow graph with the following nodes:
- Technical Analysis: Calculates indicators like SMA, RSI, and volume trends
- Market Analysis: Gathers information about sector, market cap, and PE ratio
- News Analysis: Processes recent news about the stock
- Recommendation: Combines all analyses to generate a final recommendation
The LLM (deepseek-r1:7b) processes each step and provides detailed analysis.
- Python 3.8 or higher
- Ollama installed (https://ollama.com)
- Required Python packages:
- langchain
- langchain-core
- langgraph
- yfinance
- langchain-openai
- An internet connection to fetch stock data
-
If you get permission errors when running Ollama, you might need to run:
sudo chmod +x /usr/local/bin/ollama
-
If Ollama server exits with an error (Exit 1), try running it in a dedicated terminal window without the background process:
# In a terminal dedicated to this purpose: ollama serve -
If you have issues with the virtual environment, you can create it manually:
python3 -m venv venv source venv/bin/activate pip install langchain langchain-core langgraph yfinance langchain-openai
The output provides a comprehensive analysis of the stock, including:
- Technical analysis with trend analysis and key signals
- Market analysis with sector performance and risk assessment
- News analysis with sentiment and potential impact
- Final recommendation with confidence score and target price range