Skip to content

edk12564/stockbot

Repository files navigation

StockBot

A tool for collecting and analyzing financial news about companies using Yahoo Finance API, with integrated support for the DeepSeek LLM and investment report generation.

Features

  • Collects financial news articles from Yahoo Finance API via yfinance library
  • Stores the information in a persistent vector database (ChromaDB)
  • Enables semantic search for company-specific financial information
  • Extracts structured data from news articles including:
    • Article titles
    • URLs
    • Publishers
    • Content/summaries
    • Publication dates
  • Integrates with DeepSeek-r1 1.5B model via Ollama
  • Generates Warren Buffett-style investment reports for any ticker

Installation

  1. Clone this repository
  2. Ensure you have Python 3.10+ installed
  3. Install dependencies using uv:
uv sync
  1. Install Ollama (if not already installed):
curl -fsSL https://ollama.com/install.sh | sh

Usage

Stock News Collection

Run the main stockbot script:

uv run python src/stockbot.py

When prompted:

  1. Enter a company ticker symbol (e.g., AAPL, MSFT, TSLA)
  2. The system will fetch recent news about the company from Yahoo Finance
  3. The articles will be stored in a vector database
  4. You can then search for specific financial information using natural language queries

DeepSeek Model Integration

Run the DeepSeek model installer:

uv run python src/deepseek_test.py

This script will:

  1. Verify Ollama is running
  2. Pull the DeepSeek-r1 1.5B model
  3. Test the model with a sample prompt
  4. Display information about the model

Investment Report Generation

Run the investment report generator:

uv run python src/investment_report.py AAPL

This script will:

  1. Retrieve relevant news articles for the specified ticker from ChromaDB
  2. Format the articles into a context document
  3. Send a prompt to DeepSeek with the context and ticker information
  4. Generate a detailed investment report with Warren Buffett-style analysis
  5. Save the report to [TICKER]_investment_report.md

Investment Report Format

Reports follow a structured format defined in src/improved_prompt.md with:

  • Company Overview
  • Financial Analysis
  • Competitive Position
  • Management Assessment
  • Risk Factors
  • Valuation
  • Investment Recommendation (Buy/Hold/Sell)

Customizing the Prompt

You can modify the investment report generation by editing:

  • src/improved_prompt.md - Primary prompt template with structured format
  • company-info.md - Fallback prompt template

The system will first try to use the improved prompt, then fall back to the original if needed.

Example Searches

After loading news for a company, you can search for:

  • "lawsuit" - Find news about legal issues
  • "financial results" - Find articles about earnings
  • "new products" - Find announcements about products
  • "management changes" - Find news about executive shuffles

Technical Implementation

The system consists of several main components:

  1. YahooFinanceNewsCollector: Retrieves news articles for a given ticker symbol using yfinance API
  2. VectorDatabase: Stores and indexes articles using ChromaDB for semantic search
  3. NewsArticle: Data structure for representing financial news articles
  4. DeepSeek Integration: Connects to Ollama for accessing DeepSeek-r1 1.5B model capabilities
  5. InvestmentReportGenerator: Creates detailed investment analysis reports based on collected news

Data Storage

The vector database is stored in a directory called chroma_db in the project root. This allows for persistent storage and retrieval of financial news data across multiple runs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors