StockChart API

StockChart methods for loading OHLCV data, streaming candles, controlling ranges, and adding market layers.

Import
import { StockChart } from "@sixtyfold/stock";

Use the public entry point shown above.

ChartOverlayError

Error reported when one or more declarative overlay sources cannot be applied.

Import @sixtyfold/stockclass

class ChartOverlayError extends Error
MemberDefinitionDescription
cause?Error | undefinedCause for chart overlay error.
messagestringMessage text.
name"ChartOverlayError"Display name for this chart overlay error.
sourcesreadonly string[]Sources for chart overlay error.
stack?string | undefinedStack text.

ChartRendererError

Error reported when a chart renderer fails during startup or later use.

Import @sixtyfold/stockclass

class ChartRendererError extends Error
MemberDefinitionDescription
cause?Error | undefinedCause for chart renderer error.
messagestringMessage text.
name"ChartRendererError"Display name for this chart renderer error.
phaseRendererFailurePhasePhase for chart renderer error.
stack?string | undefinedStack text.

StockChart

Imperative browser chart for aggregated OHLCV candles, volume, analytics, profiles, price lines, and markers.

Import @sixtyfold/stockclass

class StockChart
MemberDefinitionDescription
addCandle(timestamp: number, open: number, high: number, low: number, close: number, volume: number) => voidAppends one OHLCV candle to the streaming buffer and batches rapid calls into one animation frame.
addCandleBatches(batches: readonly StockCandleBatch[], options?: StockAddCandlesOptions) => voidInstalls multiple OHLCV chunks in one renderer update. Worker mode transfers and detaches every chunk buffer; main-thread mode retains the arrays by reference.
addCandles(timestamps: Float64Array, opens: Float64Array, highs: Float64Array, lows: Float64Array, closes: Float64Array, volumes: Float64Array, options?: StockAddCandlesOptions) => voidAdds aligned OHLCV columns in one renderer update. Worker mode transfers and detaches the supplied buffers; main-thread mode retains the arrays by reference.
batch(fn: () => void) => voidGroups synchronous appearance and viewport changes into one update. Nested batches are combined; data-loading calls still run immediately.
destroy() => voidReleases the chart and its owned resources.
getAppearance() => DeepReadonly<StockAppearanceOptions>Returns a read-only snapshot of the mutable appearance subset.
getOptions() => DeepReadonly<StockChartOptions>Returns a full normalized read-only snapshot of all options (construction + current appearance).
getRenderMode() => "worker" | "main"Returns the resolved rendering mode ("worker" or "main").
getViewport() => ViewportReturns a snapshot of the current viewport.
initialize() => Promise<void>Wait until the renderer is ready for data and runtime commands. The construction-time initialization watchdog rejects this promise with a ChartRendererError when the worker or main-thread fallback does not become ready in the configured interval. Applications should await this method before installing their first dataset.
initStreaming(maxCandles?: number) => voidAllocates a fixed-capacity OHLCV ring buffer for live updates.
reset(options?: { animated?: boolean; }) => voidReset the viewport to the full data extent.
resize() => voidSynchronizes the renderer with the canvas size.
setData(data: OHLCVData) => voidLoads aligned OHLCV columns and gives the renderer ownership of the normalized arrays. Worker mode transfers and detaches the buffers; main-thread mode retains the arrays by reference.
setIndicators(indicators: StockIndicator[]) => voidReplaces the built-in technical indicator definitions.
setKeyboardAnnouncements(messages: false | KeyboardAnnouncementMessages) => voidReplace or disable the localized keyboard-action announcements at runtime. Existing pending announcements are cancelled.
setLabels(labels: ChartLabels) => voidUpdate chart labels at runtime. Merges into existing labels (same semantics as updateAppearance). Throws: TypeError for malformed labels or sparse/non-object custom entries.
setMarkers(markers: StockMarker[]) => voidReplace all sparse timestamp/price markers.
setOverlay(overlay: OverlayOptions) => Promise<void>Update declarative overlay primitives at runtime. Valid primitives and successfully decoded images are installed even when another image fails. If every requested item fails, the previously rendered overlay remains installed. Resolution and renderer-delivery failures reject with ChartOverlayError; register setOverlayErrorCallback when the application also needs asynchronous notification. When called before the lazy renderer is ready, this promise includes the readiness wait. Superseded updates and chart destruction are routine cancellation and resolve without installing.
setOverlayErrorCallback(callback: OverlayErrorCallback | null) => voidRegister a callback for non-fatal overlay resolution or delivery failures. Successful overlay items are still installed. The matching setOverlay promise also rejects with the same error.
setPriceLines(priceLines: StockPriceLine[]) => voidReplace all horizontal data-anchored price levels.
setRendererErrorCallback(callback: RendererErrorCallback | null) => voidRegister a one-shot renderer failure callback. Called once before teardown for initialization or runtime failures. Without a callback, errors use console.error. Pass null to cancel it; destroy calls do not invoke it.
setStatsCallback(callback: ((stats: StockChartStats) => void) | null, options?: StockChartStatsOptions) => voidEnables renderer statistics and receives throttled snapshots. Pass null to disable them.
setTimeRange(range: TimeRange) => voidApplies one of the exported calendar/session presets. The chart does not render controls. Application-owned controls may call this method for a preset or setViewport() for any timestamp range.
setViewport(viewport: Partial<Viewport>, options?: { animated?: boolean; }) => voidSet the viewport range programmatically. Only xMin and/or xMax need to be provided; omitted fields keep current values.
setVolumeProfile(volumeProfile: VolumeProfileOptions | false) => voidReplace or disable the estimated candle-derived visible-range volume profile.
updateAppearance(patch: DeepPartial<BaseAppearanceOptions>) => voidPatch mutable appearance options at runtime. Throws: TypeError for malformed labels or sparse/non-object custom entries.