Introduction
Relevant source files
The following files were used as context for generating this wiki page:
OpenAlgo is a comprehensive, self-hosted, open-source algorithmic trading platform designed to bridge the gap between strategy design and multi-broker execution. Built using a Flask backend and a React 19 frontend, it provides a unified interface for trading across 35 broker plugins, including Indian equity/derivatives brokers and crypto exchanges like Delta Exchange. The platform is designed as a "several products in one" solution, allowing users to interact with markets via a REST API, a no-code visual builder, an in-browser Python strategy host, or dedicated analytical tools.
Sources: README.md:16-24, CLAUDE.md:10-14, okf/overview.md:17-20
Platform Architecture
OpenAlgo operates as a local or server-side instance that maintains a single broker session and shared infrastructure for multiple trading surfaces. The architecture is built around a centralized market-data pipeline and a suite of isolated database stores to ensure operational integrity and performance.
Product Surfaces
The platform exposes several distinct interfaces (surfaces) for different trading workflows:
| Surface | Route | Purpose |
|---|---|---|
| Unified Broker API | /api/v1/ | External integration for TradingView, Amibroker, Excel, etc. |
| Python Strategy Host | /python | In-browser editor for isolated, scheduled Python scripts. |
| Flow (No-Code) | /flow | Node-based visual strategy builder using market data and indicators. |
| Options & Portfolio | /tools | 18 analytical tools (Option Chain, Greeks, Vol Surface, etc.). |
| Charting Terminal | /trading | Line-based chart trading powered by openalgo-charts. |
| Scalping Terminal | /scalping | Keyboard-driven, low-latency options scalping. |
Sources: CLAUDE.md:14-23, README.md:26-36
System Components Flow
The following diagram illustrates the high-level request and data flow between the various OpenAlgo components:
This diagram shows the relationship between user interfaces, the core service layer, and the multi-layered market data pipeline.
Sources: CLAUDE.md:118-124, CLAUDE.md:139-145, README.md:204-210
Core Technical Features
Market Data Pipeline
OpenAlgo utilizes a three-layer pipeline to ensure the adapter never blocks on slow clients:
- Broker Adapters: Normalize proprietary feeds from brokers.
- ZeroMQ Bus: A fan-in bus (Port 5555) where publishers connect to a single bound subscriber (the proxy).
- WebSocket Proxy: Manages client subscriptions and throttles symbol updates (Port 8765).
Sources: CLAUDE.md:88-95, CLAUDE.md:126-132
Python Strategy Hosting
The platform includes a dedicated runner for Python strategies that ensures process isolation:
- Subprocesses: Each strategy runs as a separate OS process via
subprocess.Popen. - Environment Injection: The host injects
OPENALGO_API_KEY,OPENALGO_STRATEGY_EXCHANGE, and user-defined variables into the strategy's environment. - Scheduling: Strategies are gated by exchange-specific holiday calendars, allowing them to start and stop automatically based on market hours.
Sources: frontend/src/pages/python-strategy/PythonStrategyGuide.tsx:300-320, CLAUDE.md:16-17
Security Model
OpenAlgo is designed for single-user self-hosting. Key security invariants include:
- Authentication: Argon2 hashing for passwords and Fernet symmetric encryption for sensitive tokens.
- Static IP Mandate: Support for broker-side static IP whitelisting for transactional orders.
- Isolated Sessions: One broker session per deployment, fanned out to multiple devices (max 5) via the internal proxy.
Sources: CLAUDE.md:38-45, CLAUDE.md:104-108, README.md:144-152
Deployment and Runtime
The platform runs on Python 3.12+ and uses the uv package manager for dependency management.
Production Environment
In production, OpenAlgo uses Gunicorn with the eventlet worker class. This imposes specific constraints:
- Single Worker Mandatory: Flask-SocketIO state is in-process and requires
-w 1. - No asyncio: Eventlet is incompatible with standard
asyncioloops; asynchronous tasks must use green threads or separate OS threads. - Database Pooling: SQLite engines must use
NullPoolto avoid "bad parameter" errors from concurrent requests sharing a single connection.
Sources: CLAUDE.md:65-74, CLAUDE.md:113-116, INSTALL.md:55-60
System Diagnostics
The platform includes a diagnostics suite accessible at /admin/diagnostics that monitors:
- Hardware: CPU count, memory availability, and disk usage for log and database directories.
- Runtime: Python version, implementation details, and process uptime.
- Connectivity: On-demand TCP probes to check the ZeroMQ bus, WebSocket proxy, and active broker endpoints.
Sources: frontend/src/pages/admin/Diagnostics.tsx:180-260
Summary
OpenAlgo provides a unified technical framework for algorithmic trading by abstracting broker-specific complexities into a standardized API and symbology format. By combining high-performance market data streaming via ZeroMQ with flexible execution surfaces like the Flow builder and Python strategy host, it enables developers to build and deploy strategies in a secure, self-hosted environment.
Sources: README.md:16-24, okf/viz.html:200-210