openalgo-charts 1.0.4 → 1.0.6

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Library version string. Matches package.json (published npm release). */
2
- declare const VERSION = "1.0.4";
2
+ declare const VERSION = "1.0.6";
3
3
  /** Returns the current library version. */
4
4
  declare function version(): string;
5
5
 
@@ -1219,6 +1219,7 @@ declare class Chart {
1219
1219
  private _downLocalY;
1220
1220
  private _dragId;
1221
1221
  private _hoverId;
1222
+ private _overlayFrozen;
1222
1223
  private _dragCb;
1223
1224
  private _dragEndCb;
1224
1225
  private _axisDrag;
@@ -1365,6 +1366,21 @@ declare class Chart {
1365
1366
  private _onFrame;
1366
1367
  private _attachInput;
1367
1368
  private readonly _onPointerEnter;
1369
+ /**
1370
+ * The chart renders as stacked canvases, so the browser's right-click
1371
+ * "Save image as…" would capture only the topmost (transparent overlay)
1372
+ * layer — a blank image. Just before the native menu opens, composite the
1373
+ * clicked pane's base layer *beneath* its overlay bitmap so the saved image
1374
+ * is the visible chart, and freeze overlay repaints (live ticks repaint every
1375
+ * few hundred ms and would wipe the snapshot while the menu is open). The
1376
+ * freeze lifts on the next pointer/wheel/key input after the menu closes.
1377
+ * Apps that present their own menu (preventDefault on contextmenu) are
1378
+ * unaffected. Multi-pane note: the native save captures the clicked pane
1379
+ * only — use `downloadScreenshot()` for the full multi-pane composite.
1380
+ */
1381
+ private readonly _onContextMenu;
1382
+ /** Resume overlay repaints after the native context menu closes. */
1383
+ private _unfreezeOverlay;
1368
1384
  private _localPoint;
1369
1385
  private readonly _onPointerDown;
1370
1386
  private readonly _onPointerMove;
@@ -1575,6 +1591,78 @@ declare class LogoWatermark implements IPrimitive {
1575
1591
  private _tinted;
1576
1592
  }
1577
1593
 
1594
+ /**
1595
+ * Inline Buy/Sell button panel (ARCHITECTURE.md §9). A TradingView-style trade
1596
+ * panel docked inside the plot: a SELL button (bid), a quantity chip, and a BUY
1597
+ * button (ask), drawn on the overlay canvas so it stays fixed while the chart
1598
+ * pans/zooms. Clicks hit-test to `${id}:sell` / `${id}:buy` / `${id}:qty`, which
1599
+ * the chart routes through `subscribeClick` — the app places the order. Prices
1600
+ * update cheaply on every tick (`setPrices` / `setMark`).
1601
+ */
1602
+
1603
+ interface BuySellButtonsOptions {
1604
+ /** Stable id prefix; hit-tests emit `${id}:sell` / `${id}:buy` / `${id}:qty`. Default `trade`. */
1605
+ id?: string;
1606
+ /** Corner to dock to. Default `top-left`. */
1607
+ position?: WatermarkPosition;
1608
+ /**
1609
+ * Gap from the plot edges in media px. A number applies to both axes; pass
1610
+ * `{ x, y }` to offset independently (e.g. clear an OHLC legend at the top).
1611
+ */
1612
+ margin?: number | {
1613
+ x: number;
1614
+ y: number;
1615
+ };
1616
+ /** Quantity shown in the centre chip (e.g. lots or absolute qty). */
1617
+ qty?: string | number;
1618
+ /** Buy button color (defaults to the theme `buy`). */
1619
+ buyColor?: string;
1620
+ /** Sell button color (defaults to the theme `sell`). */
1621
+ sellColor?: string;
1622
+ /** Button labels. Default `BUY` / `SELL`. */
1623
+ buyLabel?: string;
1624
+ sellLabel?: string;
1625
+ /** Show the price line above each label. Default true. */
1626
+ showPrices?: boolean;
1627
+ }
1628
+ declare class BuySellButtons implements IPrimitive {
1629
+ private readonly _id;
1630
+ private readonly _position;
1631
+ private readonly _mx;
1632
+ private readonly _my;
1633
+ private readonly _buyLabel;
1634
+ private readonly _sellLabel;
1635
+ private readonly _showPrices;
1636
+ private _qty;
1637
+ private _buyColor?;
1638
+ private _sellColor?;
1639
+ private _bid;
1640
+ private _ask;
1641
+ private _host;
1642
+ private _sellRect;
1643
+ private _buyRect;
1644
+ private _qtyRect;
1645
+ constructor(options?: BuySellButtonsOptions);
1646
+ attached(host: PrimitiveHost): void;
1647
+ detached(): void;
1648
+ zOrder(): ZOrder;
1649
+ autoscaleInfo(): null;
1650
+ /** Distinct bid/ask (shows a spread on the two buttons). */
1651
+ setPrices(bid: number, ask: number): void;
1652
+ /** Single mark price shown on both buttons (when there is no bid/ask). */
1653
+ setMark(price: number): void;
1654
+ setQty(qty: string | number): void;
1655
+ setColors(buyColor?: string, sellColor?: string): void;
1656
+ private _origin;
1657
+ draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
1658
+ private _fmt;
1659
+ private _drawButton;
1660
+ private _drawChip;
1661
+ /** Trace a rect rounded on the left or right pair of corners only. */
1662
+ private _roundedSide;
1663
+ hitTest(x: number, y: number, _rc: PrimitiveRenderContext): PrimitiveHit | null;
1664
+ }
1665
+
1578
1666
  /**
1579
1667
  * Exponential moving average (ARCHITECTURE.md §8 — an indicator that validates
1580
1668
  * the series/extensibility model). Pure; the result is plotted as a `line`
@@ -2223,4 +2311,4 @@ declare function lerp(a: number, b: number, t: number): number;
2223
2311
  */
2224
2312
  declare function roundToTick(value: number, step: number): number;
2225
2313
 
2226
- 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 TickMarkType, 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 };
2314
+ export { ALT_PRESET, type AddSeriesOptions, type AggTick, BUILTIN_COMMANDS, type Bar, type BarUpdate, type BarsRequest, BuySellButtons, type BuySellButtonsOptions, 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 TickMarkType, 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 };