@pipsend/charts 2.0.0 → 2.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.
package/dist/typings.d.ts CHANGED
@@ -1902,6 +1902,28 @@ export declare function applyDonchianChannels(series: ISeriesApi<SeriesType>, ch
1902
1902
  export declare function applyEMA(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: EMAOptions): IndicatorRuntime<EMAOptions> & {
1903
1903
  series: ISeriesApi<"Line">;
1904
1904
  };
1905
+ /**
1906
+ * Draw a source series as Heikin Ashi candles.
1907
+ *
1908
+ * The source series is left in place holding its real prices — it is only
1909
+ * hidden — so indicators bound to it keep computing on the true OHLC, and
1910
+ * `remove()` puts the chart back exactly as it was. That makes this usable as a
1911
+ * chart-type toggle:
1912
+ *
1913
+ * ```js
1914
+ * const ha = applyHeikinAshi(candleSeries, chart);
1915
+ * // …back to regular candles:
1916
+ * ha.remove();
1917
+ * ```
1918
+ *
1919
+ * @param series - Source OHLC series (a candlestick or bar series).
1920
+ * @param chart - Chart instance.
1921
+ * @param options - Heikin Ashi configuration options.
1922
+ * @returns The Heikin Ashi candlestick series, plus live control over its options.
1923
+ */
1924
+ export declare function applyHeikinAshi(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: HeikinAshiOptions): IndicatorRuntime<HeikinAshiOptions> & {
1925
+ series: ISeriesApi<"Candlestick">;
1926
+ };
1905
1927
  /**
1906
1928
  * Ichimoku Kinko Hyo.
1907
1929
  *
@@ -2106,6 +2128,32 @@ export declare function applyWMA(series: ISeriesApi<SeriesType>, chart: IChartAp
2106
2128
  export declare function applyWilliamsR(series: ISeriesApi<SeriesType>, chart: IChartApi, options?: WilliamsROptions): IndicatorRuntime<WilliamsROptions> & {
2107
2129
  series: ISeriesApi<"Line">;
2108
2130
  };
2131
+ /**
2132
+ * Turns raw OHLC bars into Heikin Ashi ones.
2133
+ *
2134
+ * Heikin Ashi is a price transform, not an overlay: each candle averages itself
2135
+ * with the one before it, which drops most of the single-bar noise and leaves
2136
+ * runs of same-coloured bodies while a trend holds.
2137
+ *
2138
+ * ```
2139
+ * close = (O + H + L + C) / 4
2140
+ * open = (previous open + previous close) / 2 // first bar: (O + C) / 2
2141
+ * high = max(H, open, close)
2142
+ * low = min(L, open, close)
2143
+ * ```
2144
+ *
2145
+ * Because every bar folds in the one before it, the result depends on where the
2146
+ * data starts: the same bar computed from a longer history differs slightly.
2147
+ * The difference decays over a few bars, so pass the whole series rather than a
2148
+ * recent window when you can.
2149
+ *
2150
+ * Whitespace items are passed through untouched, and do not advance the
2151
+ * running open/close — a gap in the data is not a bar.
2152
+ *
2153
+ * @param bars - Source bars, ordered oldest to newest.
2154
+ * @returns The transformed bars, one per input item.
2155
+ */
2156
+ export declare function calculateHeikinAshi<HorzScaleItem = Time>(bars: readonly HeikinAshiInput<HorzScaleItem>[]): HeikinAshiPoint<HorzScaleItem>[];
2109
2157
  /**
2110
2158
  * Automatically calculate pip configuration based on price
2111
2159
  * This is completely generic and works for any instrument
@@ -3612,6 +3660,33 @@ export interface HandleScrollOptions {
3612
3660
  */
3613
3661
  vertTouchDrag: boolean;
3614
3662
  }
3663
+ export interface HeikinAshiOptions {
3664
+ /** Pane the candles are drawn in. Fixed at creation. */
3665
+ paneIndex?: number;
3666
+ /** Color of rising Heikin Ashi candles. */
3667
+ upColor?: string;
3668
+ /** Color of falling Heikin Ashi candles. */
3669
+ downColor?: string;
3670
+ /** Enable candle borders. */
3671
+ borderVisible?: boolean;
3672
+ /** Border color of rising candles. */
3673
+ borderUpColor?: string;
3674
+ /** Border color of falling candles. */
3675
+ borderDownColor?: string;
3676
+ /** Enable high and low price candle wicks. */
3677
+ wickVisible?: boolean;
3678
+ /** Wick color of rising candles. */
3679
+ wickUpColor?: string;
3680
+ /** Wick color of falling candles. */
3681
+ wickDownColor?: string;
3682
+ /**
3683
+ * Hide the source series while the Heikin Ashi candles are shown, so the two
3684
+ * do not overlap. The original visibility is restored by `remove()`.
3685
+ *
3686
+ * @defaultValue `true`
3687
+ */
3688
+ hideSource?: boolean;
3689
+ }
3615
3690
  /**
3616
3691
  * Structure describing a single item of data for histogram series
3617
3692
  */
@@ -7478,6 +7553,10 @@ export type DrawingToolType = "ruler" | "fibonacci" | "position" | "trendline" |
7478
7553
  * The valid values are integers in range [0, 255]
7479
7554
  */
7480
7555
  export type GreenComponent = Nominal<number, "GreenComponent">;
7556
+ /** A bar the Heikin Ashi transform can read: a real OHLC bar, or a gap. */
7557
+ export type HeikinAshiInput<HorzScaleItem = Time> = OhlcData<HorzScaleItem> | WhitespaceData<HorzScaleItem>;
7558
+ /** What it produces: a smoothed candle per input bar, gaps passed through. */
7559
+ export type HeikinAshiPoint<HorzScaleItem = Time> = CandlestickData<HorzScaleItem> | WhitespaceData<HorzScaleItem>;
7481
7560
  /**
7482
7561
  * Represents histogram series options.
7483
7562
  */
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
- "private": false,
3
- "version": "2.0.0",
2
+ "version": "2.1.0",
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
- "prepare": "node scripts/githooks/install.js || true",
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 -e \"const fs=require('fs');const p='website/scripts/generate-versions-dts.js'; if(fs.existsSync(p)){require('child_process').execSync('node '+p,{stdio:'inherit'});} else {console.warn('[tsc-verify] skip: '+p+' not found');}\" && 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
  }