@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.
- package/LICENSE.md +201 -0
- package/NOTICE +15 -0
- package/README.md +159 -0
- package/depth.cjs +1136 -0
- package/depth.css +2 -0
- package/depth.mjs +1136 -0
- package/depth.nopreflight.css +2 -0
- package/index.d.ts +1 -0
- package/package.json +32 -0
- package/types/ChartInner.d.ts +114 -0
- package/types/ChartOuter.d.ts +31 -0
- package/types/components/account/AccountSummary.d.ts +8 -0
- package/types/components/chart/chart-context-menu.d.ts +30 -0
- package/types/components/chart/chart-settings-dialog.d.ts +15 -0
- package/types/components/chart/chart-status-overlay.d.ts +24 -0
- package/types/components/chart/data-status.d.ts +10 -0
- package/types/components/chart/pane-legend.d.ts +37 -0
- package/types/components/chart/session-status-badge.d.ts +14 -0
- package/types/components/chart/status-bar.d.ts +9 -0
- package/types/components/chart/symbol-icon.d.ts +9 -0
- package/types/components/chart/tz.d.ts +10 -0
- package/types/components/drawings/drawing-icons.d.ts +2 -0
- package/types/components/drawings/drawing-settings-bar.d.ts +15 -0
- package/types/components/drawings/drawing-settings-dialog.d.ts +268 -0
- package/types/components/drawings/drawing-toolbar.d.ts +14 -0
- package/types/components/drawings/drawing-tools.d.ts +23 -0
- package/types/components/indicators/indicators-dialog.d.ts +20 -0
- package/types/components/indicators/indicators-settings-dialog.d.ts +164 -0
- package/types/components/multi-chart/GridDividers.d.ts +12 -0
- package/types/components/multi-chart/LayoutPicker.d.ts +19 -0
- package/types/components/plugin-panels/BottomBarPluginHost.d.ts +7 -0
- package/types/components/plugin-panels/PluginFixedPanelHost.d.ts +18 -0
- package/types/components/plugin-panels/PluginToolbarHost.d.ts +7 -0
- package/types/components/plugin-panels/PluginWindowsDropdown.d.ts +7 -0
- package/types/components/plugins/plugin-manager-dialog.d.ts +14 -0
- package/types/components/toolbar/SymbolSwitcher.d.ts +8 -0
- package/types/components/toolbar/chart-icons.d.ts +16 -0
- package/types/components/toolbar/chart-type-selector.d.ts +11 -0
- package/types/components/toolbar/timeframe-selector.d.ts +15 -0
- package/types/components/trading/OrderPanel.d.ts +36 -0
- package/types/components/trading/QuickTradingButtons.d.ts +7 -0
- package/types/components/trading/order-math.d.ts +94 -0
- package/types/components/ui/button.d.ts +11 -0
- package/types/components/ui/checkbox.d.ts +4 -0
- package/types/components/ui/color-picker.d.ts +12 -0
- package/types/components/ui/dialog.d.ts +19 -0
- package/types/components/ui/dropdown-menu.d.ts +27 -0
- package/types/components/ui/hover-card.d.ts +6 -0
- package/types/components/ui/input.d.ts +4 -0
- package/types/components/ui/popover.d.ts +7 -0
- package/types/components/ui/resizable.d.ts +23 -0
- package/types/components/ui/separator.d.ts +4 -0
- package/types/components/ui/slider.d.ts +4 -0
- package/types/components/ui/switch.d.ts +4 -0
- package/types/components/ui/tooltip.d.ts +7 -0
- package/types/core/AccountManager.d.ts +142 -0
- package/types/core/ChartModel.d.ts +84 -0
- package/types/core/ChartState.d.ts +51 -0
- package/types/core/ChartTypeRegistry.d.ts +27 -0
- package/types/core/DataEngine.d.ts +143 -0
- package/types/core/DataSourceRegistry.d.ts +106 -0
- package/types/core/DepthChart.d.ts +458 -0
- package/types/core/DrawingRegistry.d.ts +133 -0
- package/types/core/DrawingStore.d.ts +26 -0
- package/types/core/ExecutionEngine.d.ts +95 -0
- package/types/core/GlobalChartBus.d.ts +32 -0
- package/types/core/Playback.d.ts +48 -0
- package/types/core/PlaybackStateRegistry.d.ts +25 -0
- package/types/core/PluginRegistry.d.ts +67 -0
- package/types/core/PluginSchedule.d.ts +15 -0
- package/types/core/RenderEngine.d.ts +143 -0
- package/types/core/ScriptedPlugin.d.ts +153 -0
- package/types/core/SessionMapper.d.ts +54 -0
- package/types/core/SessionUtils.d.ts +53 -0
- package/types/core/TypedEventBus.d.ts +691 -0
- package/types/core/WasmPluginHost.d.ts +39 -0
- package/types/core/index.d.ts +70 -0
- package/types/core/plugin-startup.d.ts +33 -0
- package/types/core/processing/data-chunk.d.ts +37 -0
- package/types/core/processing/data-level.d.ts +13 -0
- package/types/core/processing/l2-processor.d.ts +10 -0
- package/types/core/processing/l3-processor.d.ts +26 -0
- package/types/core/processing/ohlcv-processor.d.ts +14 -0
- package/types/core/processing/tick-processor.d.ts +14 -0
- package/types/core/script-dsl.d.ts +20 -0
- package/types/core/script-scope.d.ts +4 -0
- package/types/core/script.worker.d.ts +1 -0
- package/types/hooks/useCellBridges.d.ts +36 -0
- package/types/hooks/useChartData.d.ts +153 -0
- package/types/hooks/useChartHandlers.d.ts +94 -0
- package/types/hooks/useChartInteraction.d.ts +160 -0
- package/types/hooks/useChartLayout.d.ts +21 -0
- package/types/hooks/useChartPlugin.d.ts +34 -0
- package/types/hooks/useChartSettings.d.ts +44 -0
- package/types/hooks/useChartSubscriptions.d.ts +64 -0
- package/types/hooks/useChartView.d.ts +47 -0
- package/types/hooks/usePlaybackEngine.d.ts +85 -0
- package/types/hooks/useRenderEngine.d.ts +64 -0
- package/types/hooks/useTradeLines.d.ts +80 -0
- package/types/hooks/useTradingState.d.ts +135 -0
- package/types/interfaces/IAccountAdapter.d.ts +38 -0
- package/types/interfaces/ICoordinateTransformer.d.ts +105 -0
- package/types/interfaces/IDataAdapter.d.ts +402 -0
- package/types/interfaces/IExecutionAdapter.d.ts +71 -0
- package/types/interfaces/plugins/IChartPlugin.d.ts +254 -0
- package/types/interfaces/plugins/IChartTypePlugin.d.ts +126 -0
- package/types/interfaces/plugins/IDataSourcePlugin.d.ts +20 -0
- package/types/interfaces/plugins/IDrawingPlugin.d.ts +62 -0
- package/types/interfaces/plugins/IIndicatorPlugin.d.ts +97 -0
- package/types/interfaces/plugins/index.d.ts +5 -0
- package/types/lib/bar-grid.d.ts +6 -0
- package/types/lib/book.d.ts +5 -0
- package/types/lib/clock.d.ts +7 -0
- package/types/lib/compact-buffer.d.ts +66 -0
- package/types/lib/constants.d.ts +5 -0
- package/types/lib/createSimulatedAdapter.d.ts +42 -0
- package/types/lib/dpr.d.ts +27 -0
- package/types/lib/heatmap.worker.d.ts +1 -0
- package/types/lib/indicator-stdlib.d.ts +426 -0
- package/types/lib/indicator-worker.d.ts +65 -0
- package/types/lib/matchingEngine.d.ts +144 -0
- package/types/lib/notifications/tradeToast.d.ts +31 -0
- package/types/lib/pointer-lock.d.ts +5 -0
- package/types/lib/priceFormat.d.ts +17 -0
- package/types/lib/priceTransition.d.ts +22 -0
- package/types/lib/renderers/drawFootprintChart.d.ts +5 -0
- package/types/lib/renderers/drawTradeLines.d.ts +112 -0
- package/types/lib/renderers/drawings-renderer.d.ts +57 -0
- package/types/lib/renderers/renderer.d.ts +113 -0
- package/types/lib/sampler.d.ts +7 -0
- package/types/lib/series/japaneseCharts.d.ts +88 -0
- package/types/lib/slice-worker-client.d.ts +138 -0
- package/types/lib/slice.worker.d.ts +139 -0
- package/types/lib/storage.d.ts +108 -0
- package/types/lib/symbol-info.d.ts +12 -0
- package/types/lib/symbol-search.d.ts +29 -0
- package/types/lib/timeframes.d.ts +46 -0
- package/types/lib/tradingview-import.d.ts +32 -0
- package/types/lib/types/chart-settings.d.ts +90 -0
- package/types/lib/types/drawing-types.d.ts +393 -0
- package/types/lib/types/footprint.d.ts +119 -0
- package/types/lib/types/heatmap-types.d.ts +30 -0
- package/types/lib/types/index.d.ts +147 -0
- package/types/lib/types/indicator-types.d.ts +123 -0
- package/types/lib/types/layout-sync.d.ts +43 -0
- package/types/lib/types/trading-types.d.ts +323 -0
- package/types/lib/use-forwarded-ref.d.ts +1 -0
- package/types/lib/utils.d.ts +2 -0
- package/types/plugins/alligator.d.ts +1 -0
- package/types/plugins/atr.d.ts +1 -0
- package/types/plugins/awesome-oscillator.d.ts +1 -0
- package/types/plugins/bollinger-bands.d.ts +1 -0
- package/types/plugins/cci.d.ts +1 -0
- package/types/plugins/cvd.d.ts +1 -0
- package/types/plugins/donchian.d.ts +1 -0
- package/types/plugins/ichimoku.d.ts +1 -0
- package/types/plugins/index.d.ts +25 -0
- package/types/plugins/keltner.d.ts +1 -0
- package/types/plugins/macd.d.ts +1 -0
- package/types/plugins/mfi.d.ts +1 -0
- package/types/plugins/moving-average.d.ts +1 -0
- package/types/plugins/obv.d.ts +1 -0
- package/types/plugins/psar.d.ts +1 -0
- package/types/plugins/rsi.d.ts +1 -0
- package/types/plugins/sessions.d.ts +1 -0
- package/types/plugins/stochastic.d.ts +1 -0
- package/types/plugins/supertrend.d.ts +1 -0
- package/types/plugins/volume.d.ts +1 -0
- package/types/plugins/vwap.d.ts +1 -0
- package/types/plugins/williams-r.d.ts +1 -0
- package/types/react/useDepthChart.d.ts +6 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
import { LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
2
|
+
import { ChartSettings } from '../lib/types/chart-settings';
|
|
3
|
+
import { type SessionStatus } from './SessionUtils';
|
|
4
|
+
import { BarPreviewResponse, OhlcvBar, SymbolInfo, SymbolSearchMode, SymbolSearchRequest, TradingSession } from '../interfaces/IDataAdapter';
|
|
5
|
+
import { DataLevel } from '../interfaces/IDataAdapter';
|
|
6
|
+
import { IExecutionAdapter } from '../interfaces/IExecutionAdapter';
|
|
7
|
+
import { ActiveDrawingTool, Anchor, Drawing } from '../lib/types/drawing-types';
|
|
8
|
+
import { TradeLineHitMap } from '../lib/renderers/drawTradeLines';
|
|
9
|
+
import type { TradeLine } from '../lib/types';
|
|
10
|
+
import { FootprintBar } from '../lib/types/footprint';
|
|
11
|
+
import { ChartPane, Indicator } from '../lib/types/indicator-types';
|
|
12
|
+
import { SerialTrade } from '../lib/types';
|
|
13
|
+
import { Timeframe } from '../lib/timeframes';
|
|
14
|
+
import { Fill, Order, Position, PositionClose, TradingEvent } from '../lib/types/trading-types';
|
|
15
|
+
import { PriceHistory, TradePoint, type ViewBounds } from '../lib/types';
|
|
16
|
+
import { BottomBarItem, ChartTypePlugin, ToolbarItem } from './PluginRegistry';
|
|
17
|
+
import { RenderEngine } from './RenderEngine';
|
|
18
|
+
import { PlaybackMode } from '../hooks/usePlaybackEngine';
|
|
19
|
+
import type { CrosshairSync, TimeRangeSync } from '../lib/types/layout-sync';
|
|
20
|
+
import type { PlaceOrderRequest } from '../lib/matchingEngine';
|
|
21
|
+
export interface ChartEvents {
|
|
22
|
+
'view:change': ViewBounds;
|
|
23
|
+
'crosshair:move': {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
} | null;
|
|
27
|
+
'chart:ready': void;
|
|
28
|
+
'chart:reset-view': void;
|
|
29
|
+
'chart:set-tool': {
|
|
30
|
+
tool: ActiveDrawingTool;
|
|
31
|
+
};
|
|
32
|
+
'chart:set-timeframe': {
|
|
33
|
+
tf: Timeframe;
|
|
34
|
+
};
|
|
35
|
+
'chart:add-indicator': {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
'chart:add-plugin-indicator': {
|
|
39
|
+
pluginId: string;
|
|
40
|
+
};
|
|
41
|
+
/** Take every live instance of a pool plugin off the panes. Instances are
|
|
42
|
+
* keyed `${pluginId}:${index}`. */
|
|
43
|
+
'chart:remove-plugin-indicator': {
|
|
44
|
+
pluginId: string;
|
|
45
|
+
};
|
|
46
|
+
'chart:remove-indicator': {
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
'chart:apply-settings': {
|
|
50
|
+
patch: Partial<ChartSettings>;
|
|
51
|
+
};
|
|
52
|
+
'chart:set-symbol': {
|
|
53
|
+
symbol: string;
|
|
54
|
+
id: number;
|
|
55
|
+
};
|
|
56
|
+
'chart:set-symbol-focused': {
|
|
57
|
+
symbol: string;
|
|
58
|
+
};
|
|
59
|
+
'chart:open-symbol-select': {};
|
|
60
|
+
'chart:set-type': {
|
|
61
|
+
old: string;
|
|
62
|
+
new: string;
|
|
63
|
+
};
|
|
64
|
+
'theme:change': 'light' | 'dark';
|
|
65
|
+
'chart:focused': {
|
|
66
|
+
id: number;
|
|
67
|
+
};
|
|
68
|
+
'chart:blurred': void;
|
|
69
|
+
'chart:change-layout': {
|
|
70
|
+
preset: {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
count: number;
|
|
74
|
+
cols: number;
|
|
75
|
+
rows: number;
|
|
76
|
+
areas: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/** Hovered cell's crosshair, in data space. null = pointer left the chart. */
|
|
80
|
+
'layout:crosshair': CrosshairSync | null;
|
|
81
|
+
/** Scrolled/zoomed cell's visible time range. */
|
|
82
|
+
'layout:time-range': TimeRangeSync;
|
|
83
|
+
/** A cell changed its own timeframe (chart keypad, selector, API). */
|
|
84
|
+
'layout:timeframe': {
|
|
85
|
+
id: number;
|
|
86
|
+
tf: Timeframe;
|
|
87
|
+
};
|
|
88
|
+
'timeframe:change': {
|
|
89
|
+
tf: Timeframe;
|
|
90
|
+
};
|
|
91
|
+
/** Runtime entitlement change (see `chart.allowTimeframes`). The UI re-reads
|
|
92
|
+
* `features` so locks and gates reflect what is allowed now. */
|
|
93
|
+
'features:change': void;
|
|
94
|
+
'timeframe:add-failed': {
|
|
95
|
+
message: string;
|
|
96
|
+
code: 'NO_CUSTOM_TIMEFRAMES' | 'TIMEFRAME_NOT_ALLOWED';
|
|
97
|
+
/** The timeframe the user typed, e.g. "7m". Hosts use it in their upsell copy. */
|
|
98
|
+
label?: string;
|
|
99
|
+
};
|
|
100
|
+
'status:compute': {
|
|
101
|
+
/** Cell id of the chart that produced this event (multi-chart routing) */
|
|
102
|
+
cellId: number;
|
|
103
|
+
x: number;
|
|
104
|
+
priceHistory: PriceHistory[];
|
|
105
|
+
trades: TradePoint[];
|
|
106
|
+
bounds: ViewBounds;
|
|
107
|
+
chartW: number;
|
|
108
|
+
barNs: bigint;
|
|
109
|
+
candleCache: Map<bigint, {
|
|
110
|
+
open: number;
|
|
111
|
+
high: number;
|
|
112
|
+
low: number;
|
|
113
|
+
close: number;
|
|
114
|
+
volume: number;
|
|
115
|
+
delta: number;
|
|
116
|
+
}> | null;
|
|
117
|
+
bars: {
|
|
118
|
+
time: number;
|
|
119
|
+
open: number;
|
|
120
|
+
high: number;
|
|
121
|
+
low: number;
|
|
122
|
+
close: number;
|
|
123
|
+
volume: number;
|
|
124
|
+
}[];
|
|
125
|
+
openBar: FootprintBar;
|
|
126
|
+
horizon: bigint;
|
|
127
|
+
dataLevel: DataLevel;
|
|
128
|
+
transformer: LiveTransformer;
|
|
129
|
+
};
|
|
130
|
+
/** The playback horizon advanced (tick / step / scrub). Refreshes the status
|
|
131
|
+
* bar while the cursor sits on the forming bar and isnt moving to drive
|
|
132
|
+
* status:compute. */
|
|
133
|
+
'status:refresh': void;
|
|
134
|
+
/** A cell is rebuilding its heatmap. Keyed by cell, not symbol - two panes on
|
|
135
|
+
* one instrument at different timeframes rebuild independently. */
|
|
136
|
+
'heatmap:status': {
|
|
137
|
+
recalculating: boolean;
|
|
138
|
+
cellId?: number;
|
|
139
|
+
};
|
|
140
|
+
/** Whether the market is open at the playhead, for `symbol`. Every cell
|
|
141
|
+
* announces its own, since instruments keep different hours. */
|
|
142
|
+
'session:status': SessionStatus & {
|
|
143
|
+
symbol?: string;
|
|
144
|
+
};
|
|
145
|
+
'data:preview': BarPreviewResponse;
|
|
146
|
+
/** The loaded data edges for one symbol, announced by the cell that ingested
|
|
147
|
+
* it. These gate panning and backward fetches, so `symbol` scopes it. */
|
|
148
|
+
'data:bounds': {
|
|
149
|
+
start: bigint;
|
|
150
|
+
end: bigint;
|
|
151
|
+
session: TradingSession | null;
|
|
152
|
+
symbol?: string;
|
|
153
|
+
};
|
|
154
|
+
'data:status': {
|
|
155
|
+
status: 'loading' | 'ready' | 'error';
|
|
156
|
+
error?: {
|
|
157
|
+
code: string;
|
|
158
|
+
message: string;
|
|
159
|
+
};
|
|
160
|
+
/** Symbol the status belongs to; a cell only reacts when it matches what
|
|
161
|
+
* it is displaying. Omitted = chart-wide, every cell reacts. */
|
|
162
|
+
symbol?: string;
|
|
163
|
+
};
|
|
164
|
+
'data:rehydrate': void;
|
|
165
|
+
'data:load': {
|
|
166
|
+
symbol: string;
|
|
167
|
+
dataLevel: DataLevel;
|
|
168
|
+
compactBuf: ArrayBuffer;
|
|
169
|
+
trades: SerialTrade[];
|
|
170
|
+
priceHistory: PriceHistory[];
|
|
171
|
+
footprintBars: FootprintBar[];
|
|
172
|
+
ohlcvBars: OhlcvBar[];
|
|
173
|
+
barNs: bigint;
|
|
174
|
+
dataStart: number;
|
|
175
|
+
dataEnd: number;
|
|
176
|
+
session: TradingSession | null;
|
|
177
|
+
playFromIso?: string;
|
|
178
|
+
error?: string;
|
|
179
|
+
errorMessage?: string;
|
|
180
|
+
supplemental?: Array<{
|
|
181
|
+
resolution: bigint;
|
|
182
|
+
bars: Array<{
|
|
183
|
+
time: number;
|
|
184
|
+
open: number;
|
|
185
|
+
high: number;
|
|
186
|
+
low: number;
|
|
187
|
+
close: number;
|
|
188
|
+
volume: number;
|
|
189
|
+
}>;
|
|
190
|
+
}> | null;
|
|
191
|
+
/**
|
|
192
|
+
* A re-hand-over of a window the consumer may already have, rather than
|
|
193
|
+
* a new one - a pane mounting, or switching onto a symbol another pane
|
|
194
|
+
* already loaded. Nothing behind the playhead changed, so consumers
|
|
195
|
+
* holding replay state (the matching engine) keep their position instead
|
|
196
|
+
* of rewinding and settling the window again.
|
|
197
|
+
*/
|
|
198
|
+
rehydrate?: boolean;
|
|
199
|
+
/** Pre-bucketed ingest result from DataEngine (non-ohlcv data levels only). */
|
|
200
|
+
ingestOhlcvBuf?: ArrayBuffer;
|
|
201
|
+
ingestBucketedPhBuf?: ArrayBuffer;
|
|
202
|
+
ingestTradesBuf?: ArrayBuffer;
|
|
203
|
+
ingestPhBuf?: ArrayBuffer;
|
|
204
|
+
};
|
|
205
|
+
'data:append': {
|
|
206
|
+
symbol: string;
|
|
207
|
+
dataLevel: DataLevel;
|
|
208
|
+
compactBuf: ArrayBuffer;
|
|
209
|
+
trades: SerialTrade[];
|
|
210
|
+
priceHistory: PriceHistory[];
|
|
211
|
+
footprintBars: FootprintBar[];
|
|
212
|
+
ohlcvBars: OhlcvBar[];
|
|
213
|
+
barNs: bigint;
|
|
214
|
+
dataStart: number;
|
|
215
|
+
dataEnd: number;
|
|
216
|
+
session: TradingSession | null;
|
|
217
|
+
supplemental?: Array<{
|
|
218
|
+
resolution: bigint;
|
|
219
|
+
bars: Array<{
|
|
220
|
+
time: number;
|
|
221
|
+
open: number;
|
|
222
|
+
high: number;
|
|
223
|
+
low: number;
|
|
224
|
+
close: number;
|
|
225
|
+
volume: number;
|
|
226
|
+
}>;
|
|
227
|
+
}> | null;
|
|
228
|
+
ingestOhlcvBuf?: ArrayBuffer;
|
|
229
|
+
ingestBucketedPhBuf?: ArrayBuffer;
|
|
230
|
+
ingestTradesBuf?: ArrayBuffer;
|
|
231
|
+
ingestPhBuf?: ArrayBuffer;
|
|
232
|
+
};
|
|
233
|
+
'data:request-forward': {
|
|
234
|
+
symbol?: string;
|
|
235
|
+
};
|
|
236
|
+
'data:request-backward': {
|
|
237
|
+
viewMin: bigint;
|
|
238
|
+
symbol?: string;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Jump-load: re-fetch a fresh window centered on `tNs` and reinitialize
|
|
242
|
+
* there, instead of streaming everything between the loaded edge and the
|
|
243
|
+
* target. `fromNs` is the playhead before the jump, used to settle fills over
|
|
244
|
+
* the skipped span. Costs one window regardless of jump distance.
|
|
245
|
+
*/
|
|
246
|
+
'data:seek-load': {
|
|
247
|
+
tNs: bigint;
|
|
248
|
+
fromNs: bigint;
|
|
249
|
+
};
|
|
250
|
+
'data:prepend': {
|
|
251
|
+
symbol: string;
|
|
252
|
+
dataLevel: DataLevel;
|
|
253
|
+
compactBuf: ArrayBuffer;
|
|
254
|
+
trades: SerialTrade[];
|
|
255
|
+
priceHistory: PriceHistory[];
|
|
256
|
+
footprintBars: FootprintBar[];
|
|
257
|
+
ohlcvBars: OhlcvBar[];
|
|
258
|
+
barNs: bigint;
|
|
259
|
+
dataStart: number;
|
|
260
|
+
viewMin: bigint;
|
|
261
|
+
session: TradingSession | null;
|
|
262
|
+
ingestOhlcvBuf?: ArrayBuffer;
|
|
263
|
+
ingestBucketedPhBuf?: ArrayBuffer;
|
|
264
|
+
ingestTradesBuf?: ArrayBuffer;
|
|
265
|
+
ingestPhBuf?: ArrayBuffer;
|
|
266
|
+
};
|
|
267
|
+
/** Backward pagination is exhausted for this symbol. */
|
|
268
|
+
'data:no-more-history': {
|
|
269
|
+
symbol?: string;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Forward pagination is exhausted - no more data past this symbol's loaded
|
|
273
|
+
* edge. The playback engine pauses on it, so `symbol` matters: one pane
|
|
274
|
+
* running out must not stop the clock the focused pane is driving.
|
|
275
|
+
*/
|
|
276
|
+
'data:no-more-forward': {
|
|
277
|
+
symbol?: string;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Request a forward chunk. `spanNs` is the desired data-time span, sized by
|
|
281
|
+
* the playback engine to the current consumption rate so fast playback
|
|
282
|
+
* fetches bigger chunks. Falls back to the fixed scroll window.
|
|
283
|
+
*/
|
|
284
|
+
'data:prefetch': {
|
|
285
|
+
spanNs?: bigint;
|
|
286
|
+
symbol?: string;
|
|
287
|
+
};
|
|
288
|
+
'data:prefetch-done': void;
|
|
289
|
+
'data:rebuild-footprint': {
|
|
290
|
+
barNs: bigint;
|
|
291
|
+
fpOptions: unknown;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Ask the engine for symbols. `requestId` correlates the answer: the picker
|
|
295
|
+
* fires one per keystroke and ignores anything that isnt its latest, so "AA"
|
|
296
|
+
* landing after "AAPL" cant overwrite it.
|
|
297
|
+
*/
|
|
298
|
+
'data:search-symbols': {
|
|
299
|
+
requestId: string;
|
|
300
|
+
request: SymbolSearchRequest;
|
|
301
|
+
};
|
|
302
|
+
'data:search-symbols-response': {
|
|
303
|
+
requestId: string;
|
|
304
|
+
symbols: SymbolInfo[];
|
|
305
|
+
hasMore: boolean;
|
|
306
|
+
cursor?: string;
|
|
307
|
+
/** Who did the matching. */
|
|
308
|
+
mode: SymbolSearchMode;
|
|
309
|
+
/** How long to wait after a keystroke before searching again, in ms. */
|
|
310
|
+
debounceMs: number;
|
|
311
|
+
};
|
|
312
|
+
'data:search-symbols-error': {
|
|
313
|
+
requestId: string;
|
|
314
|
+
code: string;
|
|
315
|
+
message: string;
|
|
316
|
+
};
|
|
317
|
+
/** Abandon a search (the picker closed). Carries its own requestId so one
|
|
318
|
+
* picker cant cancel another's when they share a bus. */
|
|
319
|
+
'data:search-symbols-cancel': {
|
|
320
|
+
requestId: string;
|
|
321
|
+
};
|
|
322
|
+
/** The requested span was entirely outside this symbol's trading hours, so
|
|
323
|
+
* nothing was fetched. */
|
|
324
|
+
'data:session-gap': {
|
|
325
|
+
from: bigint;
|
|
326
|
+
to: bigint;
|
|
327
|
+
symbol?: string;
|
|
328
|
+
};
|
|
329
|
+
'data:symbol-resolved': {
|
|
330
|
+
symbolInfo: SymbolInfo;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Ask the engine to re-announce a symbol's resolved info as
|
|
334
|
+
* `data:symbol-resolved`. That event is one-shot and fires mid-load, which
|
|
335
|
+
* can finish before a pane has subscribed - chart.load() runs during
|
|
336
|
+
* construction, panes mount after. A pane replays it with this on mount.
|
|
337
|
+
* No-op if the symbol hasnt resolved yet, the live event is still coming.
|
|
338
|
+
*/
|
|
339
|
+
'data:request-symbol-resolved': {
|
|
340
|
+
symbol: string;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* A pane announcing which instrument it is showing and at what bar period,
|
|
344
|
+
* on mount and whenever either changes. Lets the engine fetch at the finest
|
|
345
|
+
* resolution anyone on screen needs rather than the focused pane's.
|
|
346
|
+
*/
|
|
347
|
+
'data:pane-resolution': {
|
|
348
|
+
id: number;
|
|
349
|
+
symbol: string;
|
|
350
|
+
barNs: bigint;
|
|
351
|
+
};
|
|
352
|
+
/** A loaded time segment was re-fetched at a finer resolution after a
|
|
353
|
+
* timeframe scale-down. Consumers replace their stale bars with these. */
|
|
354
|
+
'data:refine': {
|
|
355
|
+
symbol: string;
|
|
356
|
+
dataLevel: DataLevel;
|
|
357
|
+
ohlcvBars: OhlcvBar[];
|
|
358
|
+
/** The fetch resolution of the new bars. */
|
|
359
|
+
barNs: bigint;
|
|
360
|
+
/** ISO - inclusive start of the replaced time range. */
|
|
361
|
+
from: string;
|
|
362
|
+
/** ISO - inclusive end of the replaced time range. */
|
|
363
|
+
to: string;
|
|
364
|
+
};
|
|
365
|
+
'render-engine:ready': {
|
|
366
|
+
engine: RenderEngine;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* A cell handing over its forming-bar getter. The bar mutates in place, so
|
|
370
|
+
* this is a getter and not a value - read it, dont keep it. `get: null`
|
|
371
|
+
* means the cell is going away.
|
|
372
|
+
*/
|
|
373
|
+
'data:open-bar-provider': {
|
|
374
|
+
cellId: number;
|
|
375
|
+
get: (() => FootprintBar | null) | null;
|
|
376
|
+
};
|
|
377
|
+
'price:update': {
|
|
378
|
+
bid: number;
|
|
379
|
+
ask: number;
|
|
380
|
+
ts: bigint;
|
|
381
|
+
};
|
|
382
|
+
trade: TradePoint;
|
|
383
|
+
'book:update': {
|
|
384
|
+
bestBid: number | null;
|
|
385
|
+
bestAsk: number | null;
|
|
386
|
+
};
|
|
387
|
+
'order:placed': {
|
|
388
|
+
orderId: string;
|
|
389
|
+
order: Order;
|
|
390
|
+
};
|
|
391
|
+
'order:fill': Fill;
|
|
392
|
+
'order:cancel': {
|
|
393
|
+
orderId: string;
|
|
394
|
+
};
|
|
395
|
+
'position:update': Position;
|
|
396
|
+
'position:close': PositionClose;
|
|
397
|
+
'trading:event': TradingEvent;
|
|
398
|
+
/** An order was refused by the execution engine's guard, before any book saw it. */
|
|
399
|
+
'trading:order-blocked': {
|
|
400
|
+
req: PlaceOrderRequest;
|
|
401
|
+
reason: string;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* Ghost lines for an order that hasnt been placed - what the ticket
|
|
405
|
+
* describes, drawn where it would land. An empty array clears it. Ordinary
|
|
406
|
+
* TradeLines, and should be sent `locked`: they are a readout, not a
|
|
407
|
+
* control, so they must never take a click a drawing could have had.
|
|
408
|
+
*/
|
|
409
|
+
'trading:preview': {
|
|
410
|
+
lines: TradeLine[];
|
|
411
|
+
symbol?: string;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Command: open the order ticket, following `drawingId` if one is given.
|
|
415
|
+
*
|
|
416
|
+
* Sticky, since the panel that answers it usually isnt mounted yet - the
|
|
417
|
+
* host opens the ticket in response and the ticket reads the request on the
|
|
418
|
+
* way up. `requestId` is what keeps that honest: the ticket remembers the
|
|
419
|
+
* last request it acted on, so opening it by hand later replays the request
|
|
420
|
+
* without re-linking to a box the user has moved on from.
|
|
421
|
+
*/
|
|
422
|
+
'trading:ticket-requested': {
|
|
423
|
+
drawingId: string | null;
|
|
424
|
+
requestId: string;
|
|
425
|
+
};
|
|
426
|
+
'trading:buy-market': {
|
|
427
|
+
amount: number;
|
|
428
|
+
};
|
|
429
|
+
'trading:sell-market': {
|
|
430
|
+
amount: number;
|
|
431
|
+
};
|
|
432
|
+
/** Go flat: close every open position at market. Account-wide, not pane-wide. */
|
|
433
|
+
'trading:flatten': void;
|
|
434
|
+
'execution:setAdapter': {
|
|
435
|
+
adapter: IExecutionAdapter;
|
|
436
|
+
};
|
|
437
|
+
'indicator:computed': {
|
|
438
|
+
id: string;
|
|
439
|
+
barNs: bigint;
|
|
440
|
+
};
|
|
441
|
+
'plugin:add-indicator': {
|
|
442
|
+
indicator: Indicator;
|
|
443
|
+
pane?: ChartPane;
|
|
444
|
+
};
|
|
445
|
+
'plugin:redraw-indicators': void;
|
|
446
|
+
'plugin:register-indicator': {
|
|
447
|
+
indicator: Indicator;
|
|
448
|
+
activeByDefault?: boolean;
|
|
449
|
+
pane?: ChartPane;
|
|
450
|
+
lookback?: number;
|
|
451
|
+
};
|
|
452
|
+
/** A plugin finished installing - its worker is live and capabilities are
|
|
453
|
+
* registering. Fired by PluginRegistry, not chart.use(), since install is async. */
|
|
454
|
+
'plugin:installed': {
|
|
455
|
+
id: string;
|
|
456
|
+
};
|
|
457
|
+
/** A plugin was torn down via chart.unuse(). Everything it registered
|
|
458
|
+
* (indicator instances, panes, drawing tools, chart types) is being removed. */
|
|
459
|
+
'plugin:uninstalled': {
|
|
460
|
+
id: string;
|
|
461
|
+
};
|
|
462
|
+
'plugin:register-drawing': {
|
|
463
|
+
id: string;
|
|
464
|
+
name: string;
|
|
465
|
+
icon: any;
|
|
466
|
+
};
|
|
467
|
+
'plugin:unregister-drawing': {
|
|
468
|
+
id: string;
|
|
469
|
+
};
|
|
470
|
+
'plugin:register-pane': {
|
|
471
|
+
id: string;
|
|
472
|
+
heightRatio: number;
|
|
473
|
+
};
|
|
474
|
+
'plugin:remove-pane': {
|
|
475
|
+
id: string;
|
|
476
|
+
};
|
|
477
|
+
'plugin:panel-added': {
|
|
478
|
+
id: string;
|
|
479
|
+
title: string;
|
|
480
|
+
visible: boolean;
|
|
481
|
+
};
|
|
482
|
+
'plugin:panel-removed': {
|
|
483
|
+
id: string;
|
|
484
|
+
};
|
|
485
|
+
'plugin:panel-toggle-visibility': {
|
|
486
|
+
id: string;
|
|
487
|
+
visible: boolean;
|
|
488
|
+
};
|
|
489
|
+
'plugin:register-chart-type': {
|
|
490
|
+
plugin: ChartTypePlugin;
|
|
491
|
+
};
|
|
492
|
+
'plugin:unregister-chart-type': {
|
|
493
|
+
id: string;
|
|
494
|
+
hotReload?: boolean;
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* Something needs richer data than the charted symbol serves. Emitted when a
|
|
498
|
+
* plugin is skipped at install, and when an indicator or chart type is
|
|
499
|
+
* refused at activation. `name` and `kind` are what the host puts in front of
|
|
500
|
+
* the user - an id is no use to them.
|
|
501
|
+
*/
|
|
502
|
+
'plugin:incompatible': {
|
|
503
|
+
id: string;
|
|
504
|
+
required: DataLevel;
|
|
505
|
+
actual: DataLevel;
|
|
506
|
+
name?: string;
|
|
507
|
+
kind?: 'plugin' | 'indicator' | 'chart-type';
|
|
508
|
+
};
|
|
509
|
+
'plugin:script-error': {
|
|
510
|
+
id: string;
|
|
511
|
+
error: string;
|
|
512
|
+
line?: number;
|
|
513
|
+
};
|
|
514
|
+
/** Open the plugin manager. For hosts that want their own way in. */
|
|
515
|
+
'plugin:open-manager': Record<string, never>;
|
|
516
|
+
'plugin:scripted-compute': {
|
|
517
|
+
id: string;
|
|
518
|
+
ohlcv: OhlcvBar[];
|
|
519
|
+
trades: SerialTrade[];
|
|
520
|
+
ticks: unknown[];
|
|
521
|
+
snapshots: unknown[];
|
|
522
|
+
barNs: bigint;
|
|
523
|
+
};
|
|
524
|
+
'plugin:scripted-advance': {
|
|
525
|
+
id: string;
|
|
526
|
+
newOhlcv: OhlcvBar[];
|
|
527
|
+
newTrades: SerialTrade[];
|
|
528
|
+
newTicks: unknown[];
|
|
529
|
+
newSnapshots: unknown[];
|
|
530
|
+
barNs: bigint;
|
|
531
|
+
horizon: bigint;
|
|
532
|
+
};
|
|
533
|
+
'plugin:chart-type-updated': {
|
|
534
|
+
id: string;
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* A scripted indicator's worker returned fresh draw output. Panes holding it
|
|
538
|
+
* re-snapshot and repaint their own render engine - the plugin cant, since
|
|
539
|
+
* the chart holds one render engine reference (the last cell to mount) while
|
|
540
|
+
* every cell has its own.
|
|
541
|
+
*/
|
|
542
|
+
'plugin:indicator-updated': {
|
|
543
|
+
id: string;
|
|
544
|
+
};
|
|
545
|
+
'plugin:update-code': {
|
|
546
|
+
id: string;
|
|
547
|
+
code: string;
|
|
548
|
+
};
|
|
549
|
+
'plugin:recompute-indicator': {
|
|
550
|
+
id: string;
|
|
551
|
+
};
|
|
552
|
+
'plugin:remove-indicator': {
|
|
553
|
+
id: string;
|
|
554
|
+
};
|
|
555
|
+
'plugin:add-indicator:id': {
|
|
556
|
+
id: string;
|
|
557
|
+
};
|
|
558
|
+
'plugin:toolbar-item-added': {
|
|
559
|
+
item: ToolbarItem;
|
|
560
|
+
};
|
|
561
|
+
'plugin:toolbar-item-removed': {
|
|
562
|
+
id: string;
|
|
563
|
+
};
|
|
564
|
+
'plugin:toolbar-item-updated': {
|
|
565
|
+
item: ToolbarItem;
|
|
566
|
+
};
|
|
567
|
+
'plugin:bottom-bar-item-added': {
|
|
568
|
+
item: BottomBarItem;
|
|
569
|
+
};
|
|
570
|
+
'plugin:bottom-bar-item-removed': {
|
|
571
|
+
id: string;
|
|
572
|
+
};
|
|
573
|
+
'plugin:bottom-bar-item-updated': {
|
|
574
|
+
item: BottomBarItem;
|
|
575
|
+
};
|
|
576
|
+
'plugin:bottom-bar-item-rerender': {
|
|
577
|
+
id: string;
|
|
578
|
+
};
|
|
579
|
+
'drawing:add': Drawing;
|
|
580
|
+
'drawing:move': {
|
|
581
|
+
id: string;
|
|
582
|
+
anchor: Anchor;
|
|
583
|
+
};
|
|
584
|
+
'drawing:remove': {
|
|
585
|
+
id: string;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Selection changed; `id` is null when nothing is selected. Carries only the
|
|
589
|
+
* id - read the drawing with `chart.getSelectedDrawing()`, which is live, so
|
|
590
|
+
* a box still being dragged reads as it currently stands.
|
|
591
|
+
*/
|
|
592
|
+
'drawing:selected': {
|
|
593
|
+
id: string | null;
|
|
594
|
+
};
|
|
595
|
+
'pane:hovered': {
|
|
596
|
+
id: string;
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* The trade-line hit regions a UI repaint just produced. Canvas-space rects,
|
|
600
|
+
* meaningless anywhere but the cell that painted them, so listeners must
|
|
601
|
+
* drop every id but their own - otherwise the last cell to repaint each
|
|
602
|
+
* frame decides where every other cell thinks its lines are.
|
|
603
|
+
*/
|
|
604
|
+
'hitmap:update': {
|
|
605
|
+
id: number;
|
|
606
|
+
hitMap: TradeLineHitMap;
|
|
607
|
+
};
|
|
608
|
+
'playback:seek': {
|
|
609
|
+
tNs: bigint;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Command: jump the playhead to `tNs`, pausing first. The counterpart to
|
|
613
|
+
* playback:seek, which reports where the playhead landed - this one asks for
|
|
614
|
+
* the move, and the engine loads whatever data the target needs.
|
|
615
|
+
*/
|
|
616
|
+
'playback:goto': {
|
|
617
|
+
tNs: bigint;
|
|
618
|
+
};
|
|
619
|
+
'playback:tick': {
|
|
620
|
+
bid: number;
|
|
621
|
+
ask: number;
|
|
622
|
+
last: number;
|
|
623
|
+
spread: number;
|
|
624
|
+
};
|
|
625
|
+
'playback:end': void;
|
|
626
|
+
'playback:play': void;
|
|
627
|
+
'playback:pause': void;
|
|
628
|
+
'playback:set-step-size': {
|
|
629
|
+
step: string;
|
|
630
|
+
};
|
|
631
|
+
'playback:set-speed': {
|
|
632
|
+
speed: number;
|
|
633
|
+
};
|
|
634
|
+
'playback:step-back': void;
|
|
635
|
+
'playback:step-forward': void;
|
|
636
|
+
'playback:set-mode': {
|
|
637
|
+
mode: PlaybackMode;
|
|
638
|
+
};
|
|
639
|
+
'playback:set-step-snap': {
|
|
640
|
+
snap: boolean;
|
|
641
|
+
};
|
|
642
|
+
/** A move was refused because the playhead is locked forward. */
|
|
643
|
+
'playback:blocked': {
|
|
644
|
+
tNs: bigint;
|
|
645
|
+
floorNs: bigint;
|
|
646
|
+
};
|
|
647
|
+
'account:update': {
|
|
648
|
+
balance: number;
|
|
649
|
+
equity: number;
|
|
650
|
+
realizedPnl: number;
|
|
651
|
+
unrealizedPnl: number;
|
|
652
|
+
openPositionCount: number;
|
|
653
|
+
currency: string;
|
|
654
|
+
};
|
|
655
|
+
'account:reset': void;
|
|
656
|
+
'account:deposit': {
|
|
657
|
+
amount: number;
|
|
658
|
+
ts: bigint;
|
|
659
|
+
note?: string;
|
|
660
|
+
};
|
|
661
|
+
'account:withdraw': {
|
|
662
|
+
amount: number;
|
|
663
|
+
ts: bigint;
|
|
664
|
+
note?: string;
|
|
665
|
+
};
|
|
666
|
+
error: {
|
|
667
|
+
source: string;
|
|
668
|
+
message: string;
|
|
669
|
+
error?: unknown;
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
export type InterceptableEvent = 'trading:buy-market' | 'trading:sell-market' | 'trading:flatten' | 'chart:set-timeframe' | 'chart:set-symbol' | 'chart:set-tool' | 'drawing:add' | 'drawing:remove' | 'order:placed' | 'playback:seek' | 'playback:goto' | 'playback:play' | 'playback:pause';
|
|
673
|
+
export type Interceptor<K extends keyof ChartEvents> = (data: ChartEvents[K], next: (data: ChartEvents[K]) => void) => void;
|
|
674
|
+
export declare class TypedEventBus {
|
|
675
|
+
private readonly handlers;
|
|
676
|
+
private readonly interceptors;
|
|
677
|
+
private readonly emitting;
|
|
678
|
+
private static readonly STICKY;
|
|
679
|
+
private readonly stickyCache;
|
|
680
|
+
on<K extends keyof ChartEvents>(event: K, handler: (data: ChartEvents[K]) => void): () => void;
|
|
681
|
+
/**
|
|
682
|
+
* Is anything listening for this event? For controls that ask rather than
|
|
683
|
+
* act - a button that opens the order ticket is only worth showing where a
|
|
684
|
+
* ticket exists to open.
|
|
685
|
+
*/
|
|
686
|
+
hasListeners<K extends keyof ChartEvents>(event: K): boolean;
|
|
687
|
+
off<K extends keyof ChartEvents>(event: K, handler: Function): void;
|
|
688
|
+
intercept<K extends InterceptableEvent>(event: K, interceptor: Interceptor<K>): () => void;
|
|
689
|
+
emit<K extends keyof ChartEvents>(event: K, data: ChartEvents[K]): void;
|
|
690
|
+
clear(): void;
|
|
691
|
+
}
|