DocumentationTypes Reference

Types Reference

Every TypeScript type exported from openalgo-charts. Import only what you need:

import type { Bar, ChartOptions, SeriesApi } from 'openalgo-charts';

Data Model

The core structures for time-series price data.

UTCSeconds

type UTCSeconds = number;

All internal time values are UTC seconds (integers). Feed adapters convert broker formats (IST strings, epoch milliseconds) at the edge.

OriginalTime

type OriginalTime = number | string;

The caller-supplied time value, echoed back untouched in callbacks.

Bar

interface Bar {
  time: UTCSeconds;
  open: number;
  high: number;
  low: number;
  close: number;
  volume?: number;
}

A single OHLC(V) bar. volume is optional. Line and area series read the close field.

LinePoint

interface LinePoint {
  time: UTCSeconds;
  value: number;
}

A single value point for line, area, and baseline series.

Whitespace

interface Whitespace {
  time: UTCSeconds;
}

A whitespace item occupies a logical index for alignment but draws nothing. Use it to introduce explicit gaps that the renderer respects instead of interpolating across.

The exported isWhitespace(point) guard narrows a Bar | LinePoint | Whitespace union to Whitespace at runtime. It returns true when the point has neither an open field nor a value field.


Chart

ChartOptions

interface ChartOptions {
  document?: Document;
  pixelRatio?: () => number;
  /** Injectable rAF for SSR / testing. */
  raf?: { schedule: RafScheduler; cancel?: RafCanceller };
  theme?: ChartTheme;
  priceAxisWidth?: number;
  timeAxisHeight?: number;
  /** 'normal' follows the pointer exactly; 'magnet' snaps to nearest O/H/L/C. */
  crosshairMode?: 'normal' | 'magnet';
  now?: () => number;
  conflate?: boolean;
  conflationFactor?: number;
  grid?: { vertLines?: boolean; horzLines?: boolean };
  ariaLabel?: string;
  shortcuts?: ShortcutManager | Partial<ShortcutManagerOptions> | false;
  /** Hover-revealed zoom / step controls above the time axis. Default true. */
  timeNavigator?: boolean | Partial<TimeNavigatorOptions>;
}

Options passed to createChart(container, options). All fields are optional; defaults are sensible for browser use.

AddSeriesOptions

interface AddSeriesOptions {
  paneIndex?: number;
  style?: SeriesStyle;
  priceScaleId?: 'right' | 'left' | '';
  priceFormat?:
    | { type: 'price'; precision?: number; minMove?: number }
    | { type: 'volume' }
    | { type: 'custom'; formatter: (value: number) => string };
}

Options passed to chart.addSeries(type, options). paneIndex defaults to 0 (price pane); higher indices create sub-panes on demand. priceScaleId picks the axis: 'right' (default) and 'left' autoscale independently and each draw an axis; '' is a hidden overlay scale (volume-in-price-pane). priceFormat sets that series’ axis and crosshair-tag formatting — see Scales & panes.

CrosshairMoveEvent

interface CrosshairMoveEvent {
  time: number | null;
  index: number | null;
  price: number | null;
  bar: Bar | null;
  point: { x: number; y: number } | null;
}

Emitted on every crosshair move via chart.subscribeCrosshairMove(cb). All fields are null when the pointer leaves the plot. bar is the hovered bar of the primary price series. point is the cursor position in container-relative media px, useful for positioning a floating tooltip.

SeriesApi

interface SeriesApi {
  setData(bars: readonly SeriesDataItem[]): void;
  prependData(bars: readonly SeriesDataItem[]): void;
  update(bar: SeriesDataItem): void;
  getData(): Bar[];
  applyOptions(style: Partial<SeriesStyle>): void;
  remove(): void;
  priceScale(): PriceScale;
  createMarkers(): SeriesMarkers;
}

The public handle returned by chart.addSeries(...). Use setData for the initial load, update for live bar ticks, and prependData when paging older history. applyOptions merges a partial style and repaints (recolor, { visible: false } to hide); remove detaches the series and frees its data; priceScale() returns the scale this series maps to; createMarkers() attaches a buy/sell signal layer bound to this series.


Scales

PriceRange

interface PriceRange {
  min: number;
  max: number;
}

A visible price range (min/max pair).

PriceScaleMode

type PriceScaleMode = 'linear' | 'logarithmic';

The coordinate mapping mode for a pane’s price scale.

PriceScaleOptions

interface PriceScaleOptions {
  marginTop: number;
  marginBottom: number;
  minMove: number;
  mode: PriceScaleMode;
  inverted: boolean;
}

Configuration for a pane’s price scale. marginTop and marginBottom are fractions of the pane height kept empty at each edge (default 0.1). minMove is the instrument tick size (e.g. 0.05); 0 infers precision from the visible range. inverted flips the axis so price increases downward.

LogicalRange

interface LogicalRange {
  from: number;
  to: number;
}

A range of logical bar indices as used by the time scale’s visible window. Values are fractional and may fall outside the data bounds.

TimeScaleOptions

interface TimeScaleOptions {
  barSpacing: number;
  minBarSpacing: number;
  maxBarSpacing: number;
  rightOffset: number;
}

Configuration for the shared time (x) axis. barSpacing is the media-px width per bar slot (default 8). rightOffset is the number of empty bar slots kept to the right of the latest bar (default 4).


Rendering and Style

SeriesStyle

interface SeriesStyle {
  // candle / bar family
  upColor?: string;
  downColor?: string;
  borderUpColor?: string;
  borderDownColor?: string;
  wickUpColor?: string;
  wickDownColor?: string;
  borderVisible?: boolean;
  wickVisible?: boolean;
  hollow?: boolean;
  /** Scale candle body width by volume / maxVisibleVolume (volume candles). */
  volumeScaled?: boolean;
 
  // line / area / baseline / hlc-area family
  color?: string;
  lineWidth?: number;
  step?: boolean;
  markers?: boolean;
  markerRadius?: number;
  areaTopColor?: string;
  areaBottomColor?: string;
  baseValue?: number;
  topColor?: string;
  bottomColor?: string;
  highColor?: string;
  lowColor?: string;
  closeColor?: string;
 
  // histogram / column family
  base?: number;
 
  // point & figure / kagi family
  /** Fallback box size for P&F glyphs; a column's own `boxSize` wins. */
  boxSize?: number;
  /** Kagi thick (yang) line color. */
  thickColor?: string;
  /** Kagi thin (yin) line color. */
  thinColor?: string;
}

Unified optional-field style bag for all Family-A series types. Each renderer reads the fields it needs; unused fields are ignored. Pass a partial object to AddSeriesOptions.style to override defaults. Theme colors fill in any unset fields at render time.

CandleStyle

interface CandleStyle {
  upColor: string;
  downColor: string;
  borderUpColor: string;
  borderDownColor: string;
  wickUpColor: string;
  wickDownColor: string;
  borderVisible: boolean;
  wickVisible: boolean;
  /** Draw up-candle bodies as outlines only (hollow candles). */
  hollow?: boolean;
  /** Per-bar body-width scale 0..1 (volume candles); 1 = full width. */
  widthScale?: (bar: Bar) => number;
}

Concrete style for the candlestick renderer. widthScale is a per-bar callback returning a 0..1 fraction of the optimal body width, used by the volume-candle type to scale each candle by relative volume.

HistogramStyle

interface HistogramStyle {
  color: string;
  base: number;
}

Style for the histogram (volume column) renderer. base is the price level used as the zero line.

Size

interface Size {
  width: number;
  height: number;
}

A width/height pair in pixels (media or device, depending on context). Returned by bitmapSize.

SeriesType

type SeriesType =
  | 'candlestick'
  | 'hollow-candle'
  | 'volume-candle'
  | 'bar'
  | 'high-low'
  | 'line'
  | 'line-markers'
  | 'step'
  | 'area'
  | 'hlc-area'
  | 'baseline'
  | 'column'
  | 'histogram'
  | 'point-figure'
  | 'kagi';

The string token passed to chart.addSeries(type). See Chart Types for descriptions of each type.

⚠️

'point-figure' and 'kagi' are registered by the transform tier. Import 'openalgo-charts/transform' before using them or the registry will throw.

DrawItem

interface DrawItem {
  x: number; // bar center, media px
  bar: Bar;
}

One rendered bar slot passed to a custom renderer’s draw function.

SeriesRenderContext

interface SeriesRenderContext {
  plotHeight: number;
  maxVolume: number;
  theme: ChartTheme;
}

Additional context passed to a renderer’s draw function alongside the item list and the price-to-Y function.

RendererEntry

interface RendererEntry {
  defaultStyle: SeriesStyle;
  /** True for price series whose last close drives the last-price line. */
  isPriceSeries: boolean;
  draw(
    ctx: CanvasRenderingContext2D,
    items: readonly DrawItem[],
    toY: (v: number) => number,
    barSpacing: number,
    dpr: number,
    style: SeriesStyle,
    rc: SeriesRenderContext,
  ): void;
  extents(bar: Bar, style: SeriesStyle): { min: number; max: number };
}

Descriptor for a registered chart type. extents returns the min/max price contribution of a single bar for autoscaling. Register custom types with registerChartType(name, entry). See Chart Types.


Primitives

Primitives are objects that draw on a pane independently of the series data model. They implement IPrimitive and attach via chart.addPrimitive(primitive, paneIndex). See Primitives and Plugins.

ZOrder

type ZOrder = 'bottom' | 'normal' | 'top';

Layer order of a primitive relative to series: 'bottom' renders behind series, 'normal' renders over them, 'top' renders as the topmost overlay.

PrimitiveRenderContext

interface PrimitiveRenderContext {
  timeScale: TimeScale;
  priceScale: PriceScale;
  dataLayer: DataLayer;
  plotWidth: number;
  plotHeight: number;
  priceAxisWidth: number;
  dpr: number;
  theme: ChartTheme;
}

Injected into a primitive’s draw and hitTest methods. All coordinates in these methods are in media (CSS) px relative to the pane plot.

PrimitiveHit

interface PrimitiveHit {
  externalId: string;
  zOrder: ZOrder;
  distance: number;
  cursor?: string;
}

Returned by IPrimitive.hitTest when the pointer lands on the primitive. externalId is routed to chart.subscribeClick. distance is the pixel distance from the cursor; smaller values win ties before zOrder is considered.

PrimitiveHost

interface PrimitiveHost {
  requestUpdate(): void;
}

Injected into a primitive’s attached callback. Call requestUpdate() whenever the primitive’s visual state changes so the render loop schedules a repaint.

IPrimitive

interface IPrimitive {
  zOrder(): ZOrder;
  draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
  autoscaleInfo?(): { min: number; max: number } | null;
  hitTest?(x: number, y: number, rc: PrimitiveRenderContext): PrimitiveHit | null;
  attached?(host: PrimitiveHost): void;
  detached?(): void;
}

The extension point for custom overlays, indicators, and profiles. autoscaleInfo optionally expands the pane’s price range so the primitive is not clipped by autoscale. hitTest receives media-px coordinates relative to the pane plot.

PriceLineOptions

interface PriceLineOptions {
  price: number;
  color: string;
  lineWidth: number;
  dashed: boolean;
  label?: string;
  badge?: string;
  qty?: string | number;
  leftLabel?: string;
  extentFromRight?: number;
  closeButton?: boolean;
  id: string;
  cursor?: string;
}

Options for chart.addPriceLine(opts, paneIndex). id is the externalId returned by hit-tests and routed to click/drag callbacks. extentFromRight (0..1) controls how far the line spans from the right axis (1 = full width, the default). badge, qty, leftLabel, and closeButton compose the broker-style segmented pill group at the left end of the line — [badge][qty][leftLabel][✕] — where badge is a solid segment in the line color (e.g. BUY, SL), qty and leftLabel are neutral boxed segments, and the ✕ segment hit-tests as ${id}::close. PriceLine.setDragGhost(price | null) shows a dimmed reference line at the pre-drag price while dragging.

SeriesMarker

interface SeriesMarker {
  time: number;
  position: MarkerPosition;
  price?: number;
  shape: MarkerShape;
  size: MarkerSize;
  color: string;
  text?: string;
  id?: string;
}

A single buy/sell signal or annotation anchored to a bar time. price is only used when position is 'atPrice'. id enables click callbacks via chart.subscribeClick. text renders a label adjacent to the glyph.

MarkerShape

type MarkerShape =
  | 'arrowUp'
  | 'arrowDown'
  | 'circle'
  | 'square'
  | 'diamond'
  | 'triangleUp'
  | 'triangleDown'
  | 'flag'
  | 'text';

The glyph shape for a SeriesMarker. 'text' draws no shape; only the text label is rendered.

MarkerPosition

type MarkerPosition = 'aboveBar' | 'belowBar' | 'inBar' | 'atPrice';

Vertical anchor for a marker. 'atPrice' requires the price field on SeriesMarker.

MarkerSize

type MarkerSize = 'tiny' | 'small' | 'medium' | 'big';

Discrete size presets (6, 9, 12, and 16 CSS px respectively). The actual rendered size is also clamped to the current bar spacing so glyphs never overflow their bar slot.

LogoWatermarkOptions

interface LogoWatermarkOptions {
  src?: string;
  image?: CanvasImageSource & { width: number; height: number };
  position?: WatermarkPosition;
  margin?: number;
  height?: number;
  opacity?: number;
  tint?: string;
  zOrder?: ZOrder;
}

Options for new LogoWatermark(opts). Pass src (a URL or data URI) or a preloaded image to skip loading. tint recolors the opaque pixels to a flat color so a single-tone logo reads correctly on both dark and light themes. Defaults: position 'bottom-right', margin 12, height 28, opacity 0.7, zOrder 'top'.

WatermarkPosition

type WatermarkPosition =
  | 'top-left'
  | 'top-right'
  | 'bottom-left'
  | 'bottom-right'
  | 'center';

Corner (or center) anchor for LogoWatermark.

ChartEvent

interface ChartEvent {
  time: number;
  type: 'earnings' | 'dividend' | 'split' | 'news' | string;
  label: string;
  color?: string;
  id?: string;
}

A corporate-action or news event drawn as a colored badge near the bottom of the plot. The label string is truncated to two characters inside the badge. id enables click callbacks via chart.subscribeClick.


Data Feed

The data feed layer bridges broker APIs and the chart. The chart depends only on DataFeed; everything else in this section is an adapter or helper built on top of it.

UnsubscribeFn

type UnsubscribeFn = () => void;

Returned by subscribeBars and subscribeDepth; call it to cancel the subscription.

BarsRequest

interface BarsRequest {
  symbol: string;
  exchange: string;
  interval: string;
  from?: UTCSeconds;
  to?: UTCSeconds;
}

Parameters for a historical bars request. interval uses the OpenAlgo token format: '1m', '5m', '1h', 'D', etc.

DataFeed

interface DataFeed {
  getBars(req: BarsRequest): Promise<Bar[]>;
  subscribeBars?(req: BarsRequest, onBar: (bar: Bar) => void): UnsubscribeFn;
  subscribeDepth?(req: BarsRequest, onDepth: (depth: MarketDepth) => void): UnsubscribeFn;
}

Broker-agnostic market-data source. subscribeBars and subscribeDepth are optional; detect their presence with a feature check before calling.

DepthLevel

interface DepthLevel {
  price: number;
  qty: number;
  orders?: number;
}

A single price level in an order book snapshot.

MarketDepth

interface MarketDepth {
  bids: DepthLevel[];
  asks: DepthLevel[];
  ltp: number;
  ltq?: number;
}

An order book snapshot delivered to DataFeed.subscribeDepth. bids and asks length varies by broker (5 to 200 levels).

OrderSide

type OrderSide = 'BUY' | 'SELL';

Side of a PlaceOrder request.

OrderType

type OrderType = 'MARKET' | 'LIMIT' | 'SL' | 'SL-M';

Order type for a PlaceOrder request.

PlaceOrder

interface PlaceOrder {
  symbol: string;
  exchange: string;
  side: OrderSide;
  type: OrderType;
  qty: number;
  price?: number;
  triggerPrice?: number;
  /** Idempotency token so a retried request never double-fills. */
  clientToken?: string;
}

Parameters for TradeFeed.placeOrder.

TradeFeed

interface TradeFeed {
  placeOrder(o: PlaceOrder): Promise<{ orderId: string }>;
  modifyOrder(orderId: string, patch: Partial<PlaceOrder>): Promise<void>;
  cancelOrder(orderId: string): Promise<void>;
  subscribeOrders(cb: (orders: unknown[]) => void): UnsubscribeFn;
  subscribePositions(cb: (positions: unknown[]) => void): UnsubscribeFn;
}

Broker-agnostic trading source used by the order engine.

Candle Builder

VolumeMode

type VolumeMode = 'ltq-sum' | 'day-delta';

How CandleBuilder accounts for volume. 'ltq-sum' accumulates last-traded quantity from each tick; 'day-delta' diffs a cumulative day-volume counter (Quote mode).

LateTickPolicy

type LateTickPolicy = 'foldIntoBar' | 'dropOlderThanPrevBar';

What to do when a tick arrives with a timestamp older than the current bar’s open. 'foldIntoBar' merges it into the current bar; 'dropOlderThanPrevBar' discards it.

CandleBuilderOptions

interface CandleBuilderOptions {
  intervalSec: number;
  volumeMode: VolumeMode;
  lateTickPolicy: LateTickPolicy;
  sessionAnchorSec: number;
}

Configuration for CandleBuilder. sessionAnchorSec is the UTC-seconds of a known session open so that, for example, 5-minute bars start at 09:15 IST rather than an arbitrary epoch floor.

Tick

interface Tick {
  time: UTCSeconds;
  price: number;
  ltq?: number;
  cumDayVolume?: number;
}

A single price tick fed to CandleBuilder.onTick. Provide ltq when volumeMode is 'ltq-sum', or cumDayVolume when it is 'day-delta'.

CandleUpdate

interface CandleUpdate {
  bar: Bar;
  isNew: boolean;
}

Result of CandleBuilder.onTick. isNew is true when the tick started a new interval bar (append vs. mutate in place on the series).

Tick Aggregator

TickTimeframe

type TickTimeframe =
  | { mode: 'interval'; seconds: number; anchorSec?: number }
  | { mode: 'ticks'; count: number }
  | { mode: 'volume'; perBar: number };

Timeframe discriminant for TickBarAggregator. Three modes: clock-interval bars, tick-count bars, or traded-volume-per-bar.

AggTick

interface AggTick {
  time: number;
  price: number;
  qty: number;
}

A single trade tick fed to TickBarAggregator.onTick.

BarUpdate

interface BarUpdate {
  bar: Bar;
  isNew: boolean;
}

Result of TickBarAggregator.onTick. Mirrors CandleUpdate in semantics.

OpenAlgo Adapters

OpenAlgoConfig

interface OpenAlgoConfig {
  baseUrl: string;
  apiKey: string;
  /** Injectable fetch for offline tests. Defaults to global fetch. */
  fetchImpl?: typeof fetch;
}

Connection config for OpenAlgoDataFeed (history REST) and the base for OpenAlgoLiveConfig.

OpenAlgoLiveConfig

interface OpenAlgoLiveConfig extends OpenAlgoConfig {
  /** WS proxy URL, e.g. ws://127.0.0.1:8765. */
  wsUrl: string;
  /** Volume accounting for the live candle builder. Default 'ltq-sum'. */
  volumeMode?: VolumeMode;
}

Config for OpenAlgoLiveDataFeed, which combines REST history and WebSocket live ticks into a single DataFeed implementation.

WsMode

type WsMode = 'LTP' | 'Quote' | 'Depth';

OpenAlgo WebSocket data mode. 'LTP' delivers price and last-traded quantity; 'Quote' adds cumulative day volume; 'Depth' adds a full order book.

WsState

type WsState = 'connecting' | 'open' | 'closed' | 'error';

WebSocket lifecycle state reported by OpenAlgoWsFeed.onState(cb).

WsControlMessage

interface WsControlMessage {
  type?: string;
  status?: string;
  message?: string;
  [k: string]: unknown;
}

A non-market-data control frame (auth ack, subscribe ack, or server error) surfaced by OpenAlgoWsFeed.onControl(cb).

LtpEvent

interface LtpEvent {
  symbol: string;
  exchange: string;
  ltp: number;
  ltq?: number;
  /** Cumulative day volume (Quote mode). */
  volume?: number;
  timeSec: number;
}

Normalised last-trade-price event emitted by OpenAlgoWsFeed.onLtp(cb). timeSec is UTC seconds.

SocketLike

interface SocketLike {
  send(data: string): void;
  close(): void;
  onopen: (() => void) | null;
  onclose: (() => void) | null;
  onerror?: (() => void) | null;
  onmessage: ((ev: { data: string }) => void) | null;
  /** 1 === OPEN (matches browser WebSocket.OPEN). */
  readyState?: number;
}

The minimal socket surface required by OpenAlgoWsFeed. The browser WebSocket satisfies this interface. Pass a custom implementation via socketFactory in OpenAlgoWsConfig for testing.

OpenAlgoWsConfig

interface OpenAlgoWsConfig {
  url: string;
  apiKey: string;
  socketFactory?: SocketFactory;
}

Config for OpenAlgoWsFeed. socketFactory has the shape (url: string) => SocketLike and is injectable for testing.

OpenAlgoTradeConfig

interface OpenAlgoTradeConfig {
  baseUrl: string;
  apiKey: string;
  /** Strategy label sent with every order. OpenAlgo groups orders by strategy. */
  strategy?: string;
  defaultProduct?: 'CNC' | 'NRML' | 'MIS';
  fetchImpl?: typeof fetch;
}

Config for OpenAlgoTradeFeed. defaultProduct defaults to 'MIS'.


Indicators

SupertrendPoint

interface SupertrendPoint {
  /** The Supertrend band value, or NaN during ATR warmup. */
  value: number;
  /** -1 = uptrend (bullish), +1 = downtrend (bearish). */
  direction: -1 | 1;
}

One element per bar in the array returned by supertrend(bars, period, multiplier). value holds the Supertrend band level; it is NaN for warmup bars while ATR accumulates the required history. direction follows the OpenAlgo convention: -1 means the band is below price and acting as support (uptrend, bullish); +1 means it is above price and acting as resistance (downtrend, bearish).

import type { SupertrendPoint } from 'openalgo-charts';

See also supertrendSeries, which splits the same output into two Bar[] arrays — one per direction — so each renders as a separately-colored line that breaks at every trend flip.


Trading

Types for the data-driven trading visualization layer. See Trading API.

PositionSide

type PositionSide = 'long' | 'short';

TradingOrderSide

type TradingOrderSide = 'buy' | 'sell';

TradingOrderType

type TradingOrderType = 'limit' | 'stop' | 'stop_limit';

TradeMarkerVariant

type TradeMarkerVariant = 'chevron' | 'bubble' | 'count';

Visual style of a fill marker. 'chevron' draws a directional triangle at the fill price; 'bubble' draws a labeled circle; 'count' groups fills at the same bar and draws a count badge at the VWAP.

TradingLineVariant

type TradingLineVariant = 'standard' | 'line-only';

Whether a position or order line renders with its pill label and cancel button ('standard') or as a plain line without interactive controls ('line-only').

TradingLineStyle

type TradingLineStyle = 'solid' | 'dashed' | 'dotted';

Stroke style for an order line.

TradingPosition

interface TradingPosition {
  id: string;
  side: PositionSide;
  entryPrice: number;
  size: number;
  pnlText?: string;
  pnlPercent?: string;
  color?: string;
  readOnly?: boolean;
  variant?: TradingLineVariant;
}

A position record pushed to chart.trading.setPositions. The chart renders a horizontal price line at entryPrice with a pill showing side, size, and optional P&L text. Clicking the cancel box emits 'trading:position_close'.

TradingOrder

interface TradingOrder {
  id: string;
  type: TradingOrderType;
  side: TradingOrderSide;
  price: number;
  size: number;
  parentId?: string;
  bracketRole?: 'tp' | 'sl';
  color?: string;
  lineStyle?: TradingLineStyle;
  lineWidth?: number;
  readOnly?: boolean;
  draggable?: boolean;
  variant?: TradingLineVariant;
}

An order record pushed to chart.trading.setOrders. bracketRole tags the line as a take-profit or stop-loss leg of a bracket order. Dragging emits 'trading:order_modify'; clicking the cancel box emits 'trading:order_cancel'.

TradingTrade

interface TradingTrade {
  id: string;
  side: TradingOrderSide;
  price: number;
  size: number;
  /** Execution time in milliseconds. */
  timestamp: number;
  variant?: TradeMarkerVariant;
  color?: string;
  label?: string;
}

A fill record pushed to chart.trading.setTrades. Note that timestamp is milliseconds, not UTC seconds.

TradingSyncPayload

interface TradingSyncPayload {
  positions?: TradingPosition[];
  orders?: TradingOrder[];
  trades?: TradingTrade[];
}

Batch payload for chart.trading.syncState(payload). Omit a field to leave that collection unchanged.

TradingColors

interface TradingColors {
  long: string;
  short: string;
  order: string;
  tp: string;
  sl: string;
  buy: string;
  sell: string;
}

Color palette used by the trading layer for all rendered lines and markers. Read the current palette via chart.trading.getSettings().

TradingSettings

interface TradingSettings {
  longColor?: string;
  shortColor?: string;
  orderColor?: string;
  tpColor?: string;
  slColor?: string;
  buyColor?: string;
  sellColor?: string;
}

Partial color overrides passed to chart.trading.setSettings(settings).

TradingHost

interface TradingHost {
  addPrimitive(p: IPrimitive): void;
  removePrimitive(p: IPrimitive): void;
  subscribeClick(cb: (externalId: string) => void): void;
  subscribeDrag(
    onDrag: (externalId: string, price: number) => void,
    onDragEnd?: (externalId: string, price: number) => void,
  ): void;
  emit?(event: string, payload: unknown): void;
}

The minimal surface TradingController requires from the chart. The Chart class implements this. Useful when building test doubles or alternative host environments.


Keyboard Shortcuts

ShortcutScope

type ShortcutScope = 'hover' | 'global';

'hover' fires shortcuts while the pointer is over the chart or the chart is focused. 'global' fires regardless of focus.

ShortcutPreset

type ShortcutPreset = 'default' | 'alt';

Built-in binding presets. 'alt' remaps a few defaults to Alt-modified combos for hosts that reserve bare arrow keys for their own navigation.

KeymapEntry

interface KeymapEntry {
  command: string;
  label: string;
  combos: string[];
}

One entry in the active keymap (built-in or custom). combos are normalised physical-key combo strings (e.g. 'Mod+ArrowLeft').

CustomShortcut

interface CustomShortcut {
  command: string;
  label?: string;
  combos: string | string[];
  onTrigger: () => void;
}

A user-defined shortcut registered via ShortcutManager.addCustom(shortcut) or via ShortcutManagerOptions.customShortcuts.

ShortcutManagerOptions

interface ShortcutManagerOptions {
  preset?: ShortcutPreset;
  /** Rebind (string | string[]) or unbind (null) a command. */
  overrides?: Record<string, string | string[] | null>;
  disabledCommands?: string[];
  customShortcuts?: CustomShortcut[];
  scope?: ShortcutScope;
  persist?: boolean;
  storageKey?: string;
  /** Force platform detection (Mod = Cmd on mac, Ctrl elsewhere). Auto-detected when omitted. */
  isMac?: boolean;
}

Options for new ShortcutManager(options) or ChartOptions.shortcuts. persist saves rebinds and preset selection to localStorage under storageKey.

ShortcutTriggerEvent

interface ShortcutTriggerEvent {
  command: string;
  combo: string;
  isCustom: boolean;
}

Emitted by ShortcutManager.on(cb) whenever a command fires (built-in or custom).

ShortcutListItem

interface ShortcutListItem {
  command: string;
  label: string;
  combos: string[];
  isCustom: boolean;
  isDisabled: boolean;
}

One entry returned by ShortcutManager.list(). Useful for rendering a keyboard shortcut reference panel in a settings UI.