Skip to content

Stage 2: Trading Experience

Target versions: v2.0.0 → v2.1.0
Prerequisite: Stage 0 complete; Stage 1 candlestick virtualization recommended
Parallel with: 03-scientific-depth.md


Goal

Bring velo-plot to professional trading dashboard parity with libraries like lightweight-charts and TradingView — without sacrificing the scientific core. Users building apps like portfolio-fall should get a first-class trading API out of the box.

v2.0.0 is expected to include breaking API additions (new time scale, high-level indicator API).


Current state

What exists (v1.12.0)

FeatureStatusLocation
Candlestick OHLCCandlestickRenderer, type: 'candlestick'
Volume barstype: 'bar' with Y pinned to 0 (NavigationUtils.ts)
Multi-pane stacked layoutcreateStackedChart.ts (max 5 panes)
X-axis sync between panesChartGroup in src/core/sync/index.ts
Crosshair syncsetExternalCursor()
Time axis formattingxAxis.type: 'time' (epoch ms) — not market calendar
19 indicator calculatorssrc/plugins/analysis/indicators.ts
Composite indicator panesbuildIndicatorPane, colorZones on lines
TooltipsTooltipManager with time-aware format
Streaming / realtimesrc/streaming/ + backpressure
Pattern recognition (partial)⚠️Built-in patterns only; custom throws

What is missing vs TradingView / lightweight-charts

FeatureGap
Business-day / session time scaleWeekends and market hours not skipped on X axis
High-level indicators (chart.addRSI(14))Manual calculate + buildIndicatorPane required
Interactive drawing toolsAnnotations are programmatic only
Trade markers on price chartMarkers exist on indicators, not native buy/sell on candles
Replay / bar simulationNot implemented
Price alertsNot implemented
Heikin-Ashi, Renko, KagiNot implemented
Hollow candles, baseline chartNot implemented
Symbol comparison / % scaleNot implemented
Datafeed API (UDF-style)Not implemented
syncSelectionStub in ChartGroup (fixed in Stage 0)

Work items

P0 — Market time scale

IDTaskPriorityComplexityDefinition of done
2.1TimeScale moduleP0Very HighNew src/core/time/TimeScale.ts with business-day gaps, session hours, timezone
2.2Integrate TimeScale with axis formattingP0HighxAxis.timeScale: { type: 'business-day', session: 'NYSE', timezone: 'America/New_York' }
2.3Candlestick index → timestamp mappingP0MediumOHLC data can use logical index or timestamp; gaps render correctly
2.4Docs + example: trading session chartP0Lowdocs/examples/trading/session.md

P0 — High-level indicator API

IDTaskPriorityComplexityDefinition of done
2.5chart.addIndicator() facadeP0Highchart.addIndicator('rsi', { period: 14, pane: 'new' }) calculates + renders
2.6Presets: RSI, MACD, Bollinger, EMA, SMA, StochasticP0HighOne-liner per indicator; uses worker path from Stage 1
2.7Stacked chart integrationP0Mediumstack.addIndicator('macd') appends pane via buildIndicatorPane
2.8Update portfolio-fall integration guideP1LowExample in docs

P0 — Drawing tools

IDTaskPriorityComplexityDefinition of done
2.9PluginDrawingToolsP0Very HighInteractive trendline, horizontal line, vertical line, rectangle
2.10Fibonacci retracementP1HighDrag two points → fib levels drawn
2.11Undo / redo stackP0MediumCtrl+Z / Ctrl+Y for drawings; integrates with PluginKeyboard
2.12Persist drawings in chart stateP1MediumSerialize/deserialize via existing src/serialization/
2.13Drawing mode toolbar APIP1Mediumchart.setDrawingMode('trendline')

P1 — Trade visualization

IDTaskPriorityComplexityDefinition of done
2.14Trade markers on candlestick seriesP1Mediumseries.markers: [{ time, position: 'belowBar', shape: 'arrowUp', text: 'Buy' }]
2.15Position lines (entry, SL, TP)P1MediumHorizontal price lines with labels
2.16Order flow markers from streamP2HighIntegration with PluginStreaming

P1 — Replay and alerts

IDTaskPriorityComplexityDefinition of done
2.17PluginReplayP1HighBar-by-bar playback with speed control
2.18chart.on('alert', ...) price alertsP1MediumCrosses above/below price triggers event
2.19Alert lines on chartP2LowVisual horizontal alert level

P1 — Additional chart types

IDTaskPriorityComplexityDefinition of done
2.20Heikin-Ashi series typeP1Mediumtype: 'heikin-ashi' derived from OHLC
2.21Hollow candlestick style optionP1Lowstyle.hollow: true on candlestick
2.22Baseline / area-baseline chartP2Mediumtype: 'baseline' with configurable base value
2.23Renko / Kagi (stretch)P3Very HighEvaluate demand; defer to v2.2+ if needed

P2 — Datafeed contract

IDTaskPriorityComplexityDefinition of done
2.24DatafeedAdapter interfaceP2HighUDF-inspired: getBars, subscribeBars, resolveSymbol
2.25Mock datafeed exampleP2LowDemo page with historical + realtime mock

API sketch (v2.0)

typescript
import { createStackedChart } from 'velo-plot/trading'

const stack = createStackedChart({
  container,
  panes: [
    { id: 'price', series: [{ type: 'candlestick', data: ohlc }] },
    { id: 'volume', series: [{ type: 'bar', data: volume }] },
  ],
  xAxis: {
    type: 'time',
    timeScale: { calendar: 'business-day', session: '24x7' },
  },
})

stack.addIndicator('rsi', { period: 14 })
stack.addIndicator('macd', { fast: 12, slow: 26, signal: 9 })

stack.getChart('price').setDrawingMode('trendline')
stack.getChart('price').on('alert', (e) => console.log(e))

Risks

RiskMitigation
TimeScale complexity (holidays, DST)Ship with 2–3 built-in sessions; custom holiday calendar as config
Drawing tools scope creepMVP: trendline + horizontal + undo; fib in v2.1
Breaking changes in v2.0Migration guide from manual indicator setup to addIndicator()
Trading bundle sizeTree-shake scientific/3D out of velo-plot/trading entry

Exit checklist (v2.0.0)

  • [x] Business-day time scale with at least one market session preset
  • [x] addIndicator() for RSI, MACD, Bollinger, EMA, SMA, Stochastic
  • [x] Drawing tools: trendline, horizontal, rectangle, fibonacci + undo/redo
  • [x] Trade markers on candlestick series
  • [x] Replay plugin MVP (play/pause/step)
  • [x] Price alert events
  • [x] Heikin-Ashi and hollow candles
  • [x] Trading example app in docs (price + volume + RSI + MACD)
  • [x] velo-plot/trading bundle exported and documented
  • [x] Migration guide v1.x → v2.0 published
  • [x] Dedicated API + example page per Stage 2 feature

Released under the MIT License.