@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,115 @@
|
|
|
1
|
+
import { Bar, ColumnData, SeriesType, ISeriesPrimitive } from '../core/types';
|
|
2
|
+
import { DataLayer } from '../core/data-layer';
|
|
3
|
+
import { PriceScale } from '../core/price-scale';
|
|
4
|
+
import { SeriesMarker, ChartEvent } from '../core/series-markers';
|
|
5
|
+
import { PriceLine, PriceLineOptions } from '../core/price-line';
|
|
6
|
+
import { SeriesOptionsMap } from './options';
|
|
7
|
+
export type DataChangedCallback = () => void;
|
|
8
|
+
export type VisibilityChangeCallback = (visible: boolean) => void;
|
|
9
|
+
export interface ISeriesApi<T extends SeriesType> {
|
|
10
|
+
/** Replace all data on this series. */
|
|
11
|
+
setData(data: Bar[] | ColumnData): void;
|
|
12
|
+
/** Append or update a single bar (real-time). */
|
|
13
|
+
update(bar: Bar): void;
|
|
14
|
+
/** Attach a custom series primitive (plugin). */
|
|
15
|
+
attachPrimitive(primitive: ISeriesPrimitive): void;
|
|
16
|
+
/** Detach a previously attached primitive. */
|
|
17
|
+
detachPrimitive(primitive: ISeriesPrimitive): void;
|
|
18
|
+
/** Update the series options. */
|
|
19
|
+
applyOptions(options: Partial<SeriesOptionsMap[T]>): void;
|
|
20
|
+
/** Return the current series options. */
|
|
21
|
+
options(): SeriesOptionsMap[T];
|
|
22
|
+
/** Return the associated price scale. */
|
|
23
|
+
priceScale(): PriceScale;
|
|
24
|
+
/** Return the bar at the given index, or null. */
|
|
25
|
+
dataByIndex(index: number): Bar | null;
|
|
26
|
+
/** The series type. */
|
|
27
|
+
seriesType(): T;
|
|
28
|
+
/** Set markers on this series. */
|
|
29
|
+
setMarkers(markers: SeriesMarker[]): void;
|
|
30
|
+
/** Get current markers. */
|
|
31
|
+
getMarkers(): readonly SeriesMarker[];
|
|
32
|
+
/** Set chart events on this series. */
|
|
33
|
+
setEvents(events: ChartEvent[]): void;
|
|
34
|
+
/** Get current chart events. */
|
|
35
|
+
getEvents(): readonly ChartEvent[];
|
|
36
|
+
/** Create a horizontal price line on this series. */
|
|
37
|
+
createPriceLine(options: PriceLineOptions): PriceLine;
|
|
38
|
+
/** Remove a price line. */
|
|
39
|
+
removePriceLine(line: PriceLine): void;
|
|
40
|
+
/** Get all price lines. */
|
|
41
|
+
getPriceLines(): readonly PriceLine[];
|
|
42
|
+
/** Prepend historical bars to the beginning of the series (for pagination). */
|
|
43
|
+
prependData(data: Bar[] | ColumnData): void;
|
|
44
|
+
/**
|
|
45
|
+
* Return metadata about how many bars fall outside the given logical index range.
|
|
46
|
+
* Useful for deciding when to load more historical data.
|
|
47
|
+
*/
|
|
48
|
+
barsInLogicalRange(range: {
|
|
49
|
+
from: number;
|
|
50
|
+
to: number;
|
|
51
|
+
}): {
|
|
52
|
+
barsBefore: number;
|
|
53
|
+
barsAfter: number;
|
|
54
|
+
from: number;
|
|
55
|
+
to: number;
|
|
56
|
+
};
|
|
57
|
+
/** Subscribe to data changes (setData / update). */
|
|
58
|
+
subscribeDataChanged(callback: DataChangedCallback): void;
|
|
59
|
+
/** Unsubscribe from data changes. */
|
|
60
|
+
unsubscribeDataChanged(callback: DataChangedCallback): void;
|
|
61
|
+
/** Subscribe to visibility changes. */
|
|
62
|
+
subscribeVisibilityChange(callback: VisibilityChangeCallback): void;
|
|
63
|
+
/** Unsubscribe from visibility changes. */
|
|
64
|
+
unsubscribeVisibilityChange(callback: VisibilityChangeCallback): void;
|
|
65
|
+
}
|
|
66
|
+
export declare class SeriesApi<T extends SeriesType> implements ISeriesApi<T> {
|
|
67
|
+
private _type;
|
|
68
|
+
private _dataLayer;
|
|
69
|
+
private _priceScale;
|
|
70
|
+
private _options;
|
|
71
|
+
private _primitives;
|
|
72
|
+
private _markers;
|
|
73
|
+
private _events;
|
|
74
|
+
private _priceLines;
|
|
75
|
+
private _requestRepaint;
|
|
76
|
+
private _visible;
|
|
77
|
+
private _dataChangedCallbacks;
|
|
78
|
+
private _visibilityChangeCallbacks;
|
|
79
|
+
constructor(type: T, dataLayer: DataLayer, priceScale: PriceScale, options: SeriesOptionsMap[T], requestRepaint: () => void);
|
|
80
|
+
setData(data: Bar[] | ColumnData): void;
|
|
81
|
+
update(bar: Bar): void;
|
|
82
|
+
prependData(data: Bar[] | ColumnData): void;
|
|
83
|
+
barsInLogicalRange(range: {
|
|
84
|
+
from: number;
|
|
85
|
+
to: number;
|
|
86
|
+
}): {
|
|
87
|
+
barsBefore: number;
|
|
88
|
+
barsAfter: number;
|
|
89
|
+
from: number;
|
|
90
|
+
to: number;
|
|
91
|
+
};
|
|
92
|
+
attachPrimitive(primitive: ISeriesPrimitive): void;
|
|
93
|
+
detachPrimitive(primitive: ISeriesPrimitive): void;
|
|
94
|
+
applyOptions(options: Partial<SeriesOptionsMap[T]>): void;
|
|
95
|
+
options(): SeriesOptionsMap[T];
|
|
96
|
+
priceScale(): PriceScale;
|
|
97
|
+
dataByIndex(index: number): Bar | null;
|
|
98
|
+
seriesType(): T;
|
|
99
|
+
setMarkers(markers: SeriesMarker[]): void;
|
|
100
|
+
getMarkers(): readonly SeriesMarker[];
|
|
101
|
+
setEvents(events: ChartEvent[]): void;
|
|
102
|
+
getEvents(): readonly ChartEvent[];
|
|
103
|
+
createPriceLine(options: PriceLineOptions): PriceLine;
|
|
104
|
+
removePriceLine(line: PriceLine): void;
|
|
105
|
+
getPriceLines(): readonly PriceLine[];
|
|
106
|
+
subscribeDataChanged(callback: DataChangedCallback): void;
|
|
107
|
+
unsubscribeDataChanged(callback: DataChangedCallback): void;
|
|
108
|
+
subscribeVisibilityChange(callback: VisibilityChangeCallback): void;
|
|
109
|
+
unsubscribeVisibilityChange(callback: VisibilityChangeCallback): void;
|
|
110
|
+
getDataLayer(): DataLayer;
|
|
111
|
+
getPrimitives(): readonly ISeriesPrimitive[];
|
|
112
|
+
isVisible(): boolean;
|
|
113
|
+
private _notifyPrimitives;
|
|
114
|
+
private _emitDataChanged;
|
|
115
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export interface BarData {
|
|
2
|
+
time: number;
|
|
3
|
+
open: number;
|
|
4
|
+
high: number;
|
|
5
|
+
low: number;
|
|
6
|
+
close: number;
|
|
7
|
+
volume?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ChartAccessibility manages ARIA live regions and focus management for
|
|
11
|
+
* screen-reader support on financial charts. It provides methods to announce
|
|
12
|
+
* price changes, OHLCV bar data, and manage keyboard navigation state.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ChartAccessibility {
|
|
15
|
+
private _container;
|
|
16
|
+
private _liveRegion;
|
|
17
|
+
private _description;
|
|
18
|
+
private _focusedBarIndex;
|
|
19
|
+
private _totalBars;
|
|
20
|
+
private _disposed;
|
|
21
|
+
/**
|
|
22
|
+
* Create a hidden ARIA live region inside the given container.
|
|
23
|
+
* The live region is used to announce dynamic content to screen readers.
|
|
24
|
+
*/
|
|
25
|
+
createAriaLiveRegion(container: HTMLElement): HTMLElement;
|
|
26
|
+
/**
|
|
27
|
+
* Announce the current price and change to screen readers.
|
|
28
|
+
* @param price - The current price value.
|
|
29
|
+
* @param change - The price change (positive or negative).
|
|
30
|
+
*/
|
|
31
|
+
announcePrice(price: number, change: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Announce OHLCV bar data to screen readers.
|
|
34
|
+
* @param bar - The bar data to announce.
|
|
35
|
+
*/
|
|
36
|
+
announceBar(bar: BarData): void;
|
|
37
|
+
/**
|
|
38
|
+
* Set a description on the chart container as aria-label.
|
|
39
|
+
* @param description - The description text.
|
|
40
|
+
*/
|
|
41
|
+
setChartDescription(description: string): void;
|
|
42
|
+
/** Get the current chart description. */
|
|
43
|
+
getChartDescription(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Set the chart container as focusable and focus it.
|
|
46
|
+
* This enables keyboard navigation on the chart.
|
|
47
|
+
*/
|
|
48
|
+
focusChart(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Set the total number of bars for keyboard navigation.
|
|
51
|
+
*/
|
|
52
|
+
setTotalBars(count: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get the currently focused bar index for keyboard navigation.
|
|
55
|
+
* Returns -1 if no bar is focused.
|
|
56
|
+
*/
|
|
57
|
+
get focusedBarIndex(): number;
|
|
58
|
+
/** Get total bars available for navigation. */
|
|
59
|
+
get totalBars(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Move focus to the next bar (right arrow key).
|
|
62
|
+
* Returns the new focused bar index, or -1 if at the end.
|
|
63
|
+
*/
|
|
64
|
+
focusNextBar(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Move focus to the previous bar (left arrow key).
|
|
67
|
+
* Returns the new focused bar index, or -1 if at the beginning.
|
|
68
|
+
*/
|
|
69
|
+
focusPreviousBar(): number;
|
|
70
|
+
/**
|
|
71
|
+
* Move focus to the first bar.
|
|
72
|
+
*/
|
|
73
|
+
focusFirstBar(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Move focus to the last bar.
|
|
76
|
+
*/
|
|
77
|
+
focusLastBar(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Reset focused bar index.
|
|
80
|
+
*/
|
|
81
|
+
resetFocus(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Get the ARIA live region element (or null if not created).
|
|
84
|
+
*/
|
|
85
|
+
get liveRegion(): HTMLElement | null;
|
|
86
|
+
/**
|
|
87
|
+
* Clean up: remove the live region from the DOM and reset state.
|
|
88
|
+
*/
|
|
89
|
+
dispose(): void;
|
|
90
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type AlertTriggerMode = 'crossing-up' | 'crossing-down' | 'crossing-either';
|
|
2
|
+
export type AlertLineCallback = (alert: AlertLine, direction: 'up' | 'down') => void;
|
|
3
|
+
export interface AlertLineOptions {
|
|
4
|
+
price: number;
|
|
5
|
+
color: string;
|
|
6
|
+
lineWidth: number;
|
|
7
|
+
lineStyle: 'solid' | 'dashed' | 'dotted';
|
|
8
|
+
title: string;
|
|
9
|
+
triggerMode: AlertTriggerMode;
|
|
10
|
+
/** Whether the alert is armed (will fire callbacks on crossing). */
|
|
11
|
+
armed: boolean;
|
|
12
|
+
/** Show a bell icon on the price axis. */
|
|
13
|
+
axisLabelVisible: boolean;
|
|
14
|
+
axisLabelColor?: string;
|
|
15
|
+
axisLabelTextColor?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const DEFAULT_ALERT_LINE_OPTIONS: AlertLineOptions;
|
|
18
|
+
/**
|
|
19
|
+
* AlertLine — a price level that fires callbacks when the current price
|
|
20
|
+
* crosses it. Distinct from PriceLine: alerts have armed/disarmed state,
|
|
21
|
+
* trigger modes, and can be dragged to adjust the price.
|
|
22
|
+
*/
|
|
23
|
+
export declare class AlertLine {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
private _options;
|
|
26
|
+
private _callbacks;
|
|
27
|
+
private _lastPrice;
|
|
28
|
+
private _requestRepaint;
|
|
29
|
+
constructor(id: string, options: AlertLineOptions, requestRepaint?: () => void);
|
|
30
|
+
get options(): Readonly<AlertLineOptions>;
|
|
31
|
+
applyOptions(opts: Partial<AlertLineOptions>): void;
|
|
32
|
+
/** Subscribe to alert trigger events. */
|
|
33
|
+
onTriggered(callback: AlertLineCallback): void;
|
|
34
|
+
/** Unsubscribe from alert trigger events. */
|
|
35
|
+
offTriggered(callback: AlertLineCallback): void;
|
|
36
|
+
/** Arm or disarm the alert. */
|
|
37
|
+
setArmed(armed: boolean): void;
|
|
38
|
+
isArmed(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the current price has crossed the alert level since the last
|
|
41
|
+
* check, and fire callbacks if so. Called by the chart on each data update.
|
|
42
|
+
*/
|
|
43
|
+
checkCrossing(currentPrice: number): void;
|
|
44
|
+
/** Serialize to a plain object for chart state save/restore. */
|
|
45
|
+
serialize(): {
|
|
46
|
+
id: string;
|
|
47
|
+
options: AlertLineOptions;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DeepPartial, SeriesType } from './types';
|
|
2
|
+
import { ChartOptions, IndicatorType } from '../api/options';
|
|
3
|
+
import { Periodicity } from './periodicity';
|
|
4
|
+
import { MarketSession } from './market-session';
|
|
5
|
+
import { SerializedDrawing } from '../drawings/base';
|
|
6
|
+
export declare const CHART_STATE_VERSION = 1;
|
|
7
|
+
export interface ChartState {
|
|
8
|
+
version: number;
|
|
9
|
+
options: DeepPartial<ChartOptions>;
|
|
10
|
+
periodicity?: Periodicity;
|
|
11
|
+
comparisonMode?: boolean;
|
|
12
|
+
timeScale: {
|
|
13
|
+
barSpacing: number;
|
|
14
|
+
rightOffset: number;
|
|
15
|
+
};
|
|
16
|
+
series: Array<{
|
|
17
|
+
id: string;
|
|
18
|
+
type: SeriesType;
|
|
19
|
+
options: Record<string, unknown>;
|
|
20
|
+
}>;
|
|
21
|
+
indicators: Array<{
|
|
22
|
+
type: IndicatorType;
|
|
23
|
+
sourceSeriesId: string;
|
|
24
|
+
params: Record<string, number>;
|
|
25
|
+
color?: string;
|
|
26
|
+
}>;
|
|
27
|
+
panes: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
height: number;
|
|
30
|
+
}>;
|
|
31
|
+
drawings: SerializedDrawing[];
|
|
32
|
+
marketSessions?: MarketSession[];
|
|
33
|
+
sessionFilter?: string;
|
|
34
|
+
visibleRange?: {
|
|
35
|
+
from: number;
|
|
36
|
+
to: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare function validateChartState(state: unknown): state is ChartState;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal chart interface required for synchronization.
|
|
3
|
+
* Compatible with IChartApi but allows lightweight mocking in tests.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISyncableChart {
|
|
6
|
+
subscribeCrosshairMove(callback: (state: SyncCrosshairState | null) => void): void;
|
|
7
|
+
unsubscribeCrosshairMove(callback: (state: SyncCrosshairState | null) => void): void;
|
|
8
|
+
subscribeVisibleRangeChange(callback: (range: {
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
} | null) => void): void;
|
|
12
|
+
unsubscribeVisibleRangeChange(callback: (range: {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
} | null) => void): void;
|
|
16
|
+
setVisibleRange(from: number, to: number): void;
|
|
17
|
+
}
|
|
18
|
+
export interface SyncCrosshairState {
|
|
19
|
+
time: number;
|
|
20
|
+
price: number;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
barIndex: number;
|
|
24
|
+
}
|
|
25
|
+
export type CrosshairSyncCallback = (sourceChart: ISyncableChart, state: SyncCrosshairState | null) => void;
|
|
26
|
+
export type TimeScaleSyncCallback = (sourceChart: ISyncableChart, range: {
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
}) => void;
|
|
30
|
+
/**
|
|
31
|
+
* ChartSyncGroup synchronizes multiple chart instances so that crosshair
|
|
32
|
+
* movement and time-scale panning/zooming on one chart is mirrored to all
|
|
33
|
+
* others in the group.
|
|
34
|
+
*
|
|
35
|
+
* Usage:
|
|
36
|
+
* ```ts
|
|
37
|
+
* const group = new ChartSyncGroup();
|
|
38
|
+
* group.addChart(chart1);
|
|
39
|
+
* group.addChart(chart2);
|
|
40
|
+
* group.syncCrosshair(); // enable crosshair sync
|
|
41
|
+
* group.syncTimeScale(); // enable time-scale sync
|
|
42
|
+
* // later:
|
|
43
|
+
* group.dispose();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class ChartSyncGroup {
|
|
47
|
+
private _entries;
|
|
48
|
+
private _crosshairSyncing;
|
|
49
|
+
private _timeScaleSyncing;
|
|
50
|
+
private _disposed;
|
|
51
|
+
/** Guard flag to prevent re-entrant crosshair sync loops. */
|
|
52
|
+
private _broadcastingCrosshair;
|
|
53
|
+
/** Guard flag to prevent re-entrant time-scale sync loops. */
|
|
54
|
+
private _broadcastingTimeScale;
|
|
55
|
+
private _crosshairCallbacks;
|
|
56
|
+
private _timeScaleCallbacks;
|
|
57
|
+
/** Add a chart to the sync group. */
|
|
58
|
+
addChart(chart: ISyncableChart): void;
|
|
59
|
+
/** Remove a chart from the sync group. */
|
|
60
|
+
removeChart(chart: ISyncableChart): void;
|
|
61
|
+
/** Enable crosshair synchronization across all charts in the group. */
|
|
62
|
+
syncCrosshair(): void;
|
|
63
|
+
/** Enable time-scale synchronization across all charts in the group. */
|
|
64
|
+
syncTimeScale(): void;
|
|
65
|
+
/** Subscribe to crosshair sync events for custom handling. */
|
|
66
|
+
onCrosshairSync(callback: CrosshairSyncCallback): void;
|
|
67
|
+
/** Unsubscribe from crosshair sync events for custom handling. */
|
|
68
|
+
offCrosshairSync(callback: CrosshairSyncCallback): void;
|
|
69
|
+
/** Subscribe to time-scale sync events for custom handling. */
|
|
70
|
+
onTimeScaleSync(callback: TimeScaleSyncCallback): void;
|
|
71
|
+
/** Unsubscribe from time-scale sync events for custom handling. */
|
|
72
|
+
offTimeScaleSync(callback: TimeScaleSyncCallback): void;
|
|
73
|
+
/** Get the number of charts in the group. */
|
|
74
|
+
get chartCount(): number;
|
|
75
|
+
/** Whether crosshair sync is active. */
|
|
76
|
+
get isCrosshairSyncing(): boolean;
|
|
77
|
+
/** Whether time-scale sync is active. */
|
|
78
|
+
get isTimeScaleSyncing(): boolean;
|
|
79
|
+
/** Tear down all subscriptions and clear charts. */
|
|
80
|
+
dispose(): void;
|
|
81
|
+
private _onCrosshairMove;
|
|
82
|
+
private _onVisibleRangeChange;
|
|
83
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface CrosshairState {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
barIndex: number;
|
|
5
|
+
price: number;
|
|
6
|
+
time: number;
|
|
7
|
+
/** X coordinate snapped to the bar centre (optional — falls back to x). */
|
|
8
|
+
snappedX?: number;
|
|
9
|
+
/** The pane that generated this crosshair event. */
|
|
10
|
+
sourcePaneId?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class Crosshair {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
barIndex: number;
|
|
17
|
+
price: number;
|
|
18
|
+
time: number;
|
|
19
|
+
/** The ID of the pane the pointer is currently over. */
|
|
20
|
+
sourcePaneId: string;
|
|
21
|
+
private _snappedX;
|
|
22
|
+
/** X coordinate snapped to the bar centre; falls back to x if not provided. */
|
|
23
|
+
get snappedX(): number;
|
|
24
|
+
/** Make the crosshair visible and update all properties. */
|
|
25
|
+
update(state: CrosshairState): void;
|
|
26
|
+
/** Hide the crosshair. */
|
|
27
|
+
hide(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DeepPartial } from './types';
|
|
2
|
+
import { ChartOptions } from '../api/options';
|
|
3
|
+
/**
|
|
4
|
+
* CSS custom property names used by fin-charter.
|
|
5
|
+
* All prefixed with --fc- to avoid collisions.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CSS_VARS: {
|
|
8
|
+
readonly bg: "--fc-bg";
|
|
9
|
+
readonly text: "--fc-text";
|
|
10
|
+
readonly fontSize: "--fc-font-size";
|
|
11
|
+
readonly fontFamily: "--fc-font-family";
|
|
12
|
+
readonly gridHorzColor: "--fc-grid-horz-color";
|
|
13
|
+
readonly gridVertColor: "--fc-grid-vert-color";
|
|
14
|
+
readonly crosshairVertColor: "--fc-crosshair-vert-color";
|
|
15
|
+
readonly crosshairHorzColor: "--fc-crosshair-horz-color";
|
|
16
|
+
readonly candleUpColor: "--fc-candle-up";
|
|
17
|
+
readonly candleDownColor: "--fc-candle-down";
|
|
18
|
+
readonly lineColor: "--fc-line-color";
|
|
19
|
+
readonly areaTopColor: "--fc-area-top";
|
|
20
|
+
readonly areaBottomColor: "--fc-area-bottom";
|
|
21
|
+
readonly areaLineColor: "--fc-area-line";
|
|
22
|
+
readonly volumeUpColor: "--fc-volume-up";
|
|
23
|
+
readonly volumeDownColor: "--fc-volume-down";
|
|
24
|
+
readonly watermarkColor: "--fc-watermark-color";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Read CSS custom properties from a container element and return
|
|
28
|
+
* a partial ChartOptions object. Undefined properties (not set in CSS)
|
|
29
|
+
* are omitted so mergeOptions will skip them.
|
|
30
|
+
*/
|
|
31
|
+
export declare function readCSSTheme(container: HTMLElement): DeepPartial<ChartOptions>;
|
|
32
|
+
/**
|
|
33
|
+
* Generate a CSS string that sets all custom properties for a theme.
|
|
34
|
+
* Can be applied to a container element via `element.style.cssText` or
|
|
35
|
+
* inserted into a <style> block.
|
|
36
|
+
*/
|
|
37
|
+
export declare function generateCSSTheme(options: DeepPartial<ChartOptions>): string;
|
|
38
|
+
/**
|
|
39
|
+
* Apply CSS custom properties for a theme directly to an element.
|
|
40
|
+
*/
|
|
41
|
+
export declare function applyCSSTheme(element: HTMLElement, options: DeepPartial<ChartOptions>): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ColumnStore } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Output descriptor for a custom indicator output line.
|
|
4
|
+
*/
|
|
5
|
+
export interface IndicatorOutput {
|
|
6
|
+
/** Name of this output (e.g., 'upper', 'middle', 'lower'). */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Default color for rendering. */
|
|
9
|
+
color?: string;
|
|
10
|
+
/** Rendering style: 'line' (default), 'histogram', 'dots', 'area'. */
|
|
11
|
+
style?: 'line' | 'histogram' | 'dots' | 'area';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parameter descriptor for a custom indicator parameter.
|
|
15
|
+
*/
|
|
16
|
+
export interface IndicatorParam {
|
|
17
|
+
/** Parameter name. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Default value. */
|
|
20
|
+
defaultValue: number;
|
|
21
|
+
/** Minimum value (for UI validation). */
|
|
22
|
+
min?: number;
|
|
23
|
+
/** Maximum value (for UI validation). */
|
|
24
|
+
max?: number;
|
|
25
|
+
/** Step for UI controls. */
|
|
26
|
+
step?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compute function signature for custom indicators.
|
|
30
|
+
* Receives the ColumnStore and parameter values, returns a map of output name → Float64Array.
|
|
31
|
+
*/
|
|
32
|
+
export type IndicatorComputeFn = (store: ColumnStore, params: Record<string, number>) => Map<string, Float64Array>;
|
|
33
|
+
/**
|
|
34
|
+
* Descriptor for registering a custom indicator.
|
|
35
|
+
*/
|
|
36
|
+
export interface CustomIndicatorDescriptor {
|
|
37
|
+
/** Unique name for this indicator type. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Human-readable label for UI. */
|
|
40
|
+
label: string;
|
|
41
|
+
/** Whether this indicator overlays on the main price chart or gets its own pane. */
|
|
42
|
+
overlay: boolean;
|
|
43
|
+
/** Parameter definitions with defaults. */
|
|
44
|
+
params: IndicatorParam[];
|
|
45
|
+
/** Output definitions (multiple outputs supported, e.g., MACD has signal + histogram). */
|
|
46
|
+
outputs: IndicatorOutput[];
|
|
47
|
+
/** Compute function that produces output values from bar data and parameters. */
|
|
48
|
+
compute: IndicatorComputeFn;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Registry for custom indicator types.
|
|
52
|
+
* Indicators registered here appear alongside built-in indicators.
|
|
53
|
+
*/
|
|
54
|
+
export declare class CustomIndicatorRegistry {
|
|
55
|
+
private _descriptors;
|
|
56
|
+
/** Register a custom indicator type. */
|
|
57
|
+
register(descriptor: CustomIndicatorDescriptor): void;
|
|
58
|
+
/** Unregister a custom indicator type. */
|
|
59
|
+
unregister(name: string): boolean;
|
|
60
|
+
/** Get a registered descriptor by name. */
|
|
61
|
+
get(name: string): CustomIndicatorDescriptor | undefined;
|
|
62
|
+
/** List all registered custom indicator names. */
|
|
63
|
+
list(): string[];
|
|
64
|
+
/** Check if a custom indicator type is registered. */
|
|
65
|
+
has(name: string): boolean;
|
|
66
|
+
/** Get all registered descriptors. */
|
|
67
|
+
getAll(): CustomIndicatorDescriptor[];
|
|
68
|
+
/** Compute a custom indicator's outputs for the given data and params. */
|
|
69
|
+
compute(name: string, store: ColumnStore, params: Record<string, number>): Map<string, Float64Array>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Bar } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* IDataFeed — abstraction for fetching OHLCV bar data with pagination.
|
|
4
|
+
*
|
|
5
|
+
* Implementations provide a `getBars()` method that the chart calls when
|
|
6
|
+
* the user scrolls to the edge and more historical data is needed.
|
|
7
|
+
*/
|
|
8
|
+
export interface IDataFeed {
|
|
9
|
+
/**
|
|
10
|
+
* Fetch bars for the given symbol and resolution within the time range.
|
|
11
|
+
* @param symbol - Symbol identifier (e.g., 'AAPL', 'BTCUSD')
|
|
12
|
+
* @param resolution - Bar interval (e.g., '1', '5', '15', '60', 'D', 'W')
|
|
13
|
+
* @param from - Start of range (Unix timestamp, seconds)
|
|
14
|
+
* @param to - End of range (Unix timestamp, seconds)
|
|
15
|
+
* @returns Promise resolving to an array of bars, sorted by time ascending.
|
|
16
|
+
* Empty array means no more data available for the requested range.
|
|
17
|
+
*/
|
|
18
|
+
getBars(symbol: string, resolution: string, from: number, to: number): Promise<Bar[]>;
|
|
19
|
+
}
|
|
20
|
+
export interface DataFeedManagerOptions {
|
|
21
|
+
/** Maximum number of cached range entries per symbol+resolution (default: 100). */
|
|
22
|
+
maxCacheEntries?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* DataFeedManager wraps an IDataFeed with:
|
|
26
|
+
* - Request deduplication (won't re-fetch the same range)
|
|
27
|
+
* - Local cache with configurable size limit
|
|
28
|
+
* - Gap detection for missing ranges
|
|
29
|
+
* - Loading state tracking
|
|
30
|
+
*/
|
|
31
|
+
export declare class DataFeedManager {
|
|
32
|
+
private _feed;
|
|
33
|
+
private _cache;
|
|
34
|
+
private _pendingRequests;
|
|
35
|
+
private _loading;
|
|
36
|
+
private _maxCacheEntries;
|
|
37
|
+
constructor(feed: IDataFeed, options?: DataFeedManagerOptions);
|
|
38
|
+
/** Whether a fetch is currently in progress. */
|
|
39
|
+
get loading(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Fetch bars with deduplication and caching.
|
|
42
|
+
* If the requested range (or a superset) is already cached, returns cached data.
|
|
43
|
+
* Otherwise fetches from the underlying data feed and caches the result.
|
|
44
|
+
*/
|
|
45
|
+
getBars(symbol: string, resolution: string, from: number, to: number): Promise<Bar[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Detect gaps in cached data and return the missing ranges that need fetching.
|
|
48
|
+
*/
|
|
49
|
+
findGaps(symbol: string, resolution: string, from: number, to: number): Array<{
|
|
50
|
+
from: number;
|
|
51
|
+
to: number;
|
|
52
|
+
}>;
|
|
53
|
+
/** Clear the cache for a specific symbol+resolution, or all if not specified. */
|
|
54
|
+
clearCache(symbol?: string, resolution?: string): void;
|
|
55
|
+
/** Get the number of cached entries for a symbol+resolution. */
|
|
56
|
+
cacheSize(symbol: string, resolution: string): number;
|
|
57
|
+
private _findCachedBars;
|
|
58
|
+
private _addToCache;
|
|
59
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Bar, ColumnData, ColumnStore } from './types';
|
|
2
|
+
import { MinMaxSegmentTree } from './segment-tree';
|
|
3
|
+
export declare class DataLayer {
|
|
4
|
+
store: ColumnStore;
|
|
5
|
+
readonly segmentTree: MinMaxSegmentTree;
|
|
6
|
+
constructor();
|
|
7
|
+
/** Load data. Accepts either an array of Bar objects or a ColumnData (typed arrays). */
|
|
8
|
+
setData(data: Bar[] | ColumnData): void;
|
|
9
|
+
/**
|
|
10
|
+
* Upsert a single bar:
|
|
11
|
+
* - If the timestamp matches the last bar, overwrite in-place.
|
|
12
|
+
* - Otherwise append (growing the store if needed).
|
|
13
|
+
*/
|
|
14
|
+
update(bar: Bar): void;
|
|
15
|
+
/**
|
|
16
|
+
* Binary search for the index whose time is closest to `time`.
|
|
17
|
+
* Result is clamped to [0, length-1].
|
|
18
|
+
*/
|
|
19
|
+
findIndex(time: number): number;
|
|
20
|
+
/** Return the Bar at `index`, or null if out of bounds. */
|
|
21
|
+
barAt(index: number): Bar | null;
|
|
22
|
+
/**
|
|
23
|
+
* Prepend bars to the beginning of the store.
|
|
24
|
+
* Accepts either an array of Bar objects or a ColumnData (typed arrays).
|
|
25
|
+
* The prepended data must be strictly older than the existing data.
|
|
26
|
+
*/
|
|
27
|
+
prepend(data: Bar[] | ColumnData): void;
|
|
28
|
+
/**
|
|
29
|
+
* Query the min low and max high in the range [fromIdx, toIdx] (inclusive).
|
|
30
|
+
* O(log n) time via segment tree.
|
|
31
|
+
*/
|
|
32
|
+
queryMinMax(fromIdx: number, toIdx: number): {
|
|
33
|
+
min: number;
|
|
34
|
+
max: number;
|
|
35
|
+
};
|
|
36
|
+
/** Double the capacity of the store, preserving existing data. */
|
|
37
|
+
private grow;
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InvalidationLevelValue } from './types';
|
|
2
|
+
export declare class InvalidateMask {
|
|
3
|
+
/** Map from pane id → highest invalidation level for that pane. */
|
|
4
|
+
private _levels;
|
|
5
|
+
/** Register a pane (starts at None). */
|
|
6
|
+
addPane(id: string): void;
|
|
7
|
+
/** Remove a pane from tracking. */
|
|
8
|
+
removePane(id: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Set the invalidation level for a pane.
|
|
11
|
+
* Keeps whichever value is higher (existing vs. requested).
|
|
12
|
+
*/
|
|
13
|
+
invalidate(paneId: string, level: InvalidationLevelValue): void;
|
|
14
|
+
/** Apply `level` to every tracked pane. */
|
|
15
|
+
invalidateAll(level: InvalidationLevelValue): void;
|
|
16
|
+
/** Return the current invalidation level for a pane. */
|
|
17
|
+
level(paneId: string): InvalidationLevelValue;
|
|
18
|
+
/** True if at least one pane has a level above None. */
|
|
19
|
+
needsRepaint(): boolean;
|
|
20
|
+
/** Return all tracked pane ids. */
|
|
21
|
+
paneIds(): string[];
|
|
22
|
+
/** Reset all pane levels back to None. */
|
|
23
|
+
reset(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface MarketSession {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
startMinute: number;
|
|
5
|
+
endMinute: number;
|
|
6
|
+
bgColor: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const US_EQUITY_SESSIONS: MarketSession[];
|
|
9
|
+
export declare function isInSession(minuteOfDay: number, session: MarketSession): boolean;
|
|
10
|
+
export declare function getSessionForTime(minuteOfDay: number, sessions: MarketSession[]): MarketSession | null;
|
|
11
|
+
export declare function timestampToMinuteOfDay(timestamp: number, utcOffsetOrTimezone?: number | string): number;
|