StockChart API
StockChart methods for loading OHLCV data, streaming candles, controlling ranges, and adding market layers.
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/stock·class
class ChartOverlayError extends Error| Member | Definition | Description |
|---|---|---|
cause? | Error | undefined | Cause for chart overlay error. |
message | string | Message text. |
name | "ChartOverlayError" | Display name for this chart overlay error. |
sources | readonly string[] | Sources for chart overlay error. |
stack? | string | undefined | Stack text. |
ChartRendererError
Error reported when a chart renderer fails during startup or later use.
Import @sixtyfold/stock·class
class ChartRendererError extends Error| Member | Definition | Description |
|---|---|---|
cause? | Error | undefined | Cause for chart renderer error. |
message | string | Message text. |
name | "ChartRendererError" | Display name for this chart renderer error. |
phase | RendererFailurePhase | Phase for chart renderer error. |
stack? | string | undefined | Stack text. |
StockChart
Imperative browser chart for aggregated OHLCV candles, volume, analytics, profiles, price lines, and markers.
Import @sixtyfold/stock·class
class StockChart| Member | Definition | Description |
|---|---|---|
add | (timestamp: number, open: number, high: number, low: number, close: number, volume: number) => void | Appends one OHLCV candle to the streaming buffer and batches rapid calls into one animation frame. |
add | (batches: readonly StockCandleBatch[], options?: StockAddCandlesOptions) => void | Installs multiple OHLCV chunks in one renderer update. Worker mode transfers and detaches every chunk buffer; main-thread mode retains the arrays by reference. |
add | (timestamps: Float64Array, opens: Float64Array, highs: Float64Array, lows: Float64Array, closes: Float64Array, volumes: Float64Array, options?: StockAddCandlesOptions) => void | Adds 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) => void | Groups synchronous appearance and viewport changes into one update. Nested batches are combined; data-loading calls still run immediately. |
destroy | () => void | Releases the chart and its owned resources. |
get | () => DeepReadonly<StockAppearanceOptions> | Returns a read-only snapshot of the mutable appearance subset. |
get | () => DeepReadonly<StockChartOptions> | Returns a full normalized read-only snapshot of all options (construction + current appearance). |
get | () => "worker" | "main" | Returns the resolved rendering mode ("worker" or "main"). |
get | () => Viewport | Returns 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. |
init | (maxCandles?: number) => void | Allocates a fixed-capacity OHLCV ring buffer for live updates. |
reset | (options?: { animated?: boolean; }) => void | Reset the viewport to the full data extent. |
resize | () => void | Synchronizes the renderer with the canvas size. |
set | (data: OHLCVData) => void | Loads 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. |
set | (indicators: StockIndicator[]) => void | Replaces the built-in technical indicator definitions. |
set | (messages: false | KeyboardAnnouncementMessages) => void | Replace or disable the localized keyboard-action announcements at runtime. Existing pending announcements are cancelled. |
set | (labels: ChartLabels) => void | Update chart labels at runtime. Merges into existing labels (same semantics as updateAppearance). Throws: TypeError for malformed labels or sparse/non-object custom entries. |
set | (markers: StockMarker[]) => void | Replace all sparse timestamp/price markers. |
set | (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. |
set | (callback: OverlayErrorCallback | null) => void | Register 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. |
set | (priceLines: StockPriceLine[]) => void | Replace all horizontal data-anchored price levels. |
set | (callback: RendererErrorCallback | null) => void | Register 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. |
set | (callback: ((stats: StockChartStats) => void) | null, options?: StockChartStatsOptions) => void | Enables renderer statistics and receives throttled snapshots. Pass null to disable them. |
set | (range: TimeRange) => void | Applies 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. |
set | (viewport: Partial<Viewport>, options?: { animated?: boolean; }) => void | Set the viewport range programmatically. Only xMin and/or xMax need to be provided; omitted fields keep current values. |
set | (volumeProfile: VolumeProfileOptions | false) => void | Replace or disable the estimated candle-derived visible-range volume profile. |
update | (patch: DeepPartial<BaseAppearanceOptions>) => void | Patch mutable appearance options at runtime. Throws: TypeError for malformed labels or sparse/non-object custom entries. |