acttrader-charts 1.2.0-beta.5 → 1.2.0-beta.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.
@@ -841,11 +841,13 @@ interface ChartConfig {
841
841
  */
842
842
  targetCandleWidth?: number;
843
843
  /**
844
- * Which side of the quote to use for candle close/high/low during live
845
- * tick updates. Defaults to `'bid'` (forex convention). Set to `'ask'`
846
- * if your broker streams ask-based OHLCV bars.
844
+ * Which price to use for candle close/high/low during live tick updates.
845
+ * Defaults to `'bid'` (forex convention). Set to `'ask'` if your broker
846
+ * streams ask-based OHLCV bars, or `'ltp'` for exchange/dealing feeds
847
+ * that stream a last-traded price — ticks without a valid LTP fall back
848
+ * to the bid.
847
849
  */
848
- tickClosePriceSource?: 'bid' | 'ask';
850
+ tickClosePriceSource?: 'bid' | 'ask' | 'ltp';
849
851
  /**
850
852
  * When the combined count of open positions and pending orders exceeds this
851
853
  * number, the position render style auto-defaults to `'dot'` (compact).
@@ -1255,6 +1257,8 @@ interface Tick {
1255
1257
  bid: number;
1256
1258
  ask: number;
1257
1259
  volume: number;
1260
+ /** Last traded price (exchange/dealing feeds). Absent on pure quote feeds. */
1261
+ ltp?: number;
1258
1262
  }
1259
1263
  interface IWebSocketAdapter {
1260
1264
  connect(): void;
@@ -841,11 +841,13 @@ interface ChartConfig {
841
841
  */
842
842
  targetCandleWidth?: number;
843
843
  /**
844
- * Which side of the quote to use for candle close/high/low during live
845
- * tick updates. Defaults to `'bid'` (forex convention). Set to `'ask'`
846
- * if your broker streams ask-based OHLCV bars.
844
+ * Which price to use for candle close/high/low during live tick updates.
845
+ * Defaults to `'bid'` (forex convention). Set to `'ask'` if your broker
846
+ * streams ask-based OHLCV bars, or `'ltp'` for exchange/dealing feeds
847
+ * that stream a last-traded price — ticks without a valid LTP fall back
848
+ * to the bid.
847
849
  */
848
- tickClosePriceSource?: 'bid' | 'ask';
850
+ tickClosePriceSource?: 'bid' | 'ask' | 'ltp';
849
851
  /**
850
852
  * When the combined count of open positions and pending orders exceeds this
851
853
  * number, the position render style auto-defaults to `'dot'` (compact).
@@ -1255,6 +1257,8 @@ interface Tick {
1255
1257
  bid: number;
1256
1258
  ask: number;
1257
1259
  volume: number;
1260
+ /** Last traded price (exchange/dealing feeds). Absent on pure quote feeds. */
1261
+ ltp?: number;
1258
1262
  }
1259
1263
  interface IWebSocketAdapter {
1260
1264
  connect(): void;
package/dist/index.cjs CHANGED
@@ -22212,6 +22212,8 @@ var _ChartEngine = class _ChartEngine {
22212
22212
  // Streaming
22213
22213
  this.streamAdapter = null;
22214
22214
  this.liveBidAsk = null;
22215
+ /** Last traded price from the most recent tick that carried one ('ltp' source mode). */
22216
+ this.liveLtp = null;
22215
22217
  this.tickClosePriceSource = "bid";
22216
22218
  /** True while an async data fetch is in-flight; suppresses tick processing to
22217
22219
  * prevent stale ticks from corrupting newly-loaded bars. */
@@ -23337,10 +23339,11 @@ var _ChartEngine = class _ChartEngine {
23337
23339
  if (all.length === 0) return;
23338
23340
  if (this._suppressTicks) return;
23339
23341
  this.liveBidAsk = { bid: tick.bid, ask: tick.ask };
23342
+ if (tick.ltp != null && tick.ltp > 0) this.liveLtp = tick.ltp;
23340
23343
  this.setDotTickActive();
23341
23344
  const last = all[all.length - 1];
23342
23345
  const intervalMs = this.timeframeToMs(this.timeframe);
23343
- const tickPrice = this.tickClosePriceSource === "ask" ? tick.ask : tick.bid;
23346
+ const tickPrice = this.tickClosePriceSource === "ltp" ? this.liveLtp ?? tick.bid : this.tickClosePriceSource === "ask" ? tick.ask : tick.bid;
23344
23347
  if (tick.time < last.time + intervalMs) {
23345
23348
  const updated = {
23346
23349
  ...last,
@@ -24318,6 +24321,7 @@ var _ChartEngine = class _ChartEngine {
24318
24321
  this._suppressTicks = false;
24319
24322
  if (bars.length > 0) this.setNoData(false);
24320
24323
  this.liveBidAsk = null;
24324
+ this.liveLtp = null;
24321
24325
  this.pricePanOffset = 0;
24322
24326
  this.priceScaleFactor = 1;
24323
24327
  this._displayedPriceRange = null;
@@ -25371,6 +25375,7 @@ var _ChartEngine = class _ChartEngine {
25371
25375
  if (this.siStreamDot)
25372
25376
  this.siStreamDot.style.background = this.theme.ui.stream[this.streamStatus];
25373
25377
  this.liveBidAsk = null;
25378
+ this.liveLtp = null;
25374
25379
  return this;
25375
25380
  }
25376
25381
  /**
@@ -25590,10 +25595,18 @@ var _ChartEngine = class _ChartEngine {
25590
25595
  }
25591
25596
  /** Push a live bid/ask tick directly — no adapter needed.
25592
25597
  * Pass `T` from your feed as the server timestamp (ISO string or Unix ms)
25593
- * to avoid system clock skew causing premature candle formation. */
25598
+ * to avoid system clock skew causing premature candle formation.
25599
+ * `LTP`/`LTPV` (last traded price/volume) are optional — sent by
25600
+ * exchange/dealing feeds and consumed when `tickClosePriceSource: 'ltp'`. */
25594
25601
  pushTick(prices) {
25595
25602
  const time = prices.T != null ? typeof prices.T === "string" ? new Date(prices.T).getTime() : prices.T : Date.now();
25596
- this.onTick({ time, bid: prices.B, ask: prices.A, volume: 0 });
25603
+ this.onTick({
25604
+ time,
25605
+ bid: prices.B,
25606
+ ask: prices.A,
25607
+ volume: prices.LTPV != null && prices.LTPV > 0 ? prices.LTPV : 0,
25608
+ ltp: prices.LTP != null && prices.LTP > 0 ? prices.LTP : void 0
25609
+ });
25597
25610
  return this;
25598
25611
  }
25599
25612
  // ── Trade / Position level API ────────────────────────────────────────────
@@ -27693,15 +27706,17 @@ var _ChartEngine = class _ChartEngine {
27693
27706
  let primaryPriceBoxW = 0;
27694
27707
  if (this.liveBidAsk) {
27695
27708
  const { bid, ask } = this.liveBidAsk;
27709
+ const ltpPrice = this.tickClosePriceSource === "ltp" ? this.liveLtp ?? bid : null;
27710
+ const ltpColor = lastBar.close >= lastBar.open ? theme.candle.up : theme.candle.down;
27696
27711
  if (this.showBidAskLines) {
27697
27712
  const bidTag = drawPriceLine(bid, theme.candle.down, "");
27698
27713
  const askTag = drawPriceLine(ask, theme.candle.up, "");
27699
- const primary = this.tickClosePriceSource === "ask" ? askTag : bidTag;
27714
+ const primary = ltpPrice != null ? drawPriceLine(ltpPrice, ltpColor, "") : this.tickClosePriceSource === "ask" ? askTag : bidTag;
27700
27715
  primaryPriceY = primary.y;
27701
27716
  primaryPriceBoxW = primary.boxW;
27702
27717
  } else {
27703
- const price = this.tickClosePriceSource === "ask" ? ask : bid;
27704
- const color = this.tickClosePriceSource === "ask" ? theme.candle.up : theme.candle.down;
27718
+ const price = ltpPrice ?? (this.tickClosePriceSource === "ask" ? ask : bid);
27719
+ const color = ltpPrice != null ? ltpColor : this.tickClosePriceSource === "ask" ? theme.candle.up : theme.candle.down;
27705
27720
  const tag = drawPriceLine(price, color, "");
27706
27721
  primaryPriceY = tag.y;
27707
27722
  primaryPriceBoxW = tag.boxW;