Skip to main content

AI-powered terminal stock analyzer with pluggable LLM providers

Project description

StockSensei 📈

PyPI version Monthly Downloads Python 3.13+

StockSensei is an intelligent, AI-powered terminal CLI application that acts as your personal expert financial analyst — running entirely inside your terminal. Built with Python, LangChain, and yfinance, it lets you query real-time stock data, compare companies, render structured terminal visuals, and read market news using plain natural language. No browser. No dashboard. Just your terminal.


✨ Features

  • 🖥️ Runs Entirely in Your Terminal — A first-class command-line experience built for developers and traders who live in the terminal. Launch it globally with one command from any directory.
  • 💬 Natural Language Interaction — Ask questions the way you think: "Is NVDA a better buy than AAPL right now?" or "Show me Tesla's trend over the last 3 months."
  • 📊 Structured Visual Blocks — Cards, bars, tables, sparklines, and news lists are rendered from a structured JSON output contract — not fragile model-authored markdown.
  • 📋 Deterministic Terminal Visuals — Comparison tables and stock snapshots render consistently with rich — no more ugly pipe characters or misaligned columns.
  • 📡 Real-Time Market Data — Live prices, daily % changes, market caps, P/E ratios, 52-week highs/lows, and more via yfinance.
  • 📰 News Integration — Fetch the latest headlines for any stock or company.
  • 🧠 Conversational Memory — The agent remembers context within your session, so follow-up questions just work.
  • 🧱 JSON Output Contract — The AI returns a structured response schema with a message plus ordered UI blocks, making rendering and fallback behavior safe and predictable.
  • ⚡ Animated Status Feedback — StockSensei shows a single animated status line (with tool-specific messages) while it works — no cluttered logs.
  • ⌨️ Slash-Command Completion — In interactive terminals, typing / opens a styled autocomplete dropdown for /help, /models, /clear, and /quit, powered by prompt-toolkit.
  • 🤖 Multi-Provider AI Support — Choose from OpenAI, Anthropic, Gemini, Groq, DeepSeek, OpenRouter, Ollama, or any custom OpenAI-compatible endpoint. Switch providers mid-session with /models.
  • 🔐 Zero-Config Setup — On first launch, StockSensei walks you through picking a provider and saving your API key globally — so you never have to set it again.

📸 Visual Examples

Here are a few examples of StockSensei's terminal UI in action:

StockSensei Demonstration 1 StockSensei Demonstration 2 StockSensei Demonstration 5


🛠️ Tech Stack

Layer Technology Purpose
Language Python >= 3.13 Core runtime
Financial Data yfinance Real-time prices, OHLC history, news, company info
AI Framework LangChain Tool-calling agent and structured output
LLM Providers OpenAI, Anthropic, Gemini, Groq, DeepSeek, OpenRouter, Ollama Swappable AI backends via /models
Agent State LangGraph Conversation memory and session checkpointing
Terminal UI Rich Cards, tables, panels, bars, and live status
Interactive Input prompt-toolkit Slash-command completion and terminal prompt UX
Environment python-dotenv Secure .env loading for local development
Package Manager uv Fast dependency resolution and global CLI installation

⚙️ Prerequisites

StockSensei uses uv for installation. If you don't have it yet, install it first:

Mac/Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows (PowerShell):

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Once installed, restart your terminal to make sure uv is available.


🚀 Installation & Setup

The Easiest Way (Global Install) Install StockSensei in a single command from PyPI. No cloning required:

uv tool install stocksensei

Then just run it from anywhere:

stocksensei

On first launch, StockSensei will walk you through selecting an AI provider and entering your API key — saved permanently so you only ever do this once.


Updating to the Latest Version To update StockSensei to the newest version:

uv tool upgrade stocksensei

(Alternatively, install directly from GitHub for the absolute latest: uv tool install git+https://github.com/lenminh002/StockSensei.git)


Developer Setup (Local Cloning) To modify the code or contribute:

git clone https://github.com/lenminh002/StockSensei.git
cd StockSensei
uv sync
uv run main.py

💡 Usage

Once running, just type your questions in plain English:

You: nvidia vs apple
StockSensei: [Renders a comparison table with price, P/E, market cap, 52w range]

You: show me nvda's chart for the last 3 months
StockSensei: [Draws a sparkline trend chart with annotated date range]

You: what's the latest news on tesla?
StockSensei: [Lists the 10 most recent headlines]

You: price of nvda
StockSensei: [Shows a snapshot card with live price and daily change]

Type exit, quit, q, or /quit to close the app.

Commands

/models   — switch AI provider or model
/clear    — clear conversation history and reset the terminal
/help     — show available commands and example prompts
/quit     — exit StockSensei

In an interactive terminal, typing / opens an autocomplete dropdown with all available commands and their descriptions.

Switching Providers & Models

Type /models at any time during a session to switch your AI provider or model:

You: /models

Current: openai / gpt-4.1-mini
Select provider:
  1. openai  (default: gpt-4.1-mini)
  2. anthropic  (default: claude-sonnet-4-6)
  3. groq  (default: llama-3.3-70b-versatile)
  4. + Add new provider
Your choice: 2

Select model:
  1. claude-opus-4-7
  2. claude-sonnet-4-6
  3. claude-haiku-4-5-20251001
Your choice: 1

✓ Switched to anthropic / claude-opus-4-7

Your selection is saved to ~/.stocksensei_config.json and remembered across sessions.


🧱 Structured Output Contract

StockSensei uses a strict JSON output contract. The AI always returns a structured response shaped like:

{
  "message": "Short explanation for the user.",
  "blocks": [
    {
      "type": "metric_card",
      "title": "AAPL snapshot",
      "subtitle": "Apple Inc.",
      "items": [
        {"label": "Price", "value": "$201.68", "tone": "bright_cyan"},
        {"label": "Daily change", "value": "+1.23%", "tone": "bright_green"},
        {"label": "Market cap", "value": "$3.01T", "tone": "bright_magenta"},
        {"label": "P/E", "value": "33.42", "tone": "bright_yellow"}
      ]
    },
    {
      "type": "range_bar",
      "title": "AAPL 52-week range",
      "minimum_label": "Low $170",
      "maximum_label": "High $220",
      "current_label": "Current $201.68",
      "position": 0.73
    }
  ]
}

Supported block types: text, metric_card, table, barchart, range_bar, sparkline, news.

This contract means output is deterministic, safe to render, and consistent regardless of which AI provider is active.


🤖 Supported Providers

Provider Models
OpenAI gpt-5.4, gpt-5.4-mini, o3, o4-mini, gpt-4o, gpt-4o-mini
Anthropic claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001
Gemini gemini-3.1-pro-preview, gemini-3-flash-preview, gemini-3.1-flash-lite-preview, gemini-3-deep-think, gemini-2.5-pro, gemini-2.5-flash
Groq llama-3.3-70b-versatile, llama-3.1-8b-instant, mixtral-8x7b-32768
DeepSeek deepseek-chat, deepseek-reasoner
OpenRouter openai/gpt-4.1-mini, anthropic/claude-opus-4-7, google/gemini-2.5-pro, meta-llama/llama-3.3-70b-instruct
Ollama llama3.2, qwen2.5, mistral
Custom Any OpenAI-compatible endpoint

📝 Notes

  • Config file: Provider settings and API keys are stored in ~/.stocksensei_config.json.
  • Tool architecture: Market-data tools return clean structured data; visual builder tools return render-ready block payloads; terminal rendering is handled in the CLI layer.
  • Structured rendering: The CLI validates the JSON response schema and renders supported block types — text, metric cards, tables, bar charts, range bars, sparklines, and news lists.
  • Fallback handling: If the AI output cannot be parsed as a structured response, StockSensei safely falls back to a plain text block rather than crashing.
  • Cross-Platform: Works on macOS, Linux, and Windows (PowerShell).

🗑️ Uninstall

1. Uninstall the CLI tool:

uv tool uninstall stocksensei

2. Remove saved config (optional — only if you want a full clean removal):

Mac/Linux:

rm ~/.stocksensei_config.json

Windows (PowerShell):

Remove-Item "$HOME\.stocksensei_config.json"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stocksensei-0.1.0.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stocksensei-0.1.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file stocksensei-0.1.0.tar.gz.

File metadata

  • Download URL: stocksensei-0.1.0.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stocksensei-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5cc6e4323460b29acc33914e4f1b8a2212beea941afc8367426bbbcdb626e6f
MD5 8d7e1e77dc8c5b23e2284ce2ab67ca22
BLAKE2b-256 625438a47938a23d2119f29f128b20c6bd5785f7037f372ede82cd3dc626aa90

See more details on using hashes here.

File details

Details for the file stocksensei-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stocksensei-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stocksensei-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06087110d31f9d60f11b600beeb1f0783613dfbeeff6756a7e3bbe0cc727a491
MD5 3586e5008d74c9feaaf4c561011c0f0b
BLAKE2b-256 3475da2d26b9563171b67e11df17cf95ddbcb37fdeda8abbb20374621910db87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page