@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)
@@ -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();
@@ -23736,7 +23769,7 @@ const customSeriesDefaultOptions = {
23736
23769
  * Returns the current version as a string. For example `'1.0.0'`.
23737
23770
  */
23738
23771
  function version() {
23739
- return "1.0.0";
23772
+ return "1.1.0";
23740
23773
  }
23741
23774
 
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 };
23775
+ 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 };