@christtrade/depth 0.19.0 → 0.20.0
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/README.md +175 -96
- package/depth.cjs +56 -56
- package/depth.css +1 -1
- package/depth.mjs +56 -56
- package/depth.nopreflight.css +1 -1
- package/package.json +1 -1
- package/types/components/ui/resizable.d.ts +1 -1
- package/types/core/BarStore.d.ts +69 -0
- package/types/core/DataEngine.d.ts +15 -2
- package/types/core/DepthChart.d.ts +1 -1
- package/types/core/ExecutionEngine.d.ts +3 -2
- package/types/core/RenderEngine.d.ts +2 -9
- package/types/core/TypedEventBus.d.ts +10 -9
- package/types/core/index.d.ts +1 -0
- package/types/hooks/useChartData.d.ts +11 -9
- package/types/hooks/useChartHandlers.d.ts +5 -4
- package/types/hooks/useChartInteraction.d.ts +5 -4
- package/types/hooks/useChartSettings.d.ts +5 -4
- package/types/hooks/useChartSubscriptions.d.ts +5 -4
- package/types/hooks/useChartView.d.ts +5 -4
- package/types/interfaces/plugins/IChartPlugin.d.ts +13 -2
- package/types/interfaces/plugins/IDrawingPlugin.d.ts +2 -2
- package/types/lib/matchingEngine.d.ts +3 -2
- package/types/lib/renderers/renderer.d.ts +5 -28
|
@@ -6,6 +6,7 @@ import type { BracketAmendment, Order, Position } from '../lib/types/trading-typ
|
|
|
6
6
|
import type { MboEvent, PriceHistory } from '../lib/types';
|
|
7
7
|
import type { OhlcvBar } from '../interfaces/IDataAdapter';
|
|
8
8
|
import type { SerialTrade } from '../lib/types';
|
|
9
|
+
import { BarStore } from './BarStore';
|
|
9
10
|
/**
|
|
10
11
|
* Vetoes an order before it reaches a book. Return a reason to refuse it, or
|
|
11
12
|
* null to let it through. Pre-trade risk lives here rather than in the caller,
|
|
@@ -58,8 +59,8 @@ export declare class ExecutionEngine {
|
|
|
58
59
|
private targetFor;
|
|
59
60
|
private eachBuiltIn;
|
|
60
61
|
ingestCompactBuf(buf: ArrayBuffer, symbol?: string): void;
|
|
61
|
-
ingestOhlcvBars(bars: OhlcvBar[], barNs?: bigint, symbol?: string): void;
|
|
62
|
-
appendOhlcvBars(bars: OhlcvBar[], barNs?: bigint, symbol?: string): void;
|
|
62
|
+
ingestOhlcvBars(bars: OhlcvBar[] | BarStore, barNs?: bigint, symbol?: string): void;
|
|
63
|
+
appendOhlcvBars(bars: OhlcvBar[] | BarStore, barNs?: bigint, symbol?: string): void;
|
|
63
64
|
ingestSupplementalBars(bars: Array<{
|
|
64
65
|
time: number;
|
|
65
66
|
open: number;
|
|
@@ -10,6 +10,7 @@ import type { TradeLine } from '../lib/types';
|
|
|
10
10
|
import { LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
11
11
|
import { ChartTypePlugin } from './PluginRegistry';
|
|
12
12
|
import { SessionMapper } from './SessionMapper';
|
|
13
|
+
import type { BarStore } from './BarStore';
|
|
13
14
|
import { AccountSnapshot, DataLevel, SymbolInfo } from '.';
|
|
14
15
|
import type { CrosshairSync } from '../lib/types/layout-sync';
|
|
15
16
|
/** Layout of the frame a draw hook runs in. Everything in css px */
|
|
@@ -51,15 +52,7 @@ export interface DrawParams {
|
|
|
51
52
|
horizon: bigint;
|
|
52
53
|
candleCache: Map<bigint, any> | null;
|
|
53
54
|
openBar: FootprintBar | null;
|
|
54
|
-
|
|
55
|
-
ohlcvBars: {
|
|
56
|
-
time: number;
|
|
57
|
-
open: number;
|
|
58
|
-
high: number;
|
|
59
|
-
low: number;
|
|
60
|
-
close: number;
|
|
61
|
-
volume: number;
|
|
62
|
-
}[];
|
|
55
|
+
ohlcvBars: BarStore;
|
|
63
56
|
crosshair: Crosshair | null;
|
|
64
57
|
drawings: Drawing[];
|
|
65
58
|
draft: DraftDrawing | null;
|
|
@@ -18,6 +18,7 @@ import { Fill, Order, Position, PositionClose, TradingEvent } from '../lib/types
|
|
|
18
18
|
import { PriceHistory, TradePoint, type ViewBounds } from '../lib/types';
|
|
19
19
|
import { BottomBarItem, ChartTypePlugin, ToolbarItem } from './PluginRegistry';
|
|
20
20
|
import { RenderEngine } from './RenderEngine';
|
|
21
|
+
import type { BarStore } from './BarStore';
|
|
21
22
|
import { PlaybackMode } from '../hooks/usePlaybackEngine';
|
|
22
23
|
import type { CrosshairSync, TimeRangeSync } from '../lib/types/layout-sync';
|
|
23
24
|
import type { PlaceOrderRequest } from '../lib/matchingEngine';
|
|
@@ -125,14 +126,7 @@ export interface ChartEvents {
|
|
|
125
126
|
volume: number;
|
|
126
127
|
delta: number;
|
|
127
128
|
}> | null;
|
|
128
|
-
bars:
|
|
129
|
-
time: number;
|
|
130
|
-
open: number;
|
|
131
|
-
high: number;
|
|
132
|
-
low: number;
|
|
133
|
-
close: number;
|
|
134
|
-
volume: number;
|
|
135
|
-
}[];
|
|
129
|
+
bars: BarStore;
|
|
136
130
|
openBar: FootprintBar;
|
|
137
131
|
horizon: bigint;
|
|
138
132
|
dataLevel: DataLevel;
|
|
@@ -180,7 +174,8 @@ export interface ChartEvents {
|
|
|
180
174
|
trades: SerialTrade[];
|
|
181
175
|
priceHistory: PriceHistory[];
|
|
182
176
|
footprintBars: FootprintBar[];
|
|
183
|
-
|
|
177
|
+
/** Every loaded bar. Derived from footprintBars at l3/tick, empty at l2. */
|
|
178
|
+
bars: BarStore;
|
|
184
179
|
barNs: bigint;
|
|
185
180
|
dataStart: number;
|
|
186
181
|
dataEnd: number;
|
|
@@ -220,7 +215,10 @@ export interface ChartEvents {
|
|
|
220
215
|
trades: SerialTrade[];
|
|
221
216
|
priceHistory: PriceHistory[];
|
|
222
217
|
footprintBars: FootprintBar[];
|
|
218
|
+
/** This chunk's new bars at ohlcv, empty at every other level. */
|
|
223
219
|
ohlcvBars: OhlcvBar[];
|
|
220
|
+
/** Every loaded bar, this chunk included. */
|
|
221
|
+
bars: BarStore;
|
|
224
222
|
barNs: bigint;
|
|
225
223
|
dataStart: number;
|
|
226
224
|
dataEnd: number;
|
|
@@ -265,7 +263,10 @@ export interface ChartEvents {
|
|
|
265
263
|
trades: SerialTrade[];
|
|
266
264
|
priceHistory: PriceHistory[];
|
|
267
265
|
footprintBars: FootprintBar[];
|
|
266
|
+
/** This page's new bars at ohlcv, empty at every other level. */
|
|
268
267
|
ohlcvBars: OhlcvBar[];
|
|
268
|
+
/** Every loaded bar, this page included. */
|
|
269
|
+
bars: BarStore;
|
|
269
270
|
barNs: bigint;
|
|
270
271
|
dataStart: number;
|
|
271
272
|
viewMin: bigint;
|
package/types/core/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type { DepthProps } from '../ChartOuter';
|
|
|
10
10
|
export { ExecutionEngine } from './ExecutionEngine';
|
|
11
11
|
export { DataEngine } from './DataEngine';
|
|
12
12
|
export type { DataEngineConfig, ChartDataSnapshot } from './DataEngine';
|
|
13
|
+
export { BarStore } from './BarStore';
|
|
13
14
|
export { TypedEventBus } from './TypedEventBus';
|
|
14
15
|
export type { ChartEvents } from './TypedEventBus';
|
|
15
16
|
export type { AuditResult, AuditFnEntry } from './script-audit';
|
|
@@ -14,17 +14,19 @@ import { type ChartSettings } from '../lib/types/chart-settings';
|
|
|
14
14
|
import { type TypedEventBus } from '../core/TypedEventBus';
|
|
15
15
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
16
16
|
import { type SessionMapper } from '../core/SessionMapper';
|
|
17
|
+
import { BarStore } from '../core/BarStore';
|
|
17
18
|
import { ohlcvBucketRange } from '../lib/bar-grid';
|
|
18
19
|
import { type SessionStatus } from '../core/SessionUtils';
|
|
19
20
|
export { ohlcvBucketRange };
|
|
20
|
-
export declare function aggregateOhlcvBars(bars:
|
|
21
|
+
export declare function aggregateOhlcvBars(bars: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null, from?: number): BarStore;
|
|
22
|
+
export declare function isAggregated(bars: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null, from?: number, to?: number): boolean;
|
|
23
|
+
export declare function displayFor(bars: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null): BarStore;
|
|
21
24
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Handles the boundary bucket that might straddle the old/new data boundary.
|
|
25
|
+
* Prepend fetched bars to an aggregated display store in place, merging the
|
|
26
|
+
* bucket that straddles the boundary. Costs the new bars only.
|
|
25
27
|
*/
|
|
26
|
-
export declare function prependAggregatedOhlcvBars(newBars: OhlcvBarMs[],
|
|
27
|
-
export declare function autoFitPriceAxis(view: ViewBounds, priceHistory: PriceHistory[], trades: TradePoint[], bars:
|
|
28
|
+
export declare function prependAggregatedOhlcvBars(newBars: OhlcvBarMs[], display: BarStore, targetBarNs: bigint, sessionMapper?: SessionMapper | null): BarStore;
|
|
29
|
+
export declare function autoFitPriceAxis(view: ViewBounds, priceHistory: PriceHistory[], trades: TradePoint[], bars: BarStore, openBar: FootprintBar | null, settings: ChartSettings, horizon: bigint, dataLevel?: DataLevel): void;
|
|
28
30
|
export declare function applyHorizonScrollEasing(t: number, type: string): number;
|
|
29
31
|
export interface UseChartDataParams {
|
|
30
32
|
eventBus: TypedEventBus;
|
|
@@ -76,10 +78,10 @@ export interface ChartDataResult {
|
|
|
76
78
|
footprintBarsRef: MutableRefObject<FootprintBar[]>;
|
|
77
79
|
ohlcvBarsRef: MutableRefObject<{
|
|
78
80
|
barNs: bigint;
|
|
79
|
-
bars:
|
|
80
|
-
display:
|
|
81
|
+
bars: BarStore;
|
|
82
|
+
display: BarStore;
|
|
81
83
|
}>;
|
|
82
|
-
previewBarsRef: MutableRefObject<
|
|
84
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
83
85
|
openBarRef: MutableRefObject<FootprintBar | null>;
|
|
84
86
|
openBarTsRef: MutableRefObject<bigint>;
|
|
85
87
|
openBarTradeCountRef: MutableRefObject<number>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type MutableRefObject, type RefObject } from 'react';
|
|
2
2
|
import { type Drawing } from '../lib/types/drawing-types';
|
|
3
3
|
import { type ChartPane, type Indicator, type Rect } from '../lib/types/indicator-types';
|
|
4
|
-
import { type ViewBounds, type TradeLine, type TradePoint, type PriceHistory
|
|
4
|
+
import { type ViewBounds, type TradeLine, type TradePoint, type PriceHistory } from '../lib/types';
|
|
5
5
|
import { type Timeframe } from '../lib/timeframes';
|
|
6
6
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
7
|
+
import { type BarStore } from '../core/BarStore';
|
|
7
8
|
import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
8
9
|
import { type DataLevel } from '../interfaces/IDataAdapter';
|
|
9
10
|
import { type CompactBuffer } from '../lib/compact-buffer';
|
|
@@ -20,8 +21,8 @@ export interface UseChartHandlersParams {
|
|
|
20
21
|
panesRef: MutableRefObject<ChartPane[]>;
|
|
21
22
|
ohlcvBarsRef: MutableRefObject<{
|
|
22
23
|
barNs: bigint;
|
|
23
|
-
bars:
|
|
24
|
-
display:
|
|
24
|
+
bars: BarStore;
|
|
25
|
+
display: BarStore;
|
|
25
26
|
}>;
|
|
26
27
|
sessionMapperRef: MutableRefObject<SessionMapper>;
|
|
27
28
|
activeTimeframeRef: MutableRefObject<Timeframe>;
|
|
@@ -36,7 +37,7 @@ export interface UseChartHandlersParams {
|
|
|
36
37
|
isYAxisAutoRef: MutableRefObject<boolean>;
|
|
37
38
|
priceHistoryRef: MutableRefObject<PriceHistory[]>;
|
|
38
39
|
dataLevelRef: MutableRefObject<DataLevel | null>;
|
|
39
|
-
previewBarsRef: MutableRefObject<
|
|
40
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
40
41
|
chartSettingsRef: MutableRefObject<ChartSettings>;
|
|
41
42
|
tradeLinesRef: MutableRefObject<TradeLine[]>;
|
|
42
43
|
hoveringLegend: MutableRefObject<boolean>;
|
|
@@ -5,11 +5,12 @@ import { type Crosshair } from '../lib/renderers/renderer';
|
|
|
5
5
|
import { type PluginToolActiveContext } from '../core/DrawingRegistry';
|
|
6
6
|
import type { ChartTypePlugin, ChartTypeActiveContext } from '../core/PluginRegistry';
|
|
7
7
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
8
|
+
import { type BarStore } from '../core/BarStore';
|
|
8
9
|
import { type TypedEventBus } from '../core/TypedEventBus';
|
|
9
10
|
import { type SessionMapper } from '../core/SessionMapper';
|
|
10
11
|
import { type TradingSession, type DataLevel, type SymbolInfo } from '../interfaces/IDataAdapter';
|
|
11
12
|
import { type LiveTransformer } from '../interfaces/ICoordinateTransformer';
|
|
12
|
-
import { type ViewBounds, type PriceHistory, type TradePoint
|
|
13
|
+
import { type ViewBounds, type PriceHistory, type TradePoint } from '../lib/types';
|
|
13
14
|
import { type FootprintBar } from '../lib/types/footprint';
|
|
14
15
|
import { type ChartSettings } from '../lib/types/chart-settings';
|
|
15
16
|
import { type Timeframe } from '../lib/timeframes';
|
|
@@ -102,10 +103,10 @@ export interface UseChartInteractionParams {
|
|
|
102
103
|
allPriceHistoryRef: MutableRefObject<PriceHistory[]>;
|
|
103
104
|
ohlcvBarsRef: MutableRefObject<{
|
|
104
105
|
barNs: bigint;
|
|
105
|
-
bars:
|
|
106
|
-
display:
|
|
106
|
+
bars: BarStore;
|
|
107
|
+
display: BarStore;
|
|
107
108
|
}>;
|
|
108
|
-
previewBarsRef: MutableRefObject<
|
|
109
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
109
110
|
dataLevelRef: MutableRefObject<DataLevel | null>;
|
|
110
111
|
openBarRef: MutableRefObject<FootprintBar | null>;
|
|
111
112
|
candleCacheRef: MutableRefObject<Map<bigint, any> | null>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type MutableRefObject } from 'react';
|
|
2
|
-
import { type ViewBounds, type TradePoint, type PriceHistory
|
|
2
|
+
import { type ViewBounds, type TradePoint, type PriceHistory } from '../lib/types';
|
|
3
3
|
import { type FootprintBar } from '../lib/types/footprint';
|
|
4
4
|
import { type ChartSettings } from '../lib/types/chart-settings';
|
|
5
5
|
import { type DataLevel } from '../interfaces/IDataAdapter';
|
|
6
6
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
7
|
+
import { type BarStore } from '../core/BarStore';
|
|
7
8
|
import { type CompactBuffer } from '../lib/compact-buffer';
|
|
8
9
|
export interface UseChartSettingsParams {
|
|
9
10
|
chartSettingsRef: MutableRefObject<ChartSettings>;
|
|
@@ -14,10 +15,10 @@ export interface UseChartSettingsParams {
|
|
|
14
15
|
dataLevelRef: MutableRefObject<DataLevel | null>;
|
|
15
16
|
ohlcvBarsRef: MutableRefObject<{
|
|
16
17
|
barNs: bigint;
|
|
17
|
-
bars:
|
|
18
|
-
display:
|
|
18
|
+
bars: BarStore;
|
|
19
|
+
display: BarStore;
|
|
19
20
|
}>;
|
|
20
|
-
previewBarsRef: MutableRefObject<
|
|
21
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
21
22
|
openBarRef: MutableRefObject<FootprintBar | null>;
|
|
22
23
|
horizonRef: MutableRefObject<bigint>;
|
|
23
24
|
compactBufRef: MutableRefObject<CompactBuffer>;
|
|
@@ -2,10 +2,11 @@ import { type MutableRefObject } from 'react';
|
|
|
2
2
|
import { type ChartTypePlugin, type ChartTypeActiveContext } from '../core/PluginRegistry';
|
|
3
3
|
import { type AccountManager } from '../core/AccountManager';
|
|
4
4
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
5
|
+
import { type BarStore } from '../core/BarStore';
|
|
5
6
|
import { type TypedEventBus } from '../core/TypedEventBus';
|
|
6
7
|
import { type ChartPane, type Indicator } from '../lib/types/indicator-types';
|
|
7
8
|
import { type ChartSettings } from '../lib/types/chart-settings';
|
|
8
|
-
import { type TradePoint, type
|
|
9
|
+
import { type TradePoint, type ViewBounds } from '../lib/types';
|
|
9
10
|
import { type DataLevel } from '../interfaces/IDataAdapter';
|
|
10
11
|
import { type FootprintBar } from '../lib/types/footprint';
|
|
11
12
|
import { type SerialTrade } from '../lib/types';
|
|
@@ -27,12 +28,12 @@ export interface UseChartSubscriptionsParams {
|
|
|
27
28
|
chartSettingsRef: MutableRefObject<ChartSettings>;
|
|
28
29
|
pluginChartTypeComputedRef: MutableRefObject<Map<string, unknown>>;
|
|
29
30
|
dataLevelRef: MutableRefObject<DataLevel | null>;
|
|
30
|
-
previewBarsRef: MutableRefObject<
|
|
31
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
31
32
|
candleCacheRef: MutableRefObject<Map<bigint, any> | null>;
|
|
32
33
|
ohlcvBarsRef: MutableRefObject<{
|
|
33
34
|
barNs: bigint;
|
|
34
|
-
bars:
|
|
35
|
-
display:
|
|
35
|
+
bars: BarStore;
|
|
36
|
+
display: BarStore;
|
|
36
37
|
}>;
|
|
37
38
|
openBarRef: MutableRefObject<FootprintBar | null>;
|
|
38
39
|
viewRef: MutableRefObject<ViewBounds | null>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type MutableRefObject } from 'react';
|
|
2
|
-
import { type ViewBounds, type TradePoint, type PriceHistory
|
|
2
|
+
import { type ViewBounds, type TradePoint, type PriceHistory } from '../lib/types';
|
|
3
3
|
import { type ChartSettings } from '../lib/types/chart-settings';
|
|
4
4
|
import { type DataLevel } from '../interfaces/IDataAdapter';
|
|
5
5
|
import { type RenderEngine } from '../core/RenderEngine';
|
|
6
|
+
import { BarStore } from '../core/BarStore';
|
|
6
7
|
import { type ChartPane, type Indicator } from '../lib/types/indicator-types';
|
|
7
8
|
import { FootprintBar } from '../core';
|
|
8
9
|
export interface UseChartViewParams {
|
|
@@ -12,11 +13,11 @@ export interface UseChartViewParams {
|
|
|
12
13
|
setChartSettings: (updater: ChartSettings | ((prev: ChartSettings) => ChartSettings)) => void;
|
|
13
14
|
priceHistoryRef: MutableRefObject<PriceHistory[]>;
|
|
14
15
|
tradesRef: MutableRefObject<TradePoint[]>;
|
|
15
|
-
previewBarsRef: MutableRefObject<
|
|
16
|
+
previewBarsRef: MutableRefObject<BarStore>;
|
|
16
17
|
ohlcvBarsRef: MutableRefObject<{
|
|
17
18
|
barNs: bigint;
|
|
18
|
-
bars:
|
|
19
|
-
display:
|
|
19
|
+
bars: BarStore;
|
|
20
|
+
display: BarStore;
|
|
20
21
|
}>;
|
|
21
22
|
openBarRef: MutableRefObject<FootprintBar>;
|
|
22
23
|
chartSettingsRef: MutableRefObject<ChartSettings>;
|
|
@@ -12,6 +12,7 @@ import type { ChartColors } from '../../lib/types/chart-settings';
|
|
|
12
12
|
import type { DataLevel, OhlcvBar, SymbolInfo, TickEvent } from '../IDataAdapter';
|
|
13
13
|
import type { SerialTrade, PriceHistory } from '../../lib/types';
|
|
14
14
|
import type { FootprintBar } from '../../lib/types/footprint';
|
|
15
|
+
import type { BarStore } from '../../core/BarStore';
|
|
15
16
|
import type { BracketAmendment } from '../../lib/types/trading-types';
|
|
16
17
|
import type { PlaceOrderRequest } from '../../lib/matchingEngine';
|
|
17
18
|
import type { CommandDef, CvarDef } from '../../console/Console';
|
|
@@ -152,7 +153,17 @@ export interface PluginDataSnapshot {
|
|
|
152
153
|
trades: SerialTrade[];
|
|
153
154
|
footprintBars: FootprintBar[];
|
|
154
155
|
priceHistory: PriceHistory[];
|
|
155
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Every loaded bar, as columns: `bars.close[i]`. Always present - synthesised
|
|
158
|
+
* from footprintBars when dataLevel is l3/tick. Read the columns off it each
|
|
159
|
+
* time; they're swapped as bars load. It's the store the chart draws from so
|
|
160
|
+
* read it, don't change it. `clone()` it for a copy of your own.
|
|
161
|
+
*/
|
|
162
|
+
bars: BarStore;
|
|
163
|
+
/**
|
|
164
|
+
* `bars` as objects, built on first read and kept until the bars change.
|
|
165
|
+
* @deprecated ~176 bytes a bar and a full copy - use `bars`.
|
|
166
|
+
*/
|
|
156
167
|
ohlcvBars: OhlcvBar[];
|
|
157
168
|
/** Populated when dataLevel is tick or l3. */
|
|
158
169
|
ticks: TickEvent[];
|
|
@@ -197,7 +208,7 @@ export interface PluginContext {
|
|
|
197
208
|
* data has arrived.
|
|
198
209
|
*
|
|
199
210
|
* This is the one you want for "what is the price right now". The last entry
|
|
200
|
-
* of `getData().
|
|
211
|
+
* of `getData().bars` is the last bar that was *loaded*, which during
|
|
201
212
|
* replay is somewhere in the future and at the fetch resolution rather than
|
|
202
213
|
* the charted timeframe.
|
|
203
214
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type { ChartPlugin } from './IChartPlugin';
|
|
12
12
|
import type { Anchor } from '../../lib/types/drawing-types';
|
|
13
13
|
import type { PluginDrawingRenderContext, PluginDrawingHitContext } from '../../core/DrawingRegistry';
|
|
14
|
-
import type {
|
|
14
|
+
import type { BarStore } from '../../core/BarStore';
|
|
15
15
|
export interface Point {
|
|
16
16
|
x: number;
|
|
17
17
|
y: number;
|
|
@@ -54,7 +54,7 @@ export interface DrawingPlugin extends ChartPlugin {
|
|
|
54
54
|
/**
|
|
55
55
|
* Optionally snap an anchor to the nearest bar OHLC value during placement.
|
|
56
56
|
*/
|
|
57
|
-
snap?(anchor: Anchor, bars:
|
|
57
|
+
snap?(anchor: Anchor, bars: BarStore): Anchor;
|
|
58
58
|
/** Serialise anchor positions to a JSON-safe value for persistence. */
|
|
59
59
|
serialize(anchors: Anchor[]): unknown;
|
|
60
60
|
/** Restore anchors from a previously serialised value. */
|
|
@@ -3,6 +3,7 @@ import type { Order, Fill, Position, BracketLevel, BracketAmendment, PriceTick,
|
|
|
3
3
|
import type { MboEvent, PriceHistory } from './types';
|
|
4
4
|
import type { OhlcvBar, SymbolInfo } from '../interfaces/IDataAdapter';
|
|
5
5
|
import type { SerialTrade } from './types';
|
|
6
|
+
import { BarStore } from '../core/BarStore';
|
|
6
7
|
import { TypedEventBus } from '../core';
|
|
7
8
|
export declare function sanitizeMetadata(meta: Record<string, unknown> | undefined, symbol: string, quantity: number, symbolInfo?: SymbolInfo | null): Record<string, unknown>;
|
|
8
9
|
export interface FeeSchedule {
|
|
@@ -78,12 +79,12 @@ export interface L3MatchingEngine {
|
|
|
78
79
|
/** L3 path: ingest a compact buffer and then use seekTo to replay. */
|
|
79
80
|
ingestCompactBuf: (buf: ArrayBuffer) => void;
|
|
80
81
|
/** OHLCV path: ingest bars; seekTo advances bar by bar. Resets the replay cursor. */
|
|
81
|
-
ingestOhlcvBars: (bars: OhlcvBar[], barNs?: bigint) => void;
|
|
82
|
+
ingestOhlcvBars: (bars: OhlcvBar[] | BarStore, barNs?: bigint) => void;
|
|
82
83
|
/**
|
|
83
84
|
* OHLCV path: extend the buffer forward without rewinding the replay.
|
|
84
85
|
* What a stream-append must use - see appendOhlcvBars for why.
|
|
85
86
|
*/
|
|
86
|
-
appendOhlcvBars: (bars: OhlcvBar[], barNs?: bigint) => void;
|
|
87
|
+
appendOhlcvBars: (bars: OhlcvBar[] | BarStore, barNs?: bigint) => void;
|
|
87
88
|
/** OHLCV path: ingest finer-resolution bars so seekTo uses accurate mark prices within the open bar. */
|
|
88
89
|
ingestSupplementalBars?: (bars: Array<{
|
|
89
90
|
time: number;
|
|
@@ -6,6 +6,7 @@ import { ChartSettings } from '../types/chart-settings';
|
|
|
6
6
|
import { ActiveDrawingTool, DraftDrawing, Drawing, DrawingAnchorId } from '../types/drawing-types';
|
|
7
7
|
import { AccountSnapshot, DataLevel, LiveTransformer, OhlcvBar, SymbolInfo } from '../../core';
|
|
8
8
|
import { SessionMapper } from '../../core/SessionMapper';
|
|
9
|
+
import type { BarStore } from '../../core/BarStore';
|
|
9
10
|
import { PriceTransition } from '../priceTransition';
|
|
10
11
|
import { OrdinalModel } from '../series/japaneseCharts';
|
|
11
12
|
import type { CrosshairSync } from '../types/layout-sync';
|
|
@@ -31,22 +32,8 @@ openBar: {
|
|
|
31
32
|
high: number;
|
|
32
33
|
low: number;
|
|
33
34
|
close: number;
|
|
34
|
-
} | null, ohlcvBars:
|
|
35
|
-
|
|
36
|
-
open: number;
|
|
37
|
-
high: number;
|
|
38
|
-
low: number;
|
|
39
|
-
close: number;
|
|
40
|
-
volume: number;
|
|
41
|
-
}[], transformer: LiveTransformer, isPluginChartType?: boolean, sessionMapper?: SessionMapper, dataLevel?: DataLevel, hidePriceScale?: boolean, hideTimeScale?: boolean, symbolInfo?: SymbolInfo, rightScaleWidth?: number): void;
|
|
42
|
-
export declare function drawUILayer(canvas: HTMLCanvasElement, priceHistory: PriceHistory[], trades: TradePoint[], bounds: ViewBounds, crosshair: Crosshair, showTooltip: boolean, selectedTrade: TradePoint | null, panes: ChartPane[], layouts: Record<string, Rect>, indicators: Indicator[], hoveredDividerIdx: number, hoveringLegend: boolean, barNs: bigint, chartSettings: ChartSettings, horizon: bigint, candleCache: CandleCache | null, ohlcvBars: {
|
|
43
|
-
time: number;
|
|
44
|
-
open: number;
|
|
45
|
-
high: number;
|
|
46
|
-
low: number;
|
|
47
|
-
close: number;
|
|
48
|
-
volume: number;
|
|
49
|
-
}[], openBar: OhlcvBar, tradeLines: TradeLine[], tradeLineInteraction: any, hoveredLineId?: string | null, draggingLineId?: string | null, activeTool?: ActiveDrawingTool | null, draggingAnchor?: {
|
|
35
|
+
} | null, ohlcvBars: BarStore, transformer: LiveTransformer, isPluginChartType?: boolean, sessionMapper?: SessionMapper, dataLevel?: DataLevel, hidePriceScale?: boolean, hideTimeScale?: boolean, symbolInfo?: SymbolInfo, rightScaleWidth?: number): void;
|
|
36
|
+
export declare function drawUILayer(canvas: HTMLCanvasElement, priceHistory: PriceHistory[], trades: TradePoint[], bounds: ViewBounds, crosshair: Crosshair, showTooltip: boolean, selectedTrade: TradePoint | null, panes: ChartPane[], layouts: Record<string, Rect>, indicators: Indicator[], hoveredDividerIdx: number, hoveringLegend: boolean, barNs: bigint, chartSettings: ChartSettings, horizon: bigint, candleCache: CandleCache | null, ohlcvBars: BarStore, openBar: OhlcvBar, tradeLines: TradeLine[], tradeLineInteraction: any, hoveredLineId?: string | null, draggingLineId?: string | null, activeTool?: ActiveDrawingTool | null, draggingAnchor?: {
|
|
50
37
|
drawingId: string;
|
|
51
38
|
anchor: DrawingAnchorId;
|
|
52
39
|
} | null, holdingCtrl?: boolean | null, holdingShift?: boolean | null, footprintBars?: FootprintBar[] | null, drawings?: Drawing[] | null, draft?: DraftDrawing | null, transformer?: LiveTransformer, showShiftInfo?: boolean, shiftInfoAnchor?: {
|
|
@@ -67,14 +54,7 @@ export declare function nearestTradeIndex(trades: TradePoint[], target: bigint):
|
|
|
67
54
|
export declare function findNearestTrade(clickX: number, clickY: number, trades: TradePoint[], bounds: ViewBounds, chartW: number, chartH: number, chartSettings: ChartSettings, horizon: bigint, transformer: LiveTransformer): TradePoint | null;
|
|
68
55
|
export declare function drawBackground(ctx: CanvasRenderingContext2D, cssW: number, cssH: number, chartSettings: ChartSettings): void;
|
|
69
56
|
export declare const snapTs: (ts: bigint, tf: bigint, sessionMapper?: SessionMapper | null) => bigint;
|
|
70
|
-
export declare const snapPrice: (snappedTs: bigint, rawPrice: number, chartSettings: ChartSettings, footprintBars: FootprintBar[], priceHistory: PriceHistory[], ohlcvBars:
|
|
71
|
-
time: number;
|
|
72
|
-
open: number;
|
|
73
|
-
high: number;
|
|
74
|
-
low: number;
|
|
75
|
-
close: number;
|
|
76
|
-
volume: number;
|
|
77
|
-
}[], dataLevel: DataLevel, horizon: bigint) => number;
|
|
57
|
+
export declare const snapPrice: (snappedTs: bigint, rawPrice: number, chartSettings: ChartSettings, footprintBars: FootprintBar[], priceHistory: PriceHistory[], ohlcvBars: BarStore, dataLevel: DataLevel, horizon: bigint) => number;
|
|
78
58
|
export declare function drawTooltip(ctx: CanvasRenderingContext2D, mouse: {
|
|
79
59
|
x: number;
|
|
80
60
|
y: number;
|
|
@@ -87,10 +67,7 @@ export declare function isOrdinalChartType(t: ChartType): boolean;
|
|
|
87
67
|
* (column timestamps) and autoscale (visible price extent), so all three derive
|
|
88
68
|
* from one build.
|
|
89
69
|
*/
|
|
90
|
-
export declare function getOrdinalModel(chartType: ChartType, chartSettings: ChartSettings, ohlcvBars:
|
|
91
|
-
time: number;
|
|
92
|
-
close: number;
|
|
93
|
-
}[] | undefined, candleCache: CandleCache | null, trades: TradePoint[], barNs: bigint): OrdinalModel | null;
|
|
70
|
+
export declare function getOrdinalModel(chartType: ChartType, chartSettings: ChartSettings, ohlcvBars: BarStore | undefined, candleCache: CandleCache | null, trades: TradePoint[], barNs: bigint): OrdinalModel | null;
|
|
94
71
|
/**
|
|
95
72
|
* Price extent of the columns currently visible under the transformer's view -
|
|
96
73
|
* used to auto-scale the y-axis for ordinal charts (whose prices live in the
|