OpenStock

Free, open-source stock market tracker with real-time data, watchlists, price alerts, and AI-powered market summaries.

13.7Kstars
1.8Kforks
GNU AGPLv3
TypeScript

OpenStock is an open-source alternative to expensive financial platforms that gives individual investors, students, and finance enthusiasts free access to real-time market data. It combines Finnhub market data, TradingView charting widgets, and multi-source sentiment analysis into a polished dashboard — no subscriptions, no paywalls, no vendor lock-in.

Built with Next.js 15 App Router and TypeScript, OpenStock uses Better Auth for secure authentication, MongoDB for persistent storage, Inngest for event-driven automation, and Nodemailer for email alerts. The platform supports Docker deployment and runs on any VPS or cloud provider, giving self-hosters full control over their data.

The project goes beyond basic price tracking: AI-generated weekly market summaries (via Gemini with MiniMax and Siray fallbacks) are delivered by email, while a multi-source sentiment engine aggregates signals from Reddit, X.com, financial news, and Polymarket prediction markets. Price alert checks run every five minutes via Inngest cron jobs, notifying users when targets are hit.

What You Get

  • Real-time stock data via Finnhub - Fetch live and delayed prices, company profiles, and market news for global symbols with smart exchange-suffix detection covering 40+ markets.
  • Interactive TradingView charts - Embed candlestick advanced charts, baseline comparisons, technical analysis overlays, company profile widgets, and financial summaries directly in the app.
  • Personalized watchlists - Per-user watchlists stored in MongoDB with upsert deduplication, accessible from any device, with instant cache revalidation on change.
  • Automated price alerts via Inngest - Set ABOVE/BELOW price targets that are checked every five minutes by a serverless cron job, with email notification on trigger.
  • AI-generated weekly market summaries - Inngest cron every Monday at 9 AM generates a news digest using Gemini (with MiniMax and Siray fallbacks) and broadcasts a styled HTML email to all subscribers.
  • Multi-source sentiment analysis - Optional Adanos API integration aggregates Reddit, X.com, financial news, and Polymarket prediction market signals into a unified sentiment card per symbol.
  • Global command palette (Cmd+K) - Keyboard-driven stock search powered by Finnhub with debounced querying and popular symbols shown when idle.
  • Re-engagement email workflows - Inngest daily cron detects users inactive for 30+ days and dispatches personalized re-engagement emails to bring them back to their watchlists.

Common Use Cases

  • Tracking a personal investment portfolio - An individual investor monitors their tech and energy watchlists using real-time Finnhub prices and TradingView candlestick charts, receiving email alerts when price targets are hit.
  • Self-hosting a financial dashboard - A developer deploys OpenStock on a VPS with Docker Compose, connecting their own MongoDB instance and Finnhub API key to maintain full data ownership without third-party tracking.
  • Teaching market analysis in a classroom - A finance professor deploys OpenStock for students to explore real company profiles, technical indicators, and news feeds without requiring paid subscriptions.
  • Monitoring cross-market sentiment - A trader uses the Adanos sentiment integration to compare Reddit buzz, X.com mentions, and Polymarket positions on a stock alongside its price chart to gauge crowd sentiment.
  • Running an automated investment newsletter - A finance blogger connects OpenStock’s Inngest weekly summary workflow to their Kit subscriber list, sending AI-personalized market digests each Monday without manual effort.

Under The Hood

Architecture OpenStock follows a cleanly layered Next.js 15 App Router architecture where Server Components own all data-fetching logic and client components handle interactivity. Business logic is isolated in dedicated server action modules — finnhub.actions.ts, watchlist.actions.ts, adanos.actions.ts, alert.actions.ts — each with single-responsibility boundaries and no cross-contamination between concerns. Background processing is fully decoupled: Inngest handles price alert polling every five minutes, weekly news broadcasts every Monday, and daily inactive-user detection as independent serverless workflows that never block the HTTP request cycle. Authentication is enforced at the routing layer via Next.js middleware before any page logic runs. MongoDB connection pooling is centralized through a singleton Mongoose connector, preventing redundant connections in serverless environments. The pattern of parallel Promise.all fetches (quotes and profiles simultaneously per watchlist symbol) and Next.js revalidate cache headers keeps UI fresh without client-side polling.

Tech Stack Next.js 15 with React 19 and Turbopack powers the frontend with fast server-side rendering and file-based routing. TypeScript covers the entire codebase at approximately 93% language share. Tailwind CSS v4 via @tailwindcss/postcss with shadcn/ui components (Radix UI primitives) provides the design system. MongoDB with Mongoose handles user data, watchlists, and alert records. Better Auth manages email/password authentication with a MongoDB session adapter. Finnhub serves real-time and delayed market data; TradingView embedded widgets render candlestick charts, heatmaps, technical analysis panels, and company financials. Inngest orchestrates all event-driven and scheduled workflows. Nodemailer with Gmail transport handles transactional email delivery. Multiple AI providers (Gemini, MiniMax, Siray) are abstracted behind a unified fallback caller. Vitest provides the unit testing layer.

Code Quality The test suite spans approximately 900 lines across five test files, covering utility functions with comprehensive exchange-suffix mapping cases (40+ exchanges), Adanos sentiment action mocking, AI provider switching and fallback logic, email template generation, and number formatting helpers. Error handling is consistently explicit — Finnhub fetch failures return null, watchlist operations surface typed errors, and AI provider failures degrade gracefully to a static fallback string. TypeScript interfaces (FinnhubQuote, WatchlistItem, SentimentSourceInsight, SourceComparePayload) enforce data contracts at API boundaries. Server-side caching with revalidate parameters (86400 seconds for company profiles, 300 for news, 0 for real-time quotes) is applied judiciously. Some areas show early-stage roughness: re-engagement email logic contains commented workarounds for Kit API limitations and a hardcoded test user email address, indicating code that grew fast under contributor momentum.

What Makes It Unique OpenStock’s most technically distinctive capability is its multi-source sentiment aggregation: the Adanos integration queries Reddit, X.com financial discussions, general news, and Polymarket prediction markets in parallel, normalizing heterogeneous response shapes into a unified SentimentSourceInsight interface per symbol — an approach rarely found in open-source financial tooling. The exchange-suffix translation layer maps 40+ international market suffixes to their TradingView-specific prefixes (e.g., TWSE for .TW, HKEX for .HK, BMFBOVESPA for .SA), enabling global coverage beyond US equities without any third-party dependency. The AI provider fallback chain — Gemini primary with MiniMax and Siray alternatives — implements provider-agnostic resilience that keeps email workflows running even when a single AI API is down. Price alert detection via Inngest polling every five minutes avoids WebSocket complexity while keeping latency acceptable for retail use cases.

Self-Hosting

OpenStock is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0), which is a strong copyleft license with a network use provision. In plain terms: you may use, modify, and distribute the software freely, including for commercial purposes, but if you run a modified version as a network service — meaning other people access it over the internet — you are required to release your complete modified source code under the same AGPL-3.0 license and credit the original authors. For internal corporate use where external users never interact with the modified version, the copyleft obligation does not apply. There are no enterprise or pro editions; every feature in the repository is available under the same terms.

Running OpenStock yourself requires meaningful infrastructure work. You need Node.js 20+, a MongoDB instance (MongoDB Atlas or self-hosted via the included Docker Compose configuration), a Finnhub API key (free tier supports delayed data; real-time pricing requires a paid Finnhub plan), a Gmail account configured with an app password for Nodemailer, and optionally a Google Gemini API key for AI-generated summaries. The included Dockerfile and docker-compose.yml make local and VPS deployment straightforward, but you take full responsibility for uptime, backups, MongoDB replication, and keeping dependencies current. Environment variables must be managed securely — the setup requires roughly eight to twelve secrets depending on which optional integrations you enable.

There is no official hosted or managed version of OpenStock; the project is entirely community-run. You gain full data ownership and no third-party tracking, but you give up any SLA, managed upgrades, and dedicated support. The Inngest cron workflows require either running the Inngest CLI locally or connecting to Inngest Cloud (which has a free tier) to execute scheduled jobs — without it, price alerts and weekly email summaries will not fire. As the project matures, contributors are active but release versioning is absent, so staying current means tracking the main branch rather than pinning to stable releases.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack

No spam. Unsubscribe anytime.

Join 750+ subscribers
No spam. Unsubscribe anytime.

Search