@itssumitrai/fin-charter 0.2.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 +96 -0
- package/dist/api/chart-api.d.ts +173 -0
- package/dist/api/export.d.ts +46 -0
- package/dist/api/indicator-api.d.ts +38 -0
- package/dist/api/options.d.ts +226 -0
- package/dist/api/pane-api.d.ts +28 -0
- package/dist/api/series-api.d.ts +115 -0
- package/dist/core/accessibility.d.ts +90 -0
- package/dist/core/alert-line.d.ts +49 -0
- package/dist/core/chart-state.d.ts +39 -0
- package/dist/core/chart-sync.d.ts +83 -0
- package/dist/core/crosshair.d.ts +28 -0
- package/dist/core/css-theme.d.ts +41 -0
- package/dist/core/custom-indicator.d.ts +70 -0
- package/dist/core/data-feed.d.ts +59 -0
- package/dist/core/data-layer.d.ts +38 -0
- package/dist/core/invalidation.d.ts +24 -0
- package/dist/core/market-session.d.ts +11 -0
- package/dist/core/order-line.d.ts +134 -0
- package/dist/core/pane-divider.d.ts +22 -0
- package/dist/core/pane.d.ts +32 -0
- package/dist/core/periodicity.d.ts +6 -0
- package/dist/core/plugin.d.ts +90 -0
- package/dist/core/price-line.d.ts +17 -0
- package/dist/core/price-scale.d.ts +74 -0
- package/dist/core/replay.d.ts +73 -0
- package/dist/core/rtl.d.ts +22 -0
- package/dist/core/segment-tree.d.ts +38 -0
- package/dist/core/series-markers.d.ts +18 -0
- package/dist/core/storage-adapter.d.ts +50 -0
- package/dist/core/streaming-adapter.d.ts +102 -0
- package/dist/core/symbol-resolver.d.ts +32 -0
- package/dist/core/text-label.d.ts +72 -0
- package/dist/core/time-scale.d.ts +109 -0
- package/dist/core/types.d.ts +144 -0
- package/dist/core/undo-redo.d.ts +46 -0
- package/dist/currency/currency.d.ts +8 -0
- package/dist/currency/index.d.ts +2 -0
- package/dist/drawings/arrow.d.ts +10 -0
- package/dist/drawings/base.d.ts +79 -0
- package/dist/drawings/channel.d.ts +10 -0
- package/dist/drawings/crossline.d.ts +10 -0
- package/dist/drawings/ellipse.d.ts +10 -0
- package/dist/drawings/fib-arc.d.ts +10 -0
- package/dist/drawings/fib-fan.d.ts +12 -0
- package/dist/drawings/fib-projection.d.ts +11 -0
- package/dist/drawings/fibonacci.d.ts +11 -0
- package/dist/drawings/horizontal-line.d.ts +10 -0
- package/dist/drawings/index.d.ts +7 -0
- package/dist/drawings/measurement.d.ts +11 -0
- package/dist/drawings/pitchfork.d.ts +12 -0
- package/dist/drawings/ray.d.ts +12 -0
- package/dist/drawings/rectangle.d.ts +10 -0
- package/dist/drawings/text-annotation.d.ts +11 -0
- package/dist/drawings/trendline.d.ts +10 -0
- package/dist/drawings/vertical-line.d.ts +10 -0
- package/dist/formatting/index.d.ts +5 -0
- package/dist/formatting/price-formatter.d.ts +6 -0
- package/dist/formatting/time-formatter.d.ts +7 -0
- package/dist/formatting/volume-formatter.d.ts +1 -0
- package/dist/i18n/i18n.d.ts +6 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/locales/en.d.ts +3 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index10.js +2 -0
- package/dist/index10.js.map +1 -0
- package/dist/index100.js +2 -0
- package/dist/index100.js.map +1 -0
- package/dist/index101.js +2 -0
- package/dist/index101.js.map +1 -0
- package/dist/index102.js +2 -0
- package/dist/index102.js.map +1 -0
- package/dist/index103.js +2 -0
- package/dist/index103.js.map +1 -0
- package/dist/index104.js +2 -0
- package/dist/index104.js.map +1 -0
- package/dist/index105.js +2 -0
- package/dist/index105.js.map +1 -0
- package/dist/index106.js +2 -0
- package/dist/index106.js.map +1 -0
- package/dist/index107.js +2 -0
- package/dist/index107.js.map +1 -0
- package/dist/index108.js +2 -0
- package/dist/index108.js.map +1 -0
- package/dist/index109.js +2 -0
- package/dist/index109.js.map +1 -0
- package/dist/index11.js +2 -0
- package/dist/index11.js.map +1 -0
- package/dist/index110.js +2 -0
- package/dist/index110.js.map +1 -0
- package/dist/index111.js +2 -0
- package/dist/index111.js.map +1 -0
- package/dist/index112.js +2 -0
- package/dist/index112.js.map +1 -0
- package/dist/index113.js +2 -0
- package/dist/index113.js.map +1 -0
- package/dist/index114.js +2 -0
- package/dist/index114.js.map +1 -0
- package/dist/index115.js +2 -0
- package/dist/index115.js.map +1 -0
- package/dist/index116.js +2 -0
- package/dist/index116.js.map +1 -0
- package/dist/index117.js +2 -0
- package/dist/index117.js.map +1 -0
- package/dist/index118.js +2 -0
- package/dist/index118.js.map +1 -0
- package/dist/index119.js +2 -0
- package/dist/index119.js.map +1 -0
- package/dist/index12.js +2 -0
- package/dist/index12.js.map +1 -0
- package/dist/index120.js +2 -0
- package/dist/index120.js.map +1 -0
- package/dist/index121.js +2 -0
- package/dist/index121.js.map +1 -0
- package/dist/index122.js +2 -0
- package/dist/index122.js.map +1 -0
- package/dist/index123.js +2 -0
- package/dist/index123.js.map +1 -0
- package/dist/index124.js +2 -0
- package/dist/index124.js.map +1 -0
- package/dist/index13.js +2 -0
- package/dist/index13.js.map +1 -0
- package/dist/index14.js +2 -0
- package/dist/index14.js.map +1 -0
- package/dist/index15.js +2 -0
- package/dist/index15.js.map +1 -0
- package/dist/index16.js +2 -0
- package/dist/index16.js.map +1 -0
- package/dist/index17.js +2 -0
- package/dist/index17.js.map +1 -0
- package/dist/index18.js +2 -0
- package/dist/index18.js.map +1 -0
- package/dist/index19.js +2 -0
- package/dist/index19.js.map +1 -0
- package/dist/index2.js +2 -0
- package/dist/index2.js.map +1 -0
- package/dist/index20.js +2 -0
- package/dist/index20.js.map +1 -0
- package/dist/index21.js +2 -0
- package/dist/index21.js.map +1 -0
- package/dist/index22.js +2 -0
- package/dist/index22.js.map +1 -0
- package/dist/index23.js +2 -0
- package/dist/index23.js.map +1 -0
- package/dist/index24.js +2 -0
- package/dist/index24.js.map +1 -0
- package/dist/index25.js +2 -0
- package/dist/index25.js.map +1 -0
- package/dist/index26.js +2 -0
- package/dist/index26.js.map +1 -0
- package/dist/index27.js +2 -0
- package/dist/index27.js.map +1 -0
- package/dist/index28.js +2 -0
- package/dist/index28.js.map +1 -0
- package/dist/index29.js +2 -0
- package/dist/index29.js.map +1 -0
- package/dist/index3.js +2 -0
- package/dist/index3.js.map +1 -0
- package/dist/index30.js +2 -0
- package/dist/index30.js.map +1 -0
- package/dist/index31.js +2 -0
- package/dist/index31.js.map +1 -0
- package/dist/index32.js +2 -0
- package/dist/index32.js.map +1 -0
- package/dist/index33.js +2 -0
- package/dist/index33.js.map +1 -0
- package/dist/index34.js +2 -0
- package/dist/index34.js.map +1 -0
- package/dist/index35.js +2 -0
- package/dist/index35.js.map +1 -0
- package/dist/index36.js +2 -0
- package/dist/index36.js.map +1 -0
- package/dist/index37.js +2 -0
- package/dist/index37.js.map +1 -0
- package/dist/index38.js +2 -0
- package/dist/index38.js.map +1 -0
- package/dist/index39.js +2 -0
- package/dist/index39.js.map +1 -0
- package/dist/index4.js +2 -0
- package/dist/index4.js.map +1 -0
- package/dist/index40.js +2 -0
- package/dist/index40.js.map +1 -0
- package/dist/index41.js +2 -0
- package/dist/index41.js.map +1 -0
- package/dist/index42.js +2 -0
- package/dist/index42.js.map +1 -0
- package/dist/index43.js +2 -0
- package/dist/index43.js.map +1 -0
- package/dist/index44.js +2 -0
- package/dist/index44.js.map +1 -0
- package/dist/index45.js +2 -0
- package/dist/index45.js.map +1 -0
- package/dist/index46.js +2 -0
- package/dist/index46.js.map +1 -0
- package/dist/index47.js +2 -0
- package/dist/index47.js.map +1 -0
- package/dist/index48.js +2 -0
- package/dist/index48.js.map +1 -0
- package/dist/index49.js +2 -0
- package/dist/index49.js.map +1 -0
- package/dist/index5.js +2 -0
- package/dist/index5.js.map +1 -0
- package/dist/index50.js +2 -0
- package/dist/index50.js.map +1 -0
- package/dist/index51.js +2 -0
- package/dist/index51.js.map +1 -0
- package/dist/index52.js +2 -0
- package/dist/index52.js.map +1 -0
- package/dist/index53.js +2 -0
- package/dist/index53.js.map +1 -0
- package/dist/index54.js +2 -0
- package/dist/index54.js.map +1 -0
- package/dist/index55.js +2 -0
- package/dist/index55.js.map +1 -0
- package/dist/index56.js +2 -0
- package/dist/index56.js.map +1 -0
- package/dist/index57.js +2 -0
- package/dist/index57.js.map +1 -0
- package/dist/index58.js +2 -0
- package/dist/index58.js.map +1 -0
- package/dist/index59.js +2 -0
- package/dist/index59.js.map +1 -0
- package/dist/index6.js +2 -0
- package/dist/index6.js.map +1 -0
- package/dist/index60.js +2 -0
- package/dist/index60.js.map +1 -0
- package/dist/index61.js +2 -0
- package/dist/index61.js.map +1 -0
- package/dist/index62.js +2 -0
- package/dist/index62.js.map +1 -0
- package/dist/index63.js +2 -0
- package/dist/index63.js.map +1 -0
- package/dist/index64.js +2 -0
- package/dist/index64.js.map +1 -0
- package/dist/index65.js +3 -0
- package/dist/index65.js.map +1 -0
- package/dist/index66.js +2 -0
- package/dist/index66.js.map +1 -0
- package/dist/index67.js +2 -0
- package/dist/index67.js.map +1 -0
- package/dist/index68.js +2 -0
- package/dist/index68.js.map +1 -0
- package/dist/index69.js +2 -0
- package/dist/index69.js.map +1 -0
- package/dist/index7.js +2 -0
- package/dist/index7.js.map +1 -0
- package/dist/index70.js +2 -0
- package/dist/index70.js.map +1 -0
- package/dist/index71.js +2 -0
- package/dist/index71.js.map +1 -0
- package/dist/index72.js +2 -0
- package/dist/index72.js.map +1 -0
- package/dist/index73.js +2 -0
- package/dist/index73.js.map +1 -0
- package/dist/index74.js +2 -0
- package/dist/index74.js.map +1 -0
- package/dist/index75.js +2 -0
- package/dist/index75.js.map +1 -0
- package/dist/index76.js +2 -0
- package/dist/index76.js.map +1 -0
- package/dist/index77.js +2 -0
- package/dist/index77.js.map +1 -0
- package/dist/index78.js +2 -0
- package/dist/index78.js.map +1 -0
- package/dist/index79.js +2 -0
- package/dist/index79.js.map +1 -0
- package/dist/index8.js +2 -0
- package/dist/index8.js.map +1 -0
- package/dist/index80.js +2 -0
- package/dist/index80.js.map +1 -0
- package/dist/index81.js +2 -0
- package/dist/index81.js.map +1 -0
- package/dist/index82.js +2 -0
- package/dist/index82.js.map +1 -0
- package/dist/index83.js +2 -0
- package/dist/index83.js.map +1 -0
- package/dist/index84.js +2 -0
- package/dist/index84.js.map +1 -0
- package/dist/index85.js +2 -0
- package/dist/index85.js.map +1 -0
- package/dist/index86.js +2 -0
- package/dist/index86.js.map +1 -0
- package/dist/index87.js +2 -0
- package/dist/index87.js.map +1 -0
- package/dist/index88.js +2 -0
- package/dist/index88.js.map +1 -0
- package/dist/index89.js +2 -0
- package/dist/index89.js.map +1 -0
- package/dist/index9.js +2 -0
- package/dist/index9.js.map +1 -0
- package/dist/index90.js +2 -0
- package/dist/index90.js.map +1 -0
- package/dist/index91.js +2 -0
- package/dist/index91.js.map +1 -0
- package/dist/index92.js +2 -0
- package/dist/index92.js.map +1 -0
- package/dist/index93.js +2 -0
- package/dist/index93.js.map +1 -0
- package/dist/index94.js +2 -0
- package/dist/index94.js.map +1 -0
- package/dist/index95.js +2 -0
- package/dist/index95.js.map +1 -0
- package/dist/index96.js +2 -0
- package/dist/index96.js.map +1 -0
- package/dist/index97.js +2 -0
- package/dist/index97.js.map +1 -0
- package/dist/index98.js +2 -0
- package/dist/index98.js.map +1 -0
- package/dist/index99.js +2 -0
- package/dist/index99.js.map +1 -0
- package/dist/indicators/adx.d.ts +6 -0
- package/dist/indicators/aroon.d.ts +5 -0
- package/dist/indicators/atr.d.ts +1 -0
- package/dist/indicators/awesome-oscillator.d.ts +1 -0
- package/dist/indicators/bollinger.d.ts +6 -0
- package/dist/indicators/cci.d.ts +1 -0
- package/dist/indicators/chaikin-mf.d.ts +1 -0
- package/dist/indicators/choppiness.d.ts +1 -0
- package/dist/indicators/coppock.d.ts +1 -0
- package/dist/indicators/donchian.d.ts +6 -0
- package/dist/indicators/elder-force.d.ts +1 -0
- package/dist/indicators/ema.d.ts +1 -0
- package/dist/indicators/ichimoku.d.ts +8 -0
- package/dist/indicators/index.d.ts +31 -0
- package/dist/indicators/keltner.d.ts +6 -0
- package/dist/indicators/linear-regression.d.ts +1 -0
- package/dist/indicators/macd.d.ts +6 -0
- package/dist/indicators/mfi.d.ts +1 -0
- package/dist/indicators/obv.d.ts +1 -0
- package/dist/indicators/parabolic-sar.d.ts +1 -0
- package/dist/indicators/pivot-points.d.ts +10 -0
- package/dist/indicators/roc.d.ts +1 -0
- package/dist/indicators/rsi.d.ts +1 -0
- package/dist/indicators/sma.d.ts +1 -0
- package/dist/indicators/stochastic.d.ts +5 -0
- package/dist/indicators/supertrend.d.ts +5 -0
- package/dist/indicators/trix.d.ts +5 -0
- package/dist/indicators/utils.d.ts +20 -0
- package/dist/indicators/volume-profile.d.ts +37 -0
- package/dist/indicators/volume.d.ts +1 -0
- package/dist/indicators/vwap.d.ts +1 -0
- package/dist/indicators/vwma.d.ts +1 -0
- package/dist/indicators/williams-r.d.ts +1 -0
- package/dist/interactions/axis-drag.d.ts +24 -0
- package/dist/interactions/context-menu-handler.d.ts +42 -0
- package/dist/interactions/crosshair.d.ts +20 -0
- package/dist/interactions/drawing-handler.d.ts +39 -0
- package/dist/interactions/event-router.d.ts +37 -0
- package/dist/interactions/keyboard-nav.d.ts +11 -0
- package/dist/interactions/pan-zoom.d.ts +39 -0
- package/dist/interactions/range-selection.d.ts +103 -0
- package/dist/interactions/touch-gestures.d.ts +36 -0
- package/dist/logo.svg +40 -0
- package/dist/market/exchange-map.d.ts +3 -0
- package/dist/market/index.d.ts +4 -0
- package/dist/market/market-calendar.d.ts +4 -0
- package/dist/market/market-definition.d.ts +22 -0
- package/dist/mockServiceWorker.js +349 -0
- package/dist/renderers/area.d.ts +17 -0
- package/dist/renderers/bar-ohlc.d.ts +17 -0
- package/dist/renderers/baseline-delta-mountain.d.ts +22 -0
- package/dist/renderers/baseline.d.ts +19 -0
- package/dist/renderers/candlestick.d.ts +21 -0
- package/dist/renderers/canvas-renderer.d.ts +28 -0
- package/dist/renderers/colored-line.d.ts +15 -0
- package/dist/renderers/colored-mountain.d.ts +18 -0
- package/dist/renderers/column.d.ts +14 -0
- package/dist/renderers/high-low.d.ts +14 -0
- package/dist/renderers/histogram.d.ts +16 -0
- package/dist/renderers/hlc-area.d.ts +16 -0
- package/dist/renderers/hollow-candle.d.ts +18 -0
- package/dist/renderers/kagi.d.ts +22 -0
- package/dist/renderers/line-break.d.ts +20 -0
- package/dist/renderers/line.d.ts +17 -0
- package/dist/renderers/point-figure.d.ts +20 -0
- package/dist/renderers/renderer.d.ts +59 -0
- package/dist/renderers/renko.d.ts +24 -0
- package/dist/renderers/step-line.d.ts +14 -0
- package/dist/renderers/text-cache.d.ts +23 -0
- package/dist/renderers/volume-candle.d.ts +20 -0
- package/dist/renderers/webgl/area-webgl.d.ts +28 -0
- package/dist/renderers/webgl/candlestick-webgl.d.ts +30 -0
- package/dist/renderers/webgl/index.d.ts +7 -0
- package/dist/renderers/webgl/line-webgl.d.ts +23 -0
- package/dist/renderers/webgl/webgl-utils.d.ts +23 -0
- package/dist/timezone/index.d.ts +2 -0
- package/dist/timezone/timezone.d.ts +12 -0
- package/dist/transforms/aggregate.d.ts +2 -0
- package/dist/transforms/heikin-ashi.d.ts +2 -0
- package/dist/transforms/index.d.ts +2 -0
- package/dist/ui/context-menu.d.ts +14 -0
- package/dist/ui/hud.d.ts +43 -0
- package/dist/ui/settings-popup.d.ts +15 -0
- package/package.json +129 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export type OrderSide = 'buy' | 'sell';
|
|
2
|
+
export type OrderType = 'limit' | 'stop' | 'market';
|
|
3
|
+
export type OrderModifiedCallback = (order: OrderLine) => void;
|
|
4
|
+
export type OrderCancelledCallback = (order: OrderLine) => void;
|
|
5
|
+
export interface OrderLineOptions {
|
|
6
|
+
price: number;
|
|
7
|
+
quantity: number;
|
|
8
|
+
side: OrderSide;
|
|
9
|
+
orderType: OrderType;
|
|
10
|
+
color?: string;
|
|
11
|
+
lineWidth?: number;
|
|
12
|
+
lineStyle?: 'solid' | 'dashed' | 'dotted';
|
|
13
|
+
title?: string;
|
|
14
|
+
draggable?: boolean;
|
|
15
|
+
axisLabelVisible?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* OrderLine represents a pending order on the chart (limit, stop, or market).
|
|
19
|
+
* It extends the concept of PriceLine with trading-specific properties such as
|
|
20
|
+
* quantity, side, order type, and drag-to-modify support.
|
|
21
|
+
*/
|
|
22
|
+
export declare class OrderLine {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
private _price;
|
|
25
|
+
private _quantity;
|
|
26
|
+
private _side;
|
|
27
|
+
private _orderType;
|
|
28
|
+
private _color;
|
|
29
|
+
private _lineWidth;
|
|
30
|
+
private _lineStyle;
|
|
31
|
+
private _title;
|
|
32
|
+
private _draggable;
|
|
33
|
+
private _axisLabelVisible;
|
|
34
|
+
private _onModified;
|
|
35
|
+
private _onCancelled;
|
|
36
|
+
private _cancelled;
|
|
37
|
+
constructor(options: OrderLineOptions);
|
|
38
|
+
get price(): number;
|
|
39
|
+
get quantity(): number;
|
|
40
|
+
get side(): OrderSide;
|
|
41
|
+
get orderType(): OrderType;
|
|
42
|
+
get color(): string;
|
|
43
|
+
get lineWidth(): number;
|
|
44
|
+
get lineStyle(): 'solid' | 'dashed' | 'dotted';
|
|
45
|
+
get title(): string;
|
|
46
|
+
get draggable(): boolean;
|
|
47
|
+
get axisLabelVisible(): boolean;
|
|
48
|
+
get isCancelled(): boolean;
|
|
49
|
+
/** Update the order price (e.g. after a drag). Fires onModified callbacks. */
|
|
50
|
+
setPrice(price: number): void;
|
|
51
|
+
/** Update the order quantity. Fires onModified callbacks. */
|
|
52
|
+
setQuantity(quantity: number): void;
|
|
53
|
+
/** Apply partial option updates. Fires onModified callbacks. */
|
|
54
|
+
applyOptions(opts: Partial<OrderLineOptions>): void;
|
|
55
|
+
/** Cancel this order. Fires onCancelled callbacks. */
|
|
56
|
+
cancel(): void;
|
|
57
|
+
onModified(callback: OrderModifiedCallback): void;
|
|
58
|
+
offModified(callback: OrderModifiedCallback): void;
|
|
59
|
+
onCancelled(callback: OrderCancelledCallback): void;
|
|
60
|
+
offCancelled(callback: OrderCancelledCallback): void;
|
|
61
|
+
/** Serialize to a plain object for persistence. */
|
|
62
|
+
serialize(): {
|
|
63
|
+
id: string;
|
|
64
|
+
price: number;
|
|
65
|
+
quantity: number;
|
|
66
|
+
side: OrderSide;
|
|
67
|
+
orderType: OrderType;
|
|
68
|
+
color: string;
|
|
69
|
+
lineWidth: number;
|
|
70
|
+
lineStyle: string;
|
|
71
|
+
title: string;
|
|
72
|
+
draggable: boolean;
|
|
73
|
+
axisLabelVisible: boolean;
|
|
74
|
+
};
|
|
75
|
+
private _fireModified;
|
|
76
|
+
}
|
|
77
|
+
export interface PositionLineOptions {
|
|
78
|
+
entryPrice: number;
|
|
79
|
+
quantity: number;
|
|
80
|
+
side: OrderSide;
|
|
81
|
+
color?: string;
|
|
82
|
+
lineWidth?: number;
|
|
83
|
+
lineStyle?: 'solid' | 'dashed' | 'dotted';
|
|
84
|
+
title?: string;
|
|
85
|
+
axisLabelVisible?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* PositionLine represents an open trading position on the chart.
|
|
89
|
+
* It shows the entry price, quantity, and calculates unrealized P&L
|
|
90
|
+
* given a current market price.
|
|
91
|
+
*/
|
|
92
|
+
export declare class PositionLine {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
private _entryPrice;
|
|
95
|
+
private _quantity;
|
|
96
|
+
private _side;
|
|
97
|
+
private _color;
|
|
98
|
+
private _lineWidth;
|
|
99
|
+
private _lineStyle;
|
|
100
|
+
private _title;
|
|
101
|
+
private _axisLabelVisible;
|
|
102
|
+
constructor(options: PositionLineOptions);
|
|
103
|
+
get entryPrice(): number;
|
|
104
|
+
get quantity(): number;
|
|
105
|
+
get side(): OrderSide;
|
|
106
|
+
get color(): string;
|
|
107
|
+
get lineWidth(): number;
|
|
108
|
+
get lineStyle(): 'solid' | 'dashed' | 'dotted';
|
|
109
|
+
get title(): string;
|
|
110
|
+
get axisLabelVisible(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Calculate unrealized profit/loss given the current market price.
|
|
113
|
+
* Positive means profit, negative means loss.
|
|
114
|
+
*/
|
|
115
|
+
unrealizedPnL(currentPrice: number): number;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate unrealized P&L as a percentage of the entry value.
|
|
118
|
+
*/
|
|
119
|
+
unrealizedPnLPercent(currentPrice: number): number;
|
|
120
|
+
/** Apply partial option updates. */
|
|
121
|
+
applyOptions(opts: Partial<PositionLineOptions>): void;
|
|
122
|
+
/** Serialize to a plain object for persistence. */
|
|
123
|
+
serialize(): {
|
|
124
|
+
id: string;
|
|
125
|
+
entryPrice: number;
|
|
126
|
+
quantity: number;
|
|
127
|
+
side: OrderSide;
|
|
128
|
+
color: string;
|
|
129
|
+
lineWidth: number;
|
|
130
|
+
lineStyle: string;
|
|
131
|
+
title: string;
|
|
132
|
+
axisLabelVisible: boolean;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const DIVIDER_HEIGHT = 4;
|
|
2
|
+
/**
|
|
3
|
+
* A draggable divider between two adjacent panes.
|
|
4
|
+
* On drag, redistributes height between the panes above and below.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PaneDivider {
|
|
7
|
+
readonly el: HTMLDivElement;
|
|
8
|
+
private _getAboveHeight;
|
|
9
|
+
private _setAboveHeight;
|
|
10
|
+
private _getBelowHeight;
|
|
11
|
+
private _setBelowHeight;
|
|
12
|
+
private _onResize;
|
|
13
|
+
private _dragging;
|
|
14
|
+
private _startY;
|
|
15
|
+
private _startAboveH;
|
|
16
|
+
private _startBelowH;
|
|
17
|
+
constructor(getAboveHeight: () => number, setAboveHeight: (h: number) => void, getBelowHeight: () => number, setBelowHeight: (h: number) => void, onResize: () => void);
|
|
18
|
+
destroy(): void;
|
|
19
|
+
private _onPointerDown;
|
|
20
|
+
private _onPointerMove;
|
|
21
|
+
private _onPointerUp;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PriceScale } from './price-scale';
|
|
2
|
+
export interface PaneCanvases {
|
|
3
|
+
chartCanvas: HTMLCanvasElement;
|
|
4
|
+
overlayCanvas: HTMLCanvasElement;
|
|
5
|
+
rightPriceAxisCanvas: HTMLCanvasElement;
|
|
6
|
+
leftPriceAxisCanvas: HTMLCanvasElement;
|
|
7
|
+
chartCtx: CanvasRenderingContext2D;
|
|
8
|
+
overlayCtx: CanvasRenderingContext2D;
|
|
9
|
+
rightPriceAxisCtx: CanvasRenderingContext2D;
|
|
10
|
+
leftPriceAxisCtx: CanvasRenderingContext2D;
|
|
11
|
+
/** Optional WebGL canvas layered between chart and overlay canvases. */
|
|
12
|
+
webglCanvas?: HTMLCanvasElement;
|
|
13
|
+
webglCtx?: WebGL2RenderingContext;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Internal Pane class. Holds canvases, contexts, and price scales for a single pane row.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Pane {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly row: HTMLDivElement;
|
|
21
|
+
readonly canvases: PaneCanvases;
|
|
22
|
+
readonly priceScale: PriceScale;
|
|
23
|
+
readonly leftPriceScale: PriceScale;
|
|
24
|
+
private _height;
|
|
25
|
+
constructor(id: string, height: number, useWebGL?: boolean);
|
|
26
|
+
get height(): number;
|
|
27
|
+
set height(value: number);
|
|
28
|
+
/**
|
|
29
|
+
* Layout all canvases within this pane row.
|
|
30
|
+
*/
|
|
31
|
+
layout(chartW: number, leftScaleW: number, priceAxisWidth: number, rightScaleVisible: boolean, leftScaleVisible: boolean, pixelRatio: number): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPlugin — formal plugin interface with lifecycle hooks.
|
|
3
|
+
*
|
|
4
|
+
* Plugins can add custom series types, indicators, drawing tools,
|
|
5
|
+
* UI panels, and intercept chart events.
|
|
6
|
+
*/
|
|
7
|
+
export interface IPlugin {
|
|
8
|
+
/** Unique plugin identifier. */
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** Plugin version (semver). */
|
|
11
|
+
readonly version?: string;
|
|
12
|
+
/** Plugins this plugin depends on (by name). */
|
|
13
|
+
readonly dependencies?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Called when the plugin is installed on a chart via chart.use(plugin).
|
|
16
|
+
* Receives the chart API for registering extensions.
|
|
17
|
+
*/
|
|
18
|
+
install(chart: PluginChartApi): void;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the plugin is uninstalled or the chart is destroyed.
|
|
21
|
+
*/
|
|
22
|
+
uninstall?(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Called on each paint cycle, after all series have been rendered.
|
|
25
|
+
* Allows plugins to render custom overlays.
|
|
26
|
+
*/
|
|
27
|
+
onPaint?(context: PluginPaintContext): void;
|
|
28
|
+
/**
|
|
29
|
+
* Called when chart options change.
|
|
30
|
+
*/
|
|
31
|
+
onOptionsChange?(options: Record<string, unknown>): void;
|
|
32
|
+
/**
|
|
33
|
+
* Called when data is updated on any series.
|
|
34
|
+
*/
|
|
35
|
+
onDataUpdate?(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Subset of the chart API exposed to plugins.
|
|
39
|
+
*/
|
|
40
|
+
export interface PluginChartApi {
|
|
41
|
+
/** Get the DOM container element. */
|
|
42
|
+
getContainer(): HTMLElement;
|
|
43
|
+
/** Request a chart repaint. */
|
|
44
|
+
requestRepaint(): void;
|
|
45
|
+
/** Get chart dimensions. */
|
|
46
|
+
getSize(): {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Context passed to plugin paint callbacks.
|
|
53
|
+
*/
|
|
54
|
+
export interface PluginPaintContext {
|
|
55
|
+
ctx: CanvasRenderingContext2D;
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
pixelRatio: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* PluginManager — manages plugin lifecycle, dependency resolution,
|
|
62
|
+
* and event dispatch.
|
|
63
|
+
*/
|
|
64
|
+
export declare class PluginManager {
|
|
65
|
+
private _plugins;
|
|
66
|
+
private _installOrder;
|
|
67
|
+
private _chartApi;
|
|
68
|
+
/** Set the chart API reference. Called once during chart initialization. */
|
|
69
|
+
setChartApi(api: PluginChartApi): void;
|
|
70
|
+
/**
|
|
71
|
+
* Install a plugin. Resolves dependencies (must already be installed).
|
|
72
|
+
*/
|
|
73
|
+
use(plugin: IPlugin): void;
|
|
74
|
+
/** Uninstall a plugin by name. */
|
|
75
|
+
remove(name: string): boolean;
|
|
76
|
+
/** Get an installed plugin by name. */
|
|
77
|
+
get(name: string): IPlugin | undefined;
|
|
78
|
+
/** List installed plugin names in install order. */
|
|
79
|
+
list(): string[];
|
|
80
|
+
/** Whether a plugin is installed. */
|
|
81
|
+
has(name: string): boolean;
|
|
82
|
+
/** Notify all plugins of a paint cycle. */
|
|
83
|
+
notifyPaint(context: PluginPaintContext): void;
|
|
84
|
+
/** Notify all plugins of options change. */
|
|
85
|
+
notifyOptionsChange(options: Record<string, unknown>): void;
|
|
86
|
+
/** Notify all plugins of data update. */
|
|
87
|
+
notifyDataUpdate(): void;
|
|
88
|
+
/** Uninstall all plugins in reverse order. */
|
|
89
|
+
removeAll(): void;
|
|
90
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PriceLineOptions {
|
|
2
|
+
price: number;
|
|
3
|
+
color: string;
|
|
4
|
+
lineWidth: number;
|
|
5
|
+
lineStyle: 'solid' | 'dashed' | 'dotted';
|
|
6
|
+
title: string;
|
|
7
|
+
axisLabelVisible: boolean;
|
|
8
|
+
axisLabelColor?: string;
|
|
9
|
+
axisLabelTextColor?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class PriceLine {
|
|
12
|
+
private _options;
|
|
13
|
+
private _requestRepaint;
|
|
14
|
+
constructor(options: PriceLineOptions, requestRepaint?: () => void);
|
|
15
|
+
get options(): Readonly<PriceLineOptions>;
|
|
16
|
+
applyOptions(opts: Partial<PriceLineOptions>, requestRepaint?: () => void): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type PriceScaleMode = 'linear' | 'logarithmic';
|
|
2
|
+
export interface PriceRange {
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class PriceScale {
|
|
7
|
+
readonly position: 'left' | 'right';
|
|
8
|
+
private _height;
|
|
9
|
+
/** Current (animated) min/max used by priceToY. */
|
|
10
|
+
private _min;
|
|
11
|
+
private _max;
|
|
12
|
+
/** Target min/max that autoScale sets. Current values chase these. */
|
|
13
|
+
private _targetMin;
|
|
14
|
+
private _targetMax;
|
|
15
|
+
/** True after the first autoScale call — before that, we snap instead of animating. */
|
|
16
|
+
private _initialized;
|
|
17
|
+
/** True while current min/max are still converging toward target. */
|
|
18
|
+
private _animating;
|
|
19
|
+
/** When true, setRange() was called manually and autoScale() will not override it. */
|
|
20
|
+
private _manualRange;
|
|
21
|
+
private _comparisonMode;
|
|
22
|
+
private _mode;
|
|
23
|
+
constructor(position: 'left' | 'right');
|
|
24
|
+
/** Get the current scale mode. */
|
|
25
|
+
get mode(): PriceScaleMode;
|
|
26
|
+
/** Set the scale mode (linear or logarithmic). */
|
|
27
|
+
setMode(mode: PriceScaleMode): void;
|
|
28
|
+
setHeight(height: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Auto-scale to fit [minPrice, maxPrice].
|
|
31
|
+
* Margins are handled in coordinate conversion, not here.
|
|
32
|
+
* Ignored when a manual range is active.
|
|
33
|
+
*
|
|
34
|
+
* On the first call, values snap immediately. On subsequent calls,
|
|
35
|
+
* target values are set and current values animate toward them via tick().
|
|
36
|
+
*/
|
|
37
|
+
autoScale(minPrice: number, maxPrice: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Advance the price scale animation by one frame.
|
|
40
|
+
* Returns true if still animating (caller should schedule another repaint).
|
|
41
|
+
*/
|
|
42
|
+
tick(): boolean;
|
|
43
|
+
/** True while the scale is animating toward a new target range. */
|
|
44
|
+
get isAnimating(): boolean;
|
|
45
|
+
/** Reset animation state — snap current values to target immediately. */
|
|
46
|
+
snapToTarget(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Manually override the price range.
|
|
49
|
+
* Subsequent autoScale() calls will be ignored until resetAutoScale() is called.
|
|
50
|
+
*/
|
|
51
|
+
setRange(min: number, max: number): void;
|
|
52
|
+
/** Re-enable auto-scaling (next autoScale() call will take effect). */
|
|
53
|
+
resetAutoScale(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Enable or disable comparison mode.
|
|
56
|
+
* In comparison mode the scale operates in "percent space" — callers pass
|
|
57
|
+
* percentage-change values (e.g. +12.5 for +12.5%) instead of raw prices.
|
|
58
|
+
* priceToY / yToPrice work identically; the caller is responsible for the
|
|
59
|
+
* raw-price → percentage conversion before calling priceToY.
|
|
60
|
+
*/
|
|
61
|
+
setComparisonMode(enabled: boolean): void;
|
|
62
|
+
/** Returns true when comparison mode is active. */
|
|
63
|
+
isComparisonMode(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Map a price to a y-pixel coordinate.
|
|
66
|
+
*
|
|
67
|
+
* In linear mode: equal vertical distance for equal price change.
|
|
68
|
+
* In logarithmic mode: equal vertical distance for equal percentage change.
|
|
69
|
+
*/
|
|
70
|
+
priceToY(price: number): number;
|
|
71
|
+
/** Inverse of priceToY. */
|
|
72
|
+
yToPrice(y: number): number;
|
|
73
|
+
get priceRange(): PriceRange;
|
|
74
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Bar, ColumnStore } from './types';
|
|
2
|
+
export type ReplaySpeed = 1 | 2 | 5 | 10;
|
|
3
|
+
export type ReplayBarEvent = {
|
|
4
|
+
type: 'bar';
|
|
5
|
+
barIndex: number;
|
|
6
|
+
bar: Bar;
|
|
7
|
+
};
|
|
8
|
+
export type ReplayControlEvent = {
|
|
9
|
+
type: 'pause' | 'resume' | 'end';
|
|
10
|
+
barIndex: number;
|
|
11
|
+
};
|
|
12
|
+
export type ReplayEvent = ReplayBarEvent | ReplayControlEvent;
|
|
13
|
+
export type ReplayEventCallback = (event: ReplayEvent) => void;
|
|
14
|
+
export interface ReplayOptions {
|
|
15
|
+
/** Playback speed multiplier (default: 1). */
|
|
16
|
+
speed?: ReplaySpeed;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ReplayManager — steps through historical data bar-by-bar to simulate
|
|
20
|
+
* live data streaming. Bars appear progressively as if in real-time.
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* replay.start(store, fromIndex, { speed: 2 });
|
|
24
|
+
* replay.onEvent(callback); // fired for each revealed bar or control event
|
|
25
|
+
* replay.pause();
|
|
26
|
+
* replay.stepForward();
|
|
27
|
+
* replay.resume();
|
|
28
|
+
* replay.stop();
|
|
29
|
+
*/
|
|
30
|
+
export declare class ReplayManager {
|
|
31
|
+
private _store;
|
|
32
|
+
private _currentIndex;
|
|
33
|
+
private _endIndex;
|
|
34
|
+
private _speed;
|
|
35
|
+
private _playing;
|
|
36
|
+
private _timerId;
|
|
37
|
+
private _callbacks;
|
|
38
|
+
private _baseIntervalMs;
|
|
39
|
+
/** Whether replay is currently active (playing or paused). */
|
|
40
|
+
get active(): boolean;
|
|
41
|
+
/** Whether replay is currently playing (not paused). */
|
|
42
|
+
get playing(): boolean;
|
|
43
|
+
/** Current bar index in the replay. */
|
|
44
|
+
get currentIndex(): number;
|
|
45
|
+
/** Current playback speed. */
|
|
46
|
+
get speed(): ReplaySpeed;
|
|
47
|
+
/** Subscribe to replay events. */
|
|
48
|
+
onEvent(callback: ReplayEventCallback): void;
|
|
49
|
+
/** Unsubscribe from replay events. */
|
|
50
|
+
offEvent(callback: ReplayEventCallback): void;
|
|
51
|
+
/**
|
|
52
|
+
* Start replay from the given bar index.
|
|
53
|
+
* Bars from 0 to fromIndex are initially visible; subsequent bars
|
|
54
|
+
* are revealed progressively.
|
|
55
|
+
*/
|
|
56
|
+
start(store: ColumnStore, fromIndex: number, options?: ReplayOptions): void;
|
|
57
|
+
/** Pause playback. */
|
|
58
|
+
pause(): void;
|
|
59
|
+
/** Resume playback after pause. */
|
|
60
|
+
resume(): void;
|
|
61
|
+
/** Step forward one bar (works while paused or playing). */
|
|
62
|
+
stepForward(): boolean;
|
|
63
|
+
/** Step backward one bar (works while paused or playing). */
|
|
64
|
+
stepBackward(): boolean;
|
|
65
|
+
/** Set playback speed. */
|
|
66
|
+
setSpeed(speed: ReplaySpeed): void;
|
|
67
|
+
/** Stop replay and reset state. */
|
|
68
|
+
stop(): void;
|
|
69
|
+
private _startTimer;
|
|
70
|
+
private _stopTimer;
|
|
71
|
+
private _emitBar;
|
|
72
|
+
private _emit;
|
|
73
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RTL (Right-to-Left) layout building blocks.
|
|
3
|
+
*
|
|
4
|
+
* These utilities provide the foundation for RTL support. Chart-level
|
|
5
|
+
* integration (price axis flip, time axis mirroring, tooltip/menu layout)
|
|
6
|
+
* uses these helpers when the `direction` option is set.
|
|
7
|
+
*/
|
|
8
|
+
export type TextDirection = 'ltr' | 'rtl';
|
|
9
|
+
/**
|
|
10
|
+
* Detect text direction from a locale string.
|
|
11
|
+
* Returns 'rtl' for Arabic, Hebrew, Persian, Urdu, and other RTL locales.
|
|
12
|
+
*/
|
|
13
|
+
export declare function detectDirection(locale: string): TextDirection;
|
|
14
|
+
/**
|
|
15
|
+
* Mirror an X coordinate for RTL layout.
|
|
16
|
+
* In RTL mode, x=0 becomes x=width and vice versa.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mirrorX(x: number, width: number, isRTL: boolean): number;
|
|
19
|
+
/**
|
|
20
|
+
* Get the CSS text-align value for the current direction.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveTextAlign(align: 'start' | 'end', isRTL: boolean): 'left' | 'right';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SegmentTree for O(log n) range min/max queries on Float64Array data.
|
|
3
|
+
*
|
|
4
|
+
* Supports incremental updates: when new data is appended, only the
|
|
5
|
+
* affected tree nodes are rebuilt — no full reconstruction needed.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MinMaxSegmentTree {
|
|
8
|
+
private _minTree;
|
|
9
|
+
private _maxTree;
|
|
10
|
+
private _size;
|
|
11
|
+
private _n;
|
|
12
|
+
constructor(capacity: number);
|
|
13
|
+
get length(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Build the tree from the given high/low arrays.
|
|
16
|
+
* O(n) time.
|
|
17
|
+
*/
|
|
18
|
+
build(high: Float64Array, low: Float64Array, length: number): void;
|
|
19
|
+
/**
|
|
20
|
+
* Update a single index (e.g., when the last bar is modified).
|
|
21
|
+
* O(log n) time.
|
|
22
|
+
*/
|
|
23
|
+
update(index: number, high: number, low: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Append a new value (for streaming data).
|
|
26
|
+
* O(log n) time.
|
|
27
|
+
*/
|
|
28
|
+
append(high: number, low: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Query the min low and max high in the range [from, to] (inclusive).
|
|
31
|
+
* O(log n) time.
|
|
32
|
+
*/
|
|
33
|
+
query(from: number, to: number): {
|
|
34
|
+
min: number;
|
|
35
|
+
max: number;
|
|
36
|
+
};
|
|
37
|
+
private _grow;
|
|
38
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type MarkerShape = 'circle' | 'square' | 'arrowUp' | 'arrowDown';
|
|
2
|
+
export type MarkerPosition = 'aboveBar' | 'belowBar' | 'inBar';
|
|
3
|
+
export interface SeriesMarker {
|
|
4
|
+
time: number;
|
|
5
|
+
position: MarkerPosition;
|
|
6
|
+
shape: MarkerShape;
|
|
7
|
+
color: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
export type EventType = 'earnings' | 'dividend' | 'split' | 'ipo' | 'other';
|
|
13
|
+
export interface ChartEvent extends SeriesMarker {
|
|
14
|
+
eventType: EventType;
|
|
15
|
+
title: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IStorageAdapter — interface for persisting chart drawings and state.
|
|
3
|
+
*
|
|
4
|
+
* Implementations can use localStorage, IndexedDB, REST API, etc.
|
|
5
|
+
*/
|
|
6
|
+
export interface IStorageAdapter {
|
|
7
|
+
save(key: string, state: unknown): Promise<void>;
|
|
8
|
+
load(key: string): Promise<unknown | null>;
|
|
9
|
+
delete(key: string): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* LocalStorageAdapter — persists data to browser localStorage.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LocalStorageAdapter implements IStorageAdapter {
|
|
15
|
+
private _prefix;
|
|
16
|
+
constructor(prefix?: string);
|
|
17
|
+
save(key: string, state: unknown): Promise<void>;
|
|
18
|
+
load(key: string): Promise<unknown | null>;
|
|
19
|
+
delete(key: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* IndexedDBAdapter — persists data to browser IndexedDB for larger state.
|
|
23
|
+
*/
|
|
24
|
+
export declare class IndexedDBAdapter implements IStorageAdapter {
|
|
25
|
+
private _dbName;
|
|
26
|
+
private _storeName;
|
|
27
|
+
private _dbPromise;
|
|
28
|
+
constructor(dbName?: string, storeName?: string);
|
|
29
|
+
private _getDB;
|
|
30
|
+
save(key: string, state: unknown): Promise<void>;
|
|
31
|
+
load(key: string): Promise<unknown | null>;
|
|
32
|
+
delete(key: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* DrawingPersistence — manages auto-save/load of drawings per symbol.
|
|
36
|
+
*/
|
|
37
|
+
export declare class DrawingPersistence {
|
|
38
|
+
private _adapter;
|
|
39
|
+
private _debounceMs;
|
|
40
|
+
private _debounceTimer;
|
|
41
|
+
constructor(adapter: IStorageAdapter, debounceMs?: number);
|
|
42
|
+
/** Auto-save drawings for a symbol (debounced). */
|
|
43
|
+
saveDrawings(symbol: string, drawings: unknown): void;
|
|
44
|
+
/** Load drawings for a symbol. */
|
|
45
|
+
loadDrawings(symbol: string): Promise<unknown | null>;
|
|
46
|
+
/** Delete drawings for a symbol. */
|
|
47
|
+
deleteDrawings(symbol: string): Promise<void>;
|
|
48
|
+
/** Flush any pending debounced save immediately. */
|
|
49
|
+
flush(): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Bar } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* IStreamingAdapter — interface for real-time bar data streaming.
|
|
4
|
+
*
|
|
5
|
+
* Implementations connect to WebSocket, polling, or SSE endpoints
|
|
6
|
+
* and push bar updates to the chart via callbacks.
|
|
7
|
+
*/
|
|
8
|
+
export interface IStreamingAdapter {
|
|
9
|
+
/** Connect to the data source. */
|
|
10
|
+
connect(): void;
|
|
11
|
+
/** Disconnect and clean up. */
|
|
12
|
+
disconnect(): void;
|
|
13
|
+
/** Subscribe to real-time bar updates for a symbol/resolution. */
|
|
14
|
+
subscribeBars(symbol: string, resolution: string, onBar: (bar: Bar) => void): void;
|
|
15
|
+
/** Unsubscribe from bar updates. */
|
|
16
|
+
unsubscribeBars(symbol: string, resolution: string): void;
|
|
17
|
+
}
|
|
18
|
+
export interface WebSocketAdapterOptions {
|
|
19
|
+
/** WebSocket URL (e.g., 'wss://stream.example.com/bars'). */
|
|
20
|
+
url: string;
|
|
21
|
+
/** Auto-reconnect on disconnect (default: true). */
|
|
22
|
+
reconnect?: boolean;
|
|
23
|
+
/** Max reconnect attempts (default: 10, 0 = unlimited). */
|
|
24
|
+
maxReconnectAttempts?: number;
|
|
25
|
+
/** Initial reconnect delay in ms (default: 1000). Doubles each attempt. */
|
|
26
|
+
reconnectDelay?: number;
|
|
27
|
+
/** Max reconnect delay in ms (default: 30000). */
|
|
28
|
+
maxReconnectDelay?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Parse an incoming WebSocket message into a Bar.
|
|
31
|
+
* Return null to skip the message.
|
|
32
|
+
*/
|
|
33
|
+
parseMessage?: (data: unknown) => {
|
|
34
|
+
symbol: string;
|
|
35
|
+
resolution: string;
|
|
36
|
+
bar: Bar;
|
|
37
|
+
} | null;
|
|
38
|
+
}
|
|
39
|
+
type BarCallback = (bar: Bar) => void;
|
|
40
|
+
/**
|
|
41
|
+
* WebSocketAdapter — streams bar data over a WebSocket connection
|
|
42
|
+
* with automatic reconnection and exponential backoff.
|
|
43
|
+
*/
|
|
44
|
+
export declare class WebSocketAdapter implements IStreamingAdapter {
|
|
45
|
+
private _options;
|
|
46
|
+
private _ws;
|
|
47
|
+
private _subscriptions;
|
|
48
|
+
private _reconnectAttempts;
|
|
49
|
+
private _reconnectTimer;
|
|
50
|
+
private _connected;
|
|
51
|
+
private _intentionalClose;
|
|
52
|
+
constructor(options: WebSocketAdapterOptions);
|
|
53
|
+
get connected(): boolean;
|
|
54
|
+
get reconnectAttempts(): number;
|
|
55
|
+
connect(): void;
|
|
56
|
+
disconnect(): void;
|
|
57
|
+
subscribeBars(symbol: string, resolution: string, onBar: BarCallback): void;
|
|
58
|
+
unsubscribeBars(symbol: string, resolution: string): void;
|
|
59
|
+
private _createConnection;
|
|
60
|
+
private _scheduleReconnect;
|
|
61
|
+
private _clearReconnectTimer;
|
|
62
|
+
}
|
|
63
|
+
export interface PollingAdapterOptions {
|
|
64
|
+
/** Fetch function that returns the latest bar for a symbol/resolution. */
|
|
65
|
+
fetchBar: (symbol: string, resolution: string) => Promise<Bar | null>;
|
|
66
|
+
/** Polling interval in ms (default: 5000). */
|
|
67
|
+
interval?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* PollingAdapter — polls a REST endpoint at regular intervals
|
|
71
|
+
* for the latest bar data.
|
|
72
|
+
*/
|
|
73
|
+
export declare class PollingAdapter implements IStreamingAdapter {
|
|
74
|
+
private _options;
|
|
75
|
+
private _interval;
|
|
76
|
+
private _timers;
|
|
77
|
+
private _subscriptions;
|
|
78
|
+
private _fetching;
|
|
79
|
+
constructor(options: PollingAdapterOptions);
|
|
80
|
+
connect(): void;
|
|
81
|
+
disconnect(): void;
|
|
82
|
+
subscribeBars(symbol: string, resolution: string, onBar: BarCallback): void;
|
|
83
|
+
unsubscribeBars(symbol: string, resolution: string): void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* TickBuffer — collects incoming ticks and flushes them at 60fps
|
|
87
|
+
* to avoid overwhelming the chart with per-tick repaints.
|
|
88
|
+
*/
|
|
89
|
+
export declare class TickBuffer {
|
|
90
|
+
private _buffer;
|
|
91
|
+
private _flushCallbacks;
|
|
92
|
+
private _rafId;
|
|
93
|
+
/** Register a flush callback for a symbol:resolution key. */
|
|
94
|
+
register(key: string, onFlush: BarCallback): void;
|
|
95
|
+
/** Unregister and stop flushing for a key. */
|
|
96
|
+
unregister(key: string): void;
|
|
97
|
+
/** Push a tick into the buffer (latest tick wins per key). */
|
|
98
|
+
push(key: string, bar: Bar): void;
|
|
99
|
+
private _startLoop;
|
|
100
|
+
private _stopLoop;
|
|
101
|
+
}
|
|
102
|
+
export {};
|