@alphacharts/indicators 0.0.0-stage → 0.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -2
  3. package/dist/all-DeXJJd7D.js +21 -0
  4. package/dist/all-DeXJJd7D.js.map +1 -0
  5. package/dist/all.js +10 -0
  6. package/dist/all.js.map +1 -0
  7. package/dist/assets/worker-BrUuzTIJ.js +2 -0
  8. package/dist/assets/worker-BrUuzTIJ.js.map +1 -0
  9. package/dist/define-BPvQbaq9.js +472 -0
  10. package/dist/define-BPvQbaq9.js.map +1 -0
  11. package/dist/index.js +593 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/registry-CYZuqhXX.js +49 -0
  14. package/dist/registry-CYZuqhXX.js.map +1 -0
  15. package/dist/runner-DBP0M8z3.js +229 -0
  16. package/dist/runner-DBP0M8z3.js.map +1 -0
  17. package/dist/studies.js +1 -0
  18. package/dist/tv-volume-7hh6ajKt.js +3457 -0
  19. package/dist/tv-volume-7hh6ajKt.js.map +1 -0
  20. package/dist/types/all.d.ts +3 -0
  21. package/dist/types/chart/studies.d.ts +165 -0
  22. package/dist/types/define.d.ts +46 -0
  23. package/dist/types/engine/graph.d.ts +101 -0
  24. package/dist/types/engine/kernels.d.ts +9 -0
  25. package/dist/types/engine/study.d.ts +31 -0
  26. package/dist/types/index.d.ts +12 -0
  27. package/dist/types/registry.d.ts +7 -0
  28. package/dist/types/runner.d.ts +82 -0
  29. package/dist/types/studies/all.d.ts +2 -0
  30. package/dist/types/studies/cycle.d.ts +7 -0
  31. package/dist/types/studies/index.d.ts +13 -0
  32. package/dist/types/studies/ma.d.ts +26 -0
  33. package/dist/types/studies/math.d.ts +28 -0
  34. package/dist/types/studies/momentum.d.ts +30 -0
  35. package/dist/types/studies/overlap.d.ts +14 -0
  36. package/dist/types/studies/patterns.d.ts +62 -0
  37. package/dist/types/studies/price.d.ts +6 -0
  38. package/dist/types/studies/sar.d.ts +2 -0
  39. package/dist/types/studies/statistic.d.ts +9 -0
  40. package/dist/types/studies/tv-osc.d.ts +18 -0
  41. package/dist/types/studies/tv-trend.d.ts +20 -0
  42. package/dist/types/studies/tv-volume.d.ts +14 -0
  43. package/dist/types/studies/volatility.d.ts +3 -0
  44. package/dist/types/studies/volume.d.ts +3 -0
  45. package/dist/types/types.d.ts +133 -0
  46. package/dist/types/wasm.d.ts +2 -0
  47. package/dist/types/worker.d.ts +1 -0
  48. package/dist/worker.js +8 -0
  49. package/dist/worker.js.map +1 -0
  50. package/package.json +69 -3
@@ -0,0 +1,6 @@
1
+ import type { Col } from "../engine/graph.js";
2
+ export declare const avgprice: import("../types.js").StudyDef;
3
+ export declare const medprice: import("../types.js").StudyDef;
4
+ export declare const typprice: import("../types.js").StudyDef;
5
+ export declare const wclprice: import("../types.js").StudyDef;
6
+ export type { Col };
@@ -0,0 +1,2 @@
1
+ export declare const sar: import("../types.js").StudyDef;
2
+ export declare const sarext: import("../types.js").StudyDef;
@@ -0,0 +1,9 @@
1
+ export declare const linearreg: import("../types.js").StudyDef;
2
+ export declare const linearregSlope: import("../types.js").StudyDef;
3
+ export declare const linearregIntercept: import("../types.js").StudyDef;
4
+ export declare const linearregAngle: import("../types.js").StudyDef;
5
+ export declare const tsf: import("../types.js").StudyDef;
6
+ export declare const stddev: import("../types.js").StudyDef;
7
+ export declare const variance: import("../types.js").StudyDef;
8
+ export declare const correl: import("../types.js").StudyDef;
9
+ export declare const beta: import("../types.js").StudyDef;
@@ -0,0 +1,18 @@
1
+ export declare const fisher: import("../types.js").StudyDef;
2
+ export declare const kst: import("../types.js").StudyDef;
3
+ export declare const tsi: import("../types.js").StudyDef;
4
+ export declare const vortex: import("../types.js").StudyDef;
5
+ export declare const coppock: import("../types.js").StudyDef;
6
+ export declare const connorsRsi: import("../types.js").StudyDef;
7
+ export declare const choppiness: import("../types.js").StudyDef;
8
+ export declare const rviVigor: import("../types.js").StudyDef;
9
+ export declare const rviVolatility: import("../types.js").StudyDef;
10
+ export declare const smiErgodic: import("../types.js").StudyDef;
11
+ export declare const rankCorr: import("../types.js").StudyDef;
12
+ export declare const bullBearPower: import("../types.js").StudyDef;
13
+ export declare const awesome: import("../types.js").StudyDef;
14
+ export declare const accelerator: import("../types.js").StudyDef;
15
+ export declare const massIndex: import("../types.js").StudyDef;
16
+ export declare const dpo: import("../types.js").StudyDef;
17
+ export declare const schaffTc: import("../types.js").StudyDef;
18
+ export declare const stochTv: import("../types.js").StudyDef;
@@ -0,0 +1,20 @@
1
+ export declare const smma: import("../types.js").StudyDef;
2
+ export declare const vwma: import("../types.js").StudyDef;
3
+ export declare const hma: import("../types.js").StudyDef;
4
+ export declare const alma: import("../types.js").StudyDef;
5
+ export declare const lsma: import("../types.js").StudyDef;
6
+ export declare const mcginley: import("../types.js").StudyDef;
7
+ export declare const maRibbon: import("../types.js").StudyDef;
8
+ export declare const maCross: import("../types.js").StudyDef;
9
+ export declare const envelopes: import("../types.js").StudyDef;
10
+ export declare const keltner: import("../types.js").StudyDef;
11
+ export declare const donchian: import("../types.js").StudyDef;
12
+ export declare const priceChannel: import("../types.js").StudyDef;
13
+ export declare const chandeKrollStop: import("../types.js").StudyDef;
14
+ export declare const linregChannel: import("../types.js").StudyDef;
15
+ export declare const median: import("../types.js").StudyDef;
16
+ export declare const ichimoku: import("../types.js").StudyDef;
17
+ export declare const supertrend: import("../types.js").StudyDef;
18
+ export declare const alligator: import("../types.js").StudyDef;
19
+ export declare const fractals: import("../types.js").StudyDef;
20
+ export declare const zigzag: import("../types.js").StudyDef;
@@ -0,0 +1,14 @@
1
+ export type Period = "day" | "week" | "month" | "year";
2
+ export declare const volume: import("../types.js").StudyDef;
3
+ export declare const volumeOsc: import("../types.js").StudyDef;
4
+ export declare const pvt: import("../types.js").StudyDef;
5
+ export declare const netVolume: import("../types.js").StudyDef;
6
+ export declare const elderForce: import("../types.js").StudyDef;
7
+ export declare const eom: import("../types.js").StudyDef;
8
+ export declare const chaikinMf: import("../types.js").StudyDef;
9
+ export declare const klinger: import("../types.js").StudyDef;
10
+ export declare const vwap: import("../types.js").StudyDef;
11
+ export declare const anchoredVwap: import("../types.js").StudyDef;
12
+ export declare const pivotPoints: import("../types.js").StudyDef;
13
+ export declare const histVol: import("../types.js").StudyDef;
14
+ export declare const adr: import("../types.js").StudyDef;
@@ -0,0 +1,3 @@
1
+ export declare const trange: import("../types.js").StudyDef;
2
+ export declare const atr: import("../types.js").StudyDef;
3
+ export declare const natr: import("../types.js").StudyDef;
@@ -0,0 +1,3 @@
1
+ export declare const ad: import("../types.js").StudyDef;
2
+ export declare const adosc: import("../types.js").StudyDef;
3
+ export declare const obv: import("../types.js").StudyDef;
@@ -0,0 +1,133 @@
1
+ import type { Col, Graph } from "./engine/graph.js";
2
+ export type InputType = "int" | "float" | "bool" | "source" | "select";
3
+ export type InputValue = number | boolean | string;
4
+ export interface InputDef {
5
+ key: string;
6
+ label: string;
7
+ type: InputType;
8
+ default: InputValue;
9
+ min?: number;
10
+ max?: number;
11
+ step?: number;
12
+ /** Allowed values of a "select" (strings) or "source" input. */
13
+ options?: readonly string[];
14
+ }
15
+ /** Resolved parameters passed to `build`: every input has a value. */
16
+ export interface Params {
17
+ readonly [key: string]: any;
18
+ }
19
+ export type LineStyleName = "solid" | "dashed" | "dotted";
20
+ export type MarkerShape = "circle" | "square" | "triangleUp" | "triangleDown" | "arrowUp" | "arrowDown" | "cross" | "diamond";
21
+ interface PlotBase {
22
+ /** Unique within the study; keys style overrides and the output series id. */
23
+ key: string;
24
+ title: string;
25
+ }
26
+ export type PlotDef = (PlotBase & {
27
+ kind: "line";
28
+ col: string;
29
+ color: string;
30
+ width?: number;
31
+ style?: LineStyleName;
32
+ /** Shift in bars (positive = into the future). Negative shifts and `connect` draw on the overlay. */
33
+ offset?: number;
34
+ /** Join across absent bars (drawn on the overlay). */
35
+ connect?: boolean;
36
+ }) | (PlotBase & {
37
+ kind: "histogram";
38
+ col: string;
39
+ color: string;
40
+ colorDown?: string;
41
+ }) | (PlotBase & {
42
+ kind: "area";
43
+ col: string;
44
+ color: string;
45
+ })
46
+ /** Two boundary lines with a fill between them. */
47
+ | (PlotBase & {
48
+ kind: "band";
49
+ upper: string;
50
+ lower: string;
51
+ color: string;
52
+ fill: string;
53
+ width?: number;
54
+ })
55
+ /** A fill between two columns, no boundary lines. */
56
+ | (PlotBase & {
57
+ kind: "fill";
58
+ a: string;
59
+ b: string;
60
+ color: string;
61
+ }) | (PlotBase & {
62
+ kind: "hline";
63
+ value: number | ((p: Params) => number);
64
+ color: string;
65
+ style?: LineStyleName;
66
+ }) | (PlotBase & {
67
+ kind: "markers";
68
+ /**
69
+ * Non-NaN (and for text markers non-zero) marks a bar. "value" places it at the value, "above"/"below" at the
70
+ * bar's high/low, "sign" below the bar for a positive value and above it for a negative one (candlestick scores).
71
+ */
72
+ col: string;
73
+ shape: MarkerShape;
74
+ position: "value" | "above" | "below" | "sign";
75
+ color: string;
76
+ /** Shift in bars (positive = into the future); Fractals confirm two bars late and shift back. */
77
+ offset?: number;
78
+ /** Draw the value as text (pattern scores) instead of a shape. */
79
+ text?: boolean;
80
+ })
81
+ /** ZigZag: `price` at the confirmation bar and `back` bars to the pivot; joined by straight lines. */
82
+ | (PlotBase & {
83
+ kind: "zigzag";
84
+ price: string;
85
+ back: string;
86
+ color: string;
87
+ width?: number;
88
+ });
89
+ export type StudyFamily = "overlap" | "momentum" | "volume" | "volatility" | "price" | "cycle" | "pattern" | "statistic" | "math" | "trend" | "levels" | "tv";
90
+ /** What bars a study reads: one value series, OHLC, or OHLC with volume. */
91
+ export type StudyNeeds = "value" | "ohlc" | "ohlcv";
92
+ export interface StudyDef {
93
+ id: string;
94
+ name: string;
95
+ family: StudyFamily;
96
+ inputs: readonly InputDef[];
97
+ needs: StudyNeeds;
98
+ /** Where it is drawn: on the source's pane or in a pane of its own. */
99
+ pane: "overlay" | "new";
100
+ /** Names of the computed columns, in the order `build` returns them. */
101
+ columns: readonly string[];
102
+ plots: readonly PlotDef[];
103
+ /** Declare nodes on the graph and return the output columns, one per `columns` entry. */
104
+ build(g: Graph, p: Params): readonly Col[];
105
+ /**
106
+ * Smallest step of the values a separate-pane study shows on its axis and in
107
+ * labels. Default: two decimals, and more once the values are below 1.
108
+ */
109
+ minMove?: number;
110
+ /** Short title suffix from the parameters, e.g. "14" -> "RSI (14)". */
111
+ label?(p: Params): string;
112
+ /** Reference this study is verified against, shown in the README. */
113
+ reference?: string;
114
+ }
115
+ /** One bar for the streaming engine. */
116
+ export interface BarInput {
117
+ time: number;
118
+ open: number;
119
+ high: number;
120
+ low: number;
121
+ close: number;
122
+ volume: number;
123
+ }
124
+ /** Columnar bars. A value-only source passes just `close`. */
125
+ export interface BarColumns {
126
+ time: Float64Array;
127
+ open?: Float64Array;
128
+ high?: Float64Array;
129
+ low?: Float64Array;
130
+ close: Float64Array;
131
+ volume?: Float64Array;
132
+ }
133
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function enableWasm(): Promise<void>;
2
+ export declare function disableWasm(): void;
@@ -0,0 +1 @@
1
+ export {};
package/dist/worker.js ADDED
@@ -0,0 +1,8 @@
1
+ import { o as e } from "./runner-DBP0M8z3.js";
2
+ import { t } from "./all-DeXJJd7D.js";
3
+ //#region src/worker.ts
4
+ var n = new Map(t.map((e) => [e.id, e])), r = self, i = e((e, t) => r.postMessage(e, t), (e) => n.get(e));
5
+ r.onmessage = (e) => i(e.data);
6
+ //#endregion
7
+
8
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","names":["serveWorker","byId","ALL_STUDIES","s","scope","handle","m","id"],"sources":["../src/worker.ts"],"sourcesContent":["// Worker entry: `new Worker(new URL(\"@alphacharts/indicators/worker\", import.meta.url), { type: \"module\" })`.\n// Knows every built-in study; imports the full set because a worker is not on\n// the page's critical path.\n\nimport { serveWorker } from \"./runner.js\";\nimport { ALL_STUDIES } from \"./studies/all.js\";\n\nconst byId = new Map(ALL_STUDIES.map((s) => [s.id, s]));\nconst scope = self as unknown as { postMessage(m: unknown, t?: Transferable[]): void; onmessage: ((e: { data: unknown }) => void) | null };\nconst handle = serveWorker((m, t) => scope.postMessage(m, t), (id) => byId.get(id));\nscope.onmessage = (e) => handle(e.data);\n"],"mappings":";;;AAOA,IAAMC,IAAO,IAAI,IAAIC,EAAY,KAAK,MAAM,CAACC,EAAE,IAAIA,CAAC,CAAC,CAAC,GAChDC,IAAQ,MACRC,IAASL,GAAa,GAAG,MAAMI,EAAM,YAAYE,GAAG,CAAC,IAAI,MAAOL,EAAK,IAAIM,CAAE,CAAC;AAClF,EAAM,aAAa,MAAMF,EAAO,EAAE,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "@alphacharts/indicators",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Technical studies for AlphaCharts: a typed study model, an incremental engine, a Web Worker runner and 210 studies.",
5
+ "keywords": [
6
+ "indicators",
7
+ "technical-analysis",
8
+ "ta-lib",
9
+ "rsi",
10
+ "macd",
11
+ "chart"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "Alphabench",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/alphabench/alphacharts.git",
18
+ "directory": "packages/indicators"
19
+ },
20
+ "homepage": "https://github.com/alphabench/alphacharts#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/alphabench/alphacharts/issues"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/types/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/types/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ },
37
+ "./all": {
38
+ "types": "./dist/types/all.d.ts",
39
+ "default": "./dist/all.js"
40
+ },
41
+ "./studies": {
42
+ "types": "./dist/types/studies/index.d.ts",
43
+ "default": "./dist/studies.js"
44
+ },
45
+ "./worker": {
46
+ "types": "./dist/types/worker.d.ts",
47
+ "default": "./dist/worker.js"
48
+ }
49
+ },
50
+ "files": [
51
+ "dist"
52
+ ],
53
+ "dependencies": {
54
+ "@alphacharts/wasm": "0.1.0"
55
+ },
56
+ "peerDependencies": {
57
+ "@alphacharts/core": "^0.1.0"
58
+ },
59
+ "devDependencies": {
60
+ "typescript": "5.9.3",
61
+ "vite": "8.3.1",
62
+ "vitest": "5.0.2",
63
+ "@alphacharts/core": "0.1.0"
64
+ },
65
+ "scripts": {
66
+ "build": "vite build && tsc -p tsconfig.build.json",
67
+ "typecheck": "tsc -p tsconfig.json",
68
+ "typecheck:dist": "tsc -p tsconfig.dist.json",
69
+ "test": "vitest run",
70
+ "fixtures": "python scripts/gen_fixtures.py"
71
+ }
6
72
  }