Daily Stock Analysis with Gemini AI: A Free Open‑Source Tool

Daily Stock Analysis Powered by Gemini AI

Welcome to the daily_stock_analysis project – a fully‑featured, open‑source solution for automated A‑Share analysis that runs for free on GitHub Actions or Docker. Built with Python 3.10+, it integrates multiple data providers, Gemini (Google AI Studio) for natural‑language market insights, and versatile notification channels.


What This Tool Offers

Feature Description
AI Decision Dashboard One‑sentence conclusions, precise buy/sell price points, and a checklist of conditions evaluated by Gemini.
Multi‑Dimensional Analysis Combine technical indicators, volume distribution, sentiment from news, and real‑time market quotes.
Market Review Daily snapshot of major indices, sector performance, and cross‑border capital flows.
Multiple Channels Enterprise WeChat, Feishu, Telegram, email, and any custom webhook (e.g., Discord, Slack, DingTalk).
Zero‑Cost Deployment Run on free GitHub Actions without paying for a server.
Extensible Architecture Plug in any OpenAI‑compatible API, add new data providers, or modify the notification logic with minimal code changes.

Tech Stack Overview

  • Python 3.10+ with pyproject.toml / requirements.txt.
  • Data Sources: AkShare (free), Tushare, Baostock, YFinance.
  • News Search: Tavily (free key) or SerpAPI as fallback.
  • AI Backend: Google Gemini (default), with optional OpenAI‑compatible APIs like DeepSeek, Claude, or locally hosted models.
  • Deployment: GitHub Actions (.github/workflows/daily_analysis.yml) or Docker Compose with a single docker-compose up -d.
  • Scheduler: Simple cron logic that triggers the analysis each weekday at 18:00 Beijing time.

Quick Start – GitHub Actions (Zero‑Cost)

  1. Fork the Repository – Click Fork in the upper‑right corner.
  2. Create Required Secrets – Navigate to Settings → Secrets → Actions and add:
    GEMINI_API_KEY          # (required)  Gemini key from Google AI Studio
    # OR
    OPENAI_API_KEY          # optional, if you prefer an OpenAI‑compatible endpoint
    OPENAI_BASE_URL         # optional – e.g., https://api.deepseek.com/v1
    OPENAI_MODEL            # optional – e.g., deepseek-chat
    WECHAT_WEBHOOK_URL      # optional – Enterprise WeChat
    FEISHU_WEBHOOK_URL      # optional – Feishu
    TELEGRAM_BOT_TOKEN      # optional – Telegram bot token
    TELEGRAM_CHAT_ID        # optional – Telegram chat id
    EMAIL_SENDER            # optional – sender email
    EMAIL_PASSWORD          # optional – app password
    EMAIL_RECEIVERS         # optional – comma‑separated list
    CUSTOM_WEBHOOK_URLS     # optional – any POST JSON webhook
    FEISHU_APP_ID           # optional – Feishu app id
    FEISHU_APP_SECRET       # optional
    FEISHU_FOLDER_TOKEN     # optional – Feishu folder key
    STOCK_LIST              # (required) list of tickers, e.g., 600519,300750,002594
    TAVILY_API_KEYS         # (recommended) for news search
    SERPAPI_API_KEYS        # optional 
    TUSHARE_TOKEN           # optional
    
  3. Enable the Workflow – Go to the Actions tab, click I understand my workflows, go ahead and enable them.
  4. Test Immediately – Select the “每日股票分析” workflow and click Run workflow.
  5. Celebrate – The workflow will build a Docker image, fetch data, run the analysis, and post the results to your specified channels.

Quick Start – Local or Docker Deployment

Use this method if you prefer a local sandbox or want to tweak the code.

# Clone & install
git clone https://github.com/ZhuLinsen/daily_stock_analysis.git
cd daily_stock_analysis
pip install -r requirements.txt

# Copy env example
cp .env.example .env
nano .env   # fill in values

# Run a full analysis
python main.py

# Only market review
python main.py --market-review

# Run scheduled task (cron inside the container)
python main.py --schedule

For Docker:

# Create config file
cp .env.example .env
nano .env

# Launch services
docker-compose up -d

# Tail logs
docker-compose logs -f


How the Analysis Works

  1. Data Fetch – Stock price, volume, MA5/MA10/MA20, volume distribution, and news headlines are sourced from the configured providers.
  2. AI Inference – The analyzer.py module feeds cleaned indicators and news into Gemini (or the selected OpenAI‑compatible model) and receives a concise decision summary, target and stop‑loss prices, and a compliance checklist.
  3. Market‑Reviewmarket_analyzer.py aggregates daily index moves, sector performance, and capital flows.
  4. Notificationnotification.py formats the dashboard and market review into Markdown or interactive cards and posts to every enabled channel.
  5. Schedulingscheduler.py and the GitHub Actions workflow ensure the job runs once per weekday at 18:00 local time.

Customization Ideas

Area Extension
Add a new data source Implement a new fetcher in data_provider/ and update config.py.
Use another AI model Pass OPENAI_API_KEY/BASE_URL/MODEL and skip GEMINI_* variables.
Change notification format Edit notification.py to output a custom card or embed charts.
Automate portfolio updates Create a STOCK_LIST file that the script watches for changes.
Deploy a web UI Add a FastAPI or Flask interface that serves the dashboard.

Roadmap Highlights

  • Custom Webhook & Push Services – Support for Pushover, Discord, Slack, and proprietary APIs.
  • Cross‑Market Expansion – Include HK, US, and EU market data.
  • Historical Backtesting – Run simulations against past data.
  • Web Dashboard – Real‑time analytics with live charts.
  • Community‑Driven Enhancements – Contributions for new data sources and models are very welcome.

How to Contribute

  • Fork and create a feature/bug‑fix branch.
  • Run tests (pytest) and lint (ruff).
  • Open a PR with a clear description and link to any relevant issue.
  • Reviewers will check for documentation updates and consistency with the codebase.

Final Thoughts

daily_stock_analysis is a modern, low‑friction toolkit for anyone looking to add AI‑driven market insights to their daily workflow. With zero hosting costs and a plug‑and‑play architecture, you can start receiving market dashboards in your corporate chat or inbox in minutes. Grab the repo, set your secrets, and watch the tool auto‑run every weekday.

Happy analyzing!

Original Article: View Original

Share this article