@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/typings.d.ts CHANGED
@@ -96,6 +96,55 @@ export declare class InteractiveLineManager {
96
96
  */
97
97
  isCreating(): boolean;
98
98
  }
99
+ /**
100
+ * Gestor de marcadores de posiciones de trading
101
+ */
102
+ export declare class PositionMarkersManager<TimeType> {
103
+ private _markersPlugin;
104
+ private _positions;
105
+ private _options;
106
+ constructor(series: ISeriesApi<SeriesType, TimeType>, options?: PositionMarkersOptions);
107
+ /**
108
+ * Agrega una posición al gráfico
109
+ */
110
+ addPosition(position: TradingPosition<TimeType>): void;
111
+ /**
112
+ * Agrega múltiples posiciones al gráfico
113
+ */
114
+ addPositions(positions: TradingPosition<TimeType>[]): void;
115
+ /**
116
+ * Establece las posiciones (reemplaza las existentes)
117
+ */
118
+ setPositions(positions: TradingPosition<TimeType>[]): void;
119
+ /**
120
+ * Elimina una posición por ID
121
+ */
122
+ removePosition(id: string): void;
123
+ /**
124
+ * Limpia todas las posiciones
125
+ */
126
+ clearPositions(): void;
127
+ /**
128
+ * Obtiene todas las posiciones actuales
129
+ */
130
+ getPositions(): readonly TradingPosition<TimeType>[];
131
+ /**
132
+ * Actualiza las opciones del gestor
133
+ */
134
+ applyOptions(options: PositionMarkersOptions): void;
135
+ /**
136
+ * Convierte las posiciones a marcadores de serie
137
+ */
138
+ private _positionsToMarkers;
139
+ /**
140
+ * Actualiza los marcadores en el gráfico
141
+ */
142
+ private _updateMarkers;
143
+ /**
144
+ * Desconecta el plugin y limpia recursos
145
+ */
146
+ detach(): void;
147
+ }
99
148
  export declare const customSeriesDefaultOptions: CustomSeriesOptions;
100
149
  /**
101
150
  * Enumeration representing the sign of a marker.
@@ -456,6 +505,51 @@ export declare function createInteractiveLineManager(chart: IChartApi, series: I
456
505
  * @returns An instance of IChartApiBase configured for price-based horizontal scaling.
457
506
  */
458
507
  export declare function createOptionsChart(container: string | HTMLElement, options?: DeepPartial<PriceChartOptions>): IChartApiBase<number>;
508
+ /**
509
+ * Crea un gestor de marcadores de posiciones de trading
510
+ *
511
+ * @param series - Serie a la que se adjuntarán los marcadores
512
+ * @param positions - Posiciones iniciales (opcional)
513
+ * @param options - Opciones de configuración (opcional)
514
+ * @returns Instancia del gestor de posiciones
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * // Crear el gestor
519
+ * const positionMarkers = createPositionMarkers(candleSeries);
520
+ *
521
+ * // Agregar una posición long
522
+ * positionMarkers.addPosition({
523
+ * type: 'long',
524
+ * entry: { time: '2023-01-01', price: 100.50 },
525
+ * exit: { time: '2023-01-05', price: 105.20 },
526
+ * id: 'pos-1'
527
+ * });
528
+ *
529
+ * // Agregar una posición short
530
+ * positionMarkers.addPosition({
531
+ * type: 'short',
532
+ * entry: { time: '2023-01-10', price: 110.00 },
533
+ * exit: { time: '2023-01-15', price: 107.50 },
534
+ * id: 'pos-2'
535
+ * });
536
+ *
537
+ * // Agregar múltiples posiciones
538
+ * positionMarkers.setPositions([
539
+ * {
540
+ * type: 'long',
541
+ * entry: { time: '2023-02-01', price: 95.00 },
542
+ * exit: { time: '2023-02-10', price: 98.50 }
543
+ * },
544
+ * {
545
+ * type: 'short',
546
+ * entry: { time: '2023-02-15', price: 102.00 },
547
+ * exit: { time: '2023-02-20', price: 99.00 }
548
+ * }
549
+ * ]);
550
+ * ```
551
+ */
552
+ export declare function createPositionMarkers<TimeType>(series: ISeriesApi<SeriesType, TimeType>, positions?: TradingPosition<TimeType>[], options?: PositionMarkersOptions): PositionMarkersManager<TimeType>;
459
553
  /**
460
554
  * A function to create a series markers primitive.
461
555
  *
@@ -3605,6 +3699,29 @@ export interface Point {
3605
3699
  */
3606
3700
  readonly y: Coordinate;
3607
3701
  }
3702
+ /**
3703
+ * Opciones para el gestor de posiciones
3704
+ */
3705
+ export interface PositionMarkersOptions {
3706
+ /**
3707
+ * Colores predeterminados para posiciones long
3708
+ */
3709
+ longColors?: {
3710
+ entry?: string;
3711
+ exit?: string;
3712
+ };
3713
+ /**
3714
+ * Colores predeterminados para posiciones short
3715
+ */
3716
+ shortColors?: {
3717
+ entry?: string;
3718
+ exit?: string;
3719
+ };
3720
+ /**
3721
+ * Tamaño predeterminado de las flechas
3722
+ */
3723
+ defaultSize?: number;
3724
+ }
3608
3725
  /**
3609
3726
  * Extends LocalizationOptions for price-based charts.
3610
3727
  * Includes settings specific to formatting price values on the horizontal scale.
@@ -4574,6 +4691,52 @@ export interface TradingLineOptions {
4574
4691
  onDragMove?: (price: number) => void;
4575
4692
  onDragEnd?: (price: number) => void;
4576
4693
  }
4694
+ /**
4695
+ * Representa una posición de trading con punto de entrada y salida
4696
+ */
4697
+ export interface TradingPosition<TimeType> {
4698
+ /**
4699
+ * Tipo de posición (long o short)
4700
+ */
4701
+ type: PositionType;
4702
+ /**
4703
+ * Punto de entrada
4704
+ */
4705
+ entry: {
4706
+ time: TimeType;
4707
+ price: number;
4708
+ };
4709
+ /**
4710
+ * Punto de salida
4711
+ */
4712
+ exit: {
4713
+ time: TimeType;
4714
+ price: number;
4715
+ };
4716
+ /**
4717
+ * ID opcional para identificar la posición
4718
+ */
4719
+ id?: string;
4720
+ /**
4721
+ * Color personalizado para las flechas (opcional)
4722
+ * Si no se especifica, se usarán colores predeterminados según el tipo
4723
+ */
4724
+ color?: {
4725
+ entry?: string;
4726
+ exit?: string;
4727
+ };
4728
+ /**
4729
+ * Tamaño de las flechas (opcional, por defecto 1)
4730
+ */
4731
+ size?: number;
4732
+ /**
4733
+ * Texto opcional para las flechas
4734
+ */
4735
+ text?: {
4736
+ entry?: string;
4737
+ exit?: string;
4738
+ };
4739
+ }
4577
4740
  /**
4578
4741
  * Configuration options for the UpDownMarkers plugin.
4579
4742
  */
@@ -4914,6 +5077,10 @@ export type OverlayPriceScaleOptions = Omit<PriceScaleOptions, "visible" | "auto
4914
5077
  * A function used to format a percentage value as a string.
4915
5078
  */
4916
5079
  export type PercentageFormatterFn = (percentageValue: number) => string;
5080
+ /**
5081
+ * Tipo de posición de trading
5082
+ */
5083
+ export type PositionType = "long" | "short";
4917
5084
  /**
4918
5085
  * Represents information used to format prices.
4919
5086
  */
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
- "private": false,
3
- "version": "0.0.11",
2
+ "version": "0.0.12",
4
3
  "name": "@pipsend/charts",
5
4
  "author": "Pipsend",
6
5
  "license": "SEE LICENSE IN LICENSE",
@@ -54,88 +53,7 @@
54
53
  "bollinger-bands",
55
54
  "financial-analysis"
56
55
  ],
57
- "engines": {
58
- "node": ">=22.3"
59
- },
60
56
  "dependencies": {
61
57
  "fancy-canvas": "2.1.0"
62
- },
63
- "devDependencies": {
64
- "@juggle/resize-observer": "3.4.0",
65
- "@rollup/plugin-node-resolve": "16.0.1",
66
- "@rollup/plugin-replace": "6.0.2",
67
- "@rollup/plugin-terser": "0.4.4",
68
- "@size-limit/file": "11.2.0",
69
- "@size-limit/webpack": "11.2.0",
70
- "@types/chai": "5.2.1",
71
- "@types/express": "5.0.1",
72
- "@types/glob": "8.1.0",
73
- "@types/node": "22",
74
- "@types/pixelmatch": "5.2.6",
75
- "@types/pngjs": "6.0.5",
76
- "@typescript-eslint/eslint-plugin": "7.18.0",
77
- "@typescript-eslint/eslint-plugin-tslint": "7.0.2",
78
- "@typescript-eslint/parser": "7.18.0",
79
- "ajv": "7.2.4",
80
- "bytes": "3.1.2",
81
- "chai": "5.2.0",
82
- "chai-exclude": "3.0.1",
83
- "cross-env": "7.0.3",
84
- "dts-bundle-generator": "9.5.1",
85
- "eslint": "8",
86
- "eslint-formatter-unix": "8.40.0",
87
- "eslint-plugin-deprecation": "3.0.0",
88
- "eslint-plugin-import": "2.31.0",
89
- "eslint-plugin-unicorn": "56.0.1",
90
- "esno": "4.8.0",
91
- "glob": "11.0.1",
92
- "markdown-it": "14.1.0",
93
- "markdown-it-anchor": "9.2.0",
94
- "markdownlint-cli": "0.44.0",
95
- "npm-run-all": "4.1.5",
96
- "rimraf": "6.0.1",
97
- "rollup": "4.40.0",
98
- "size-limit": "11.2.0",
99
- "ts-node": "10.9.2",
100
- "ts-patch": "3.3.0",
101
- "ts-transformer-properties-rename": "0.17.0",
102
- "ts-transformer-strip-const-enums": "2.0.0",
103
- "tslib": "2.8.1",
104
- "tslint": "6.1.3",
105
- "tslint-eslint-rules": "5.4.0",
106
- "tslint-microsoft-contrib": "6.2.0",
107
- "tsx": "4.19.3",
108
- "typescript": "5.5.4",
109
- "yargs": "17.7.2"
110
- },
111
- "scripts": {
112
- "install-hooks": "node scripts/githooks/install.js",
113
- "clean": "rimraf lib/ dist/",
114
- "bundle-dts": "dts-bundle-generator --config dts-config.json",
115
- "tsc": "tspc -p tsconfig.prod.json",
116
- "tsc-watch": "npm run tsc -- --watch --preserveWatchOutput",
117
- "tsc-verify": "node website/scripts/generate-versions-dts.js && tsc -b tsconfig.composite.json",
118
- "lint": "npm-run-all -p lint:**",
119
- "lint:eslint": "eslint --format=unix ./",
120
- "lint:md": "markdownlint -i \"**/node_modules/**\" -i \"**/website/docs/api/**\" -i \"**/website/versioned_docs/**/api/**\" -i \"**/*.mdx\" \"**/*.md\"",
121
- "check-dts-docs": "npm-run-all -p check-dts-docs-duplicates check-dts-docs-eslint",
122
- "check-dts-docs-duplicates": "node ./scripts/check-typings-for-duplicates.js ./dist/typings.d.ts",
123
- "check-dts-docs-eslint": "eslint --format=unix ./dist/typings.d.ts --no-ignore",
124
- "check-markdown-links": "node scripts/check-markdown-links.js",
125
- "rollup": "rollup -c rollup.config.js",
126
- "rollup-watch": "npm run rollup -- --watch",
127
- "build": "npm-run-all tsc rollup bundle-dts",
128
- "build:watch": "npm-run-all tsc -p tsc-watch rollup-watch",
129
- "build:prod": "cross-env NODE_ENV=production npm run build",
130
- "build:release": "cross-env BUILD_TAG=release npm run build:prod",
131
- "prepare-release": "npm-run-all clean build:release && npm run prepare-package-json-for-release",
132
- "prepare-package-json-for-release": "node ./scripts/clean-package-json.js",
133
- "size-limit": "size-limit",
134
- "verify": "npm-run-all clean -p build:prod check-markdown-links -p lint check-dts-docs tsc-verify test size-limit -p type-tests",
135
- "test": "esno --import ./tests/unittests/setup.units.mjs --test './tests/unittests/**/*.spec.ts'",
136
- "type-tests": "tsc -b ./src/tsconfig.composite.json && tsc -p ./tests/type-checks/tsconfig.composite.json --noEmit",
137
- "e2e:coverage": "esno ./tests/e2e/coverage/runner.ts ./dist/pipsend-charts.standalone.development.js",
138
- "e2e:interactions": "esno ./tests/e2e/interactions/runner.ts ./dist/pipsend-charts.standalone.development.js",
139
- "e2e:memleaks": "esno ./tests/e2e/memleaks/runner.ts ./dist/pipsend-charts.standalone.development.js"
140
58
  }
141
59
  }