@pipsend/charts 1.0.0 → 1.1.1

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,6 +1,6 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v1.0.0
3
+ * Pipsend Charts v1.1.1-dev+202601191502
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -18133,33 +18133,67 @@ class PositionCalculator {
18133
18133
  }
18134
18134
  }
18135
18135
  /**
18136
- * Default pip configurations for common symbols
18136
+ * Automatically calculate pip configuration based on price
18137
+ * This is completely generic and works for any instrument
18137
18138
  */
18138
- const DEFAULT_PIP_CONFIGS = {
18139
- // FX Majors (4 decimals)
18140
- 'EURUSD': { symbol: 'EURUSD', pipValue: 0.0001 },
18141
- 'GBPUSD': { symbol: 'GBPUSD', pipValue: 0.0001 },
18142
- 'AUDUSD': { symbol: 'AUDUSD', pipValue: 0.0001 },
18143
- 'NZDUSD': { symbol: 'NZDUSD', pipValue: 0.0001 },
18144
- 'USDCAD': { symbol: 'USDCAD', pipValue: 0.0001 },
18145
- 'USDCHF': { symbol: 'USDCHF', pipValue: 0.0001 },
18146
- // JPY Pairs (2 decimals)
18147
- 'USDJPY': { symbol: 'USDJPY', pipValue: 0.01 },
18148
- 'EURJPY': { symbol: 'EURJPY', pipValue: 0.01 },
18149
- 'GBPJPY': { symbol: 'GBPJPY', pipValue: 0.01 },
18150
- 'AUDJPY': { symbol: 'AUDJPY', pipValue: 0.01 },
18151
- // Crypto (variable)
18152
- 'BTCUSD': { symbol: 'BTCUSD', pipValue: 1 },
18153
- 'ETHUSD': { symbol: 'ETHUSD', pipValue: 0.1 },
18154
- // Default
18155
- 'DEFAULT': { symbol: 'DEFAULT', pipValue: 0.0001 },
18156
- };
18139
+ function calculatePipConfig(price) {
18140
+ // Convert price to string to analyze decimal places
18141
+ const priceStr = price.toString();
18142
+ const parts = priceStr.split('.');
18143
+ // Count decimal places
18144
+ const decimals = parts.length > 1 ? parts[1].length : 0;
18145
+ // Calculate pip value based on decimal places
18146
+ // Strategy: 1 pip = smallest meaningful price movement
18147
+ // For prices with many decimals, use 0.0001 (FX style)
18148
+ // For prices with few decimals, use 0.1 or 1
18149
+ let pipValue;
18150
+ if (decimals >= 5) {
18151
+ // Very high precision (rare, but handle it)
18152
+ pipValue = 0.00001;
18153
+ }
18154
+ else if (decimals === 4) {
18155
+ // FX majors: 1.2345 → pip = 0.0001
18156
+ pipValue = 0.0001;
18157
+ }
18158
+ else if (decimals === 3) {
18159
+ // JPY pairs or some commodities: 123.456 → pip = 0.001
18160
+ pipValue = 0.001;
18161
+ }
18162
+ else if (decimals === 2) {
18163
+ // Most commodities/indices: 1234.56 → pip = 0.01
18164
+ pipValue = 0.01;
18165
+ }
18166
+ else if (decimals === 1) {
18167
+ // Some indices: 12345.6 → pip = 0.1
18168
+ pipValue = 0.1;
18169
+ }
18170
+ else {
18171
+ // Whole numbers: 12345 → pip = 1
18172
+ pipValue = 1;
18173
+ }
18174
+ return {
18175
+ pipValue,
18176
+ decimals
18177
+ };
18178
+ }
18157
18179
  /**
18158
- * Helper function to get pip config for a symbol
18180
+ * Helper function for backward compatibility
18181
+ * Now ignores symbol and uses price-based detection
18159
18182
  */
18160
- function getPipConfig(symbol) {
18161
- const upperSymbol = symbol.toUpperCase();
18162
- return DEFAULT_PIP_CONFIGS[upperSymbol] || DEFAULT_PIP_CONFIGS['DEFAULT'];
18183
+ function getPipConfig(symbolOrPrice, price) {
18184
+ // If first argument is a number, use it as price
18185
+ if (typeof symbolOrPrice === 'number') {
18186
+ return calculatePipConfig(symbolOrPrice);
18187
+ }
18188
+ // If price is provided, use it
18189
+ if (price !== undefined) {
18190
+ return calculatePipConfig(price);
18191
+ }
18192
+ // Fallback: return default config (will be recalculated when price is known)
18193
+ return {
18194
+ pipValue: 0.1,
18195
+ decimals: 1
18196
+ };
18163
18197
  }
18164
18198
 
18165
18199
  class PositionPaneRenderer {
@@ -18210,11 +18244,10 @@ class PositionTool extends DrawingToolBase {
18210
18244
  entryLineColor: '#ffffff',
18211
18245
  opacity: 0.3,
18212
18246
  showTooltips: true,
18213
- symbol: 'DEFAULT',
18214
18247
  ...options,
18215
18248
  };
18216
- // Initialize calculator
18217
- const pipConfig = this._private__positionOptions.pipConfig || getPipConfig(this._private__positionOptions.symbol || 'DEFAULT');
18249
+ // Initialize calculator with automatic pip detection based on entry price
18250
+ const pipConfig = this._private__positionOptions.pipConfig || getPipConfig(this._private__positionOptions.entryPrice);
18218
18251
  this._private__calculator = new PositionCalculator(pipConfig);
18219
18252
  // Create primitive and setup
18220
18253
  this._private__createPrimitive();
@@ -18711,6 +18744,8 @@ class PositionTool extends DrawingToolBase {
18711
18744
  if (this._private__primitive) {
18712
18745
  this._series.detachPrimitive(this._private__primitive);
18713
18746
  this._private__primitive = null;
18747
+ // Force chart redraw to clear the detached primitive
18748
+ this._chart.timeScale().applyOptions({});
18714
18749
  }
18715
18750
  if (this._private__positionOptions.onRemove) {
18716
18751
  this._private__positionOptions.onRemove();
@@ -19223,6 +19258,8 @@ class RulerTool extends DrawingToolBase {
19223
19258
  if (this._private__primitive) {
19224
19259
  this._series.detachPrimitive(this._private__primitive);
19225
19260
  this._private__primitive = null;
19261
+ // Force chart redraw to clear the detached primitive
19262
+ this._chart.timeScale().applyOptions({});
19226
19263
  }
19227
19264
  if (this._private__drawingManager) {
19228
19265
  this._private__drawingManager._internal_destroy();
@@ -19912,6 +19949,8 @@ class FibonacciTool extends DrawingToolBase {
19912
19949
  if (this._private__primitive) {
19913
19950
  this._series.detachPrimitive(this._private__primitive);
19914
19951
  this._private__primitive = null;
19952
+ // Force chart redraw to clear the detached primitive
19953
+ this._chart.timeScale().applyOptions({});
19915
19954
  }
19916
19955
  if (this._private__drawingManager) {
19917
19956
  this._private__drawingManager._internal_destroy();
@@ -19926,6 +19965,8 @@ class FibonacciTool extends DrawingToolBase {
19926
19965
  if (this._private__primitive) {
19927
19966
  this._series.detachPrimitive(this._private__primitive);
19928
19967
  this._private__primitive = null;
19968
+ // Force chart redraw to clear the detached primitive
19969
+ this._chart.timeScale().applyOptions({});
19929
19970
  }
19930
19971
  if (this._private__fibOptions.onRemove) {
19931
19972
  this._private__fibOptions.onRemove();
@@ -20293,6 +20334,8 @@ class TrendLineTool extends DrawingToolBase {
20293
20334
  if (this._private__primitive) {
20294
20335
  this._series.detachPrimitive(this._private__primitive);
20295
20336
  this._private__primitive = null;
20337
+ // Force chart redraw to clear the detached primitive
20338
+ this._chart.timeScale().applyOptions({});
20296
20339
  }
20297
20340
  if (this._private__trendOptions.onRemove) {
20298
20341
  this._private__trendOptions.onRemove();
@@ -20492,6 +20535,8 @@ class HorizontalLineTool extends DrawingToolBase {
20492
20535
  if (this._private__primitive) {
20493
20536
  this._series.detachPrimitive(this._private__primitive);
20494
20537
  this._private__primitive = null;
20538
+ // Force chart redraw to clear the detached primitive
20539
+ this._chart.timeScale().applyOptions({});
20495
20540
  }
20496
20541
  if (this._private__hLineOptions.onRemove) {
20497
20542
  this._private__hLineOptions.onRemove();
@@ -20693,6 +20738,8 @@ class VerticalLineTool extends DrawingToolBase {
20693
20738
  if (this._private__primitive) {
20694
20739
  this._series.detachPrimitive(this._private__primitive);
20695
20740
  this._private__primitive = null;
20741
+ // Force chart redraw to clear the detached primitive
20742
+ this._chart.timeScale().applyOptions({});
20696
20743
  }
20697
20744
  if (this._private__vLineOptions.onRemove) {
20698
20745
  this._private__vLineOptions.onRemove();
@@ -21115,6 +21162,8 @@ class ArrowTool extends DrawingToolBase {
21115
21162
  if (this._private__primitive) {
21116
21163
  this._series.detachPrimitive(this._private__primitive);
21117
21164
  this._private__primitive = null;
21165
+ // Force chart redraw to clear the detached primitive
21166
+ this._chart.timeScale().applyOptions({});
21118
21167
  }
21119
21168
  if (this._private__arrowOptions.onRemove) {
21120
21169
  this._private__arrowOptions.onRemove();
@@ -21591,6 +21640,8 @@ class RectangleTool extends DrawingToolBase {
21591
21640
  if (this._private__primitive) {
21592
21641
  this._series.detachPrimitive(this._private__primitive);
21593
21642
  this._private__primitive = null;
21643
+ // Force chart redraw to clear the detached primitive
21644
+ this._chart.timeScale().applyOptions({});
21594
21645
  }
21595
21646
  if (this._private__rectOptions.onRemove) {
21596
21647
  this._private__rectOptions.onRemove();
@@ -21970,6 +22021,8 @@ class CircleTool extends DrawingToolBase {
21970
22021
  if (this._private__primitive) {
21971
22022
  this._series.detachPrimitive(this._private__primitive);
21972
22023
  this._private__primitive = null;
22024
+ // Force chart redraw to clear the detached primitive
22025
+ this._chart.timeScale().applyOptions({});
21973
22026
  }
21974
22027
  if (this._private__circleOptions.onRemove) {
21975
22028
  this._private__circleOptions.onRemove();
@@ -22344,6 +22397,8 @@ class FibonacciFanTool extends DrawingToolBase {
22344
22397
  if (this._private__primitive) {
22345
22398
  this._series.detachPrimitive(this._private__primitive);
22346
22399
  this._private__primitive = null;
22400
+ // Force chart redraw to clear the detached primitive
22401
+ this._chart.timeScale().applyOptions({});
22347
22402
  }
22348
22403
  if (this._private__fanOptions.onRemove) {
22349
22404
  this._private__fanOptions.onRemove();
@@ -22722,6 +22777,8 @@ class FibonacciExtensionTool extends DrawingToolBase {
22722
22777
  if (this._private__primitive) {
22723
22778
  this._series.detachPrimitive(this._private__primitive);
22724
22779
  this._private__primitive = null;
22780
+ // Force chart redraw to clear the detached primitive
22781
+ this._chart.timeScale().applyOptions({});
22725
22782
  }
22726
22783
  }
22727
22784
  }
@@ -22958,6 +23015,8 @@ class GanttTool extends DrawingToolBase {
22958
23015
  if (this._private__primitive) {
22959
23016
  this._series.detachPrimitive(this._private__primitive);
22960
23017
  this._private__primitive = null;
23018
+ // Force chart redraw to clear the detached primitive
23019
+ this._chart.timeScale().applyOptions({});
22961
23020
  }
22962
23021
  if (this._private__ganttOptions.onRemove) {
22963
23022
  this._private__ganttOptions.onRemove();
@@ -23404,6 +23463,8 @@ class BrushTool extends DrawingToolBase {
23404
23463
  if (this._private__primitive) {
23405
23464
  this._series.detachPrimitive(this._private__primitive);
23406
23465
  this._private__primitive = null;
23466
+ // Force chart redraw to clear the detached primitive
23467
+ this._chart.timeScale().applyOptions({});
23407
23468
  }
23408
23469
  if (this._private__brushOptions.onRemove) {
23409
23470
  this._private__brushOptions.onRemove();
@@ -23716,6 +23777,9 @@ class TextTool extends DrawingToolBase {
23716
23777
  }
23717
23778
  if (this._private__primitive && this._series) {
23718
23779
  this._series.detachPrimitive(this._private__primitive);
23780
+ this._private__primitive = null;
23781
+ // Force chart redraw to clear the detached primitive
23782
+ this._chart.timeScale().applyOptions({});
23719
23783
  }
23720
23784
  if (this._private__textOptions.onRemove) {
23721
23785
  this._private__textOptions.onRemove();
@@ -23736,7 +23800,7 @@ const customSeriesDefaultOptions = {
23736
23800
  * Returns the current version as a string. For example `'1.0.0'`.
23737
23801
  */
23738
23802
  function version() {
23739
- return "1.0.0";
23803
+ return "1.1.1-dev+202601191502";
23740
23804
  }
23741
23805
 
23742
- export { areaSeries as AreaSeries, ArrowTool, barSeries as BarSeries, baselineSeries as BaselineSeries, BrushTool, candlestickSeries as CandlestickSeries, CircleTool, ColorType, CrosshairMode, DEFAULT_PIP_CONFIGS, DEFAULT_SESSIONS, DraggablePriceLine, DrawingToolsManager, EXTENDED_FIBONACCI_RATIOS, FibonacciCalculator, FibonacciExtensionTool, FibonacciFanTool, FibonacciTool, GanttTool, histogramSeries as HistogramSeries, HorizontalLineTool, InteractiveLineManager, LastPriceAnimationMode, lineSeries as LineSeries, LineStyle, LineType, MismatchDirection, PositionCalculator, PositionMarkersManager, PositionTool, PriceLineSource, PriceScaleMode, RectangleTool, RulerCalculator, RulerTool, STANDARD_FIBONACCI_RATIOS, TextTool, TickMarkType, TrackingModeExitMode, TradingSessionsIndicator, TrendLineTool, VerticalLineTool, VolumeProfileIndicator, applyATR, applyBollingerBands, applyEMA, applyMACD, applyOBV, applyRSI, applySMA, applyStochastic, applyVolume, applyWMA, createArrowTool, createBrushTool, createChart, createChartEx, createCircleTool, createFibonacciExtensionTool, createFibonacciFanTool, createFibonacciTool, createGanttTool, createHorizontalLineTool, createImageWatermark, createInteractiveLineManager, createOptionsChart, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, isBusinessDay, isUTCTimestamp, setOBVVolumeData, setVolumeData, setVolumeProfileData, version };
23806
+ export { areaSeries as AreaSeries, ArrowTool, barSeries as BarSeries, baselineSeries as BaselineSeries, BrushTool, candlestickSeries as CandlestickSeries, CircleTool, ColorType, CrosshairMode, DEFAULT_SESSIONS, DraggablePriceLine, DrawingToolsManager, EXTENDED_FIBONACCI_RATIOS, FibonacciCalculator, FibonacciExtensionTool, FibonacciFanTool, FibonacciTool, GanttTool, histogramSeries as HistogramSeries, HorizontalLineTool, InteractiveLineManager, LastPriceAnimationMode, lineSeries as LineSeries, LineStyle, LineType, MismatchDirection, PositionCalculator, PositionMarkersManager, PositionTool, PriceLineSource, PriceScaleMode, RectangleTool, RulerCalculator, RulerTool, STANDARD_FIBONACCI_RATIOS, TextTool, TickMarkType, TrackingModeExitMode, TradingSessionsIndicator, TrendLineTool, VerticalLineTool, VolumeProfileIndicator, applyATR, applyBollingerBands, applyEMA, applyMACD, applyOBV, applyRSI, applySMA, applyStochastic, applyVolume, applyWMA, calculatePipConfig, createArrowTool, createBrushTool, createChart, createChartEx, createCircleTool, createFibonacciExtensionTool, createFibonacciFanTool, createFibonacciTool, createGanttTool, createHorizontalLineTool, createImageWatermark, createInteractiveLineManager, createOptionsChart, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, isBusinessDay, isUTCTimestamp, setOBVVolumeData, setVolumeData, setVolumeProfileData, version };