@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,144 @@
|
|
|
1
|
+
import type { UseTradingStateReturn } from '../hooks/useTradingState';
|
|
2
|
+
import type { Order, Fill, Position, BracketLevel, BracketAmendment, PriceTick, OrderType, OrderSide } from './types/trading-types';
|
|
3
|
+
import type { MboEvent, PriceHistory } from './types';
|
|
4
|
+
import type { OhlcvBar, SymbolInfo } from '../interfaces/IDataAdapter';
|
|
5
|
+
import type { SerialTrade } from './types';
|
|
6
|
+
import { TypedEventBus } from '../core';
|
|
7
|
+
export declare function sanitizeMetadata(meta: Record<string, unknown> | undefined, symbol: string, quantity: number, symbolInfo?: SymbolInfo | null): Record<string, unknown>;
|
|
8
|
+
export interface FeeSchedule {
|
|
9
|
+
/** CME exchange fee per contract per side (e.g. NQ: $0.85). */
|
|
10
|
+
exchangeFeePerContract: number;
|
|
11
|
+
/** Broker commission per contract per side. */
|
|
12
|
+
commissionPerContract: number;
|
|
13
|
+
/** NFA regulatory fee per contract (one-way). */
|
|
14
|
+
nfaFeePerContract: number;
|
|
15
|
+
/** Clearing fee per contract. */
|
|
16
|
+
clearingFeePerContract: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const NQ_FEE_SCHEDULE: FeeSchedule;
|
|
19
|
+
export declare const MICRO_FEE_SCHEDULE: FeeSchedule;
|
|
20
|
+
export declare const ZERO_FEE_SCHEDULE: FeeSchedule;
|
|
21
|
+
export declare function feeScheduleFor(symbolInfo?: SymbolInfo | null): FeeSchedule;
|
|
22
|
+
export interface L3EngineOptions {
|
|
23
|
+
symbolInfo?: SymbolInfo;
|
|
24
|
+
tickSize?: number;
|
|
25
|
+
fees?: FeeSchedule;
|
|
26
|
+
fillLatencyMs?: number;
|
|
27
|
+
/** 'net' = CME-style futures netting. 'hedge' = independent positions. */
|
|
28
|
+
nettingMode?: 'net' | 'hedge';
|
|
29
|
+
marketSlippageTicks?: number;
|
|
30
|
+
eventBus?: TypedEventBus;
|
|
31
|
+
}
|
|
32
|
+
export type FillAmbiguity = 'pessimistic' | 'optimistic';
|
|
33
|
+
export interface FillSearchOptions {
|
|
34
|
+
/** When false, jumps skip fill evaluation entirely (fast navigation). */
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Cap on how fine the skipped span is evaluated, as a function of the jumped
|
|
38
|
+
* span (ns). Bounds the work for huge jumps (e.g. a month -> hourly bars).
|
|
39
|
+
* Returns a barNs. This is what keeps gap settlement from fetching the
|
|
40
|
+
* highest granularity over a long span.
|
|
41
|
+
*/
|
|
42
|
+
maxResolution: (spanNs: bigint) => bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Tie-break when a single (finest-allowed) bar's range contains conflicting
|
|
45
|
+
* triggers - e.g. both a stop-loss and a take-profit. 'pessimistic' assumes
|
|
46
|
+
* the worse (stop) side filled first. OHLC alone can't disambiguate intrabar
|
|
47
|
+
* order, so this is a policy, not ground truth.
|
|
48
|
+
*/
|
|
49
|
+
ambiguity: FillAmbiguity;
|
|
50
|
+
}
|
|
51
|
+
export declare const DEFAULT_FILL_SEARCH: FillSearchOptions;
|
|
52
|
+
export interface PlaceOrderRequest {
|
|
53
|
+
side: OrderSide;
|
|
54
|
+
type: OrderType;
|
|
55
|
+
qty: number;
|
|
56
|
+
limitPrice?: number;
|
|
57
|
+
stopPrice?: number;
|
|
58
|
+
tif?: Order['tif'];
|
|
59
|
+
bracketTp?: BracketLevel[];
|
|
60
|
+
bracketSl?: BracketLevel[];
|
|
61
|
+
symbol?: string;
|
|
62
|
+
reduceOnly?: boolean;
|
|
63
|
+
targetPositionId?: string;
|
|
64
|
+
metadata?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
export interface L3MatchingEngine {
|
|
67
|
+
onMboEvent: (event: MboEvent, tsNs: bigint) => void;
|
|
68
|
+
onTick: (tick: PriceTick) => void;
|
|
69
|
+
/** L3 path: ingest a compact buffer and then use seekTo to replay. */
|
|
70
|
+
ingestCompactBuf: (buf: ArrayBuffer) => void;
|
|
71
|
+
/** OHLCV path: ingest bars; seekTo advances bar by bar. Resets the replay cursor. */
|
|
72
|
+
ingestOhlcvBars: (bars: OhlcvBar[], barNs?: bigint) => void;
|
|
73
|
+
/**
|
|
74
|
+
* OHLCV path: extend the buffer forward without rewinding the replay.
|
|
75
|
+
* What a stream-append must use - see appendOhlcvBars for why.
|
|
76
|
+
*/
|
|
77
|
+
appendOhlcvBars: (bars: OhlcvBar[], barNs?: bigint) => void;
|
|
78
|
+
/** OHLCV path: ingest finer-resolution bars so seekTo uses accurate mark prices within the open bar. */
|
|
79
|
+
ingestSupplementalBars?: (bars: Array<{
|
|
80
|
+
time: number;
|
|
81
|
+
open: number;
|
|
82
|
+
high: number;
|
|
83
|
+
low: number;
|
|
84
|
+
close: number;
|
|
85
|
+
volume: number;
|
|
86
|
+
}>) => void;
|
|
87
|
+
/** Cursor-preserving counterpart of ingestSupplementalBars. */
|
|
88
|
+
appendSupplementalBars?: (bars: Array<{
|
|
89
|
+
time: number;
|
|
90
|
+
open: number;
|
|
91
|
+
high: number;
|
|
92
|
+
low: number;
|
|
93
|
+
close: number;
|
|
94
|
+
volume: number;
|
|
95
|
+
}>) => void;
|
|
96
|
+
/** Tick path: ingest SerialTrades (trade-by-trade); seekTo replays each trade. */
|
|
97
|
+
ingestTicks: (trades: SerialTrade[]) => void;
|
|
98
|
+
/** L2 path: ingest pre-sampled BBO history; seekTo advances snapshot by snapshot. */
|
|
99
|
+
ingestPriceHistory: (history: PriceHistory[]) => void;
|
|
100
|
+
/** Cursor-preserving forms of the three above, for streamed extensions. */
|
|
101
|
+
appendTicks: (trades: SerialTrade[]) => void;
|
|
102
|
+
appendPriceHistory: (history: PriceHistory[]) => void;
|
|
103
|
+
appendCompactBuf: (buf: ArrayBuffer) => void;
|
|
104
|
+
seekTo: (tNs: bigint) => void;
|
|
105
|
+
getPrice: () => number;
|
|
106
|
+
placeOrder: (req: PlaceOrderRequest) => string;
|
|
107
|
+
cancelOrder: (orderId: string) => void;
|
|
108
|
+
amendOrder: (orderId: string, newPrice: number) => void;
|
|
109
|
+
syncPosition: (position: Position) => void;
|
|
110
|
+
syncOrder: (order: Order) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Amend a bracket level on an open position.
|
|
113
|
+
* Accepts a full BracketAmendment (typed) keyed by stable BracketLevel.id.
|
|
114
|
+
*/
|
|
115
|
+
amendBracket: (amendment: BracketAmendment) => void;
|
|
116
|
+
closePosition: (positionId: string) => void;
|
|
117
|
+
reversePosition: (positionId: string) => void;
|
|
118
|
+
totalFeesPaid: () => number;
|
|
119
|
+
totalRealizedPnl: () => number;
|
|
120
|
+
/** All orders ever placed - includes working, filled, cancelled, rejected. */
|
|
121
|
+
getOrders: () => Order[];
|
|
122
|
+
/** All fills produced by this engine. */
|
|
123
|
+
getFills: () => Fill[];
|
|
124
|
+
/** All positions that have been fully closed. */
|
|
125
|
+
getPositionHistory: () => Position[];
|
|
126
|
+
/** Configure gap-fill search (jump settlement). Merges into current config. */
|
|
127
|
+
setFillSearch: (patch: Partial<FillSearchOptions>) => void;
|
|
128
|
+
getFillSearch: () => FillSearchOptions;
|
|
129
|
+
/** Cheap gate: is there any resting order / untriggered bracket that could fill? */
|
|
130
|
+
hasPendingTriggers: () => boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Replay a skipped span's bars (fetched at fillSearch.maxResolution) to apply
|
|
133
|
+
* fills the jump would otherwise have skipped. Bars must be time-ascending.
|
|
134
|
+
*/
|
|
135
|
+
settleGapBars: (bars: Array<{
|
|
136
|
+
tsNs: bigint;
|
|
137
|
+
open: number;
|
|
138
|
+
high: number;
|
|
139
|
+
low: number;
|
|
140
|
+
close: number;
|
|
141
|
+
}>, ambiguity?: FillAmbiguity) => void;
|
|
142
|
+
destroy: () => void;
|
|
143
|
+
}
|
|
144
|
+
export declare function createL3MatchingEngine(tradingState: UseTradingStateReturn, options?: L3EngineOptions): L3MatchingEngine;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CloseReason, PositionSide } from '../types/trading-types';
|
|
2
|
+
type Tone = 'success' | 'loss' | 'info' | 'neutral';
|
|
3
|
+
export declare function notifyPositionOpened(p: {
|
|
4
|
+
side: PositionSide;
|
|
5
|
+
symbol: string;
|
|
6
|
+
qty: number;
|
|
7
|
+
entryPrice: number;
|
|
8
|
+
tickSize?: number;
|
|
9
|
+
}): void;
|
|
10
|
+
export declare function notifyPositionClosed(p: {
|
|
11
|
+
side: PositionSide;
|
|
12
|
+
symbol: string;
|
|
13
|
+
pnl: number;
|
|
14
|
+
rMultiple?: number;
|
|
15
|
+
reason?: CloseReason;
|
|
16
|
+
partial?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
/** Generic, non-domain message - keeps ad-hoc toasts on the same design system. */
|
|
19
|
+
export declare function notifyMessage(title: string, opts?: {
|
|
20
|
+
description?: string;
|
|
21
|
+
tone?: Tone;
|
|
22
|
+
}): void;
|
|
23
|
+
export declare function notifyBracketMoved(p: {
|
|
24
|
+
kind: 'tp' | 'sl' | 'be';
|
|
25
|
+
symbol: string;
|
|
26
|
+
price: number;
|
|
27
|
+
tickSize?: number;
|
|
28
|
+
/** True when the level was just created rather than dragged to a new price. */
|
|
29
|
+
created?: boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SymbolInfo } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* Format a price using the symbol's display precision (`priceFormat.precision`),
|
|
4
|
+
* falling back to 2 decimal places when the symbol info is absent. This is the
|
|
5
|
+
* single source of truth for how prices are rendered across the chart, so axis
|
|
6
|
+
* labels, pills, tooltips and trade lines all stay consistent.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatPrice(value: number, symbolInfo?: SymbolInfo): string;
|
|
9
|
+
/** Fallback tick used when a symbol provides no price metadata at all. */
|
|
10
|
+
export declare const DEFAULT_TICK_SIZE = 0.25;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the instrument's minimum price increment from symbol info, preferring
|
|
13
|
+
* `priceFormat.minTick`, then the deprecated `tickSize`, and finally a sensible
|
|
14
|
+
* default. Single source of truth for tick snapping, footprint/volume-profile
|
|
15
|
+
* bucketing and tick-distance readouts so they all match the instrument.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveTickSize(symbolInfo?: SymbolInfo | null): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class PriceTransition {
|
|
2
|
+
private readonly durationMs;
|
|
3
|
+
private readonly tweens;
|
|
4
|
+
private symbolKey;
|
|
5
|
+
constructor(durationMs?: number);
|
|
6
|
+
/**
|
|
7
|
+
* Forget all in-flight tweens when the symbol changes, so switching
|
|
8
|
+
* instruments never animates one price across to a wildly different one.
|
|
9
|
+
*/
|
|
10
|
+
setSymbol(key: string | undefined): void;
|
|
11
|
+
/**
|
|
12
|
+
* Value to render for `key` (e.g. 'last' / 'bid' / 'ask'), easing toward
|
|
13
|
+
* `target` whenever a new target arrives. With `enabled` false (or a
|
|
14
|
+
* non-finite target) it passes the target straight through and drops any
|
|
15
|
+
* pending tween, so toggling the setting off snaps to the truth immediately.
|
|
16
|
+
*/
|
|
17
|
+
value(key: string, target: number, now: number, enabled: boolean): number;
|
|
18
|
+
/** True while any tween is still in flight - caller should request another frame. */
|
|
19
|
+
isAnimating(now: number): boolean;
|
|
20
|
+
reset(): void;
|
|
21
|
+
private sample;
|
|
22
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FootprintBar, FootprintMode } from '../types/footprint';
|
|
2
|
+
import type { ViewBounds } from '../types';
|
|
3
|
+
import type { ChartSettings } from '../types/chart-settings';
|
|
4
|
+
import { LiveTransformer } from '../../core';
|
|
5
|
+
export declare function drawFootprintChart(ctx: CanvasRenderingContext2D, bars: FootprintBar[], bounds: ViewBounds, w: number, h: number, barNs: bigint, mode: FootprintMode, tickSize: number, footprintVolume: 'none' | 'split' | 'total', chartSettings: ChartSettings, horizon: bigint, transformer: LiveTransformer): void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ChartSettings } from '../types/chart-settings';
|
|
2
|
+
import { LiveTransformer, SymbolInfo } from '../../core';
|
|
3
|
+
import { useTradeLines } from '../../hooks/useTradeLines';
|
|
4
|
+
import { ViewBounds } from '../types';
|
|
5
|
+
import { TradeLine } from '../types';
|
|
6
|
+
import { Crosshair } from './renderer';
|
|
7
|
+
/**
|
|
8
|
+
* Draws the full visualizer for one ghost pill being dragged.
|
|
9
|
+
*
|
|
10
|
+
* Call once per active drag - i.e. for each slot where
|
|
11
|
+
* gs.draggingGhost === `${kind}_${index}`
|
|
12
|
+
*
|
|
13
|
+
* @param ctx Canvas 2D context
|
|
14
|
+
* @param w Chart width (same as drawTradeLines `w` param)
|
|
15
|
+
* @param pH Chart height (priceAxisH)
|
|
16
|
+
* @param entryPrice The entry-line's price (used to compute distance)
|
|
17
|
+
* @param dragPrice The current ghost price (snapped)
|
|
18
|
+
* @param kind 'tp' | 'sl'
|
|
19
|
+
* @param yOffset Same yOffset used in drawTradeLines
|
|
20
|
+
* @param bounds ViewBounds
|
|
21
|
+
* @param chartSettings ChartSettings
|
|
22
|
+
* @param tickSize Optional - used to show distance in ticks
|
|
23
|
+
*/
|
|
24
|
+
export declare function drawGhostDragVisualizer(ctx: CanvasRenderingContext2D, w: number, pH: number, entryPrice: number, dragPrice: number, kind: 'tp' | 'sl', yOffset: number, bounds: ViewBounds, chartSettings: ChartSettings, tickSize?: number, transformer?: LiveTransformer, symbolInfo?: SymbolInfo): void;
|
|
25
|
+
/**
|
|
26
|
+
* Draws all trade lines onto the UI canvas layer.
|
|
27
|
+
*
|
|
28
|
+
* Returns a hit-test map so chart.tsx can wire up mouse interactions without
|
|
29
|
+
* re-computing geometry. See TradeLineHitMap below.
|
|
30
|
+
*/
|
|
31
|
+
export declare function drawTradeLines(ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement, bounds: ViewBounds, w: number, h: number, chartSettings: ChartSettings, tradeLines: TradeLine[], priceAxisH: number, yOffset: number, hoveredLineId: string | null, draggingLineId: string | null, tradeLineInteraction: ReturnType<typeof useTradeLines>, tickSize: number, transformer: LiveTransformer, rightScaleWidth: number, symbolInfo: SymbolInfo, crosshair: Crosshair): {
|
|
32
|
+
hitMap: TradeLineHitMap;
|
|
33
|
+
suspendCrosshair: boolean;
|
|
34
|
+
};
|
|
35
|
+
export interface GhostSlotState {
|
|
36
|
+
/**
|
|
37
|
+
* Prices for each TP ghost slot.
|
|
38
|
+
* Index matches the slot shown in the ghost pill row (tp_0, tp_1, …).
|
|
39
|
+
* undefined = user hasn't dragged this slot yet.
|
|
40
|
+
*/
|
|
41
|
+
tpPrices: (number | undefined)[];
|
|
42
|
+
/**
|
|
43
|
+
* Prices for each SL ghost slot.
|
|
44
|
+
*/
|
|
45
|
+
slPrices: (number | undefined)[];
|
|
46
|
+
/** e.g. "tp_0", "sl_1" - which ghost pill is currently hovered */
|
|
47
|
+
hoveredGhost?: string | null;
|
|
48
|
+
/** e.g. "tp_0", "sl_1" - which ghost pill is currently being dragged */
|
|
49
|
+
draggingGhost?: string | null;
|
|
50
|
+
draggingGhostIdx?: number | null;
|
|
51
|
+
draggingGhostType?: 'tp' | 'sl' | null;
|
|
52
|
+
}
|
|
53
|
+
/** Map from entry-line id -> ghost state */
|
|
54
|
+
export type GhostInteractionState = Record<string, GhostSlotState>;
|
|
55
|
+
export interface TradeLineHitRegion {
|
|
56
|
+
id: string;
|
|
57
|
+
/** Pixel Y of the actual price line */
|
|
58
|
+
y: number;
|
|
59
|
+
top: number;
|
|
60
|
+
bottom: number;
|
|
61
|
+
pill?: {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
w: number;
|
|
65
|
+
h: number;
|
|
66
|
+
};
|
|
67
|
+
closeBtn?: {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
w: number;
|
|
71
|
+
h: number;
|
|
72
|
+
};
|
|
73
|
+
reverseBtn?: {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
w: number;
|
|
77
|
+
h: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export interface GhostPillHitRegion {
|
|
81
|
+
lineId: string;
|
|
82
|
+
/** e.g. "tp_0", "sl_2" */
|
|
83
|
+
ghostId: string;
|
|
84
|
+
index: number;
|
|
85
|
+
kind: 'tp' | 'sl';
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
w: number;
|
|
89
|
+
h: number;
|
|
90
|
+
currentPrice?: number;
|
|
91
|
+
}
|
|
92
|
+
export interface TradeLineHitMap {
|
|
93
|
+
lines: TradeLineHitRegion[];
|
|
94
|
+
pricePills: {
|
|
95
|
+
id: string | undefined;
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
w: number;
|
|
99
|
+
h: number;
|
|
100
|
+
}[];
|
|
101
|
+
/** Hit regions for ghost TP/SL mini-pills */
|
|
102
|
+
ghostPills: GhostPillHitRegion[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Given a mouse position, return which line (and which part of it) was hit.
|
|
106
|
+
* Call this from chart.tsx on mousemove / click instead of manual hit-testing.
|
|
107
|
+
*/
|
|
108
|
+
export declare function hitTestTradeLines(mx: number, my: number, hitMap: TradeLineHitMap): {
|
|
109
|
+
lineId: string | null;
|
|
110
|
+
part: 'line' | 'pill' | 'close' | 'reverse' | 'pricePill' | null;
|
|
111
|
+
ghostHit?: GhostPillHitRegion;
|
|
112
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Crosshair } from './renderer';
|
|
2
|
+
import type { SymbolInfo } from '../../core';
|
|
3
|
+
import type { ChartPane } from '../types/indicator-types';
|
|
4
|
+
import type { Drawing, DraftDrawing, HitResult, DrawingAnchorId, LongDrawing, ShortDrawing } from '../types/drawing-types';
|
|
5
|
+
import { ChartSettings } from '../types/chart-settings';
|
|
6
|
+
import { FootprintBar } from '../types/footprint';
|
|
7
|
+
import { PriceHistory, ViewBounds } from '../types';
|
|
8
|
+
import { LiveTransformer } from '../../core';
|
|
9
|
+
export declare const Y_AXIS_WIDTH = 65;
|
|
10
|
+
export declare const X_AXIS_HEIGHT = 30;
|
|
11
|
+
/**
|
|
12
|
+
* Snap a timestamp to the nearest bar-open boundary.
|
|
13
|
+
* When barNs is 0n (tick/raw mode) the value is returned unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare function snapTsToBar(ts: bigint, barNs: bigint): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Geometry of a position box, in prices snapped to the instrument's tick.
|
|
18
|
+
* Shared by the renderer and the hit-test so the handles you see are the
|
|
19
|
+
* handles you grab.
|
|
20
|
+
*/
|
|
21
|
+
export declare function positionLevels(d: LongDrawing | ShortDrawing, tick: number): {
|
|
22
|
+
entry: number;
|
|
23
|
+
up: number;
|
|
24
|
+
down: number;
|
|
25
|
+
top: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
};
|
|
28
|
+
export declare function drawDrawingsLayer(canvas: HTMLCanvasElement, drawings: Drawing[], bounds: ViewBounds, panes: ChartPane[], selectedId: string | null, hoveredId: string | null, hotAnchor: DrawingAnchorId | null, draft?: DraftDrawing | null, crosshair?: Crosshair, skipId?: string | null, holdingCtrl?: boolean | null, holdingShift?: boolean | null, barNs?: bigint | null, chartSettings?: ChartSettings, footprintBars?: FootprintBar[], priceHistory?: PriceHistory[], transformer?: LiveTransformer, hidePriceScale?: boolean, hideTimeScale?: boolean, priceScaleWidth?: number, symbolInfo?: SymbolInfo, horizon?: bigint): void;
|
|
29
|
+
/**
|
|
30
|
+
* Hit-test drawings against a pointer position.
|
|
31
|
+
*
|
|
32
|
+
* UNITS: everything here is CSS px - `mx`/`my` come from clientX/Y minus the
|
|
33
|
+
* canvas rect, and pane layouts are computed in CSS px (useChartLayout divides
|
|
34
|
+
* by the DPR). Pass `canvas.width / dpr`, NOT `canvas.width`: on a DPR-2 screen
|
|
35
|
+
* the bitmap is twice the CSS size, which silently doubles chartW/mainH here and
|
|
36
|
+
* puts every drawing's computed screen position at ~2x - hits stop landing.
|
|
37
|
+
* Note the sibling getDrawingLabelAnchor() takes the RAW bitmap size and divides
|
|
38
|
+
* internally; the two do not share a convention.
|
|
39
|
+
*/
|
|
40
|
+
export declare function hitTestDrawings(mx: number, my: number, drawings: Drawing[], bounds: ViewBounds, panes: ChartPane[],
|
|
41
|
+
/** canvas width in CSS px (canvas.width / dpr) */
|
|
42
|
+
cssW: number,
|
|
43
|
+
/** canvas height in CSS px (canvas.height / dpr) */
|
|
44
|
+
cssH: number, transformer: LiveTransformer, hideTimeScale: boolean, priceScaleWidth: number, symbolInfo?: SymbolInfo): HitResult;
|
|
45
|
+
/** UNITS: takes the RAW bitmap size (canvas.width/height) and converts to CSS px
|
|
46
|
+
* internally - the opposite of hitTestDrawings(), which wants CSS px already. */
|
|
47
|
+
export declare function getDrawingLabelAnchor(d: Drawing, bounds: ViewBounds, panes: ChartPane[], canvasW: number, canvasH: number, transformer: LiveTransformer, hideTimeScale: boolean, priceScaleWidth: number): {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
};
|
|
51
|
+
export declare function moveDrawingAnchorDelta(d: Drawing, anchor: DrawingAnchorId, dts: bigint, // delta ts since last frame
|
|
52
|
+
dprice: number, // delta price since last frame
|
|
53
|
+
curTs: bigint, // absolute cursor position (for individual anchor snap)
|
|
54
|
+
curPrice: number, holdingShift: boolean): {
|
|
55
|
+
drawing: Drawing;
|
|
56
|
+
anchor: DrawingAnchorId;
|
|
57
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ChartPane, Indicator, Rect } from '../types/indicator-types';
|
|
2
|
+
import { BookSnapshot, PriceHistory, TradePoint } from '../types';
|
|
3
|
+
import type { ChartType, TradeLine, ViewBounds } from '../types';
|
|
4
|
+
import type { FootprintBar } from '../types/footprint';
|
|
5
|
+
import { ChartSettings } from '../types/chart-settings';
|
|
6
|
+
import { ActiveDrawingTool, DraftDrawing, Drawing, DrawingAnchorId } from '../types/drawing-types';
|
|
7
|
+
import { AccountSnapshot, DataLevel, LiveTransformer, OhlcvBar, SymbolInfo } from '../../core';
|
|
8
|
+
import { SessionMapper } from '../../core/SessionMapper';
|
|
9
|
+
import { PriceTransition } from '../priceTransition';
|
|
10
|
+
import { OrdinalModel } from '../series/japaneseCharts';
|
|
11
|
+
import type { CrosshairSync } from '../types/layout-sync';
|
|
12
|
+
export type CandleCache = Map<bigint, {
|
|
13
|
+
open: number;
|
|
14
|
+
high: number;
|
|
15
|
+
low: number;
|
|
16
|
+
close: number;
|
|
17
|
+
}>;
|
|
18
|
+
export type Crosshair = {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
} | null;
|
|
22
|
+
export declare const Y_AXIS_WIDTH = 65;
|
|
23
|
+
export declare const X_AXIS_HEIGHT = 30;
|
|
24
|
+
export declare const TRADE_SNAP_RADIUS = 12;
|
|
25
|
+
export declare const COLORS: {
|
|
26
|
+
background: string;
|
|
27
|
+
buyLine: string;
|
|
28
|
+
sellLine: string;
|
|
29
|
+
grid: string;
|
|
30
|
+
label: string;
|
|
31
|
+
axisBg: string;
|
|
32
|
+
crosshair: string;
|
|
33
|
+
crosshairBg: string;
|
|
34
|
+
crosshairText: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function computeRightScaleWidth(bounds: ViewBounds, symbolInfo: SymbolInfo | undefined, chartSettings: ChartSettings, hidePriceScale?: boolean, ctx?: CanvasRenderingContext2D | null): number;
|
|
37
|
+
export declare function drawBaseLayer(canvas: HTMLCanvasElement, panes: ChartPane[], layouts: Record<string, Rect>, indicators: Indicator[], trades: TradePoint[], priceHistory: PriceHistory[], snapshots: BookSnapshot[], bounds: ViewBounds, footprintBars: FootprintBar[], heatmapBitmap: ImageBitmap | null, bitmapOffsetX: number, bitmapOffsetY: number, bitmapOffsetW: number, bitmapOffsetH: number, barNs: bigint, chartSettings: ChartSettings, horizon: bigint, candleCache: CandleCache | null,
|
|
38
|
+
/** Live incrementally-built open bar - overrides the cache for the current bucket. */
|
|
39
|
+
openBar: {
|
|
40
|
+
ts: bigint;
|
|
41
|
+
open: number;
|
|
42
|
+
high: number;
|
|
43
|
+
low: number;
|
|
44
|
+
close: number;
|
|
45
|
+
} | null, ohlcvBars: {
|
|
46
|
+
time: number;
|
|
47
|
+
open: number;
|
|
48
|
+
high: number;
|
|
49
|
+
low: number;
|
|
50
|
+
close: number;
|
|
51
|
+
volume: number;
|
|
52
|
+
}[], transformer: LiveTransformer, isPluginChartType?: boolean, sessionMapper?: SessionMapper, dataLevel?: DataLevel, hidePriceScale?: boolean, hideTimeScale?: boolean, symbolInfo?: SymbolInfo, rightScaleWidth?: number): void;
|
|
53
|
+
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: {
|
|
54
|
+
time: number;
|
|
55
|
+
open: number;
|
|
56
|
+
high: number;
|
|
57
|
+
low: number;
|
|
58
|
+
close: number;
|
|
59
|
+
volume: number;
|
|
60
|
+
}[], openBar: OhlcvBar, tradeLines: TradeLine[], tradeLineInteraction: any, hoveredLineId?: string | null, draggingLineId?: string | null, activeTool?: ActiveDrawingTool | null, draggingAnchor?: {
|
|
61
|
+
drawingId: string;
|
|
62
|
+
anchor: DrawingAnchorId;
|
|
63
|
+
} | null, holdingCtrl?: boolean | null, holdingShift?: boolean | null, footprintBars?: FootprintBar[] | null, drawings?: Drawing[] | null, draft?: DraftDrawing | null, transformer?: LiveTransformer, showShiftInfo?: boolean, shiftInfoAnchor?: {
|
|
64
|
+
ts: bigint;
|
|
65
|
+
price: number;
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}, shiftInfoAnchor2?: {
|
|
69
|
+
ts: bigint;
|
|
70
|
+
price: number;
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
} | null, dataLevel?: DataLevel, accountSnapshot?: AccountSnapshot, symbolInfo?: SymbolInfo, hidePriceScale?: boolean, hideTimeScale?: boolean, rightScaleWidth?: number, priceTransition?: PriceTransition, syncCrosshair?: CrosshairSync | null): import("./drawTradeLines").TradeLineHitMap;
|
|
74
|
+
export declare function applyHeatmapContrast(src: ImageBitmap, chartW: number, chartH: number, threshold: number): ImageData;
|
|
75
|
+
export declare function drawHeatmap(ctx: CanvasRenderingContext2D, snapshots: BookSnapshot[], bounds: ViewBounds, chartW: number, chartH: number, contrastThreshold?: number): void;
|
|
76
|
+
export declare function nearestIndex(priceHistory: PriceHistory[], target: bigint): number;
|
|
77
|
+
export declare function nearestTradeIndex(trades: TradePoint[], target: bigint): number;
|
|
78
|
+
export declare function findNearestTrade(clickX: number, clickY: number, trades: TradePoint[], bounds: ViewBounds, chartW: number, chartH: number, chartSettings: ChartSettings, horizon: bigint, transformer: LiveTransformer): TradePoint | null;
|
|
79
|
+
export declare const snapTs: (ts: bigint, tf: bigint, sessionMapper?: SessionMapper | null) => bigint;
|
|
80
|
+
export declare const snapPrice: (snappedTs: bigint, rawPrice: number, chartSettings: ChartSettings, footprintBars: FootprintBar[], priceHistory: PriceHistory[], ohlcvBars: {
|
|
81
|
+
time: number;
|
|
82
|
+
open: number;
|
|
83
|
+
high: number;
|
|
84
|
+
low: number;
|
|
85
|
+
close: number;
|
|
86
|
+
volume: number;
|
|
87
|
+
}[], dataLevel: DataLevel, horizon: bigint) => number;
|
|
88
|
+
export declare function drawTooltip(ctx: CanvasRenderingContext2D, mouse: {
|
|
89
|
+
x: number;
|
|
90
|
+
y: number;
|
|
91
|
+
}, priceHistory: PriceHistory[], bounds: ViewBounds, w: number, h: number, transformer: LiveTransformer, symbolInfo?: SymbolInfo): void;
|
|
92
|
+
/** True for the price-driven chart types that render on an ordinal (column) x-axis. */
|
|
93
|
+
export declare function isOrdinalChartType(t: ChartType): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Memoised ordinal model for the current chart type + data + params. Returns
|
|
96
|
+
* null for non-ordinal types. Shared by the renderer, the transformer wiring
|
|
97
|
+
* (column timestamps) and autoscale (visible price extent), so all three derive
|
|
98
|
+
* from one build.
|
|
99
|
+
*/
|
|
100
|
+
export declare function getOrdinalModel(chartType: ChartType, chartSettings: ChartSettings, ohlcvBars: {
|
|
101
|
+
time: number;
|
|
102
|
+
close: number;
|
|
103
|
+
}[] | undefined, candleCache: CandleCache | null, trades: TradePoint[], barNs: bigint): OrdinalModel | null;
|
|
104
|
+
/**
|
|
105
|
+
* Price extent of the columns currently visible under the transformer's view -
|
|
106
|
+
* used to auto-scale the y-axis for ordinal charts (whose prices live in the
|
|
107
|
+
* model, not in the time-indexed bars autoFitPriceAxis scans). Returns null when
|
|
108
|
+
* nothing is visible.
|
|
109
|
+
*/
|
|
110
|
+
export declare function ordinalVisiblePriceRange(model: OrdinalModel, transformer: LiveTransformer): {
|
|
111
|
+
min: number;
|
|
112
|
+
max: number;
|
|
113
|
+
} | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createL3MatchingEngine } from './matchingEngine';
|
|
2
|
+
import { MboEvent, PriceHistory, TradePoint } from './types';
|
|
3
|
+
export declare function isoToNs(isoString: string): bigint;
|
|
4
|
+
export declare function sampleTrades(events: MboEvent[], engine: ReturnType<typeof createL3MatchingEngine>): {
|
|
5
|
+
tradePoints: TradePoint[];
|
|
6
|
+
priceHistory: PriceHistory[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type PricePoint = {
|
|
2
|
+
ts: bigint;
|
|
3
|
+
price: number;
|
|
4
|
+
};
|
|
5
|
+
/** One Renko brick spanning [yLow, yHigh] (a single brick-size band). */
|
|
6
|
+
export type RenkoBrick = {
|
|
7
|
+
ts: bigint;
|
|
8
|
+
yLow: number;
|
|
9
|
+
yHigh: number;
|
|
10
|
+
dir: 1 | -1;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A Kagi line segment. Endpoints are given as Kagi *column indices* (`i1`/`i2`)
|
|
14
|
+
* - one column per turning point - so duplicate turning-point timestamps never
|
|
15
|
+
* collapse onto the same x. `yang` = thick bullish line.
|
|
16
|
+
*/
|
|
17
|
+
export type KagiSegment = {
|
|
18
|
+
i1: number;
|
|
19
|
+
y1: number;
|
|
20
|
+
i2: number;
|
|
21
|
+
y2: number;
|
|
22
|
+
yang: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** Turning points + index-referenced segments for a Kagi line. */
|
|
25
|
+
export type KagiResult = {
|
|
26
|
+
columns: PricePoint[];
|
|
27
|
+
segments: KagiSegment[];
|
|
28
|
+
};
|
|
29
|
+
/** One Three-Line-Break block from `open` to `close`. */
|
|
30
|
+
export type LineBreakBox = {
|
|
31
|
+
ts: bigint;
|
|
32
|
+
open: number;
|
|
33
|
+
close: number;
|
|
34
|
+
dir: 1 | -1;
|
|
35
|
+
};
|
|
36
|
+
/** The three price-driven (ordinal-axis) chart kinds. */
|
|
37
|
+
export type OrdinalKind = 'renko' | 'kagi' | 'line-break';
|
|
38
|
+
/**
|
|
39
|
+
* Shared model consumed by the transformer (column timestamps), the renderer
|
|
40
|
+
* (draw by column index) and autoscale (price extent over an index range).
|
|
41
|
+
* `columnTs` is non-decreasing with one entry per drawn column; `pLow`/`pHigh`
|
|
42
|
+
* are the per-column price extents. The matching render data is carried too so
|
|
43
|
+
* everything derives from one build.
|
|
44
|
+
*/
|
|
45
|
+
export type OrdinalModel = {
|
|
46
|
+
kind: OrdinalKind;
|
|
47
|
+
columnTs: BigInt64Array;
|
|
48
|
+
pLow: Float64Array;
|
|
49
|
+
pHigh: Float64Array;
|
|
50
|
+
bricks?: RenkoBrick[];
|
|
51
|
+
boxes?: LineBreakBox[];
|
|
52
|
+
kagiSegments?: KagiSegment[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A "nice" rounded number near `x` (1/2/5 x 10ⁿ) - used to derive a readable
|
|
56
|
+
* default brick size / reversal amount from the data when the user hasn't set
|
|
57
|
+
* one explicitly.
|
|
58
|
+
*/
|
|
59
|
+
export declare function niceNumber(x: number): number;
|
|
60
|
+
/** Default brick / reversal magnitude: ~1/40 of the series' price range. */
|
|
61
|
+
export declare function autoThreshold(series: PricePoint[]): number;
|
|
62
|
+
/**
|
|
63
|
+
* Build Renko bricks from a close series. A brick forms in the trend direction
|
|
64
|
+
* once price advances a full `brick`; reversing direction requires two bricks
|
|
65
|
+
* of movement (the canonical Renko reversal), so the bands always tile cleanly.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildRenko(series: PricePoint[], brick: number): RenkoBrick[];
|
|
68
|
+
/**
|
|
69
|
+
* Build a Kagi line from a close series. The line extends with the trend and
|
|
70
|
+
* jogs to a new column only when price reverses by `reversal`. Each vertical
|
|
71
|
+
* leg is split into a thin "yin" portion and a thick "yang" portion at the
|
|
72
|
+
* previous shoulder (last peak) / waist (last trough) - Kagi's defining trait.
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildKagi(series: PricePoint[], reversal: number): KagiResult;
|
|
75
|
+
/**
|
|
76
|
+
* Build Three Line Break blocks from a close series. A new block forms when
|
|
77
|
+
* price closes beyond the high/low of the last `lineCount` blocks (so a
|
|
78
|
+
* reversal needs to break `lineCount` blocks, while continuation only needs to
|
|
79
|
+
* exceed the last block).
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildThreeLineBreak(series: PricePoint[], lineCount?: number): LineBreakBox[];
|
|
82
|
+
/**
|
|
83
|
+
* Build the shared ordinal model for one of the price-driven chart kinds.
|
|
84
|
+
* Columns are emitted in render order; `columnTs` feeds the transformer and
|
|
85
|
+
* `pLow`/`pHigh` feed autoscale. Render data (bricks / boxes / kagi segments)
|
|
86
|
+
* is carried so the renderer reuses this single build.
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildOrdinalModel(kind: OrdinalKind, series: PricePoint[], param: number): OrdinalModel;
|