@pipsend/charts 0.0.11 → 0.0.13

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.
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v0.0.11-dev+202510282325
4
- * Copyright (c) 2025 Pipsend
3
+ * Pipsend Charts v0.0.12
4
+ * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
7
7
  */
@@ -15588,6 +15588,205 @@
15588
15588
  return wrapper;
15589
15589
  }
15590
15590
 
15591
+ /**
15592
+ * Gestor de marcadores de posiciones de trading
15593
+ */
15594
+ class PositionMarkersManager {
15595
+ constructor(series, options) {
15596
+ this._private__markersPlugin = null;
15597
+ this._private__positions = [];
15598
+ this._private__options = {
15599
+ longColors: {
15600
+ entry: options?.longColors?.entry ?? '#26a69a',
15601
+ exit: options?.longColors?.exit ?? '#ef5350',
15602
+ },
15603
+ shortColors: {
15604
+ entry: options?.shortColors?.entry ?? '#ef5350',
15605
+ exit: options?.shortColors?.exit ?? '#26a69a',
15606
+ },
15607
+ defaultSize: options?.defaultSize ?? 1,
15608
+ };
15609
+ this._private__markersPlugin = createSeriesMarkers(series);
15610
+ }
15611
+ /**
15612
+ * Agrega una posición al gráfico
15613
+ */
15614
+ addPosition(position) {
15615
+ this._private__positions.push(position);
15616
+ this._private__updateMarkers();
15617
+ }
15618
+ /**
15619
+ * Agrega múltiples posiciones al gráfico
15620
+ */
15621
+ addPositions(positions) {
15622
+ this._private__positions.push(...positions);
15623
+ this._private__updateMarkers();
15624
+ }
15625
+ /**
15626
+ * Establece las posiciones (reemplaza las existentes)
15627
+ */
15628
+ setPositions(positions) {
15629
+ this._private__positions = [...positions];
15630
+ this._private__updateMarkers();
15631
+ }
15632
+ /**
15633
+ * Elimina una posición por ID
15634
+ */
15635
+ removePosition(id) {
15636
+ this._private__positions = this._private__positions.filter(p => p.id !== id);
15637
+ this._private__updateMarkers();
15638
+ }
15639
+ /**
15640
+ * Limpia todas las posiciones
15641
+ */
15642
+ clearPositions() {
15643
+ this._private__positions = [];
15644
+ this._private__updateMarkers();
15645
+ }
15646
+ /**
15647
+ * Obtiene todas las posiciones actuales
15648
+ */
15649
+ getPositions() {
15650
+ return this._private__positions;
15651
+ }
15652
+ /**
15653
+ * Actualiza las opciones del gestor
15654
+ */
15655
+ applyOptions(options) {
15656
+ if (options.longColors) {
15657
+ this._private__options.longColors = {
15658
+ ...this._private__options.longColors,
15659
+ ...options.longColors,
15660
+ };
15661
+ }
15662
+ if (options.shortColors) {
15663
+ this._private__options.shortColors = {
15664
+ ...this._private__options.shortColors,
15665
+ ...options.shortColors,
15666
+ };
15667
+ }
15668
+ if (options.defaultSize !== undefined) {
15669
+ this._private__options.defaultSize = options.defaultSize;
15670
+ }
15671
+ this._private__updateMarkers();
15672
+ }
15673
+ /**
15674
+ * Convierte las posiciones a marcadores de serie
15675
+ */
15676
+ _private__positionsToMarkers() {
15677
+ const markers = [];
15678
+ for (const position of this._private__positions) {
15679
+ const isLong = position.type === 'long';
15680
+ const size = position.size ?? this._private__options.defaultSize;
15681
+ const entryColor = position.color?.entry ??
15682
+ (isLong ? this._private__options.longColors.entry : this._private__options.shortColors.entry);
15683
+ const exitColor = position.color?.exit ??
15684
+ (isLong ? this._private__options.longColors.exit : this._private__options.shortColors.exit);
15685
+ const entryMarker = {
15686
+ time: position.entry.time,
15687
+ position: 'atPriceMiddle',
15688
+ price: position.entry.price,
15689
+ shape: isLong ? 'arrowUp' : 'arrowDown',
15690
+ color: entryColor,
15691
+ size: size,
15692
+ };
15693
+ if (position.text?.entry) {
15694
+ entryMarker.text = position.text.entry;
15695
+ }
15696
+ if (position.id) {
15697
+ entryMarker.id = `${position.id}-entry`;
15698
+ }
15699
+ markers.push(entryMarker);
15700
+ const exitMarker = {
15701
+ time: position.exit.time,
15702
+ position: 'atPriceMiddle',
15703
+ price: position.exit.price,
15704
+ shape: isLong ? 'arrowDown' : 'arrowUp',
15705
+ color: exitColor,
15706
+ size: size,
15707
+ };
15708
+ if (position.text?.exit) {
15709
+ exitMarker.text = position.text.exit;
15710
+ }
15711
+ if (position.id) {
15712
+ exitMarker.id = `${position.id}-exit`;
15713
+ }
15714
+ markers.push(exitMarker);
15715
+ }
15716
+ return markers;
15717
+ }
15718
+ /**
15719
+ * Actualiza los marcadores en el gráfico
15720
+ */
15721
+ _private__updateMarkers() {
15722
+ if (this._private__markersPlugin) {
15723
+ const markers = this._private__positionsToMarkers();
15724
+ this._private__markersPlugin.setMarkers(markers);
15725
+ }
15726
+ }
15727
+ /**
15728
+ * Desconecta el plugin y limpia recursos
15729
+ */
15730
+ detach() {
15731
+ if (this._private__markersPlugin) {
15732
+ this._private__markersPlugin.detach();
15733
+ this._private__markersPlugin = null;
15734
+ }
15735
+ this._private__positions = [];
15736
+ }
15737
+ }
15738
+ /**
15739
+ * Crea un gestor de marcadores de posiciones de trading
15740
+ *
15741
+ * @param series - Serie a la que se adjuntarán los marcadores
15742
+ * @param positions - Posiciones iniciales (opcional)
15743
+ * @param options - Opciones de configuración (opcional)
15744
+ * @returns Instancia del gestor de posiciones
15745
+ *
15746
+ * @example
15747
+ * ```typescript
15748
+ * // Crear el gestor
15749
+ * const positionMarkers = createPositionMarkers(candleSeries);
15750
+ *
15751
+ * // Agregar una posición long
15752
+ * positionMarkers.addPosition({
15753
+ * type: 'long',
15754
+ * entry: { time: '2023-01-01', price: 100.50 },
15755
+ * exit: { time: '2023-01-05', price: 105.20 },
15756
+ * id: 'pos-1'
15757
+ * });
15758
+ *
15759
+ * // Agregar una posición short
15760
+ * positionMarkers.addPosition({
15761
+ * type: 'short',
15762
+ * entry: { time: '2023-01-10', price: 110.00 },
15763
+ * exit: { time: '2023-01-15', price: 107.50 },
15764
+ * id: 'pos-2'
15765
+ * });
15766
+ *
15767
+ * // Agregar múltiples posiciones
15768
+ * positionMarkers.setPositions([
15769
+ * {
15770
+ * type: 'long',
15771
+ * entry: { time: '2023-02-01', price: 95.00 },
15772
+ * exit: { time: '2023-02-10', price: 98.50 }
15773
+ * },
15774
+ * {
15775
+ * type: 'short',
15776
+ * entry: { time: '2023-02-15', price: 102.00 },
15777
+ * exit: { time: '2023-02-20', price: 99.00 }
15778
+ * }
15779
+ * ]);
15780
+ * ```
15781
+ */
15782
+ function createPositionMarkers(series, positions, options) {
15783
+ const manager = new PositionMarkersManager(series, options);
15784
+ if (positions && positions.length > 0) {
15785
+ manager.setPositions(positions);
15786
+ }
15787
+ return manager;
15788
+ }
15789
+
15591
15790
  /**
15592
15791
  * Apply SMA (Simple Moving Average) indicator to a series
15593
15792
  * @param series - Source series to calculate SMA from
@@ -17087,7 +17286,7 @@
17087
17286
  * Returns the current version as a string. For example `'1.0.0'`.
17088
17287
  */
17089
17288
  function version() {
17090
- return "0.0.11-dev+202510282325";
17289
+ return "0.0.12";
17091
17290
  }
17092
17291
 
17093
17292
  var PipsendChartsModule = /*#__PURE__*/Object.freeze({
@@ -17106,6 +17305,7 @@
17106
17305
  get LineStyle () { return LineStyle; },
17107
17306
  get LineType () { return LineType; },
17108
17307
  get MismatchDirection () { return MismatchDirection; },
17308
+ PositionMarkersManager: PositionMarkersManager,
17109
17309
  get PriceLineSource () { return PriceLineSource; },
17110
17310
  get PriceScaleMode () { return PriceScaleMode; },
17111
17311
  get TickMarkType () { return TickMarkType; },
@@ -17125,6 +17325,7 @@
17125
17325
  createImageWatermark: createImageWatermark,
17126
17326
  createInteractiveLineManager: createInteractiveLineManager,
17127
17327
  createOptionsChart: createOptionsChart,
17328
+ createPositionMarkers: createPositionMarkers,
17128
17329
  createSeriesMarkers: createSeriesMarkers,
17129
17330
  createTextWatermark: createTextWatermark,
17130
17331
  createTradingLine: createTradingLine,
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v0.0.11-dev+202510282325
4
- * Copyright (c) 2025 Pipsend
3
+ * Pipsend Charts v0.0.12
4
+ * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
7
7
  */
@@ -15585,6 +15585,205 @@ function createUpDownMarkers(series, options = {}) {
15585
15585
  return wrapper;
15586
15586
  }
15587
15587
 
15588
+ /**
15589
+ * Gestor de marcadores de posiciones de trading
15590
+ */
15591
+ class PositionMarkersManager {
15592
+ constructor(series, options) {
15593
+ this._private__markersPlugin = null;
15594
+ this._private__positions = [];
15595
+ this._private__options = {
15596
+ longColors: {
15597
+ entry: options?.longColors?.entry ?? '#26a69a',
15598
+ exit: options?.longColors?.exit ?? '#ef5350',
15599
+ },
15600
+ shortColors: {
15601
+ entry: options?.shortColors?.entry ?? '#ef5350',
15602
+ exit: options?.shortColors?.exit ?? '#26a69a',
15603
+ },
15604
+ defaultSize: options?.defaultSize ?? 1,
15605
+ };
15606
+ this._private__markersPlugin = createSeriesMarkers(series);
15607
+ }
15608
+ /**
15609
+ * Agrega una posición al gráfico
15610
+ */
15611
+ addPosition(position) {
15612
+ this._private__positions.push(position);
15613
+ this._private__updateMarkers();
15614
+ }
15615
+ /**
15616
+ * Agrega múltiples posiciones al gráfico
15617
+ */
15618
+ addPositions(positions) {
15619
+ this._private__positions.push(...positions);
15620
+ this._private__updateMarkers();
15621
+ }
15622
+ /**
15623
+ * Establece las posiciones (reemplaza las existentes)
15624
+ */
15625
+ setPositions(positions) {
15626
+ this._private__positions = [...positions];
15627
+ this._private__updateMarkers();
15628
+ }
15629
+ /**
15630
+ * Elimina una posición por ID
15631
+ */
15632
+ removePosition(id) {
15633
+ this._private__positions = this._private__positions.filter(p => p.id !== id);
15634
+ this._private__updateMarkers();
15635
+ }
15636
+ /**
15637
+ * Limpia todas las posiciones
15638
+ */
15639
+ clearPositions() {
15640
+ this._private__positions = [];
15641
+ this._private__updateMarkers();
15642
+ }
15643
+ /**
15644
+ * Obtiene todas las posiciones actuales
15645
+ */
15646
+ getPositions() {
15647
+ return this._private__positions;
15648
+ }
15649
+ /**
15650
+ * Actualiza las opciones del gestor
15651
+ */
15652
+ applyOptions(options) {
15653
+ if (options.longColors) {
15654
+ this._private__options.longColors = {
15655
+ ...this._private__options.longColors,
15656
+ ...options.longColors,
15657
+ };
15658
+ }
15659
+ if (options.shortColors) {
15660
+ this._private__options.shortColors = {
15661
+ ...this._private__options.shortColors,
15662
+ ...options.shortColors,
15663
+ };
15664
+ }
15665
+ if (options.defaultSize !== undefined) {
15666
+ this._private__options.defaultSize = options.defaultSize;
15667
+ }
15668
+ this._private__updateMarkers();
15669
+ }
15670
+ /**
15671
+ * Convierte las posiciones a marcadores de serie
15672
+ */
15673
+ _private__positionsToMarkers() {
15674
+ const markers = [];
15675
+ for (const position of this._private__positions) {
15676
+ const isLong = position.type === 'long';
15677
+ const size = position.size ?? this._private__options.defaultSize;
15678
+ const entryColor = position.color?.entry ??
15679
+ (isLong ? this._private__options.longColors.entry : this._private__options.shortColors.entry);
15680
+ const exitColor = position.color?.exit ??
15681
+ (isLong ? this._private__options.longColors.exit : this._private__options.shortColors.exit);
15682
+ const entryMarker = {
15683
+ time: position.entry.time,
15684
+ position: 'atPriceMiddle',
15685
+ price: position.entry.price,
15686
+ shape: isLong ? 'arrowUp' : 'arrowDown',
15687
+ color: entryColor,
15688
+ size: size,
15689
+ };
15690
+ if (position.text?.entry) {
15691
+ entryMarker.text = position.text.entry;
15692
+ }
15693
+ if (position.id) {
15694
+ entryMarker.id = `${position.id}-entry`;
15695
+ }
15696
+ markers.push(entryMarker);
15697
+ const exitMarker = {
15698
+ time: position.exit.time,
15699
+ position: 'atPriceMiddle',
15700
+ price: position.exit.price,
15701
+ shape: isLong ? 'arrowDown' : 'arrowUp',
15702
+ color: exitColor,
15703
+ size: size,
15704
+ };
15705
+ if (position.text?.exit) {
15706
+ exitMarker.text = position.text.exit;
15707
+ }
15708
+ if (position.id) {
15709
+ exitMarker.id = `${position.id}-exit`;
15710
+ }
15711
+ markers.push(exitMarker);
15712
+ }
15713
+ return markers;
15714
+ }
15715
+ /**
15716
+ * Actualiza los marcadores en el gráfico
15717
+ */
15718
+ _private__updateMarkers() {
15719
+ if (this._private__markersPlugin) {
15720
+ const markers = this._private__positionsToMarkers();
15721
+ this._private__markersPlugin.setMarkers(markers);
15722
+ }
15723
+ }
15724
+ /**
15725
+ * Desconecta el plugin y limpia recursos
15726
+ */
15727
+ detach() {
15728
+ if (this._private__markersPlugin) {
15729
+ this._private__markersPlugin.detach();
15730
+ this._private__markersPlugin = null;
15731
+ }
15732
+ this._private__positions = [];
15733
+ }
15734
+ }
15735
+ /**
15736
+ * Crea un gestor de marcadores de posiciones de trading
15737
+ *
15738
+ * @param series - Serie a la que se adjuntarán los marcadores
15739
+ * @param positions - Posiciones iniciales (opcional)
15740
+ * @param options - Opciones de configuración (opcional)
15741
+ * @returns Instancia del gestor de posiciones
15742
+ *
15743
+ * @example
15744
+ * ```typescript
15745
+ * // Crear el gestor
15746
+ * const positionMarkers = createPositionMarkers(candleSeries);
15747
+ *
15748
+ * // Agregar una posición long
15749
+ * positionMarkers.addPosition({
15750
+ * type: 'long',
15751
+ * entry: { time: '2023-01-01', price: 100.50 },
15752
+ * exit: { time: '2023-01-05', price: 105.20 },
15753
+ * id: 'pos-1'
15754
+ * });
15755
+ *
15756
+ * // Agregar una posición short
15757
+ * positionMarkers.addPosition({
15758
+ * type: 'short',
15759
+ * entry: { time: '2023-01-10', price: 110.00 },
15760
+ * exit: { time: '2023-01-15', price: 107.50 },
15761
+ * id: 'pos-2'
15762
+ * });
15763
+ *
15764
+ * // Agregar múltiples posiciones
15765
+ * positionMarkers.setPositions([
15766
+ * {
15767
+ * type: 'long',
15768
+ * entry: { time: '2023-02-01', price: 95.00 },
15769
+ * exit: { time: '2023-02-10', price: 98.50 }
15770
+ * },
15771
+ * {
15772
+ * type: 'short',
15773
+ * entry: { time: '2023-02-15', price: 102.00 },
15774
+ * exit: { time: '2023-02-20', price: 99.00 }
15775
+ * }
15776
+ * ]);
15777
+ * ```
15778
+ */
15779
+ function createPositionMarkers(series, positions, options) {
15780
+ const manager = new PositionMarkersManager(series, options);
15781
+ if (positions && positions.length > 0) {
15782
+ manager.setPositions(positions);
15783
+ }
15784
+ return manager;
15785
+ }
15786
+
15588
15787
  /**
15589
15788
  * Apply SMA (Simple Moving Average) indicator to a series
15590
15789
  * @param series - Source series to calculate SMA from
@@ -17084,7 +17283,7 @@ const customSeriesDefaultOptions = {
17084
17283
  * Returns the current version as a string. For example `'1.0.0'`.
17085
17284
  */
17086
17285
  function version() {
17087
- return "0.0.11-dev+202510282325";
17286
+ return "0.0.12";
17088
17287
  }
17089
17288
 
17090
- export { areaSeries as AreaSeries, barSeries as BarSeries, baselineSeries as BaselineSeries, candlestickSeries as CandlestickSeries, ColorType, CrosshairMode, DraggablePriceLine, histogramSeries as HistogramSeries, InteractiveLineManager, LastPriceAnimationMode, lineSeries as LineSeries, LineStyle, LineType, MismatchDirection, PriceLineSource, PriceScaleMode, TickMarkType, TrackingModeExitMode, applyATR, applyBollingerBands, applyEMA, applyMACD, applyOBV, applyRSI, applySMA, applyStochastic, applyVolume, applyWMA, createChart, createChartEx, createImageWatermark, createInteractiveLineManager, createOptionsChart, createSeriesMarkers, createTextWatermark, createTradingLine, createUpDownMarkers, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, isBusinessDay, isUTCTimestamp, setOBVVolumeData, setVolumeData, version };
17289
+ export { areaSeries as AreaSeries, barSeries as BarSeries, baselineSeries as BaselineSeries, candlestickSeries as CandlestickSeries, ColorType, CrosshairMode, DraggablePriceLine, histogramSeries as HistogramSeries, InteractiveLineManager, LastPriceAnimationMode, lineSeries as LineSeries, LineStyle, LineType, MismatchDirection, PositionMarkersManager, PriceLineSource, PriceScaleMode, TickMarkType, TrackingModeExitMode, applyATR, applyBollingerBands, applyEMA, applyMACD, applyOBV, applyRSI, applySMA, applyStochastic, applyVolume, applyWMA, createChart, createChartEx, createImageWatermark, createInteractiveLineManager, createOptionsChart, createPositionMarkers, createSeriesMarkers, createTextWatermark, createTradingLine, createUpDownMarkers, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, isBusinessDay, isUTCTimestamp, setOBVVolumeData, setVolumeData, version };