@christtrade/depth 0.12.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/LICENSE.md +201 -0
  2. package/NOTICE +15 -0
  3. package/README.md +159 -0
  4. package/depth.cjs +1136 -0
  5. package/depth.css +2 -0
  6. package/depth.mjs +1136 -0
  7. package/depth.nopreflight.css +2 -0
  8. package/index.d.ts +1 -0
  9. package/package.json +32 -0
  10. package/types/ChartInner.d.ts +114 -0
  11. package/types/ChartOuter.d.ts +31 -0
  12. package/types/components/account/AccountSummary.d.ts +8 -0
  13. package/types/components/chart/chart-context-menu.d.ts +30 -0
  14. package/types/components/chart/chart-settings-dialog.d.ts +15 -0
  15. package/types/components/chart/chart-status-overlay.d.ts +24 -0
  16. package/types/components/chart/data-status.d.ts +10 -0
  17. package/types/components/chart/pane-legend.d.ts +37 -0
  18. package/types/components/chart/session-status-badge.d.ts +14 -0
  19. package/types/components/chart/status-bar.d.ts +9 -0
  20. package/types/components/chart/symbol-icon.d.ts +9 -0
  21. package/types/components/chart/tz.d.ts +10 -0
  22. package/types/components/drawings/drawing-icons.d.ts +2 -0
  23. package/types/components/drawings/drawing-settings-bar.d.ts +15 -0
  24. package/types/components/drawings/drawing-settings-dialog.d.ts +268 -0
  25. package/types/components/drawings/drawing-toolbar.d.ts +14 -0
  26. package/types/components/drawings/drawing-tools.d.ts +23 -0
  27. package/types/components/indicators/indicators-dialog.d.ts +20 -0
  28. package/types/components/indicators/indicators-settings-dialog.d.ts +164 -0
  29. package/types/components/multi-chart/GridDividers.d.ts +12 -0
  30. package/types/components/multi-chart/LayoutPicker.d.ts +19 -0
  31. package/types/components/plugin-panels/BottomBarPluginHost.d.ts +7 -0
  32. package/types/components/plugin-panels/PluginFixedPanelHost.d.ts +18 -0
  33. package/types/components/plugin-panels/PluginToolbarHost.d.ts +7 -0
  34. package/types/components/plugin-panels/PluginWindowsDropdown.d.ts +7 -0
  35. package/types/components/plugins/plugin-manager-dialog.d.ts +14 -0
  36. package/types/components/toolbar/SymbolSwitcher.d.ts +8 -0
  37. package/types/components/toolbar/chart-icons.d.ts +16 -0
  38. package/types/components/toolbar/chart-type-selector.d.ts +11 -0
  39. package/types/components/toolbar/timeframe-selector.d.ts +15 -0
  40. package/types/components/trading/OrderPanel.d.ts +36 -0
  41. package/types/components/trading/QuickTradingButtons.d.ts +7 -0
  42. package/types/components/trading/order-math.d.ts +94 -0
  43. package/types/components/ui/button.d.ts +11 -0
  44. package/types/components/ui/checkbox.d.ts +4 -0
  45. package/types/components/ui/color-picker.d.ts +12 -0
  46. package/types/components/ui/dialog.d.ts +19 -0
  47. package/types/components/ui/dropdown-menu.d.ts +27 -0
  48. package/types/components/ui/hover-card.d.ts +6 -0
  49. package/types/components/ui/input.d.ts +4 -0
  50. package/types/components/ui/popover.d.ts +7 -0
  51. package/types/components/ui/resizable.d.ts +23 -0
  52. package/types/components/ui/separator.d.ts +4 -0
  53. package/types/components/ui/slider.d.ts +4 -0
  54. package/types/components/ui/switch.d.ts +4 -0
  55. package/types/components/ui/tooltip.d.ts +7 -0
  56. package/types/core/AccountManager.d.ts +142 -0
  57. package/types/core/ChartModel.d.ts +84 -0
  58. package/types/core/ChartState.d.ts +51 -0
  59. package/types/core/ChartTypeRegistry.d.ts +27 -0
  60. package/types/core/DataEngine.d.ts +143 -0
  61. package/types/core/DataSourceRegistry.d.ts +106 -0
  62. package/types/core/DepthChart.d.ts +458 -0
  63. package/types/core/DrawingRegistry.d.ts +133 -0
  64. package/types/core/DrawingStore.d.ts +26 -0
  65. package/types/core/ExecutionEngine.d.ts +95 -0
  66. package/types/core/GlobalChartBus.d.ts +32 -0
  67. package/types/core/Playback.d.ts +48 -0
  68. package/types/core/PlaybackStateRegistry.d.ts +25 -0
  69. package/types/core/PluginRegistry.d.ts +67 -0
  70. package/types/core/PluginSchedule.d.ts +15 -0
  71. package/types/core/RenderEngine.d.ts +143 -0
  72. package/types/core/ScriptedPlugin.d.ts +153 -0
  73. package/types/core/SessionMapper.d.ts +54 -0
  74. package/types/core/SessionUtils.d.ts +53 -0
  75. package/types/core/TypedEventBus.d.ts +691 -0
  76. package/types/core/WasmPluginHost.d.ts +39 -0
  77. package/types/core/index.d.ts +70 -0
  78. package/types/core/plugin-startup.d.ts +33 -0
  79. package/types/core/processing/data-chunk.d.ts +37 -0
  80. package/types/core/processing/data-level.d.ts +13 -0
  81. package/types/core/processing/l2-processor.d.ts +10 -0
  82. package/types/core/processing/l3-processor.d.ts +26 -0
  83. package/types/core/processing/ohlcv-processor.d.ts +14 -0
  84. package/types/core/processing/tick-processor.d.ts +14 -0
  85. package/types/core/script-dsl.d.ts +20 -0
  86. package/types/core/script-scope.d.ts +4 -0
  87. package/types/core/script.worker.d.ts +1 -0
  88. package/types/hooks/useCellBridges.d.ts +36 -0
  89. package/types/hooks/useChartData.d.ts +153 -0
  90. package/types/hooks/useChartHandlers.d.ts +94 -0
  91. package/types/hooks/useChartInteraction.d.ts +160 -0
  92. package/types/hooks/useChartLayout.d.ts +21 -0
  93. package/types/hooks/useChartPlugin.d.ts +34 -0
  94. package/types/hooks/useChartSettings.d.ts +44 -0
  95. package/types/hooks/useChartSubscriptions.d.ts +64 -0
  96. package/types/hooks/useChartView.d.ts +47 -0
  97. package/types/hooks/usePlaybackEngine.d.ts +85 -0
  98. package/types/hooks/useRenderEngine.d.ts +64 -0
  99. package/types/hooks/useTradeLines.d.ts +80 -0
  100. package/types/hooks/useTradingState.d.ts +135 -0
  101. package/types/interfaces/IAccountAdapter.d.ts +38 -0
  102. package/types/interfaces/ICoordinateTransformer.d.ts +105 -0
  103. package/types/interfaces/IDataAdapter.d.ts +402 -0
  104. package/types/interfaces/IExecutionAdapter.d.ts +71 -0
  105. package/types/interfaces/plugins/IChartPlugin.d.ts +254 -0
  106. package/types/interfaces/plugins/IChartTypePlugin.d.ts +126 -0
  107. package/types/interfaces/plugins/IDataSourcePlugin.d.ts +20 -0
  108. package/types/interfaces/plugins/IDrawingPlugin.d.ts +62 -0
  109. package/types/interfaces/plugins/IIndicatorPlugin.d.ts +97 -0
  110. package/types/interfaces/plugins/index.d.ts +5 -0
  111. package/types/lib/bar-grid.d.ts +6 -0
  112. package/types/lib/book.d.ts +5 -0
  113. package/types/lib/clock.d.ts +7 -0
  114. package/types/lib/compact-buffer.d.ts +66 -0
  115. package/types/lib/constants.d.ts +5 -0
  116. package/types/lib/createSimulatedAdapter.d.ts +42 -0
  117. package/types/lib/dpr.d.ts +27 -0
  118. package/types/lib/heatmap.worker.d.ts +1 -0
  119. package/types/lib/indicator-stdlib.d.ts +426 -0
  120. package/types/lib/indicator-worker.d.ts +65 -0
  121. package/types/lib/matchingEngine.d.ts +144 -0
  122. package/types/lib/notifications/tradeToast.d.ts +31 -0
  123. package/types/lib/pointer-lock.d.ts +5 -0
  124. package/types/lib/priceFormat.d.ts +17 -0
  125. package/types/lib/priceTransition.d.ts +22 -0
  126. package/types/lib/renderers/drawFootprintChart.d.ts +5 -0
  127. package/types/lib/renderers/drawTradeLines.d.ts +112 -0
  128. package/types/lib/renderers/drawings-renderer.d.ts +57 -0
  129. package/types/lib/renderers/renderer.d.ts +113 -0
  130. package/types/lib/sampler.d.ts +7 -0
  131. package/types/lib/series/japaneseCharts.d.ts +88 -0
  132. package/types/lib/slice-worker-client.d.ts +138 -0
  133. package/types/lib/slice.worker.d.ts +139 -0
  134. package/types/lib/storage.d.ts +108 -0
  135. package/types/lib/symbol-info.d.ts +12 -0
  136. package/types/lib/symbol-search.d.ts +29 -0
  137. package/types/lib/timeframes.d.ts +46 -0
  138. package/types/lib/tradingview-import.d.ts +32 -0
  139. package/types/lib/types/chart-settings.d.ts +90 -0
  140. package/types/lib/types/drawing-types.d.ts +393 -0
  141. package/types/lib/types/footprint.d.ts +119 -0
  142. package/types/lib/types/heatmap-types.d.ts +30 -0
  143. package/types/lib/types/index.d.ts +147 -0
  144. package/types/lib/types/indicator-types.d.ts +123 -0
  145. package/types/lib/types/layout-sync.d.ts +43 -0
  146. package/types/lib/types/trading-types.d.ts +323 -0
  147. package/types/lib/use-forwarded-ref.d.ts +1 -0
  148. package/types/lib/utils.d.ts +2 -0
  149. package/types/plugins/alligator.d.ts +1 -0
  150. package/types/plugins/atr.d.ts +1 -0
  151. package/types/plugins/awesome-oscillator.d.ts +1 -0
  152. package/types/plugins/bollinger-bands.d.ts +1 -0
  153. package/types/plugins/cci.d.ts +1 -0
  154. package/types/plugins/cvd.d.ts +1 -0
  155. package/types/plugins/donchian.d.ts +1 -0
  156. package/types/plugins/ichimoku.d.ts +1 -0
  157. package/types/plugins/index.d.ts +25 -0
  158. package/types/plugins/keltner.d.ts +1 -0
  159. package/types/plugins/macd.d.ts +1 -0
  160. package/types/plugins/mfi.d.ts +1 -0
  161. package/types/plugins/moving-average.d.ts +1 -0
  162. package/types/plugins/obv.d.ts +1 -0
  163. package/types/plugins/psar.d.ts +1 -0
  164. package/types/plugins/rsi.d.ts +1 -0
  165. package/types/plugins/sessions.d.ts +1 -0
  166. package/types/plugins/stochastic.d.ts +1 -0
  167. package/types/plugins/supertrend.d.ts +1 -0
  168. package/types/plugins/volume.d.ts +1 -0
  169. package/types/plugins/vwap.d.ts +1 -0
  170. package/types/plugins/williams-r.d.ts +1 -0
  171. package/types/react/useDepthChart.d.ts +6 -0
@@ -0,0 +1,39 @@
1
+ export interface WasmPluginExports {
2
+ memory: WebAssembly.Memory;
3
+ alloc(bytes: number): number;
4
+ dealloc(ptr: number, bytes: number): void;
5
+ init(barsPtr: number, barRows: number, tradesPtr: number, tradeRows: number, barMs: number): number;
6
+ update?(barsPtr: number, barRows: number, tradesPtr: number, tradeRows: number, barMs: number): number;
7
+ set_params?(ptr: number, bytes: number): void;
8
+ }
9
+ export interface WasmBar {
10
+ ts: bigint | number;
11
+ open: number;
12
+ high: number;
13
+ low: number;
14
+ close: number;
15
+ volume: number;
16
+ }
17
+ export interface WasmTrade {
18
+ ts: bigint | number;
19
+ price: number;
20
+ size: number;
21
+ side: string;
22
+ }
23
+ export declare class WasmPlugin {
24
+ private readonly exports;
25
+ private readonly pluginId;
26
+ constructor(exports: WasmPluginExports, pluginId: string);
27
+ /** Without one, every horizon tick re-runs init over the full window. */
28
+ get hasUpdate(): boolean;
29
+ /** Hands the plugin's declared params over as JSON. No-op if it takes none. */
30
+ setParams(params: Record<string, unknown>): void;
31
+ init(bars: WasmBar[], trades: WasmTrade[], barNs: bigint): Float64Array | null;
32
+ update(bars: WasmBar[], trades: WasmTrade[], barNs: bigint): Float64Array | null;
33
+ private alloc;
34
+ private call;
35
+ private readResult;
36
+ }
37
+ export declare function instantiateWasmPlugin(wasmUrl: string, pluginId: string): Promise<WasmPlugin>;
38
+ /** Drops a module from the compile cache, so the next load refetches it. */
39
+ export declare function evictWasmModule(wasmUrl: string): void;
@@ -0,0 +1,70 @@
1
+ export { DepthChart } from './DepthChart';
2
+ export type { ChartOptions } from './DepthChart';
3
+ export { useDepthChart } from '../react/useDepthChart';
4
+ export { default as Depth } from '../ChartOuter';
5
+ export type { DepthProps } from '../ChartOuter';
6
+ export { ExecutionEngine } from './ExecutionEngine';
7
+ export { DataEngine } from './DataEngine';
8
+ export type { DataEngineConfig, ChartDataSnapshot } from './DataEngine';
9
+ export { TypedEventBus } from './TypedEventBus';
10
+ export type { ChartEvents } from './TypedEventBus';
11
+ export { RenderEngine } from './RenderEngine';
12
+ export type { DrawParams } from './RenderEngine';
13
+ export type { IDataAdapter, DataLevel, TickEvent, OhlcvBar, L2Snapshot, MboEvent, } from '../interfaces/IDataAdapter';
14
+ export type { IExecutionAdapter } from '../interfaces/IExecutionAdapter';
15
+ export { LiveTransformer } from '../interfaces/ICoordinateTransformer';
16
+ export type { ICoordinateTransformer, PriceScaleMode, TransformedDrawHook, } from '../interfaces/ICoordinateTransformer';
17
+ export { PluginRegistry } from './PluginRegistry';
18
+ export type { PluginIcon, InstalledPlugin } from './PluginRegistry';
19
+ export type { PluginCatalogEntry, PluginStartupEntry, PluginStartupRecord, } from './plugin-startup';
20
+ export type { StyleField } from '../components/drawings/drawing-settings-dialog';
21
+ export type { PluginDrawingToolDef } from './DrawingRegistry';
22
+ export type { PluginDataSource } from './DataSourceRegistry';
23
+ export { ChartModel } from './ChartModel';
24
+ export type { ChartModelInit, ChartPluginRef, ChartPaneState } from './ChartModel';
25
+ export { DrawingStore } from './DrawingStore';
26
+ export type { ChartPlugin, PluginType, Permission, PluginManifest, PluginContext, PluginDataSnapshot, DrawingPlugin, ChartTypePlugin, ChartTypeRenderContext, DataSourcePlugin, IndicatorPlugin, IndicatorRenderContext, } from '../interfaces/plugins';
27
+ export { createScriptedPlugin } from './ScriptedPlugin';
28
+ export { isCompatible, DATA_LEVEL_LABELS, incompatibleReason } from './processing/data-level';
29
+ export { processL3Chunk, mergeL3Chunks } from './processing/l3-processor';
30
+ export type { ProcessedL3Chunk, L3DataChunk } from './processing/l3-processor';
31
+ export { processOhlcvChunk, processOhlcvWithSupplemental } from './processing/ohlcv-processor';
32
+ export type { OhlcvDataChunk } from './processing/ohlcv-processor';
33
+ export { processTickChunk } from './processing/tick-processor';
34
+ export type { TickDataChunk } from './processing/tick-processor';
35
+ export { processL2Chunk } from './processing/l2-processor';
36
+ export type { L2DataChunk } from './processing/l2-processor';
37
+ export type { DataChunk } from './processing/data-chunk';
38
+ export { isEmptyChunk } from './processing/data-chunk';
39
+ export type { TradePoint, PriceHistory, ViewBounds, OhlcvBarMs } from '../lib/types';
40
+ export type { Timeframe } from '../lib/timeframes';
41
+ export type { DrawingTool } from '../lib/types/drawing-types';
42
+ export type { FootprintBar, FootprintOptions } from '../lib/types/footprint';
43
+ export type { ChartSettings } from '../lib/types/chart-settings';
44
+ export { DEFAULT_CHART_SETTINGS } from '../lib/types/chart-settings';
45
+ export type { PlaceOrderRequest, L3EngineOptions, FeeSchedule } from '../lib/matchingEngine';
46
+ export { createL3MatchingEngine, feeScheduleFor, MICRO_FEE_SCHEDULE, NQ_FEE_SCHEDULE, ZERO_FEE_SCHEDULE, } from '../lib/matchingEngine';
47
+ export { SimulatedMarketAdapter, createSimulatedAdapter } from '../lib/createSimulatedAdapter';
48
+ export { AccountManager } from './AccountManager';
49
+ export type { AccountOptions, AccountSaveState } from './AccountManager';
50
+ export type { ChartSaveState, LayoutDescriptor } from './DepthChart';
51
+ export { SAVE_VERSION, stringifyChartSave, parseChartSave } from './DepthChart';
52
+ export type { IAccountAdapter, AccountAdapterCallbacks, AccountSnapshot, } from '../interfaces/IAccountAdapter';
53
+ export { AccountSummary } from '../components/account/AccountSummary';
54
+ export { QuickTradingButtons } from '../components/trading/QuickTradingButtons';
55
+ export { OrderPanel } from '../components/trading/OrderPanel';
56
+ export type { OrderPanelProps } from '../components/trading/OrderPanel';
57
+ export { AMOUNT_MODES, amountFromQty, contractValue, deriveTicket, levelPrice, levelTicks, moneyPerTick, priceDecimals, qtyFromAmount, roundQty, roundToTick, specForSymbol, tickSizeOf, tickValueOf, ticketFromPosition, ticksBetween, } from '../components/trading/order-math';
58
+ export type { AmountMode, Ticket, TicketInput, TicketProblem, } from '../components/trading/order-math';
59
+ export { isMarketOpen, nextOpenNs, prevCloseNs, clipToSession, getSessionStatus, } from './SessionUtils';
60
+ export type { SessionWindow, SessionStatus } from './SessionUtils';
61
+ export type { SymbolInfo, SymbolType, SymbolSearchMode, SymbolSearchRequest, SymbolSearchResponse, AdapterCapabilities, TradingSession, TradingSubsession, DayOfWeek, SessionCorrection, PriceFormat, FractionalFormat, ContractSpec, } from '../interfaces/IDataAdapter';
62
+ /** The built-in matcher, so server-side adapters can rank like the picker does. */
63
+ export { searchSymbolsLocally, normalizeSymbolSearchResponse } from '../lib/symbol-search';
64
+ export { SessionMapper, createSessionMapper } from './SessionMapper';
65
+ export type { SessionSegment } from './SessionMapper';
66
+ export { walkBackMarketNs } from './SessionUtils';
67
+ export { STORAGE_NAMESPACE, StorageKey, isPersistenceEnabled, setPersistenceEnabled, onPersistenceChange, onChartStorageChange, clearChartStorage, chartStorageKeys, chartStorageSize, serializeChartPreferences, restoreChartPreferences, readJSON, writeJSON, setChartStorageBackend, } from '../lib/storage';
68
+ export type { ChartPreferences, ChartStorageBackend } from '../lib/storage';
69
+ export { importTradingViewSettings, hasTradingViewSettings, readTradingViewChartSettings, readTradingViewFavoriteDrawings, resetTradingViewImport, } from '../lib/tradingview-import';
70
+ export type { TradingViewImportResult } from '../lib/tradingview-import';
@@ -0,0 +1,33 @@
1
+ import type { PluginType } from '../interfaces/plugins/IChartPlugin';
2
+ /**
3
+ * A plugin the host has code for, whether or not it is loaded. Supplied by
4
+ * `chart.setPluginCatalog()`; the chart resolves ids against it when it loads
5
+ * startup plugins and when the plugin manager offers one.
6
+ */
7
+ export interface PluginCatalogEntry {
8
+ id: string;
9
+ /** Source, in the chart's plugin scripting language. */
10
+ code: string;
11
+ name?: string;
12
+ type?: PluginType;
13
+ description?: string;
14
+ group?: string;
15
+ }
16
+ /**
17
+ * What should happen to a plugin when the chart opens.
18
+ *
19
+ * `autostart: false` is a tombstone, not an absence - it says the user turned
20
+ * this plugin off, which a save document restored from another session must not
21
+ * override. An id with no entry at all has no opinion attached.
22
+ */
23
+ export interface PluginStartupEntry {
24
+ /** Install the plugin when the chart opens. */
25
+ autostart: boolean;
26
+ /** Indicators only: also put an instance on a pane. */
27
+ activate?: boolean;
28
+ }
29
+ export type PluginStartupRecord = Record<string, PluginStartupEntry>;
30
+ export declare function ptrace(...args: unknown[]): void;
31
+ export declare function readPluginStartup(): PluginStartupRecord;
32
+ /** Merge a patch into one plugin's entry. `null` forgets the plugin entirely. */
33
+ export declare function writePluginStartup(id: string, patch: Partial<PluginStartupEntry> | null): PluginStartupRecord;
@@ -0,0 +1,37 @@
1
+ import type { OhlcvBar } from '../../interfaces/IDataAdapter';
2
+ import type { SerialTrade } from '../../lib/types';
3
+ import type { PriceHistory } from '../../lib/types';
4
+ import type { FootprintBar } from '../../lib/types/footprint';
5
+ export interface L3DataChunk {
6
+ kind: 'l3';
7
+ /** 20-byte compact encoding of all MBO events. L3-only. */
8
+ compactBuf: ArrayBuffer;
9
+ trades: SerialTrade[];
10
+ priceHistory: PriceHistory[];
11
+ footprintBars: FootprintBar[];
12
+ dataStart: number;
13
+ dataEnd: number;
14
+ }
15
+ export interface TickDataChunk {
16
+ kind: 'tick';
17
+ trades: SerialTrade[];
18
+ priceHistory: PriceHistory[];
19
+ footprintBars: FootprintBar[];
20
+ dataStart: number;
21
+ dataEnd: number;
22
+ }
23
+ export interface OhlcvDataChunk {
24
+ kind: 'ohlcv';
25
+ ohlcvBars: OhlcvBar[];
26
+ dataStart: number;
27
+ dataEnd: number;
28
+ }
29
+ export interface L2DataChunk {
30
+ kind: 'l2';
31
+ priceHistory: PriceHistory[];
32
+ dataStart: number;
33
+ dataEnd: number;
34
+ }
35
+ export type DataChunk = L3DataChunk | TickDataChunk | OhlcvDataChunk | L2DataChunk;
36
+ export declare function isEmptyChunk(chunk: DataChunk): boolean;
37
+ export declare function mergeChunks(a: DataChunk, b: DataChunk): DataChunk;
@@ -0,0 +1,13 @@
1
+ import type { DataLevel } from '../../interfaces/IDataAdapter';
2
+ /**
3
+ * Does `actual` satisfy the `required` minimum level?
4
+ *
5
+ * @example
6
+ * isCompatible('ohlcv', 'l3') // true, l3 can serve ohlcv plugins
7
+ * isCompatible('l3', 'ohlcv') // false, ohlcv cannot serve l3 plugins
8
+ */
9
+ export declare function isCompatible(required: DataLevel, actual: DataLevel): boolean;
10
+ /** How a data level is written for the user. Nobody outside the code says "l3". */
11
+ export declare const DATA_LEVEL_LABELS: Record<DataLevel, string>;
12
+ /** The one line shown when something is refused for want of richer data. */
13
+ export declare function incompatibleReason(required: DataLevel, actual: DataLevel): string;
@@ -0,0 +1,10 @@
1
+ import type { L2Snapshot } from '../../interfaces/IDataAdapter';
2
+ import type { PriceHistory } from '../../lib/types';
3
+ export interface L2DataChunk {
4
+ kind: 'l2';
5
+ priceHistory: PriceHistory[];
6
+ /** Unix ms timestamps */
7
+ dataStart: number;
8
+ dataEnd: number;
9
+ }
10
+ export declare function processL2Chunk(snapshots: L2Snapshot[], _barNs: bigint): L2DataChunk;
@@ -0,0 +1,26 @@
1
+ import { type FootprintBar, type FootprintOptions } from '../../lib/types/footprint';
2
+ import type { MboEvent, PriceHistory } from '../../lib/types';
3
+ import type { SerialTrade } from '../../lib/types';
4
+ export interface ProcessedL3Chunk {
5
+ kind: 'l3';
6
+ /** 20-byte compact encoding of all MBO events. L3-only. */
7
+ compactBuf: ArrayBuffer;
8
+ trades: SerialTrade[];
9
+ priceHistory: PriceHistory[];
10
+ footprintBars: FootprintBar[];
11
+ /** ISO timestamp of the first event. */
12
+ dataStart: number;
13
+ /** ISO timestamp of the last event. */
14
+ dataEnd: number;
15
+ }
16
+ export type L3DataChunk = ProcessedL3Chunk;
17
+ /**
18
+ * Process a batch of L3 MboEvents into the internal representation.
19
+ *
20
+ * @param events Raw MBO events, sorted ascending by ts_event.
21
+ * @param barNs Bar size in ns for the footprint. Pass 0n to skip it.
22
+ * @param fpOptions Forwarded to buildFootprint().
23
+ */
24
+ export declare function processL3Chunk(events: MboEvent[], barNs: bigint, fpOptions?: FootprintOptions): ProcessedL3Chunk;
25
+ /** Merge two chunks in order, earlier one first. */
26
+ export declare function mergeL3Chunks(a: ProcessedL3Chunk, b: ProcessedL3Chunk): ProcessedL3Chunk;
@@ -0,0 +1,14 @@
1
+ import type { OhlcvBar, SupplementalBarSet } from '../../interfaces/IDataAdapter';
2
+ export interface OhlcvDataChunk {
3
+ kind: 'ohlcv';
4
+ ohlcvBars: OhlcvBar[];
5
+ /** Unix ms timestamps */
6
+ dataStart: number;
7
+ dataEnd: number;
8
+ supplemental?: Array<{
9
+ resolution: bigint;
10
+ bars: OhlcvBar[];
11
+ }>;
12
+ }
13
+ export declare function processOhlcvChunk(bars: OhlcvBar[], _barNs: bigint): OhlcvDataChunk;
14
+ export declare function processOhlcvWithSupplemental(primaryBars: OhlcvBar[], _supplemental: SupplementalBarSet[], barNs: bigint): OhlcvDataChunk;
@@ -0,0 +1,14 @@
1
+ import type { TickEvent } from '../../interfaces/IDataAdapter';
2
+ import type { SerialTrade } from '../../lib/types';
3
+ import type { PriceHistory } from '../../lib/types';
4
+ import type { FootprintBar } from '../../lib/types/footprint';
5
+ export interface TickDataChunk {
6
+ kind: 'tick';
7
+ trades: SerialTrade[];
8
+ priceHistory: PriceHistory[];
9
+ footprintBars: FootprintBar[];
10
+ /** Unix ms timestamps */
11
+ dataStart: number;
12
+ dataEnd: number;
13
+ }
14
+ export declare function processTickChunk(ticks: TickEvent[], barNs: bigint): TickDataChunk;
@@ -0,0 +1,20 @@
1
+ export declare const PluginType: Readonly<{
2
+ readonly indicator: "indicator";
3
+ readonly drawing: "drawing";
4
+ readonly chartType: "chart-type";
5
+ readonly dataSource: "data-source";
6
+ readonly extension: "extension";
7
+ }>;
8
+ export declare const DataLevel: Readonly<{
9
+ readonly mbo: "l3";
10
+ readonly l3: "l3";
11
+ readonly l2: "l2";
12
+ readonly ohlcv: "ohlcv";
13
+ readonly tick: "tick";
14
+ }>;
15
+ export declare const Layout: Readonly<{
16
+ readonly overlay: "overlay";
17
+ readonly pane: "pane";
18
+ }>;
19
+ /** The DSL globals as one bag, for splatting into an eval scope. */
20
+ export declare const SCRIPT_DSL: Record<string, unknown>;
@@ -0,0 +1,4 @@
1
+ /** Resolves a handler source string against a prepared script scope. */
2
+ export type ScopedCompiler = <T extends Function>(src: string | null | undefined) => T | null;
3
+ export declare function compileFromSrc<T extends Function>(src: string | null | undefined): T | null;
4
+ export declare function makeScopedCompiler(script: string, extra?: Record<string, unknown>, onError?: (msg: string) => void): ScopedCompiler;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { DepthChart, ExecutionEngine } from '../core';
2
+ import { TypedEventBus } from '../core/TypedEventBus';
3
+ export declare const MAX = 8;
4
+ export declare function useTradingBridge(symbol: string, externalEngine?: ExecutionEngine, eventBus?: TypedEventBus, chart?: DepthChart): {
5
+ symbol: string;
6
+ trading: import("./useTradingState").UseTradingStateReturn;
7
+ executionEngine: ExecutionEngine;
8
+ redrawFnRef: import("react").MutableRefObject<() => void>;
9
+ tradingEvents: import("react").MutableRefObject<any[]>;
10
+ };
11
+ export type TradingBridge = ReturnType<typeof useTradingBridge>;
12
+ export interface CellBridges {
13
+ /**
14
+ * Indexed by cell. Cells on the same symbol get the *same* bridge object -
15
+ * that is the point, so don't dedupe by identity and don't assume
16
+ * `byCell.length` distinct engines.
17
+ */
18
+ byCell: TradingBridge[];
19
+ /**
20
+ * One entry per distinct symbol on screen.
21
+ *
22
+ * Anything fanned out to engines - data ingest, playback seeks - must walk
23
+ * this, not `byCell`: handing a bar stream to a shared engine once per cell
24
+ * showing it replays the same bars through the fill logic N times.
25
+ */
26
+ bySymbol: TradingBridge[];
27
+ }
28
+ export declare function useCellBridges(symbols: string[], eventBus: TypedEventBus, chart?: DepthChart,
29
+ /**
30
+ * The one ExecutionEngine every bridge registers its book with - normally
31
+ * `chart.executionEngine`, which is also what plugins call and what the
32
+ * DataEngine settles jump gaps through. Leave it out and each bridge gets a
33
+ * private wrapper, which is fine for a single chart but leaves those two
34
+ * holding an engine with no books in it.
35
+ */
36
+ engine?: ExecutionEngine): CellBridges;
@@ -0,0 +1,153 @@
1
+ import { type MutableRefObject, type RefObject } from 'react';
2
+ import { type BookState } from '../lib/types';
3
+ import { type PriceHistory, type TradePoint, type ViewBounds, type OhlcvBarMs } from '../lib/types';
4
+ import { type FootprintBar } from '../lib/types/footprint';
5
+ import { type CompactBuffer } from '../lib/compact-buffer';
6
+ import { type SerialTrade } from '../lib/types';
7
+ import { SymbolInfo } from '../interfaces/IDataAdapter';
8
+ import { type DataLevel, type TradingSession } from '../interfaces/IDataAdapter';
9
+ import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
10
+ import { type DomPanelHandle } from '../lib/types';
11
+ import { type Indicator, type ChartPane, type Rect } from '../lib/types/indicator-types';
12
+ import { type Timeframe } from '../lib/timeframes';
13
+ import { type ChartSettings } from '../lib/types/chart-settings';
14
+ import { type TypedEventBus } from '../core/TypedEventBus';
15
+ import { type RenderEngine } from '../core/RenderEngine';
16
+ import { type SessionMapper } from '../core/SessionMapper';
17
+ import { ohlcvBucketRange } from '../lib/bar-grid';
18
+ import { type SessionStatus } from '../core/SessionUtils';
19
+ export { ohlcvBucketRange };
20
+ export declare function aggregateOhlcvBars(bars: OhlcvBarMs[], targetBarNs: bigint, sessionMapper?: SessionMapper | null): OhlcvBarMs[];
21
+ /**
22
+ * Incrementally prepend newly fetched bars to an existing aggregated display array.
23
+ * O(new_bars) instead of O(total_bars) - only re-aggregates the new chunk.
24
+ * Handles the boundary bucket that might straddle the old/new data boundary.
25
+ */
26
+ export declare function prependAggregatedOhlcvBars(newBars: OhlcvBarMs[], existingDisplay: OhlcvBarMs[], targetBarNs: bigint, sessionMapper?: SessionMapper | null): OhlcvBarMs[];
27
+ export declare function autoFitPriceAxis(view: ViewBounds, priceHistory: PriceHistory[], trades: TradePoint[], bars: OhlcvBarMs[], openBar: FootprintBar | null, settings: ChartSettings, horizon: bigint, dataLevel?: DataLevel): void;
28
+ export declare function applyHorizonScrollEasing(t: number, type: string): number;
29
+ export interface UseChartDataParams {
30
+ eventBus: TypedEventBus;
31
+ activeTimeframeRef: MutableRefObject<Timeframe>;
32
+ horizonRef: MutableRefObject<bigint>;
33
+ chartSettingsRef: MutableRefObject<ChartSettings>;
34
+ sessionMapperRef: MutableRefObject<SessionMapper>;
35
+ resolvedSessionRef: MutableRefObject<TradingSession | null>;
36
+ resolvedSymbolInfoRef: MutableRefObject<SymbolInfo>;
37
+ viewRef: MutableRefObject<ViewBounds | null>;
38
+ /** Auto-computed right price-axis width (css px). */
39
+ priceScaleWidthRef: MutableRefObject<number>;
40
+ panesRef: MutableRefObject<ChartPane[]>;
41
+ indicatorsRef: MutableRefObject<Indicator[]>;
42
+ transformer: LiveTransformer;
43
+ renderEngineRef: MutableRefObject<RenderEngine | null>;
44
+ isYAxisAutoRef: MutableRefObject<boolean>;
45
+ isDragging: MutableRefObject<boolean>;
46
+ dragMode: MutableRefObject<string>;
47
+ layoutsCacheRef: MutableRefObject<Record<string, Rect>>;
48
+ baseCanvasRef: RefObject<HTMLCanvasElement>;
49
+ selectedDrawingIdRef: MutableRefObject<string | null>;
50
+ pushDrawParamsRef: MutableRefObject<() => void>;
51
+ autofitIndicatorPanesRef: MutableRefObject<() => void>;
52
+ updateSettingsBarPosRef: MutableRefObject<(id: string | null) => void>;
53
+ resetViewRef: MutableRefObject<() => void>;
54
+ syncPixelLayoutsRef: MutableRefObject<(panes?: ChartPane[]) => void>;
55
+ doBaseRedrawRef: MutableRefObject<() => void>;
56
+ setIndicators: (inds: Indicator[]) => void;
57
+ setPanes: (updater: ((prev: ChartPane[]) => ChartPane[]) | ChartPane[]) => void;
58
+ getPanel: () => DomPanelHandle | null;
59
+ onDataBoundsChange?: (start: bigint, end: bigint) => void;
60
+ onHorizonUpdate: (h: bigint) => void;
61
+ cellSymbol: string;
62
+ /** Which cell this is, for events that are this pane's own business. */
63
+ cellId: number;
64
+ managed?: boolean;
65
+ externalDomPanelRef?: MutableRefObject<DomPanelHandle | null>;
66
+ hidePriceScale: boolean;
67
+ hideTimeScale: boolean;
68
+ /** The loaded symbol serves a different data level than the last one did. */
69
+ onDataLevelChangeRef: MutableRefObject<() => void>;
70
+ }
71
+ export interface ChartDataResult {
72
+ compactBufRef: MutableRefObject<CompactBuffer>;
73
+ allTradesRef: MutableRefObject<TradePoint[]>;
74
+ tradesRef: MutableRefObject<TradePoint[]>;
75
+ priceHistoryRef: MutableRefObject<PriceHistory[]>;
76
+ allPriceHistoryRef: MutableRefObject<PriceHistory[]>;
77
+ footprintBarsRef: MutableRefObject<FootprintBar[]>;
78
+ ohlcvBarsRef: MutableRefObject<{
79
+ barNs: bigint;
80
+ bars: OhlcvBarMs[];
81
+ display: OhlcvBarMs[];
82
+ }>;
83
+ previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
84
+ openBarRef: MutableRefObject<FootprintBar | null>;
85
+ openBarTsRef: MutableRefObject<bigint>;
86
+ openBarTradeCountRef: MutableRefObject<number>;
87
+ phCursorRef: MutableRefObject<number>;
88
+ playheadIdxRef: MutableRefObject<number>;
89
+ replayedUpToRef: MutableRefObject<number>;
90
+ dataLevelRef: MutableRefObject<DataLevel | null>;
91
+ datasetStartRef: MutableRefObject<bigint>;
92
+ datasetEndRef: MutableRefObject<bigint>;
93
+ prevSessionStatusRef: MutableRefObject<SessionStatus | null>;
94
+ candleCacheRef: MutableRefObject<Map<bigint, {
95
+ open: number;
96
+ high: number;
97
+ low: number;
98
+ close: number;
99
+ volume: number;
100
+ delta: number;
101
+ }> | null>;
102
+ supplementalBarsRef: MutableRefObject<any>;
103
+ serialisedTradesBufRef: MutableRefObject<ArrayBuffer | null>;
104
+ serialisedPhBufRef: MutableRefObject<ArrayBuffer | null>;
105
+ serialisedOhlcvBufRef: MutableRefObject<ArrayBuffer | null>;
106
+ fpRebuildSeqRef: MutableRefObject<number>;
107
+ rawBitmapRef: MutableRefObject<ImageBitmap | null>;
108
+ heatmapBitmapRef: MutableRefObject<ImageBitmap | null>;
109
+ heatmapBitmapOffsetsRef: MutableRefObject<{
110
+ x: number;
111
+ y: number;
112
+ w: number;
113
+ h: number;
114
+ } | null>;
115
+ cacheBoundsRef: MutableRefObject<ViewBounds | null>;
116
+ liveBookRef: MutableRefObject<BookState>;
117
+ prevHorizonBarRef: MutableRefObject<bigint>;
118
+ lastBarAdvanceTimeRef: MutableRefObject<number>;
119
+ horizonScrollAnimRef: MutableRefObject<any>;
120
+ workerRef: MutableRefObject<Worker | null>;
121
+ dataWorkerRef: MutableRefObject<Worker | null>;
122
+ indicatorWorkerRef: MutableRefObject<Worker | null>;
123
+ workerReadyRef: MutableRefObject<boolean>;
124
+ workerRequestIdRef: MutableRefObject<number>;
125
+ _internalDomPanelRef: MutableRefObject<DomPanelHandle | null>;
126
+ seekHorizon: (horizon: bigint, triggerResample?: boolean, hotPath?: boolean,
127
+ /** Explicit navigation: bring the view along instead of leaving it behind. */
128
+ recenter?: boolean) => void;
129
+ applyHorizon: (horizon: bigint, triggerResample?: boolean, hotPath?: boolean) => void;
130
+ scheduleResample: () => void;
131
+ runIndicatorWorker: (trades: SerialTrade[], barNs: bigint) => void;
132
+ getTradesUpToHorizon: (horizon: bigint) => TradePoint[];
133
+ requestFootprintRebuild: () => void;
134
+ syncOhlcvOpenBar: (horizon: bigint) => void;
135
+ rebuildCandleCache: (trades: TradePoint[], barNs: bigint) => void;
136
+ rebuildContrastBitmap: (contrast: number) => void;
137
+ foldEventsIntoOpenBar: (prevIdx: number, newIdx: number, barNs: bigint, horizon: bigint) => boolean;
138
+ mergeOpenBar: () => void;
139
+ resetPlayhead: (idx: number) => void;
140
+ fpSettingsFromRef: () => {
141
+ imbalanceRatio: number;
142
+ stackMinCount: number;
143
+ diagRatio: number;
144
+ absorptionMult: number;
145
+ absorptionDeltaFrac: number;
146
+ };
147
+ cancelAndRestartWorker: () => void;
148
+ runHorizonAdvance: (horizon: bigint) => void;
149
+ updatePriceHistoryToRawIdx: (rawIdx: number) => void;
150
+ findPriceHistoryIdx: (horizon: bigint) => number;
151
+ loadData: () => void;
152
+ }
153
+ export declare function useChartData(p: UseChartDataParams): ChartDataResult;
@@ -0,0 +1,94 @@
1
+ import { type MutableRefObject, type RefObject } from 'react';
2
+ import { type Drawing } from '../lib/types/drawing-types';
3
+ import { type ChartPane, type Indicator, type Rect } from '../lib/types/indicator-types';
4
+ import { type ViewBounds, type TradeLine, type TradePoint, type PriceHistory, type OhlcvBarMs } from '../lib/types';
5
+ import { type Timeframe } from '../lib/timeframes';
6
+ import { type RenderEngine } from '../core/RenderEngine';
7
+ import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
8
+ import { type DataLevel } from '../interfaces/IDataAdapter';
9
+ import { type CompactBuffer } from '../lib/compact-buffer';
10
+ import { type ChartSettings } from '../lib/types/chart-settings';
11
+ import { type SessionMapper } from '../core/SessionMapper';
12
+ import { type FootprintBar } from '../lib/types/footprint';
13
+ import { type SerialTrade } from '../lib/types';
14
+ export interface UseChartHandlersParams {
15
+ drawingsRef: MutableRefObject<Drawing[]>;
16
+ drawingsCanvasRef: RefObject<HTMLCanvasElement>;
17
+ viewRef: MutableRefObject<ViewBounds | null>;
18
+ selectedDrawingIdRef: MutableRefObject<string | null>;
19
+ indicatorsRef: MutableRefObject<Indicator[]>;
20
+ panesRef: MutableRefObject<ChartPane[]>;
21
+ ohlcvBarsRef: MutableRefObject<{
22
+ barNs: bigint;
23
+ bars: OhlcvBarMs[];
24
+ display: OhlcvBarMs[];
25
+ }>;
26
+ sessionMapperRef: MutableRefObject<SessionMapper>;
27
+ activeTimeframeRef: MutableRefObject<Timeframe>;
28
+ horizonRef: MutableRefObject<bigint>;
29
+ phCursorRef: MutableRefObject<number>;
30
+ candleCacheRef: MutableRefObject<Map<bigint, any> | null>;
31
+ tradesRef: MutableRefObject<TradePoint[]>;
32
+ openBarRef: MutableRefObject<FootprintBar | null>;
33
+ openBarTsRef: MutableRefObject<bigint>;
34
+ openBarTradeCountRef: MutableRefObject<number>;
35
+ compactBufRef: MutableRefObject<CompactBuffer>;
36
+ isYAxisAutoRef: MutableRefObject<boolean>;
37
+ priceHistoryRef: MutableRefObject<PriceHistory[]>;
38
+ dataLevelRef: MutableRefObject<DataLevel | null>;
39
+ previewBarsRef: MutableRefObject<OhlcvBarMs[]>;
40
+ chartSettingsRef: MutableRefObject<ChartSettings>;
41
+ tradeLinesRef: MutableRefObject<TradeLine[]>;
42
+ hoveringLegend: MutableRefObject<boolean>;
43
+ renderEngineRef: MutableRefObject<RenderEngine | null>;
44
+ transformer: LiveTransformer;
45
+ maximizedPaneId: string | null;
46
+ setIndicators: (inds: Indicator[]) => void;
47
+ setPanes: (updater: ChartPane[] | ((prev: ChartPane[]) => ChartPane[])) => void;
48
+ setSelectedDrawingId: (id: string | null) => void;
49
+ setSettingsBarPos: (pos: {
50
+ x: number;
51
+ y: number;
52
+ } | null) => void;
53
+ setIndicatorSettingsId: (id: string | null) => void;
54
+ setActiveTimeframe: (tf: Timeframe) => void;
55
+ setMaximizedPaneId: (updater: string | null | ((prev: string | null) => string | null)) => void;
56
+ pushDrawParams: () => void;
57
+ updateSettingsBarPos: (id: string | null) => void;
58
+ recomputeLayouts: () => void;
59
+ scheduleResample: () => void;
60
+ runIndicatorWorker: (trades: SerialTrade[], barNs: bigint) => void;
61
+ getTradesUpToHorizon: (horizon: bigint) => TradePoint[];
62
+ getLayouts: () => Record<string, Rect>;
63
+ rebuildCandleCache: (trades: TradePoint[], barNs: bigint) => void;
64
+ syncOhlcvOpenBar: (horizon: bigint) => void;
65
+ updatePriceHistoryToRawIdx: (rawIdx: number) => void;
66
+ findPriceHistoryIdx: (horizon: bigint) => number;
67
+ resetXAxis: () => void;
68
+ resetYAxis: () => void;
69
+ autofitIndicatorPanes: () => void;
70
+ hideTimeScale: boolean;
71
+ priceScaleWidthRef: MutableRefObject<number>;
72
+ }
73
+ export interface UseChartHandlersResult {
74
+ handleUpdateDrawing: (id: string, patch: Partial<Drawing>) => void;
75
+ handleDeleteDrawing: (id: string) => void;
76
+ handleDeleteDrawings: () => void;
77
+ handleDuplicateDrawing: (id: string) => void;
78
+ handleToggleIndicator: (indicatorId: string) => void;
79
+ handleRemoveIndicator: (indicatorId: string) => void;
80
+ handleOpenIndicatorSettings: (indicatorId: string) => void;
81
+ handleRemoveIndicators: () => void;
82
+ handleMoveUp: (paneId: string) => void;
83
+ handleMoveDown: (paneId: string) => void;
84
+ handleRemovePane: (paneId: string) => void;
85
+ handleExpand: (paneId: string) => void;
86
+ handleCollapse: (paneId: string) => void;
87
+ handleMaximize: (paneId: string) => void;
88
+ handleEnter: () => void;
89
+ handleLeave: () => void;
90
+ handleTimeframeChange: (tf: Timeframe) => void;
91
+ handleAddIndicator: (defId: string) => void;
92
+ handleAddTradeLine: (opts: TradeLine) => void;
93
+ }
94
+ export declare function useChartHandlers(p: UseChartHandlersParams): UseChartHandlersResult;