@pipsend/charts 0.0.11 → 0.0.12
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.
- package/dist/pipsend-charts.development.mjs +203 -4
- package/dist/pipsend-charts.production.mjs +3 -3
- package/dist/pipsend-charts.standalone.development.js +204 -3
- package/dist/pipsend-charts.standalone.development.mjs +203 -4
- package/dist/pipsend-charts.standalone.production.js +3 -3
- package/dist/pipsend-charts.standalone.production.mjs +3 -3
- package/dist/typings.d.ts +167 -0
- package/package.json +1 -83
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @license
|
|
3
|
-
* Pipsend Charts v0.0.
|
|
4
|
-
* Copyright (c)
|
|
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
|
*/
|
|
@@ -15192,6 +15192,205 @@ function createUpDownMarkers(series, options = {}) {
|
|
|
15192
15192
|
return wrapper;
|
|
15193
15193
|
}
|
|
15194
15194
|
|
|
15195
|
+
/**
|
|
15196
|
+
* Gestor de marcadores de posiciones de trading
|
|
15197
|
+
*/
|
|
15198
|
+
class PositionMarkersManager {
|
|
15199
|
+
constructor(series, options) {
|
|
15200
|
+
this._private__markersPlugin = null;
|
|
15201
|
+
this._private__positions = [];
|
|
15202
|
+
this._private__options = {
|
|
15203
|
+
longColors: {
|
|
15204
|
+
entry: options?.longColors?.entry ?? '#26a69a',
|
|
15205
|
+
exit: options?.longColors?.exit ?? '#ef5350',
|
|
15206
|
+
},
|
|
15207
|
+
shortColors: {
|
|
15208
|
+
entry: options?.shortColors?.entry ?? '#ef5350',
|
|
15209
|
+
exit: options?.shortColors?.exit ?? '#26a69a',
|
|
15210
|
+
},
|
|
15211
|
+
defaultSize: options?.defaultSize ?? 1,
|
|
15212
|
+
};
|
|
15213
|
+
this._private__markersPlugin = createSeriesMarkers(series);
|
|
15214
|
+
}
|
|
15215
|
+
/**
|
|
15216
|
+
* Agrega una posición al gráfico
|
|
15217
|
+
*/
|
|
15218
|
+
addPosition(position) {
|
|
15219
|
+
this._private__positions.push(position);
|
|
15220
|
+
this._private__updateMarkers();
|
|
15221
|
+
}
|
|
15222
|
+
/**
|
|
15223
|
+
* Agrega múltiples posiciones al gráfico
|
|
15224
|
+
*/
|
|
15225
|
+
addPositions(positions) {
|
|
15226
|
+
this._private__positions.push(...positions);
|
|
15227
|
+
this._private__updateMarkers();
|
|
15228
|
+
}
|
|
15229
|
+
/**
|
|
15230
|
+
* Establece las posiciones (reemplaza las existentes)
|
|
15231
|
+
*/
|
|
15232
|
+
setPositions(positions) {
|
|
15233
|
+
this._private__positions = [...positions];
|
|
15234
|
+
this._private__updateMarkers();
|
|
15235
|
+
}
|
|
15236
|
+
/**
|
|
15237
|
+
* Elimina una posición por ID
|
|
15238
|
+
*/
|
|
15239
|
+
removePosition(id) {
|
|
15240
|
+
this._private__positions = this._private__positions.filter(p => p.id !== id);
|
|
15241
|
+
this._private__updateMarkers();
|
|
15242
|
+
}
|
|
15243
|
+
/**
|
|
15244
|
+
* Limpia todas las posiciones
|
|
15245
|
+
*/
|
|
15246
|
+
clearPositions() {
|
|
15247
|
+
this._private__positions = [];
|
|
15248
|
+
this._private__updateMarkers();
|
|
15249
|
+
}
|
|
15250
|
+
/**
|
|
15251
|
+
* Obtiene todas las posiciones actuales
|
|
15252
|
+
*/
|
|
15253
|
+
getPositions() {
|
|
15254
|
+
return this._private__positions;
|
|
15255
|
+
}
|
|
15256
|
+
/**
|
|
15257
|
+
* Actualiza las opciones del gestor
|
|
15258
|
+
*/
|
|
15259
|
+
applyOptions(options) {
|
|
15260
|
+
if (options.longColors) {
|
|
15261
|
+
this._private__options.longColors = {
|
|
15262
|
+
...this._private__options.longColors,
|
|
15263
|
+
...options.longColors,
|
|
15264
|
+
};
|
|
15265
|
+
}
|
|
15266
|
+
if (options.shortColors) {
|
|
15267
|
+
this._private__options.shortColors = {
|
|
15268
|
+
...this._private__options.shortColors,
|
|
15269
|
+
...options.shortColors,
|
|
15270
|
+
};
|
|
15271
|
+
}
|
|
15272
|
+
if (options.defaultSize !== undefined) {
|
|
15273
|
+
this._private__options.defaultSize = options.defaultSize;
|
|
15274
|
+
}
|
|
15275
|
+
this._private__updateMarkers();
|
|
15276
|
+
}
|
|
15277
|
+
/**
|
|
15278
|
+
* Convierte las posiciones a marcadores de serie
|
|
15279
|
+
*/
|
|
15280
|
+
_private__positionsToMarkers() {
|
|
15281
|
+
const markers = [];
|
|
15282
|
+
for (const position of this._private__positions) {
|
|
15283
|
+
const isLong = position.type === 'long';
|
|
15284
|
+
const size = position.size ?? this._private__options.defaultSize;
|
|
15285
|
+
const entryColor = position.color?.entry ??
|
|
15286
|
+
(isLong ? this._private__options.longColors.entry : this._private__options.shortColors.entry);
|
|
15287
|
+
const exitColor = position.color?.exit ??
|
|
15288
|
+
(isLong ? this._private__options.longColors.exit : this._private__options.shortColors.exit);
|
|
15289
|
+
const entryMarker = {
|
|
15290
|
+
time: position.entry.time,
|
|
15291
|
+
position: 'atPriceMiddle',
|
|
15292
|
+
price: position.entry.price,
|
|
15293
|
+
shape: isLong ? 'arrowUp' : 'arrowDown',
|
|
15294
|
+
color: entryColor,
|
|
15295
|
+
size: size,
|
|
15296
|
+
};
|
|
15297
|
+
if (position.text?.entry) {
|
|
15298
|
+
entryMarker.text = position.text.entry;
|
|
15299
|
+
}
|
|
15300
|
+
if (position.id) {
|
|
15301
|
+
entryMarker.id = `${position.id}-entry`;
|
|
15302
|
+
}
|
|
15303
|
+
markers.push(entryMarker);
|
|
15304
|
+
const exitMarker = {
|
|
15305
|
+
time: position.exit.time,
|
|
15306
|
+
position: 'atPriceMiddle',
|
|
15307
|
+
price: position.exit.price,
|
|
15308
|
+
shape: isLong ? 'arrowDown' : 'arrowUp',
|
|
15309
|
+
color: exitColor,
|
|
15310
|
+
size: size,
|
|
15311
|
+
};
|
|
15312
|
+
if (position.text?.exit) {
|
|
15313
|
+
exitMarker.text = position.text.exit;
|
|
15314
|
+
}
|
|
15315
|
+
if (position.id) {
|
|
15316
|
+
exitMarker.id = `${position.id}-exit`;
|
|
15317
|
+
}
|
|
15318
|
+
markers.push(exitMarker);
|
|
15319
|
+
}
|
|
15320
|
+
return markers;
|
|
15321
|
+
}
|
|
15322
|
+
/**
|
|
15323
|
+
* Actualiza los marcadores en el gráfico
|
|
15324
|
+
*/
|
|
15325
|
+
_private__updateMarkers() {
|
|
15326
|
+
if (this._private__markersPlugin) {
|
|
15327
|
+
const markers = this._private__positionsToMarkers();
|
|
15328
|
+
this._private__markersPlugin.setMarkers(markers);
|
|
15329
|
+
}
|
|
15330
|
+
}
|
|
15331
|
+
/**
|
|
15332
|
+
* Desconecta el plugin y limpia recursos
|
|
15333
|
+
*/
|
|
15334
|
+
detach() {
|
|
15335
|
+
if (this._private__markersPlugin) {
|
|
15336
|
+
this._private__markersPlugin.detach();
|
|
15337
|
+
this._private__markersPlugin = null;
|
|
15338
|
+
}
|
|
15339
|
+
this._private__positions = [];
|
|
15340
|
+
}
|
|
15341
|
+
}
|
|
15342
|
+
/**
|
|
15343
|
+
* Crea un gestor de marcadores de posiciones de trading
|
|
15344
|
+
*
|
|
15345
|
+
* @param series - Serie a la que se adjuntarán los marcadores
|
|
15346
|
+
* @param positions - Posiciones iniciales (opcional)
|
|
15347
|
+
* @param options - Opciones de configuración (opcional)
|
|
15348
|
+
* @returns Instancia del gestor de posiciones
|
|
15349
|
+
*
|
|
15350
|
+
* @example
|
|
15351
|
+
* ```typescript
|
|
15352
|
+
* // Crear el gestor
|
|
15353
|
+
* const positionMarkers = createPositionMarkers(candleSeries);
|
|
15354
|
+
*
|
|
15355
|
+
* // Agregar una posición long
|
|
15356
|
+
* positionMarkers.addPosition({
|
|
15357
|
+
* type: 'long',
|
|
15358
|
+
* entry: { time: '2023-01-01', price: 100.50 },
|
|
15359
|
+
* exit: { time: '2023-01-05', price: 105.20 },
|
|
15360
|
+
* id: 'pos-1'
|
|
15361
|
+
* });
|
|
15362
|
+
*
|
|
15363
|
+
* // Agregar una posición short
|
|
15364
|
+
* positionMarkers.addPosition({
|
|
15365
|
+
* type: 'short',
|
|
15366
|
+
* entry: { time: '2023-01-10', price: 110.00 },
|
|
15367
|
+
* exit: { time: '2023-01-15', price: 107.50 },
|
|
15368
|
+
* id: 'pos-2'
|
|
15369
|
+
* });
|
|
15370
|
+
*
|
|
15371
|
+
* // Agregar múltiples posiciones
|
|
15372
|
+
* positionMarkers.setPositions([
|
|
15373
|
+
* {
|
|
15374
|
+
* type: 'long',
|
|
15375
|
+
* entry: { time: '2023-02-01', price: 95.00 },
|
|
15376
|
+
* exit: { time: '2023-02-10', price: 98.50 }
|
|
15377
|
+
* },
|
|
15378
|
+
* {
|
|
15379
|
+
* type: 'short',
|
|
15380
|
+
* entry: { time: '2023-02-15', price: 102.00 },
|
|
15381
|
+
* exit: { time: '2023-02-20', price: 99.00 }
|
|
15382
|
+
* }
|
|
15383
|
+
* ]);
|
|
15384
|
+
* ```
|
|
15385
|
+
*/
|
|
15386
|
+
function createPositionMarkers(series, positions, options) {
|
|
15387
|
+
const manager = new PositionMarkersManager(series, options);
|
|
15388
|
+
if (positions && positions.length > 0) {
|
|
15389
|
+
manager.setPositions(positions);
|
|
15390
|
+
}
|
|
15391
|
+
return manager;
|
|
15392
|
+
}
|
|
15393
|
+
|
|
15195
15394
|
/**
|
|
15196
15395
|
* Apply SMA (Simple Moving Average) indicator to a series
|
|
15197
15396
|
* @param series - Source series to calculate SMA from
|
|
@@ -16691,7 +16890,7 @@ const customSeriesDefaultOptions = {
|
|
|
16691
16890
|
* Returns the current version as a string. For example `'1.0.0'`.
|
|
16692
16891
|
*/
|
|
16693
16892
|
function version() {
|
|
16694
|
-
return "0.0.
|
|
16893
|
+
return "0.0.12";
|
|
16695
16894
|
}
|
|
16696
16895
|
|
|
16697
|
-
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 };
|
|
16896
|
+
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 };
|