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

  • Python 3.13+ — required regardless of install method.
  • pip or uv — either works for installation (see below).

🚀 Installation & Setup

Using pip (standard)

pip install stocksensei

Using uv (faster)

If you prefer uv, install it first if you don't have it:

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"

Then install as a global tool:

uv tool install stocksensei

Then 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

With pip:

pip install --upgrade stocksensei

With uv:

uv tool upgrade stocksensei

(For the absolute latest before a PyPI release: 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       # or: pip install -e .
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).

📄 License

This project is licensed under the MIT License.

© 2025 Minh Nguyen Le, Minh Le Hoang


🗑️ Uninstall

1. Uninstall the CLI tool:

With pip:

pip uninstall stocksensei

With uv:

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.1.tar.gz (25.3 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.1-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stocksensei-0.1.1.tar.gz
  • Upload date:
  • Size: 25.3 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.1.tar.gz
Algorithm Hash digest
SHA256 f10b666a0f7c27d43aa9a04b51c2bd4e8f4d6bfcb6d198f48f38ec6d00bc22a7
MD5 95d6b0e42d7958529ea4606ccb49728c
BLAKE2b-256 0b7b8238347e798fa2d2e7661f0d04459b9c52ab4b51b47150547cbad36ede59

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stocksensei-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61cafe3161078ba32fca99f4a3ff3d134d5053a7f9e4ba6244fe88806518ecd6
MD5 9db4ee997e462e5643e780cd36eb9add
BLAKE2b-256 09f9bd6d45c11add2f93f007a9ba984a803c76b91698a7e1e0890e3cbdae5ddb

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