@christtrade/depth 0.12.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/LICENSE.md +201 -0
  2. package/NOTICE +15 -0
  3. package/README.md +159 -0
  4. package/depth.cjs +1136 -0
  5. package/depth.css +2 -0
  6. package/depth.mjs +1136 -0
  7. package/depth.nopreflight.css +2 -0
  8. package/index.d.ts +1 -0
  9. package/package.json +32 -0
  10. package/types/ChartInner.d.ts +114 -0
  11. package/types/ChartOuter.d.ts +31 -0
  12. package/types/components/account/AccountSummary.d.ts +8 -0
  13. package/types/components/chart/chart-context-menu.d.ts +30 -0
  14. package/types/components/chart/chart-settings-dialog.d.ts +15 -0
  15. package/types/components/chart/chart-status-overlay.d.ts +24 -0
  16. package/types/components/chart/data-status.d.ts +10 -0
  17. package/types/components/chart/pane-legend.d.ts +37 -0
  18. package/types/components/chart/session-status-badge.d.ts +14 -0
  19. package/types/components/chart/status-bar.d.ts +9 -0
  20. package/types/components/chart/symbol-icon.d.ts +9 -0
  21. package/types/components/chart/tz.d.ts +10 -0
  22. package/types/components/drawings/drawing-icons.d.ts +2 -0
  23. package/types/components/drawings/drawing-settings-bar.d.ts +15 -0
  24. package/types/components/drawings/drawing-settings-dialog.d.ts +268 -0
  25. package/types/components/drawings/drawing-toolbar.d.ts +14 -0
  26. package/types/components/drawings/drawing-tools.d.ts +23 -0
  27. package/types/components/indicators/indicators-dialog.d.ts +20 -0
  28. package/types/components/indicators/indicators-settings-dialog.d.ts +164 -0
  29. package/types/components/multi-chart/GridDividers.d.ts +12 -0
  30. package/types/components/multi-chart/LayoutPicker.d.ts +19 -0
  31. package/types/components/plugin-panels/BottomBarPluginHost.d.ts +7 -0
  32. package/types/components/plugin-panels/PluginFixedPanelHost.d.ts +18 -0
  33. package/types/components/plugin-panels/PluginToolbarHost.d.ts +7 -0
  34. package/types/components/plugin-panels/PluginWindowsDropdown.d.ts +7 -0
  35. package/types/components/plugins/plugin-manager-dialog.d.ts +14 -0
  36. package/types/components/toolbar/SymbolSwitcher.d.ts +8 -0
  37. package/types/components/toolbar/chart-icons.d.ts +16 -0
  38. package/types/components/toolbar/chart-type-selector.d.ts +11 -0
  39. package/types/components/toolbar/timeframe-selector.d.ts +15 -0
  40. package/types/components/trading/OrderPanel.d.ts +36 -0
  41. package/types/components/trading/QuickTradingButtons.d.ts +7 -0
  42. package/types/components/trading/order-math.d.ts +94 -0
  43. package/types/components/ui/button.d.ts +11 -0
  44. package/types/components/ui/checkbox.d.ts +4 -0
  45. package/types/components/ui/color-picker.d.ts +12 -0
  46. package/types/components/ui/dialog.d.ts +19 -0
  47. package/types/components/ui/dropdown-menu.d.ts +27 -0
  48. package/types/components/ui/hover-card.d.ts +6 -0
  49. package/types/components/ui/input.d.ts +4 -0
  50. package/types/components/ui/popover.d.ts +7 -0
  51. package/types/components/ui/resizable.d.ts +23 -0
  52. package/types/components/ui/separator.d.ts +4 -0
  53. package/types/components/ui/slider.d.ts +4 -0
  54. package/types/components/ui/switch.d.ts +4 -0
  55. package/types/components/ui/tooltip.d.ts +7 -0
  56. package/types/core/AccountManager.d.ts +142 -0
  57. package/types/core/ChartModel.d.ts +84 -0
  58. package/types/core/ChartState.d.ts +51 -0
  59. package/types/core/ChartTypeRegistry.d.ts +27 -0
  60. package/types/core/DataEngine.d.ts +143 -0
  61. package/types/core/DataSourceRegistry.d.ts +106 -0
  62. package/types/core/DepthChart.d.ts +458 -0
  63. package/types/core/DrawingRegistry.d.ts +133 -0
  64. package/types/core/DrawingStore.d.ts +26 -0
  65. package/types/core/ExecutionEngine.d.ts +95 -0
  66. package/types/core/GlobalChartBus.d.ts +32 -0
  67. package/types/core/Playback.d.ts +48 -0
  68. package/types/core/PlaybackStateRegistry.d.ts +25 -0
  69. package/types/core/PluginRegistry.d.ts +67 -0
  70. package/types/core/PluginSchedule.d.ts +15 -0
  71. package/types/core/RenderEngine.d.ts +143 -0
  72. package/types/core/ScriptedPlugin.d.ts +153 -0
  73. package/types/core/SessionMapper.d.ts +54 -0
  74. package/types/core/SessionUtils.d.ts +53 -0
  75. package/types/core/TypedEventBus.d.ts +691 -0
  76. package/types/core/WasmPluginHost.d.ts +39 -0
  77. package/types/core/index.d.ts +70 -0
  78. package/types/core/plugin-startup.d.ts +33 -0
  79. package/types/core/processing/data-chunk.d.ts +37 -0
  80. package/types/core/processing/data-level.d.ts +13 -0
  81. package/types/core/processing/l2-processor.d.ts +10 -0
  82. package/types/core/processing/l3-processor.d.ts +26 -0
  83. package/types/core/processing/ohlcv-processor.d.ts +14 -0
  84. package/types/core/processing/tick-processor.d.ts +14 -0
  85. package/types/core/script-dsl.d.ts +20 -0
  86. package/types/core/script-scope.d.ts +4 -0
  87. package/types/core/script.worker.d.ts +1 -0
  88. package/types/hooks/useCellBridges.d.ts +36 -0
  89. package/types/hooks/useChartData.d.ts +153 -0
  90. package/types/hooks/useChartHandlers.d.ts +94 -0
  91. package/types/hooks/useChartInteraction.d.ts +160 -0
  92. package/types/hooks/useChartLayout.d.ts +21 -0
  93. package/types/hooks/useChartPlugin.d.ts +34 -0
  94. package/types/hooks/useChartSettings.d.ts +44 -0
  95. package/types/hooks/useChartSubscriptions.d.ts +64 -0
  96. package/types/hooks/useChartView.d.ts +47 -0
  97. package/types/hooks/usePlaybackEngine.d.ts +85 -0
  98. package/types/hooks/useRenderEngine.d.ts +64 -0
  99. package/types/hooks/useTradeLines.d.ts +80 -0
  100. package/types/hooks/useTradingState.d.ts +135 -0
  101. package/types/interfaces/IAccountAdapter.d.ts +38 -0
  102. package/types/interfaces/ICoordinateTransformer.d.ts +105 -0
  103. package/types/interfaces/IDataAdapter.d.ts +402 -0
  104. package/types/interfaces/IExecutionAdapter.d.ts +71 -0
  105. package/types/interfaces/plugins/IChartPlugin.d.ts +254 -0
  106. package/types/interfaces/plugins/IChartTypePlugin.d.ts +126 -0
  107. package/types/interfaces/plugins/IDataSourcePlugin.d.ts +20 -0
  108. package/types/interfaces/plugins/IDrawingPlugin.d.ts +62 -0
  109. package/types/interfaces/plugins/IIndicatorPlugin.d.ts +97 -0
  110. package/types/interfaces/plugins/index.d.ts +5 -0
  111. package/types/lib/bar-grid.d.ts +6 -0
  112. package/types/lib/book.d.ts +5 -0
  113. package/types/lib/clock.d.ts +7 -0
  114. package/types/lib/compact-buffer.d.ts +66 -0
  115. package/types/lib/constants.d.ts +5 -0
  116. package/types/lib/createSimulatedAdapter.d.ts +42 -0
  117. package/types/lib/dpr.d.ts +27 -0
  118. package/types/lib/heatmap.worker.d.ts +1 -0
  119. package/types/lib/indicator-stdlib.d.ts +426 -0
  120. package/types/lib/indicator-worker.d.ts +65 -0
  121. package/types/lib/matchingEngine.d.ts +144 -0
  122. package/types/lib/notifications/tradeToast.d.ts +31 -0
  123. package/types/lib/pointer-lock.d.ts +5 -0
  124. package/types/lib/priceFormat.d.ts +17 -0
  125. package/types/lib/priceTransition.d.ts +22 -0
  126. package/types/lib/renderers/drawFootprintChart.d.ts +5 -0
  127. package/types/lib/renderers/drawTradeLines.d.ts +112 -0
  128. package/types/lib/renderers/drawings-renderer.d.ts +57 -0
  129. package/types/lib/renderers/renderer.d.ts +113 -0
  130. package/types/lib/sampler.d.ts +7 -0
  131. package/types/lib/series/japaneseCharts.d.ts +88 -0
  132. package/types/lib/slice-worker-client.d.ts +138 -0
  133. package/types/lib/slice.worker.d.ts +139 -0
  134. package/types/lib/storage.d.ts +108 -0
  135. package/types/lib/symbol-info.d.ts +12 -0
  136. package/types/lib/symbol-search.d.ts +29 -0
  137. package/types/lib/timeframes.d.ts +46 -0
  138. package/types/lib/tradingview-import.d.ts +32 -0
  139. package/types/lib/types/chart-settings.d.ts +90 -0
  140. package/types/lib/types/drawing-types.d.ts +393 -0
  141. package/types/lib/types/footprint.d.ts +119 -0
  142. package/types/lib/types/heatmap-types.d.ts +30 -0
  143. package/types/lib/types/index.d.ts +147 -0
  144. package/types/lib/types/indicator-types.d.ts +123 -0
  145. package/types/lib/types/layout-sync.d.ts +43 -0
  146. package/types/lib/types/trading-types.d.ts +323 -0
  147. package/types/lib/use-forwarded-ref.d.ts +1 -0
  148. package/types/lib/utils.d.ts +2 -0
  149. package/types/plugins/alligator.d.ts +1 -0
  150. package/types/plugins/atr.d.ts +1 -0
  151. package/types/plugins/awesome-oscillator.d.ts +1 -0
  152. package/types/plugins/bollinger-bands.d.ts +1 -0
  153. package/types/plugins/cci.d.ts +1 -0
  154. package/types/plugins/cvd.d.ts +1 -0
  155. package/types/plugins/donchian.d.ts +1 -0
  156. package/types/plugins/ichimoku.d.ts +1 -0
  157. package/types/plugins/index.d.ts +25 -0
  158. package/types/plugins/keltner.d.ts +1 -0
  159. package/types/plugins/macd.d.ts +1 -0
  160. package/types/plugins/mfi.d.ts +1 -0
  161. package/types/plugins/moving-average.d.ts +1 -0
  162. package/types/plugins/obv.d.ts +1 -0
  163. package/types/plugins/psar.d.ts +1 -0
  164. package/types/plugins/rsi.d.ts +1 -0
  165. package/types/plugins/sessions.d.ts +1 -0
  166. package/types/plugins/stochastic.d.ts +1 -0
  167. package/types/plugins/supertrend.d.ts +1 -0
  168. package/types/plugins/volume.d.ts +1 -0
  169. package/types/plugins/vwap.d.ts +1 -0
  170. package/types/plugins/williams-r.d.ts +1 -0
  171. package/types/react/useDepthChart.d.ts +6 -0
@@ -0,0 +1,15 @@
1
+ import { type Timeframe } from '../../lib/timeframes';
2
+ import type { FeaturesOptions } from '../../core/DepthChart';
3
+ import type { TypedEventBus } from '../../core/TypedEventBus';
4
+ interface TimeframeSelectorProps {
5
+ eventBus: TypedEventBus;
6
+ value: Timeframe;
7
+ customTimeframes: Timeframe[];
8
+ features: FeaturesOptions;
9
+ onChange: (tf: Timeframe) => void;
10
+ onAddCustom: (tf: Timeframe) => void;
11
+ onRemoveCustom: (label: string) => void;
12
+ onOpenChange?: (open: boolean) => void;
13
+ }
14
+ export declare function TimeframeSelector({ eventBus, value, customTimeframes, features, onChange, onAddCustom, onRemoveCustom, onOpenChange, }: TimeframeSelectorProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import type { TypedEventBus } from '../../core/TypedEventBus';
3
+ import type { ContractSpec } from '../../interfaces/IDataAdapter';
4
+ import type { PlaceOrderRequest } from '../../lib/matchingEngine';
5
+ import type { ActiveDrawingTool } from '../../lib/types/drawing-types';
6
+ export interface OrderPanelProps {
7
+ eventBus: TypedEventBus;
8
+ spec: ContractSpec;
9
+ symbol?: string;
10
+ /** Send the order. Wire to `chart.executionEngine.placeOrder` */
11
+ onPlaceOrder: (req: PlaceOrderRequest) => void;
12
+ onClose?: () => void;
13
+ /** Seed balance; kept current from `account:update` after mount */
14
+ balance?: number;
15
+ currencySymbol?: string;
16
+ /** Viewport pixels, clamped. Only used the first open; after that the panel
17
+ * reopens wherever it was last dragged. */
18
+ initialPosition?: {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ /**
23
+ * How the panel reads the chart's drawings, so it can build the ticket from
24
+ * a long/short box and stay linked to it. Functions rather than values, so a
25
+ * box dragged since it was selected reads as it now stands.
26
+ */
27
+ drawings?: {
28
+ /** `() => chart.getSelectedDrawing()` */
29
+ selected: () => ActiveDrawingTool | null;
30
+ /** `(id) => chart.getDrawing(id)` - null once deleted */
31
+ byId: (id: string) => ActiveDrawingTool | null;
32
+ /** `(fn) => chart.onDrawingsChanged(fn)` */
33
+ subscribe: (fn: () => void) => () => void;
34
+ };
35
+ }
36
+ export declare function OrderPanel({ eventBus, spec, symbol, onPlaceOrder, onClose, balance: initialBalance, currencySymbol, initialPosition, drawings, }: OrderPanelProps): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { TypedEventBus } from '../../core/TypedEventBus';
3
+ interface QuickTradingButtonsProps {
4
+ eventBus: TypedEventBus;
5
+ }
6
+ export declare function QuickTradingButtons({ eventBus }: QuickTradingButtonsProps): React.JSX.Element;
7
+ export {};
@@ -0,0 +1,94 @@
1
+ import type { ContractSpec, SymbolInfo } from '../../interfaces/IDataAdapter';
2
+ import type { OrderSide, OrderType } from '../../lib/types/trading-types';
3
+ export declare const tickSizeOf: (spec: ContractSpec) => number;
4
+ export declare function tickValueOf(spec: ContractSpec): number;
5
+ export declare function specForSymbol(info: SymbolInfo | null | undefined): ContractSpec;
6
+ export declare const qtyStepOf: (spec: ContractSpec) => number;
7
+ export declare const minQtyOf: (spec: ContractSpec) => number;
8
+ export declare const qtyDecimals: (spec: ContractSpec) => number;
9
+ export declare function roundQty(qty: number, spec: ContractSpec): number;
10
+ export declare function priceDecimals(spec: ContractSpec): number;
11
+ export declare function roundToTick(price: number, spec: ContractSpec): number;
12
+ export declare const ticksBetween: (from: number, to: number, spec: ContractSpec) => number;
13
+ export declare const moneyPerTick: (qty: number, spec: ContractSpec) => number;
14
+ export declare const contractValue: (price: number, qty: number, spec: ContractSpec) => number;
15
+ export declare function levelPrice(kind: 'tp' | 'sl', entry: number, ticks: number, side: OrderSide, spec: ContractSpec): number;
16
+ export declare function levelTicks(kind: 'tp' | 'sl', entry: number, price: number, side: OrderSide, spec: ContractSpec): number;
17
+ export type AmountMode = 'contracts' | 'value' | 'balancePct' | 'riskUsd' | 'riskPct';
18
+ export declare const AMOUNT_MODES: {
19
+ id: AmountMode;
20
+ label: string;
21
+ needsStop?: true;
22
+ }[];
23
+ export declare const modeNeedsStop: (mode: AmountMode) => boolean;
24
+ export interface SizingContext {
25
+ entry: number;
26
+ /** Ticks from entry to the stop. 0 when no stop is set */
27
+ stopTicks: number;
28
+ balance: number;
29
+ spec: ContractSpec;
30
+ }
31
+ export declare function qtyFromAmount(mode: AmountMode, amount: number, ctx: SizingContext): number;
32
+ export declare function amountFromQty(mode: AmountMode, qty: number, ctx: SizingContext): number;
33
+ export interface TicketInput {
34
+ side: OrderSide;
35
+ type: OrderType;
36
+ /** Ignored for market orders, which price off `mark` */
37
+ limitPrice: number;
38
+ stopPrice: number;
39
+ mark: number;
40
+ bid: number;
41
+ ask: number;
42
+ amountMode: AmountMode;
43
+ amount: number;
44
+ tpEnabled: boolean;
45
+ tpTicks: number;
46
+ slEnabled: boolean;
47
+ slTicks: number;
48
+ balance: number;
49
+ spec: ContractSpec;
50
+ }
51
+ export interface TicketProblem {
52
+ field: 'amount' | 'entry' | 'tp' | 'sl';
53
+ message: string;
54
+ }
55
+ export interface Ticket {
56
+ entry: number;
57
+ qty: number;
58
+ tickValue: number;
59
+ contractValue: number;
60
+ tpPrice: number | null;
61
+ slPrice: number | null;
62
+ risk: {
63
+ usd: number;
64
+ pct: number;
65
+ } | null;
66
+ reward: {
67
+ usd: number;
68
+ pct: number;
69
+ } | null;
70
+ /** Reward divided by risk. Null unless both sides are set */
71
+ rr: number | null;
72
+ spread: {
73
+ ticks: number;
74
+ usd: number;
75
+ };
76
+ problems: TicketProblem[];
77
+ ok: boolean;
78
+ }
79
+ export interface PositionGeometry {
80
+ entry: number;
81
+ upAmount: number;
82
+ downAmount: number;
83
+ qty: number;
84
+ }
85
+ export interface CopiedTicket {
86
+ side: OrderSide;
87
+ type: OrderType;
88
+ entry: number;
89
+ target: number;
90
+ stop: number;
91
+ qty: number;
92
+ }
93
+ export declare function ticketFromPosition(side: OrderSide, box: PositionGeometry, mark: number, spec: ContractSpec): CopiedTicket;
94
+ export declare function deriveTicket(input: TicketInput): Ticket;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ declare const buttonVariants: (props?: {
4
+ variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost";
5
+ size?: "icon" | "default" | "sm" | "lg";
6
+ } & import("class-variance-authority/types").ClassProp) => string;
7
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
9
+ }
10
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
11
+ export { Button, buttonVariants };
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
4
+ export { Checkbox };
@@ -0,0 +1,12 @@
1
+ import type { ButtonProps } from './button';
2
+ interface ColorPickerProps {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ onBlur?: () => void;
6
+ presets?: string[];
7
+ hideButton?: boolean;
8
+ open?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ }
11
+ declare const ColorPicker: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "value" | "onBlur" | "onChange"> & ColorPickerProps & import("react").RefAttributes<HTMLInputElement>>;
12
+ export { ColorPicker };
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
3
+ declare const Dialog: React.FC<DialogPrimitive.DialogProps>;
4
+ declare const DialogTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ declare const DialogPortal: React.FC<DialogPrimitive.DialogPortalProps>;
6
+ declare const DialogClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
+ declare const DialogContent: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ declare const DialogHeader: {
10
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
11
+ displayName: string;
12
+ };
13
+ declare const DialogFooter: {
14
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
15
+ displayName: string;
16
+ };
17
+ declare const DialogTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
18
+ declare const DialogDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
19
+ export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
@@ -0,0 +1,27 @@
1
+ import * as React from "react";
2
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
3
+ declare const DropdownMenu: React.FC<DropdownMenuPrimitive.DropdownMenuProps>;
4
+ declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ declare const DropdownMenuGroup: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>>;
6
+ declare const DropdownMenuPortal: React.FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
7
+ declare const DropdownMenuSub: React.FC<DropdownMenuPrimitive.DropdownMenuSubProps>;
8
+ declare const DropdownMenuRadioGroup: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
9
+ declare const DropdownMenuSubTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubTriggerProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
10
+ inset?: boolean;
11
+ } & React.RefAttributes<HTMLDivElement>>;
12
+ declare const DropdownMenuSubContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
14
+ declare const DropdownMenuItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
15
+ inset?: boolean;
16
+ } & React.RefAttributes<HTMLDivElement>>;
17
+ declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
18
+ declare const DropdownMenuRadioItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuRadioItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
+ declare const DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
20
+ inset?: boolean;
21
+ } & React.RefAttributes<HTMLDivElement>>;
22
+ declare const DropdownMenuSeparator: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
23
+ declare const DropdownMenuShortcut: {
24
+ ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
25
+ displayName: string;
26
+ };
27
+ export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup, };
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
3
+ declare const HoverCard: React.FC<HoverCardPrimitive.HoverCardProps>;
4
+ declare const HoverCardTrigger: React.ForwardRefExoticComponent<HoverCardPrimitive.HoverCardTriggerProps & React.RefAttributes<HTMLAnchorElement>>;
5
+ declare const HoverCardContent: React.ForwardRefExoticComponent<Omit<HoverCardPrimitive.HoverCardContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
6
+ export { HoverCard, HoverCardTrigger, HoverCardContent };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ declare const Input: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
3
+ declare const InputWO: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
4
+ export { Input, InputWO };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
3
+ declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
4
+ declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
6
+ declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
+ export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
@@ -0,0 +1,23 @@
1
+ import * as ResizablePrimitive from 'react-resizable-panels';
2
+ declare const ResizablePanelGroup: ({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => import("react").JSX.Element;
3
+ declare const ResizablePanel: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLDivElement | HTMLElement | HTMLSpanElement | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | HTMLButtonElement | HTMLObjectElement | HTMLAreaElement | HTMLLabelElement | HTMLMapElement | HTMLOptionElement | HTMLTitleElement | HTMLStyleElement | HTMLLinkElement | HTMLInputElement | HTMLAnchorElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLLegendElement | HTMLLIElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOutputElement | HTMLParagraphElement | HTMLPreElement | HTMLProgressElement | HTMLSlotElement | HTMLScriptElement | HTMLSelectElement | HTMLSourceElement | HTMLTableElement | HTMLTemplateElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLTableCaptionElement | HTMLMenuElement | HTMLPictureElement>, "id" | "onResize"> & {
4
+ className?: string | undefined;
5
+ collapsedSize?: number | undefined;
6
+ collapsible?: boolean | undefined;
7
+ defaultSize?: number | undefined;
8
+ id?: string | undefined;
9
+ maxSize?: number | undefined;
10
+ minSize?: number | undefined;
11
+ onCollapse?: ResizablePrimitive.PanelOnCollapse | undefined;
12
+ onExpand?: ResizablePrimitive.PanelOnExpand | undefined;
13
+ onResize?: ResizablePrimitive.PanelOnResize | undefined;
14
+ order?: number | undefined;
15
+ style?: object | undefined;
16
+ tagName?: keyof HTMLElementTagNameMap | undefined;
17
+ } & {
18
+ children?: import("react").ReactNode;
19
+ } & import("react").RefAttributes<ResizablePrimitive.ImperativePanelHandle>>;
20
+ declare const ResizableHandle: ({ withHandle, className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
21
+ withHandle?: boolean;
22
+ }) => import("react").JSX.Element;
23
+ export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
3
+ declare const Separator: React.ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ export { Separator };
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import * as SliderPrimitive from "@radix-ui/react-slider";
3
+ declare const Slider: React.ForwardRefExoticComponent<Omit<SliderPrimitive.SliderProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
4
+ export { Slider };
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import * as SwitchPrimitives from "@radix-ui/react-switch";
3
+ declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
4
+ export { Switch };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
+ declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
4
+ declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
5
+ declare const TooltipTrigger: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
6
+ declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,142 @@
1
+ import type { TypedEventBus } from './TypedEventBus';
2
+ import type { Fill, Order, Position } from '../lib/types/trading-types';
3
+ import type { IAccountAdapter, AccountSnapshot } from '../interfaces/IAccountAdapter';
4
+ import type { ExecutionEngine } from './ExecutionEngine';
5
+ import type { FillSearchOptions } from '../lib/matchingEngine';
6
+ export interface LedgerFill extends Fill {
7
+ /** Playhead timestamp (ns bigint) used for ledger ordering. Separate from Fill.ts. */
8
+ playheadTs: bigint;
9
+ }
10
+ export interface LedgerOrder {
11
+ id: string;
12
+ order: Order;
13
+ /** Playhead timestamp when the order was first placed (ns). */
14
+ placedAt: bigint;
15
+ /** Playhead timestamp of the most recent status update (ns). */
16
+ updatedAt: bigint;
17
+ }
18
+ export interface LedgerPosition {
19
+ id: string;
20
+ position: Position;
21
+ /** Playhead timestamp when this position was first opened (ns). */
22
+ openedAt: bigint;
23
+ /** Playhead timestamp when this position was closed (ns). Undefined = still open. */
24
+ closedAt?: bigint;
25
+ /** Realized P&L booked at close, in cash. Only set when closedAt is. */
26
+ realizedPnlAtClose?: number;
27
+ }
28
+ export interface LedgerAdjustment {
29
+ /** Positive = deposit, negative = withdrawal. */
30
+ amount: number;
31
+ ts: bigint;
32
+ note?: string;
33
+ }
34
+ /** One equity snapshot - recorded after every position close and balance adjustment. */
35
+ export interface EquityPoint {
36
+ ts: bigint;
37
+ balance: number;
38
+ equity: number;
39
+ realizedPnl: number;
40
+ }
41
+ /** Performance stats derived from the visible closed-position set. */
42
+ export interface AccountStats {
43
+ /** Positions closed with realizedPnlAtClose > 0. */
44
+ winCount: number;
45
+ /** Positions closed with realizedPnlAtClose <= 0. */
46
+ lossCount: number;
47
+ /** winCount / (winCount + lossCount). NaN when no closed positions. */
48
+ winRate: number;
49
+ /** Sum of winning P&L / |sum of losing P&L|. Infinity when no losers. */
50
+ profitFactor: number;
51
+ /** Mean realized risk-reward ratio across closed positions. */
52
+ avgRR: number;
53
+ /** Largest single-position winning P&L. */
54
+ largestWin: number;
55
+ /** Largest single-position losing P&L (negative number). */
56
+ largestLoss: number;
57
+ /** Average hold duration in nanoseconds for closed positions. */
58
+ avgHoldTimeNs: bigint;
59
+ /** Total exchange + clearing fees across all fills. */
60
+ totalFees: number;
61
+ /** Total broker commissions across all fills. */
62
+ totalCommission: number;
63
+ /** Number of orders currently in a terminal state (filled). */
64
+ filledOrderCount: number;
65
+ /** Number of orders cancelled or rejected. */
66
+ cancelledOrderCount: number;
67
+ }
68
+ export interface AccountOptions {
69
+ eventBus: TypedEventBus;
70
+ /** Execution engine, so the account can expose fill-search controls. */
71
+ executionEngine?: ExecutionEngine;
72
+ /** Starting cash balance. Default: 100_000 */
73
+ initialBalance?: number;
74
+ /**
75
+ * Settlement currency the balance is denominated in. Display only - contract
76
+ * details live on SymbolInfo, and nothing here converts between currencies.
77
+ * Default: 'USD'
78
+ */
79
+ currency?: string;
80
+ /** Custom adapter (e.g. live broker). If omitted, uses eventBus trading events. */
81
+ adapter?: IAccountAdapter;
82
+ adjustments?: LedgerAdjustment[];
83
+ fills?: LedgerFill[];
84
+ positions?: LedgerPosition[];
85
+ orders?: LedgerOrder[];
86
+ }
87
+ export declare class AccountManager {
88
+ private readonly eventBus;
89
+ readonly currency: string;
90
+ private initialBalance;
91
+ private fills;
92
+ private orders;
93
+ /** Keyed by position id for O(1) upsert. */
94
+ private positionMap;
95
+ /** Manual deposits / withdrawals - sorted by ts. */
96
+ private adjustments;
97
+ private horizonNs;
98
+ private adapter;
99
+ private executionEngine;
100
+ private unsubs;
101
+ private destroyed;
102
+ constructor(options: AccountOptions);
103
+ setFillSearch(patch: Partial<FillSearchOptions>): void;
104
+ getFillSearch(): FillSearchOptions | null;
105
+ setAdapter(adapter: IAccountAdapter | null): void;
106
+ deposit(amount: number, ts?: bigint, note?: string): void;
107
+ withdraw(amount: number, ts?: bigint, note?: string): void;
108
+ reset(): void;
109
+ /** Move the account view to time t. Everything derived recomputes. */
110
+ seekTo(tNs: bigint): void;
111
+ getSnapshot(): AccountSnapshot & {
112
+ fills: LedgerFill[];
113
+ orders: LedgerOrder[];
114
+ openPositions: LedgerPosition[];
115
+ closedPositions: LedgerPosition[];
116
+ stats: AccountStats;
117
+ equityCurve: EquityPoint[];
118
+ };
119
+ private _ingestFill;
120
+ private _ingestOrder;
121
+ private _ingestPositionUpdate;
122
+ private _ingestPositionClose;
123
+ private _ingestAdjustment;
124
+ private _deriveTotals;
125
+ private _deriveBalance;
126
+ private _buildEquityCurve;
127
+ private _buildStats;
128
+ private _emit;
129
+ private _subscribeEventBus;
130
+ private _insertIdxByPlayheadTs;
131
+ private _insertIdxByTs;
132
+ serialize(): AccountSaveState;
133
+ restore(state: AccountSaveState): void;
134
+ destroy(): void;
135
+ }
136
+ export interface AccountSaveState {
137
+ initialBalance: number;
138
+ fills: LedgerFill[];
139
+ orders: LedgerOrder[];
140
+ positions: LedgerPosition[];
141
+ adjustments: LedgerAdjustment[];
142
+ }
@@ -0,0 +1,84 @@
1
+ import { type Timeframe } from '../lib/timeframes';
2
+ import type { DrawingTool } from '../lib/types/drawing-types';
3
+ import type { FootprintOptions } from '../lib/types/footprint';
4
+ import type { ChartSettings } from '../lib/types/chart-settings';
5
+ /**
6
+ * A pane's reference to a plugin from the shared pool. The plugin's code lives
7
+ * once in the pool; the pane only stores which one it uses and how.
8
+ */
9
+ export interface ChartPluginRef {
10
+ /** Plugin id in the shared pool. */
11
+ id: string;
12
+ /** Unique per activation, so the same plugin can be added more than once. */
13
+ instanceId: string;
14
+ /** User inputs for this instance (e.g. an indicator's `settings`). */
15
+ config?: Record<string, unknown>;
16
+ /**
17
+ * State the plugin explicitly persisted through its storage. Never derived
18
+ * series - those recompute from price action on restore.
19
+ */
20
+ state?: Record<string, unknown>;
21
+ }
22
+ export interface ChartModelInit {
23
+ id?: string;
24
+ symbol: string;
25
+ timeframe: Timeframe;
26
+ settings?: ChartSettings;
27
+ activeTool?: DrawingTool;
28
+ fpOptions?: FootprintOptions;
29
+ plugins?: ChartPluginRef[];
30
+ }
31
+ /**
32
+ * Serializable snapshot of one pane. Drawings aren't here - they belong to the
33
+ * symbol, see DrawingStore. `settings` is a diff against
34
+ * DEFAULT_CHART_SETTINGS, and `timeframe` is the label, re-resolved on restore.
35
+ */
36
+ export interface ChartPaneState {
37
+ id: string;
38
+ symbol: string;
39
+ timeframe: string;
40
+ settings: Partial<ChartSettings>;
41
+ plugins: ChartPluginRef[];
42
+ }
43
+ type Listener = (model: ChartModel) => void;
44
+ export declare class ChartModel {
45
+ readonly id: string;
46
+ private _symbol;
47
+ private _timeframe;
48
+ private _settings;
49
+ private _activeTool;
50
+ private _fpOptions;
51
+ private _plugins;
52
+ private _restoredPlugins;
53
+ private listeners;
54
+ constructor(init: ChartModelInit);
55
+ get symbol(): string;
56
+ setSymbol(symbol: string): void;
57
+ get timeframe(): Timeframe;
58
+ setTimeframe(tf: Timeframe): void;
59
+ get activeTool(): DrawingTool;
60
+ setActiveTool(tool: DrawingTool): void;
61
+ get fpOptions(): FootprintOptions;
62
+ setFpOptions(fpOptions: FootprintOptions): void;
63
+ get settings(): Readonly<ChartSettings>;
64
+ /** Merge a patch into this pane's settings. Independent per pane. */
65
+ setSettings(patch: Partial<ChartSettings>): void;
66
+ get plugins(): readonly ChartPluginRef[];
67
+ /** Activate a pool plugin on this pane, or replace an existing instance. */
68
+ use(ref: ChartPluginRef): void;
69
+ unuse(instanceId: string): void;
70
+ /** Replace the whole set of refs, e.g. mirrored from a pane's live list. */
71
+ setPlugins(refs: ChartPluginRef[]): void;
72
+ /** Plugin refs from a restore awaiting reconstruction into live indicators. */
73
+ get restoredPlugins(): readonly ChartPluginRef[];
74
+ /** Drop a restored ref once its indicator is back, so removing it later
75
+ * doesn't re-add it. */
76
+ consumeRestoredPlugin(instanceId: string): void;
77
+ serialize(): ChartPaneState;
78
+ /** Apply a saved pane snapshot. Panes read this on init, and the live owner
79
+ * mirrors it back out from then on. */
80
+ restore(state: ChartPaneState): void;
81
+ subscribe(fn: Listener): () => void;
82
+ private _notify;
83
+ }
84
+ export {};
@@ -0,0 +1,51 @@
1
+ import type { TypedEventBus } from './TypedEventBus';
2
+ import type { ActiveDrawingTool } from '../lib/types/drawing-types';
3
+ import type { FootprintOptions } from '../lib/types/footprint';
4
+ import { Timeframe } from '../lib/timeframes';
5
+ import type { SyncInLayout } from '../lib/types/layout-sync';
6
+ export interface ChartStateShape {
7
+ /** Drawing tool armed for creation. `cursor` when nothing is armed. */
8
+ activeTool: ActiveDrawingTool;
9
+ /** Id of the selected drawing, or null. Kept apart from activeTool, since
10
+ * selecting a drawing must not arm its tool. */
11
+ selectedDrawingId: string | null;
12
+ /** Symbol being charted. */
13
+ symbol: string;
14
+ /** Footprint display options. */
15
+ fpOptions: FootprintOptions;
16
+ /** Whether playback is currently running. */
17
+ isPlaying: boolean;
18
+ /** ISO horizon string, used by DataEngine to align the initial data. */
19
+ horizonIso: string;
20
+ timeframe: Timeframe;
21
+ layout: {
22
+ id: string;
23
+ label: string;
24
+ count: number;
25
+ cols: number;
26
+ rows: number;
27
+ areas: string;
28
+ };
29
+ /** Which properties a layout's cells share - crosshair, symbol, interval,
30
+ * time, date range. */
31
+ syncInLayout?: SyncInLayout;
32
+ /** Divider sizes (fr) for the grid, plus the focused pane index. */
33
+ gridColSizes?: number[];
34
+ gridRowSizes?: number[];
35
+ focusedPane?: number;
36
+ }
37
+ export declare class ChartState {
38
+ private _state;
39
+ constructor(initial: ChartStateShape);
40
+ get<K extends keyof ChartStateShape>(key: K): ChartStateShape[K];
41
+ /** Shallow-frozen snapshot of the whole state. For plugins and debugging,
42
+ * not a hot path. */
43
+ snapshot(): Readonly<ChartStateShape>;
44
+ set<K extends keyof ChartStateShape>(key: K, value: ChartStateShape[K], eventBus?: TypedEventBus): void;
45
+ /**
46
+ * Update several fields at once, emitting for each changed one that has a
47
+ * mapping. For when fields move together, like a timeframe switch touching
48
+ * both barNs and fpOptions.
49
+ */
50
+ patch(partial: Partial<ChartStateShape>, eventBus?: TypedEventBus): void;
51
+ }
@@ -0,0 +1,27 @@
1
+ export interface PluginChartTypeInitContext {
2
+ data: unknown;
3
+ }
4
+ export interface PluginChartTypeUpdateContext {
5
+ data: unknown;
6
+ }
7
+ export interface PluginChartTypeDrawContext {
8
+ ctx: CanvasRenderingContext2D;
9
+ width: number;
10
+ height: number;
11
+ }
12
+ export interface PluginChartTypeDef {
13
+ id: string;
14
+ name: string;
15
+ icon?: any;
16
+ init(ctx: PluginChartTypeInitContext): void;
17
+ update(ctx: PluginChartTypeUpdateContext): void;
18
+ draw(ctx: PluginChartTypeDrawContext): void;
19
+ }
20
+ export declare class ChartTypeRegistry {
21
+ private types;
22
+ register(def: PluginChartTypeDef): () => void;
23
+ get(id: string): PluginChartTypeDef | undefined;
24
+ getAll(): PluginChartTypeDef[];
25
+ has(id: string): boolean;
26
+ }
27
+ export declare const chartTypeRegistry: ChartTypeRegistry;