Trading & Charting Interface
Relevant source files
The following files were used as context for generating this wiki page:
The Trading & Charting Interface in OpenAlgo provides a professional-grade terminal for real-time market visualization and manual trade execution. It is built as a self-hosted environment that integrates directly with a connected broker session to provide live market data feeds and order management capabilities.
The interface supports multi-pane layouts, synchronized chart interactions (crosshair, time, and symbol), and drawing tools for technical analysis. It serves as one of OpenAlgo's four primary trading surfaces, bridging the gap between automated strategy execution and manual chart-based trading.
Sources: README.md:28-35, CLAUDE.md:10-18, frontend/src/pages/Home.tsx:49-52
Architecture and Layout Management
The interface is built using a React-based frontend that manages multiple ChartPane components within a dynamic CSS grid. Users can select from several layout presets, ranging from a single chart to an 8-pane grid (4x2).
Layout Presets
Layout configurations are persisted in local storage using the oa-trading-layout key.
| Preset ID | Label | Grid Dimensions |
|---|---|---|
single | Single | 1 × 1 |
cols2 | 2 columns | 2 × 1 |
rows2 | 2 rows | 1 × 2 |
oneTwo | 1 + 2 | Mixed |
grid4 | 2 × 2 | 2 × 2 |
grid6 | 3 × 2 | 3 × 2 |
grid8 | 4 × 2 | 4 × 2 |
Sources: frontend/src/pages/Trading.tsx:43-98, frontend/src/pages/Trading.tsx:132-134
Visual Grid Representation
The following diagram illustrates the relationship between the Trading page container and its constituent panes.
The interface manages the active terminal state to ensure drawing tools and shortcuts are applied to the correctly focused pane.
Sources: frontend/src/pages/Trading.tsx:142-168
Data Synchronization Engine
OpenAlgo implements a LinkGroup mechanism to synchronize state across multiple chart panes. This allows traders to view different timeframes or instruments while maintaining a unified perspective.
Sync Capabilities
- Crosshair: Mirrors the pointer position across all linked charts.
- Viewport (Time Range): Synchronizes panning and zooming actions.
- Symbol: Forces all panes to load the same instrument when one is changed.
The sync engine uses localStorage (via oa-trading-sync) to persist user preferences across sessions.
Sources: frontend/src/pages/Trading.tsx:106-129, frontend/src/pages/Trading.tsx:177-183
Market Data & WebSocket Integration
The charting interface relies on a unified WebSocket proxy to deliver real-time ticks. Every pane shares the same API key and WebSocket URL, retrieved from the backend during initialization.
Data Flow
- Authentication: The frontend fetches a session-specific API key from
/api/websocket/apikey. - Configuration: WebSocket connection details are retrieved from
/api/websocket/config. - Subscription: Individual panes subscribe to symbols (LTP, Quotes, or Depth) via the
openalgo-chartspackage. - Distribution: The backend
websocket_proxymanages the fan-out of data from the broker to all active frontend sessions.
Sources: frontend/src/pages/Trading.tsx:189-210, CLAUDE.md:120-125, README.md:104-110
Technical Analysis and Drawing Tools
The interface includes a DrawingRail component that provides technical analysis tools. These tools operate on a "last focused" basis, where user actions (Undo, Delete, Magnet toggle) are routed to the active TradingTerminal.
Key Features
- Magnet Mode: Snaps drawings to candle prices.
- Shortcut Arming: Supports keyboard shortcuts to quickly select tools.
- Draw Stats: Tracks the number of drawings, undo/redo availability, and current selection status.
Sources: frontend/src/pages/Trading.tsx:142-171, frontend/src/pages/Trading.tsx:280-295
Integration with External Platforms
While the built-in interface provides native charting, OpenAlgo also acts as a bridge for external charting platforms via webhooks.
| Platform | Integration Method | Capability |
|---|---|---|
| TradingView | Webhooks | JSON-based alerts (BUY, SELL, SHORT, COVER) |
| GoCharting | Webhooks | REST API /api/v1/placeorder integration |
| Amibroker | Direct SDK/REST | AFL-script driven execution |
| Excel/Sheets | REST API | Data streaming and order placement |
Sources: frontend/src/pages/strategy/ViewStrategy.tsx:298-311, frontend/src/pages/GoCharting.tsx:90-94, README.md:225-235
Summary
The Trading & Charting Interface is a central component of the OpenAlgo platform, offering a high-performance environment for manual and semi-automated trading. By combining flexible layout management, robust cross-pane synchronization, and unified WebSocket streaming, it provides a cohesive experience across different broker plugins. The interface ensures that technical analysis performed via drawing tools is seamlessly integrated with the underlying execution engine.