@pipsend/charts 1.0.0 → 1.1.0

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.0
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -18529,33 +18529,67 @@
18529
18529
  }
18530
18530
  }
18531
18531
  /**
18532
- * Default pip configurations for common symbols
18532
+ * Automatically calculate pip configuration based on price
18533
+ * This is completely generic and works for any instrument
18533
18534
  */
18534
- const DEFAULT_PIP_CONFIGS = {
18535
- // FX Majors (4 decimals)
18536
- 'EURUSD': { symbol: 'EURUSD', pipValue: 0.0001 },
18537
- 'GBPUSD': { symbol: 'GBPUSD', pipValue: 0.0001 },
18538
- 'AUDUSD': { symbol: 'AUDUSD', pipValue: 0.0001 },
18539
- 'NZDUSD': { symbol: 'NZDUSD', pipValue: 0.0001 },
18540
- 'USDCAD': { symbol: 'USDCAD', pipValue: 0.0001 },
18541
- 'USDCHF': { symbol: 'USDCHF', pipValue: 0.0001 },
18542
- // JPY Pairs (2 decimals)
18543
- 'USDJPY': { symbol: 'USDJPY', pipValue: 0.01 },
18544
- 'EURJPY': { symbol: 'EURJPY', pipValue: 0.01 },
18545
- 'GBPJPY': { symbol: 'GBPJPY', pipValue: 0.01 },
18546
- 'AUDJPY': { symbol: 'AUDJPY', pipValue: 0.01 },
18547
- // Crypto (variable)
18548
- 'BTCUSD': { symbol: 'BTCUSD', pipValue: 1 },
18549
- 'ETHUSD': { symbol: 'ETHUSD', pipValue: 0.1 },
18550
- // Default
18551
- 'DEFAULT': { symbol: 'DEFAULT', pipValue: 0.0001 },
18552
- };
18535
+ function calculatePipConfig(price) {
18536
+ // Convert price to string to analyze decimal places
18537
+ const priceStr = price.toString();
18538
+ const parts = priceStr.split('.');
18539
+ // Count decimal places
18540
+ const decimals = parts.length > 1 ? parts[1].length : 0;
18541
+ // Calculate pip value based on decimal places
18542
+ // Strategy: 1 pip = smallest meaningful price movement
18543
+ // For prices with many decimals, use 0.0001 (FX style)
18544
+ // For prices with few decimals, use 0.1 or 1
18545
+ let pipValue;
18546
+ if (decimals >= 5) {
18547
+ // Very high precision (rare, but handle it)
18548
+ pipValue = 0.00001;
18549
+ }
18550
+ else if (decimals === 4) {
18551
+ // FX majors: 1.2345 → pip = 0.0001
18552
+ pipValue = 0.0001;
18553
+ }
18554
+ else if (decimals === 3) {
18555
+ // JPY pairs or some commodities: 123.456 → pip = 0.001
18556
+ pipValue = 0.001;
18557
+ }
18558
+ else if (decimals === 2) {
18559
+ // Most commodities/indices: 1234.56 → pip = 0.01
18560
+ pipValue = 0.01;
18561
+ }
18562
+ else if (decimals === 1) {
18563
+ // Some indices: 12345.6 → pip = 0.1
18564
+ pipValue = 0.1;
18565
+ }
18566
+ else {
18567
+ // Whole numbers: 12345 → pip = 1
18568
+ pipValue = 1;
18569
+ }
18570
+ return {
18571
+ pipValue,
18572
+ decimals
18573
+ };
18574
+ }
18553
18575
  /**
18554
- * Helper function to get pip config for a symbol
18576
+ * Helper function for backward compatibility
18577
+ * Now ignores symbol and uses price-based detection
18555
18578
  */
18556
- function getPipConfig(symbol) {
18557
- const upperSymbol = symbol.toUpperCase();
18558
- return DEFAULT_PIP_CONFIGS[upperSymbol] || DEFAULT_PIP_CONFIGS['DEFAULT'];
18579
+ function getPipConfig(symbolOrPrice, price) {
18580
+ // If first argument is a number, use it as price
18581
+ if (typeof symbolOrPrice === 'number') {
18582
+ return calculatePipConfig(symbolOrPrice);
18583
+ }
18584
+ // If price is provided, use it
18585
+ if (price !== undefined) {
18586
+ return calculatePipConfig(price);
18587
+ }
18588
+ // Fallback: return default config (will be recalculated when price is known)
18589
+ return {
18590
+ pipValue: 0.1,
18591
+ decimals: 1
18592
+ };
18559
18593
  }
18560
18594
 
18561
18595
  class PositionPaneRenderer {
@@ -18606,11 +18640,10 @@
18606
18640
  entryLineColor: '#ffffff',
18607
18641
  opacity: 0.3,
18608
18642
  showTooltips: true,
18609
- symbol: 'DEFAULT',
18610
18643
  ...options,
18611
18644
  };
18612
- // Initialize calculator
18613
- const pipConfig = this._private__positionOptions.pipConfig || getPipConfig(this._private__positionOptions.symbol || 'DEFAULT');
18645
+ // Initialize calculator with automatic pip detection based on entry price
18646
+ const pipConfig = this._private__positionOptions.pipConfig || getPipConfig(this._private__positionOptions.entryPrice);
18614
18647
  this._private__calculator = new PositionCalculator(pipConfig);
18615
18648
  // Create primitive and setup
18616
18649
  this._private__createPrimitive();
@@ -24132,7 +24165,7 @@
24132
24165
  * Returns the current version as a string. For example `'1.0.0'`.
24133
24166
  */
24134
24167
  function version() {
24135
- return "1.0.0";
24168
+ return "1.1.0";
24136
24169
  }
24137
24170
 
24138
24171
  var PipsendChartsModule = /*#__PURE__*/Object.freeze({
@@ -24146,7 +24179,6 @@
24146
24179
  CircleTool: CircleTool,
24147
24180
  get ColorType () { return ColorType; },
24148
24181
  get CrosshairMode () { return CrosshairMode; },
24149
- DEFAULT_PIP_CONFIGS: DEFAULT_PIP_CONFIGS,
24150
24182
  DEFAULT_SESSIONS: DEFAULT_SESSIONS,
24151
24183
  DraggablePriceLine: DraggablePriceLine,
24152
24184
  DrawingToolsManager: DrawingToolsManager,
@@ -24190,6 +24222,7 @@
24190
24222
  applyStochastic: applyStochastic,
24191
24223
  applyVolume: applyVolume,
24192
24224
  applyWMA: applyWMA,
24225
+ calculatePipConfig: calculatePipConfig,
24193
24226
  createArrowTool: createArrowTool,
24194
24227
  createBrushTool: createBrushTool,
24195
24228
  createChart: createChart,
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v1.0.0
3
+ * Pipsend Charts v1.1.0
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -18526,33 +18526,67 @@ class PositionCalculator {
18526
18526
  }
18527
18527
  }
18528
18528
  /**
18529
- * Default pip configurations for common symbols
18529
+ * Automatically calculate pip configuration based on price
18530
+ * This is completely generic and works for any instrument
18530
18531
  */
18531
- const DEFAULT_PIP_CONFIGS = {
18532
- // FX Majors (4 decimals)
18533
- 'EURUSD': { symbol: 'EURUSD', pipValue: 0.0001 },
18534
- 'GBPUSD': { symbol: 'GBPUSD', pipValue: 0.0001 },
18535
- 'AUDUSD': { symbol: 'AUDUSD', pipValue: 0.0001 },
18536
- 'NZDUSD': { symbol: 'NZDUSD', pipValue: 0.0001 },
18537
- 'USDCAD': { symbol: 'USDCAD', pipValue: 0.0001 },
18538
- 'USDCHF': { symbol: 'USDCHF', pipValue: 0.0001 },
18539
- // JPY Pairs (2 decimals)
18540
- 'USDJPY': { symbol: 'USDJPY', pipValue: 0.01 },
18541
- 'EURJPY': { symbol: 'EURJPY', pipValue: 0.01 },
18542
- 'GBPJPY': { symbol: 'GBPJPY', pipValue: 0.01 },
18543
- 'AUDJPY': { symbol: 'AUDJPY', pipValue: 0.01 },
18544
- // Crypto (variable)
18545
- 'BTCUSD': { symbol: 'BTCUSD', pipValue: 1 },
18546
- 'ETHUSD': { symbol: 'ETHUSD', pipValue: 0.1 },
18547
- // Default
18548
- 'DEFAULT': { symbol: 'DEFAULT', pipValue: 0.0001 },
18549
- };
18532
+ function calculatePipConfig(price) {
18533
+ // Convert price to string to analyze decimal places
18534
+ const priceStr = price.toString();
18535
+ const parts = priceStr.split('.');
18536
+ // Count decimal places
18537
+ const decimals = parts.length > 1 ? parts[1].length : 0;
18538
+ // Calculate pip value based on decimal places
18539
+ // Strategy: 1 pip = smallest meaningful price movement
18540
+ // For prices with many decimals, use 0.0001 (FX style)
18541
+ // For prices with few decimals, use 0.1 or 1
18542
+ let pipValue;
18543
+ if (decimals >= 5) {
18544
+ // Very high precision (rare, but handle it)
18545
+ pipValue = 0.00001;
18546
+ }
18547
+ else if (decimals === 4) {
18548
+ // FX majors: 1.2345 → pip = 0.0001
18549
+ pipValue = 0.0001;
18550
+ }
18551
+ else if (decimals === 3) {
18552
+ // JPY pairs or some commodities: 123.456 → pip = 0.001
18553
+ pipValue = 0.001;
18554
+ }
18555
+ else if (decimals === 2) {
18556
+ // Most commodities/indices: 1234.56 → pip = 0.01
18557
+ pipValue = 0.01;
18558
+ }
18559
+ else if (decimals === 1) {
18560
+ // Some indices: 12345.6 → pip = 0.1
18561
+ pipValue = 0.1;
18562
+ }
18563
+ else {
18564
+ // Whole numbers: 12345 → pip = 1
18565
+ pipValue = 1;
18566
+ }
18567
+ return {
18568
+ pipValue,
18569
+ decimals
18570
+ };
18571
+ }
18550
18572
  /**
18551
- * Helper function to get pip config for a symbol
18573
+ * Helper function for backward compatibility
18574
+ * Now ignores symbol and uses price-based detection
18552
18575
  */
18553
- function getPipConfig(symbol) {
18554
- const upperSymbol = symbol.toUpperCase();
18555
- return DEFAULT_PIP_CONFIGS[upperSymbol] || DEFAULT_PIP_CONFIGS['DEFAULT'];
18576
+ function getPipConfig(symbolOrPrice, price) {
18577
+ // If first argument is a number, use it as price
18578
+ if (typeof symbolOrPrice === 'number') {
18579
+ return calculatePipConfig(symbolOrPrice);
18580
+ }
18581
+ // If price is provided, use it
18582
+ if (price !== undefined) {
18583
+ return calculatePipConfig(price);
18584
+ }
18585
+ // Fallback: return default config (will be recalculated when price is known)
18586
+ return {
18587
+ pipValue: 0.1,
18588
+ decimals: 1
18589
+ };
18556
18590
  }
18557
18591
 
18558
18592
  class PositionPaneRenderer {
@@ -18603,11 +18637,10 @@ class PositionTool extends DrawingToolBase {
18603
18637
  entryLineColor: '#ffffff',
18604
18638
  opacity: 0.3,
18605
18639
  showTooltips: true,
18606
- symbol: 'DEFAULT',
18607
18640
  ...options,
18608
18641
  };
18609
- // Initialize calculator
18610
- const pipConfig = this._private__positionOptions.pipConfig || getPipConfig(this._private__positionOptions.symbol || 'DEFAULT');
18642
+ // Initialize calculator with automatic pip detection based on entry price
18643
+ const pipConfig = this._private__positionOptions.pipConfig || getPipConfig(this._private__positionOptions.entryPrice);
18611
18644
  this._private__calculator = new PositionCalculator(pipConfig);
18612
18645
  // Create primitive and setup
18613
18646
  this._private__createPrimitive();
@@ -24129,7 +24162,7 @@ const customSeriesDefaultOptions = {
24129
24162
  * Returns the current version as a string. For example `'1.0.0'`.
24130
24163
  */
24131
24164
  function version() {
24132
- return "1.0.0";
24165
+ return "1.1.0";
24133
24166
  }
24134
24167
 
24135
- 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 };
24168
+ 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 };