openalgo-charts 1.0.1 → 1.0.2
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/dist/index.d.ts +99 -4
- package/dist/openalgo-charts.mjs +1 -1
- package/dist/openalgo-charts.mjs.map +1 -1
- package/dist/openalgo-charts.standalone.js +1 -1
- package/dist/openalgo-charts.standalone.js.map +1 -1
- package/dist/openalgo-charts.transform.mjs +1 -1
- package/dist/openalgo-charts.transform.mjs.map +1 -1
- package/dist/profile/index.d.ts +16 -0
- package/dist/trade/index.d.ts +16 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Library version string. Matches package.json (published npm release). */
|
|
2
|
-
declare const VERSION = "1.0.
|
|
2
|
+
declare const VERSION = "1.0.2";
|
|
3
3
|
/** Returns the current library version. */
|
|
4
4
|
declare function version(): string;
|
|
5
5
|
|
|
@@ -220,6 +220,18 @@ declare class TimeScale {
|
|
|
220
220
|
xToIndex(x: number): number;
|
|
221
221
|
/** Currently visible logical index range (fractional, unclamped to data). */
|
|
222
222
|
visibleRange(): LogicalRange;
|
|
223
|
+
/** Alias of `visibleRange()` for naming parity with common charting APIs. */
|
|
224
|
+
getVisibleLogicalRange(): LogicalRange;
|
|
225
|
+
/**
|
|
226
|
+
* Set the visible logical range (best effort): pick a bar spacing so the span
|
|
227
|
+
* fills the width and anchor the right edge at `range.to`. Bar spacing is
|
|
228
|
+
* clamped to [min,max], so an extreme span lands at the nearest zoom. Fires the
|
|
229
|
+
* change handler so a host that mutates the scale directly still repaints.
|
|
230
|
+
*/
|
|
231
|
+
setVisibleLogicalRange(range: LogicalRange): void;
|
|
232
|
+
/** Repaint hook injected by the host chart, fired after `setVisibleLogicalRange`. */
|
|
233
|
+
setChangeHandler(fn: (() => void) | null): void;
|
|
234
|
+
private _onChange;
|
|
223
235
|
/**
|
|
224
236
|
* Pan by a pixel delta. Positive `dx` drags chart content to the right
|
|
225
237
|
* (revealing older bars), matching a natural left-button drag.
|
|
@@ -351,8 +363,12 @@ interface SeriesStyle {
|
|
|
351
363
|
hollow?: boolean;
|
|
352
364
|
/** Scale candle body width by volume / maxVisibleVolume (volume candles). */
|
|
353
365
|
volumeScaled?: boolean;
|
|
366
|
+
/** Whether the series is drawn and counted in autoscale. Default true. */
|
|
367
|
+
visible?: boolean;
|
|
354
368
|
color?: string;
|
|
355
369
|
lineWidth?: number;
|
|
370
|
+
/** Line dash style for line/step/area/HLC series. Default 'solid'. */
|
|
371
|
+
lineStyle?: 'solid' | 'dashed' | 'dotted';
|
|
356
372
|
step?: boolean;
|
|
357
373
|
markers?: boolean;
|
|
358
374
|
markerRadius?: number;
|
|
@@ -385,6 +401,10 @@ interface ChartTheme {
|
|
|
385
401
|
axisText: string;
|
|
386
402
|
axisLine: string;
|
|
387
403
|
crosshair: string;
|
|
404
|
+
/** Axis label font size in px (default 11). */
|
|
405
|
+
axisFontSize?: number;
|
|
406
|
+
/** Grid line dash style (default 'solid'). */
|
|
407
|
+
gridStyle?: 'solid' | 'dashed' | 'dotted';
|
|
388
408
|
upColor: string;
|
|
389
409
|
downColor: string;
|
|
390
410
|
wickUpColor: string;
|
|
@@ -526,10 +546,17 @@ declare class SeriesMarkers implements IPrimitive {
|
|
|
526
546
|
* so the core never switches on type.
|
|
527
547
|
*/
|
|
528
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Which price axis a series maps to. 'right' (default) and 'left' each draw an
|
|
551
|
+
* axis and autoscale independently; '' is a hidden overlay scale (no axis, its
|
|
552
|
+
* own autoscale) used to pin a volume histogram inside the price pane.
|
|
553
|
+
*/
|
|
554
|
+
type PriceScaleId = 'right' | 'left' | '';
|
|
529
555
|
interface SeriesRecord {
|
|
530
556
|
dataId: SeriesId;
|
|
531
557
|
type: SeriesType;
|
|
532
558
|
style: SeriesStyle;
|
|
559
|
+
scaleId: PriceScaleId;
|
|
533
560
|
}
|
|
534
561
|
/** Public handle returned by `chart.addSeries(...)`. */
|
|
535
562
|
interface SeriesApi {
|
|
@@ -541,6 +568,12 @@ interface SeriesApi {
|
|
|
541
568
|
update(bar: SeriesDataItem): void;
|
|
542
569
|
/** Current bars for this series (sorted old -> new, normalized to OHLC). Handy for computing the next live update. */
|
|
543
570
|
getData(): Bar[];
|
|
571
|
+
/** Merge a partial style into the series and repaint (recolor, `{ visible:false }` to hide, ...). */
|
|
572
|
+
applyOptions(style: Partial<SeriesStyle>): void;
|
|
573
|
+
/** Remove the series from its pane and free its data rows. */
|
|
574
|
+
remove(): void;
|
|
575
|
+
/** The price scale this series maps to (call `.setOptions({ marginTop, marginBottom })` on it). */
|
|
576
|
+
priceScale(): PriceScale;
|
|
544
577
|
/** Create a markers layer (buy/sell signals, shapes) bound to this series. */
|
|
545
578
|
createMarkers(): SeriesMarkers;
|
|
546
579
|
}
|
|
@@ -556,6 +589,8 @@ interface PaneRenderContext {
|
|
|
556
589
|
dataLayer: DataLayer;
|
|
557
590
|
dpr: number;
|
|
558
591
|
priceAxisWidth: number;
|
|
592
|
+
/** Left inset (px) reserved chart-wide for a left price axis; 0/absent when none. */
|
|
593
|
+
leftAxisWidth?: number;
|
|
559
594
|
timeAxisHeight: number;
|
|
560
595
|
/** Only the bottom pane draws the time axis. */
|
|
561
596
|
showTimeAxis: boolean;
|
|
@@ -577,6 +612,9 @@ declare class Pane {
|
|
|
577
612
|
readonly base: CanvasLayer;
|
|
578
613
|
readonly top: CanvasLayer;
|
|
579
614
|
readonly priceScale: PriceScale;
|
|
615
|
+
/** Extra scales created on demand: left axis and a hidden overlay (volume). */
|
|
616
|
+
private _leftScale;
|
|
617
|
+
private _overlayScale;
|
|
580
618
|
/** Relative height weight within the chart (price=1, volume≈0.3). */
|
|
581
619
|
weight: number;
|
|
582
620
|
private readonly _series;
|
|
@@ -585,6 +623,14 @@ declare class Pane {
|
|
|
585
623
|
private _height;
|
|
586
624
|
constructor(doc: Document);
|
|
587
625
|
addSeries(record: SeriesRecord): void;
|
|
626
|
+
/** The PriceScale for a scale id, creating the left/overlay scale on first use. */
|
|
627
|
+
private _scaleFor;
|
|
628
|
+
/** The price scale a series maps to (for the series handle's `priceScale()`). */
|
|
629
|
+
scaleOf(record: SeriesRecord): PriceScale;
|
|
630
|
+
/** True when a left-axis scale is active (some series maps to it). */
|
|
631
|
+
hasLeftScale(): boolean;
|
|
632
|
+
/** Remove a series record if present; returns true if it was found. */
|
|
633
|
+
removeSeries(record: SeriesRecord): boolean;
|
|
588
634
|
series(): readonly SeriesRecord[];
|
|
589
635
|
addPrimitive(primitive: IPrimitive, host: PrimitiveHost): void;
|
|
590
636
|
/** Remove a primitive if present; returns true if it was found. */
|
|
@@ -596,8 +642,9 @@ declare class Pane {
|
|
|
596
642
|
hitTestPrimitives(x: number, y: number, ctx: PaneRenderContext): PrimitiveHit | null;
|
|
597
643
|
resize(width: number, height: number, dpr: number): void;
|
|
598
644
|
private _layout;
|
|
599
|
-
/**
|
|
645
|
+
/** Autoscale each active price scale from its own series (independent axes). */
|
|
600
646
|
autoscale(ctx: PaneRenderContext): void;
|
|
647
|
+
private _autoscaleScale;
|
|
601
648
|
/** Paint background + grid + series + axes on the base canvas. */
|
|
602
649
|
paintBase(ctx: PaneRenderContext): void;
|
|
603
650
|
/**
|
|
@@ -1021,7 +1068,30 @@ interface AddSeriesOptions {
|
|
|
1021
1068
|
paneIndex?: number;
|
|
1022
1069
|
/** Style overrides merged onto the chart type's defaults. */
|
|
1023
1070
|
style?: SeriesStyle;
|
|
1071
|
+
/**
|
|
1072
|
+
* Which price axis this series maps to. 'right' (default) and 'left' each draw
|
|
1073
|
+
* an axis and autoscale independently; '' is a hidden overlay scale (no axis)
|
|
1074
|
+
* for a volume histogram inside the price pane.
|
|
1075
|
+
*/
|
|
1076
|
+
priceScaleId?: PriceScaleId;
|
|
1077
|
+
/**
|
|
1078
|
+
* Value formatting applied to this series' price scale (axis + crosshair tag):
|
|
1079
|
+
* `price` (tick-size precision), `volume` (compact 1.2K / 3.4M / 5.6B), or a
|
|
1080
|
+
* `custom` formatter (currency, percent, ...).
|
|
1081
|
+
*/
|
|
1082
|
+
priceFormat?: {
|
|
1083
|
+
type: 'price';
|
|
1084
|
+
precision?: number;
|
|
1085
|
+
minMove?: number;
|
|
1086
|
+
} | {
|
|
1087
|
+
type: 'volume';
|
|
1088
|
+
} | {
|
|
1089
|
+
type: 'custom';
|
|
1090
|
+
formatter: (value: number) => string;
|
|
1091
|
+
};
|
|
1024
1092
|
}
|
|
1093
|
+
/** Compact volume/number formatter (1.2K / 3.4M / 5.6B). */
|
|
1094
|
+
declare function compactVolume(v: number): string;
|
|
1025
1095
|
/**
|
|
1026
1096
|
* Emitted on every crosshair move (and `null` fields on pointer-leave) so a host
|
|
1027
1097
|
* can render an OHLC legend / tooltip. `bar` is the hovered bar of the primary
|
|
@@ -1047,7 +1117,7 @@ declare class Chart {
|
|
|
1047
1117
|
private readonly _container;
|
|
1048
1118
|
private readonly _doc;
|
|
1049
1119
|
private readonly _pixelRatio;
|
|
1050
|
-
private
|
|
1120
|
+
private _theme;
|
|
1051
1121
|
private readonly _panes;
|
|
1052
1122
|
private readonly _loop;
|
|
1053
1123
|
private readonly _dataLayer;
|
|
@@ -1106,6 +1176,7 @@ declare class Chart {
|
|
|
1106
1176
|
private _priceFormatter;
|
|
1107
1177
|
private _priceScaleOptions;
|
|
1108
1178
|
private _timeFormatter;
|
|
1179
|
+
private _leftAxisWidth;
|
|
1109
1180
|
constructor(container: HTMLElement, options?: ChartOptions);
|
|
1110
1181
|
/** Register a callback fired when the user pans near the left (oldest) edge. */
|
|
1111
1182
|
setHistoryLoader(loader: () => void): void;
|
|
@@ -1113,6 +1184,12 @@ declare class Chart {
|
|
|
1113
1184
|
historyLoadComplete(): void;
|
|
1114
1185
|
get dataLayer(): DataLayer;
|
|
1115
1186
|
get timeScale(): TimeScale;
|
|
1187
|
+
/** Restore a saved logical range (e.g. preserve the user's zoom across a data reload). */
|
|
1188
|
+
setVisibleLogicalRange(range: LogicalRange): void;
|
|
1189
|
+
/** The current visible logical range. */
|
|
1190
|
+
getVisibleLogicalRange(): LogicalRange;
|
|
1191
|
+
/** Fit all bars into view (no-arg convenience; bar count from the data). */
|
|
1192
|
+
fitContent(): void;
|
|
1116
1193
|
/** The keyboard shortcut manager (null when shortcuts are disabled). */
|
|
1117
1194
|
get shortcuts(): ShortcutManager | null;
|
|
1118
1195
|
/**
|
|
@@ -1204,11 +1281,29 @@ declare class Chart {
|
|
|
1204
1281
|
* at runtime. Pass undefined to restore the IST default.
|
|
1205
1282
|
*/
|
|
1206
1283
|
setTimeFormatter(fn: ((utcSeconds: number) => string) | undefined): void;
|
|
1284
|
+
/** Swap the palette at runtime (dark/light toggle) without recreating the chart. */
|
|
1285
|
+
setTheme(theme: ChartTheme): void;
|
|
1286
|
+
/**
|
|
1287
|
+
* Apply a subset of chart options at runtime (theme, grid, formatters,
|
|
1288
|
+
* crosshair mode) without recreating the chart.
|
|
1289
|
+
*/
|
|
1290
|
+
applyOptions(opts: {
|
|
1291
|
+
theme?: ChartTheme;
|
|
1292
|
+
grid?: {
|
|
1293
|
+
vertLines?: boolean;
|
|
1294
|
+
horzLines?: boolean;
|
|
1295
|
+
};
|
|
1296
|
+
priceFormatter?: ((price: number) => string) | null;
|
|
1297
|
+
timeFormatter?: ((utcSeconds: number) => string) | undefined;
|
|
1298
|
+
crosshairMode?: CrosshairMode;
|
|
1299
|
+
}): void;
|
|
1207
1300
|
panes(): readonly Pane[];
|
|
1208
1301
|
invalidate(build: (mask: InvalidateMask) => void): void;
|
|
1209
1302
|
applySize(width: number, height: number): void;
|
|
1210
1303
|
/** Distribute height across panes by weight; sync the shared time-scale width. */
|
|
1211
1304
|
private _relayout;
|
|
1305
|
+
/** Reserve a chart-wide left-axis column when any pane has a left price scale. */
|
|
1306
|
+
private _recomputeLeftAxis;
|
|
1212
1307
|
private _weightTotal;
|
|
1213
1308
|
/** Cumulative top + height of each pane, by weight (the source of truth for hit-testing). */
|
|
1214
1309
|
private _paneLayout;
|
|
@@ -2031,4 +2126,4 @@ declare function lerp(a: number, b: number, t: number): number;
|
|
|
2031
2126
|
*/
|
|
2032
2127
|
declare function roundToTick(value: number, step: number): number;
|
|
2033
2128
|
|
|
2034
|
-
export { ALT_PRESET, type AddSeriesOptions, type AggTick, BUILTIN_COMMANDS, type Bar, type BarUpdate, type BarsRequest, CandleBuilder, type CandleBuilderOptions, type CandleStyle, type CandleUpdate, Chart, type ChartEvent, type ChartOptions, type ChartTheme, type CrosshairMoveEvent, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, type DataFeed, type DepthLevel, type DrawItem, EventMarkers, FakeDataFeed, type FeedScheduler, type HistogramStyle, type IPrimitive, IST_OFFSET_SECONDS, InvalidationLevel, type KeymapEntry, type LateTickPolicy, type LinePoint, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OriginalTime, Pane, type PaneInvalidation, type PlaceOrder, type PositionSide, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleMode, type PriceScaleOptions, type PrimitiveHit, type PrimitiveHost, type PrimitiveRenderContext, type RendererEntry, type SeriesApi, type SeriesDataItem, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesStyle, type SeriesType, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, type Tick, TickBarAggregator, type TickTimeframe, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, type UnsubscribeFn, VERSION, type VolumeMode, type WatermarkPosition, type Whitespace, type WsControlMessage, type WsMode, type WsState, type ZOrder, atr, autoscaleRange, bestHit, bitmapSize, clamp, conflateBars, conflateItems, conflationGroupSize, createChart, darkTheme, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, formatCombo, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, generateBars, getChartType, intervalToSeconds, isNewIstDay, isReservedCombo, isValidCombo, isWhitespace, istStringToUtcSeconds, lerp, lightTheme, mapHistoryResponse, mapOrder, mapPosition, markerSizePx, mergeBars, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, precisionForStep, registerChartType, registeredChartTypes, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, snapToDevicePixel, supertrend, supertrendSeries, toBar, trueRange, utcSecondsToIstDateString, utcSecondsToIstParts, version, verticalGradient, watermarkRect };
|
|
2129
|
+
export { ALT_PRESET, type AddSeriesOptions, type AggTick, BUILTIN_COMMANDS, type Bar, type BarUpdate, type BarsRequest, CandleBuilder, type CandleBuilderOptions, type CandleStyle, type CandleUpdate, Chart, type ChartEvent, type ChartOptions, type ChartTheme, type CrosshairMoveEvent, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, type DataFeed, type DepthLevel, type DrawItem, EventMarkers, FakeDataFeed, type FeedScheduler, type HistogramStyle, type IPrimitive, IST_OFFSET_SECONDS, InvalidationLevel, type KeymapEntry, type LateTickPolicy, type LinePoint, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OriginalTime, Pane, type PaneInvalidation, type PlaceOrder, type PositionSide, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PrimitiveHit, type PrimitiveHost, type PrimitiveRenderContext, type RendererEntry, type SeriesApi, type SeriesDataItem, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesStyle, type SeriesType, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, type Tick, TickBarAggregator, type TickTimeframe, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, type UnsubscribeFn, VERSION, type VolumeMode, type WatermarkPosition, type Whitespace, type WsControlMessage, type WsMode, type WsState, type ZOrder, atr, autoscaleRange, bestHit, bitmapSize, clamp, compactVolume, conflateBars, conflateItems, conflationGroupSize, createChart, darkTheme, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, formatCombo, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, generateBars, getChartType, intervalToSeconds, isNewIstDay, isReservedCombo, isValidCombo, isWhitespace, istStringToUtcSeconds, lerp, lightTheme, mapHistoryResponse, mapOrder, mapPosition, markerSizePx, mergeBars, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, precisionForStep, registerChartType, registeredChartTypes, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, snapToDevicePixel, supertrend, supertrendSeries, toBar, trueRange, utcSecondsToIstDateString, utcSecondsToIstParts, version, verticalGradient, watermarkRect };
|