@alphacharts/indicators 0.1.0 → 0.1.1
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/README.md +19 -8
- package/dist/{all-DeXJJd7D.js → all-_xzUPrL7.js} +9 -9
- package/dist/{all-DeXJJd7D.js.map → all-_xzUPrL7.js.map} +1 -1
- package/dist/all.js +2 -2
- package/dist/define-XUgQMhSl.js +687 -0
- package/dist/define-XUgQMhSl.js.map +1 -0
- package/dist/index.js +269 -118
- package/dist/index.js.map +1 -1
- package/dist/{registry-CYZuqhXX.js → registry-DdYYyZN_.js} +5 -1
- package/dist/registry-DdYYyZN_.js.map +1 -0
- package/dist/{runner-DBP0M8z3.js → runner-B53M0IsJ.js} +15 -7
- package/dist/runner-B53M0IsJ.js.map +1 -0
- package/dist/studies.js +1 -1
- package/dist/{tv-volume-7hh6ajKt.js → tv-volume-BYSbfrVk.js} +197 -200
- package/dist/tv-volume-BYSbfrVk.js.map +1 -0
- package/dist/types/chart/marker-floor.d.ts +9 -0
- package/dist/types/chart/studies.d.ts +29 -2
- package/dist/types/engine/feed.d.ts +88 -0
- package/dist/types/engine/graph.d.ts +37 -2
- package/dist/types/engine/study.d.ts +9 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/runner.d.ts +11 -2
- package/dist/types/studies/tv-volume.d.ts +1 -0
- package/dist/types/types.d.ts +40 -4
- package/dist/worker.js +2 -2
- package/package.json +8 -5
- package/dist/assets/worker-BrUuzTIJ.js +0 -2
- package/dist/assets/worker-BrUuzTIJ.js.map +0 -1
- package/dist/define-BPvQbaq9.js +0 -472
- package/dist/define-BPvQbaq9.js.map +0 -1
- package/dist/registry-CYZuqhXX.js.map +0 -1
- package/dist/runner-DBP0M8z3.js.map +0 -1
- package/dist/tv-volume-7hh6ajKt.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first bar index whose mark is kept, over bars `[0, n)` of `col`: marks at
|
|
3
|
+
* or after it are drawn, those before are not. 0 when the plot asks for no limit.
|
|
4
|
+
*/
|
|
5
|
+
export declare function markerFloor(col: ArrayLike<number>, n: number, o: {
|
|
6
|
+
last?: number;
|
|
7
|
+
within?: number;
|
|
8
|
+
text?: boolean;
|
|
9
|
+
}): number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Chart, type ChartPlugin, type DataChange, type PluginApi, type PluginPaneView, type Series, type SeriesType } from "@alphacharts/core";
|
|
2
|
+
import { type FeedBar, type FeedBars, type FeedConfig } from "../engine/feed.js";
|
|
2
3
|
import { type StudyRunner } from "../runner.js";
|
|
3
4
|
import type { InputValue, Params, StudyDef } from "../types.js";
|
|
4
5
|
export declare const PLUGIN_ID = "alphacharts.studies";
|
|
@@ -37,6 +38,11 @@ export declare class Study {
|
|
|
37
38
|
private engine;
|
|
38
39
|
private outs;
|
|
39
40
|
private lines;
|
|
41
|
+
/** Background shading: one primitive per bgcolor plot, attached to the series of the pane it shades. */
|
|
42
|
+
private shades;
|
|
43
|
+
/** Outside series the host gave this study, by key. */
|
|
44
|
+
private feeds;
|
|
45
|
+
private sameScale;
|
|
40
46
|
private styles;
|
|
41
47
|
private shown;
|
|
42
48
|
private pane;
|
|
@@ -67,8 +73,11 @@ export declare class Study {
|
|
|
67
73
|
refresh(onlyLast?: boolean): void;
|
|
68
74
|
/** Output series, in plot order. */
|
|
69
75
|
series(): readonly AnySeries[];
|
|
70
|
-
/**
|
|
71
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Change inputs; unspecified ones keep their value, and the keys in `reset` go back to their defaults (a preset that
|
|
78
|
+
* has no value for an input the study has). Validated before anything changes. Outside series the study was given stay.
|
|
79
|
+
*/
|
|
80
|
+
setInputs(partial: Readonly<Record<string, InputValue>>, reset?: readonly string[]): void;
|
|
72
81
|
setVisible(visible: boolean): void;
|
|
73
82
|
setStyle(plotKey: string, style: PlotStyle): void;
|
|
74
83
|
remove(): void;
|
|
@@ -88,6 +97,20 @@ export declare class Study {
|
|
|
88
97
|
inputs: Record<string, InputValue>;
|
|
89
98
|
source: string;
|
|
90
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Give the study outside series `key` (see engine/feed.ts for what a feed is and how it is joined), replacing the
|
|
102
|
+
* previous bars of that key, and compute everything again. The study keeps its own copy.
|
|
103
|
+
*/
|
|
104
|
+
setFeed(key: string, bars: FeedBars, cfg: FeedConfig): void;
|
|
105
|
+
/** Keys of the outside series given so far. */
|
|
106
|
+
feedKeys(): string[];
|
|
107
|
+
/**
|
|
108
|
+
* A live bar of outside series `key` (same time as its last bar revises it, a later time appends). Only the study's
|
|
109
|
+
* last bar is evaluated again, and only when it sees a different feed bar through the join; otherwise nothing is
|
|
110
|
+
* recomputed or redrawn.
|
|
111
|
+
*/
|
|
112
|
+
pushFeedBar(key: string, bar: FeedBar): void;
|
|
113
|
+
get isShown(): boolean;
|
|
91
114
|
private get ohlc();
|
|
92
115
|
private checkSource;
|
|
93
116
|
/** Whether `d` is the store of one of this study's inputs. */
|
|
@@ -105,6 +128,8 @@ export declare class Study {
|
|
|
105
128
|
private seriesOptions;
|
|
106
129
|
private createSeries;
|
|
107
130
|
private syncAll;
|
|
131
|
+
/** Background shades and bar colours, from the engine's columns (every bar). */
|
|
132
|
+
private syncOverlays;
|
|
108
133
|
private writeSeries;
|
|
109
134
|
/** Show enough decimals for values below 1 (three significant digits); only ever grows. A def's own `minMove` wins; an overlay reads like its source. */
|
|
110
135
|
private widen;
|
|
@@ -122,6 +147,8 @@ export declare class StudiesPlugin implements ChartPlugin {
|
|
|
122
147
|
api: PluginApi | null;
|
|
123
148
|
private readonly studies;
|
|
124
149
|
private counter;
|
|
150
|
+
/** Sources whose bars the plugin has coloured: the plugin owns their colour column while a barcolor study exists. */
|
|
151
|
+
private readonly coloured;
|
|
125
152
|
constructor(chart: Chart, runner: StudyRunner | undefined, resolve: (id: string) => StudyDef);
|
|
126
153
|
install(api: PluginApi): void;
|
|
127
154
|
uninstall(): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Graph } from "./graph.js";
|
|
2
|
+
export type FeedField = "open" | "high" | "low" | "close" | "volume";
|
|
3
|
+
export declare const FEED_FIELDS: readonly FeedField[];
|
|
4
|
+
export type FeedAlign = "same" | "closed";
|
|
5
|
+
export interface FeedConfig {
|
|
6
|
+
align: FeedAlign;
|
|
7
|
+
/** Nominal length of one feed bar, ms. Used by "closed" (> 0); ignored by "same". */
|
|
8
|
+
spanMs: number;
|
|
9
|
+
}
|
|
10
|
+
/** Columnar bars of a feed, in the feed's own time. */
|
|
11
|
+
export interface FeedBars {
|
|
12
|
+
time: Float64Array;
|
|
13
|
+
open: Float64Array;
|
|
14
|
+
high: Float64Array;
|
|
15
|
+
low: Float64Array;
|
|
16
|
+
close: Float64Array;
|
|
17
|
+
volume: Float64Array;
|
|
18
|
+
}
|
|
19
|
+
export interface FeedBar {
|
|
20
|
+
time: number;
|
|
21
|
+
open: number;
|
|
22
|
+
high: number;
|
|
23
|
+
low: number;
|
|
24
|
+
close: number;
|
|
25
|
+
volume: number;
|
|
26
|
+
}
|
|
27
|
+
/** A feed as sent to a runner: its bars and how to join them. */
|
|
28
|
+
export interface FeedData extends FeedConfig {
|
|
29
|
+
bars: FeedBars;
|
|
30
|
+
}
|
|
31
|
+
export type FeedChange = "appended" | "revised";
|
|
32
|
+
/**
|
|
33
|
+
* A feed is a graph of its own whose bars are the other series' bars: its base columns (time, open, high, low, close,
|
|
34
|
+
* volume) are the series itself, and whatever is computed from it (a script's `ta.rsi(outside(...), 14)`) is computed
|
|
35
|
+
* on those bars, so a window of 14 is 14 of the series' bars whatever the chart's timeframe. The chart's graph reads
|
|
36
|
+
* the result through the join (`Graph.joined`). Loading or ticking the feed evaluates its graph at once.
|
|
37
|
+
*/
|
|
38
|
+
export declare class Feed {
|
|
39
|
+
readonly graph: Graph;
|
|
40
|
+
align: FeedAlign;
|
|
41
|
+
spanMs: number;
|
|
42
|
+
private cur;
|
|
43
|
+
get n(): number;
|
|
44
|
+
/** Replace the bars (copied) and the join. Throws, naming `what`, on bars that are not a series. */
|
|
45
|
+
load(bars: FeedBars, cfg: FeedConfig, what?: string): void;
|
|
46
|
+
/** Change how the bars are joined, keeping them. */
|
|
47
|
+
configure(cfg: FeedConfig, what?: string): void;
|
|
48
|
+
/** A live bar: the same time as the last bar replaces it, a later time appends; an earlier time throws. */
|
|
49
|
+
apply(b: FeedBar, what?: string): FeedChange;
|
|
50
|
+
/** The bars as a runner takes them (copies, length n). */
|
|
51
|
+
snapshot(): FeedBars;
|
|
52
|
+
/** Index of the feed bar the study bar at time `t` sees, or -1 when it sees none. */
|
|
53
|
+
lookup(t: number): number;
|
|
54
|
+
value(field: FeedField, i: number): number;
|
|
55
|
+
}
|
|
56
|
+
/** Row `field` of every bar in `feed` joined onto `times`, as a plain array: the join in one call (for tests and tools). */
|
|
57
|
+
export declare function joinFeed(feed: Feed, field: FeedField, times: ArrayLike<number>): Float64Array;
|
|
58
|
+
export type JoinReason =
|
|
59
|
+
/** Every chart bar sees a feed bar. */
|
|
60
|
+
"complete"
|
|
61
|
+
/** Some chart bars see a feed bar and some do not (holes in the feed, or the feed starts later or ends earlier). */
|
|
62
|
+
| "partial"
|
|
63
|
+
/** The join finds nothing: the chart has no bars, or the feed has none. */
|
|
64
|
+
| "empty"
|
|
65
|
+
/** Same-length join and the feed's bar times never equal the chart's: the two sit on different clocks (offsetMs). */
|
|
66
|
+
| "different-clock"
|
|
67
|
+
/** Longer-timeframe join and no feed bar has finished by any chart bar (the feed starts after the chart ends, or is too short). */
|
|
68
|
+
| "no-finished-bar";
|
|
69
|
+
export interface JoinReport {
|
|
70
|
+
align: FeedAlign;
|
|
71
|
+
chartBars: number;
|
|
72
|
+
/** Chart bars that see a feed bar. A chart bar that sees none is blank (NaN) in everything read from the feed. */
|
|
73
|
+
matched: number;
|
|
74
|
+
reason: JoinReason;
|
|
75
|
+
/**
|
|
76
|
+
* For "different-clock": how far the feed's bars sit from the chart's, in ms, in (-spanMs/2, spanMs/2]: the first feed bar's
|
|
77
|
+
* time minus the first chart bar's, modulo the bar length. NSE hourly bars open at 09:15 and MCX's at 09:00, so a chart on one
|
|
78
|
+
* reading the other gives +900000 or -900000. Otherwise null.
|
|
79
|
+
*/
|
|
80
|
+
offsetMs: number | null;
|
|
81
|
+
/** One sentence a host can show where it would otherwise show "blank". */
|
|
82
|
+
message: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Why a join gives what it gives, for a host to explain a blank outside series: how many chart bars `cfg` joins to a bar of `feedTimes`
|
|
86
|
+
* and, when none, the reason. A pure function of the two time columns and the config handed to `setFeed`; it reads no value.
|
|
87
|
+
*/
|
|
88
|
+
export declare function describeJoin(chartTimes: ArrayLike<number>, feedTimes: ArrayLike<number>, cfg: FeedConfig): JoinReport;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Feed, type FeedField } from "./feed.js";
|
|
1
2
|
export type Ref = Col | number;
|
|
2
3
|
export declare class Col {
|
|
3
4
|
v: Float64Array;
|
|
@@ -23,6 +24,8 @@ export declare class Graph {
|
|
|
23
24
|
readonly close: Col;
|
|
24
25
|
readonly volume: Col;
|
|
25
26
|
private readonly sources;
|
|
27
|
+
/** Outside series by key: bars given by the host, joined onto this graph's bars by `external`. */
|
|
28
|
+
readonly feeds: Map<string, Feed>;
|
|
26
29
|
constructor(cap?: number);
|
|
27
30
|
/** An auxiliary column (state a node keeps per bar). */
|
|
28
31
|
col(): Col;
|
|
@@ -41,6 +44,15 @@ export declare class Graph {
|
|
|
41
44
|
/** A constant as a column-compatible value. */
|
|
42
45
|
private val;
|
|
43
46
|
src(name: SourceName): Node;
|
|
47
|
+
/** The feed `key` (created empty on first use: its bars arrive from the host, and until they do every join is absent). */
|
|
48
|
+
feed(key: string): Feed;
|
|
49
|
+
/** Field `field` of feed `key` joined onto this graph's bars (see feed.ts for the two joins). NaN where the join finds no bar. */
|
|
50
|
+
external(key: string, field: FeedField): Node;
|
|
51
|
+
/**
|
|
52
|
+
* A column of feed `key`'s own graph (its base columns by name, or anything computed on its bars) read through the
|
|
53
|
+
* join: at each bar of this graph, the value at the feed row the join finds, NaN when it finds none.
|
|
54
|
+
*/
|
|
55
|
+
joined(key: string, col: Col | FeedField): Node;
|
|
44
56
|
map(x: Col, f: (x: number) => number): Node;
|
|
45
57
|
map2(x: Ref, y: Ref, f: (x: number, y: number) => number): Node;
|
|
46
58
|
add(x: Ref, y: Ref): Node;
|
|
@@ -80,9 +92,11 @@ export declare class Graph {
|
|
|
80
92
|
/**
|
|
81
93
|
* Population variance over p bars (TA-Lib VAR): mean-centred two-pass over the
|
|
82
94
|
* window, because running sums of squares lose ~1e-8 relative on price series.
|
|
95
|
+
* `sample` divides by p - 1 instead (the unbiased estimator, the one a Sharpe or volatility estimate from a sample uses): the
|
|
96
|
+
* population value scaled by p / (p - 1), undefined for p = 1.
|
|
83
97
|
*/
|
|
84
|
-
variance(x: Col, p: number): Node;
|
|
85
|
-
stdev(x: Col, p: number): Node;
|
|
98
|
+
variance(x: Col, p: number, sample?: boolean): Node;
|
|
99
|
+
stdev(x: Col, p: number, sample?: boolean): Node;
|
|
86
100
|
/**
|
|
87
101
|
* Least-squares line over the last p bars against x = 0..p-1 (oldest..newest).
|
|
88
102
|
* `value` is the line at the newest bar; `slope` per bar; `intercept` at the oldest bar.
|
|
@@ -96,6 +110,27 @@ export declare class Graph {
|
|
|
96
110
|
alias(c: Col): Node;
|
|
97
111
|
/** True range: max(h-l, |h-c'|, |l-c'|); the first bar has no previous close, so is absent (TA-Lib TRANGE). */
|
|
98
112
|
tr(): Node;
|
|
113
|
+
/** True range with the first bar's range as high - low (Wilder; Pine's `ta.tr(true)`). */
|
|
114
|
+
trFirst(): Node;
|
|
115
|
+
/**
|
|
116
|
+
* Average true range as Wilder defined it: the first true range is high - low, the seed is the
|
|
117
|
+
* mean of true ranges 0..p-1 (first value at bar p-1), then Wilder's smoothing. Not TA-Lib's ATR (TA-Lib skips the first
|
|
118
|
+
* true range, so it starts one bar later and differs by a different seed).
|
|
119
|
+
*/
|
|
99
120
|
atr(p: number): Node;
|
|
121
|
+
/**
|
|
122
|
+
* Bars per year, read from the bars of this graph and from nothing after the bar it is written on (a causal annualisation). Intraday bars: the median number of bars per exchange-clock day over the
|
|
123
|
+
* last {@link BPY_SESSIONS} finished days, times 252 sessions (nights and weekends add no bars). A day or longer between bars: 252 a
|
|
124
|
+
* year for daily bars that leave weekends out, otherwise calendar time (365 days over the median spacing: weekly 52.14,
|
|
125
|
+
* monthly 12.17), the median over the last {@link BPY_COARSE} bars. Constant within a day, so a finished bar's value never changes
|
|
126
|
+
* when later bars arrive or the last bar is revised; absent before the first day has finished (and, for a day or
|
|
127
|
+
* longer, before six bars). The day is cut at `offsetMin` minutes east of UTC: 0 suits every session inside one UTC day
|
|
128
|
+
* (NSE, BSE, MCX, NYSE, LSE).
|
|
129
|
+
*/
|
|
130
|
+
barsPerYear(offsetMin?: number): Node;
|
|
100
131
|
}
|
|
132
|
+
/** Finished days whose bar counts the median is taken over (barsPerYear). */
|
|
133
|
+
export declare const BPY_SESSIONS = 60;
|
|
134
|
+
/** Bars the spacing and the weekend test are read from when bars are a day or longer (barsPerYear). */
|
|
135
|
+
export declare const BPY_COARSE = 120;
|
|
101
136
|
export declare function checkPeriod(p: number): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Graph, type Col } from "./graph.js";
|
|
2
2
|
import type { BarColumns, BarInput, InputValue, Params, StudyDef } from "../types.js";
|
|
3
|
+
import type { FeedBar, FeedConfig, FeedBars } from "./feed.js";
|
|
3
4
|
/** Validate `given` against the study's inputs and fill defaults. Throws on anything unknown or out of range. */
|
|
4
5
|
export declare function resolveParams(def: StudyDef, given?: Readonly<Record<string, InputValue>>): Params;
|
|
5
6
|
/** A study bound to parameters and a graph: appends, revises and batch-loads bars. */
|
|
@@ -18,6 +19,14 @@ export declare class StudyEngine {
|
|
|
18
19
|
* returns false when `cancelled()` turns true.
|
|
19
20
|
*/
|
|
20
21
|
loadChunked(d: BarColumns, chunk: number, pause: () => Promise<void>, cancelled: () => boolean): Promise<boolean>;
|
|
22
|
+
/** Give the study outside series `key`: bars in their own time and how to join them (copied). Run the study again afterwards. */
|
|
23
|
+
setFeed(key: string, bars: FeedBars, cfg: FeedConfig): void;
|
|
24
|
+
/**
|
|
25
|
+
* A live bar of outside series `key`: the feed's last bar is replaced or one is appended, and what the study computed
|
|
26
|
+
* on the feed's bars follows. When the study's last bar now sees a different feed row (or the same one revised), that
|
|
27
|
+
* bar is evaluated again and `true` is returned; otherwise nothing of the study is recomputed. O(1) amortised.
|
|
28
|
+
*/
|
|
29
|
+
pushFeed(key: string, bar: FeedBar): boolean;
|
|
21
30
|
/** Append a bar (time later than the last). */
|
|
22
31
|
push(b: BarInput): void;
|
|
23
32
|
/** Replace the last bar (a tick revision). */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,10 +2,13 @@ export * from "./types.js";
|
|
|
2
2
|
export { Graph, Col, Node, SOURCE_NAMES } from "./engine/graph.js";
|
|
3
3
|
export type { Ref, SourceName } from "./engine/graph.js";
|
|
4
4
|
export { StudyEngine, resolveParams, runStudy } from "./engine/study.js";
|
|
5
|
+
export { Feed, FEED_FIELDS, describeJoin, joinFeed } from "./engine/feed.js";
|
|
6
|
+
export type { FeedAlign, FeedBar, FeedBars, FeedChange, FeedConfig, FeedData, FeedField, JoinReason, JoinReport } from "./engine/feed.js";
|
|
5
7
|
export { registerStudy, registerStudies, getStudy, listStudies, validateDef } from "./registry.js";
|
|
6
8
|
export { defineStudy } from "./define.js";
|
|
7
9
|
export { addStudy, installStudies, StudiesPlugin, Study, PLUGIN_ID } from "./chart/studies.js";
|
|
8
10
|
export type { AddStudyOptions, PlotStyle } from "./chart/studies.js";
|
|
11
|
+
export { markerFloor } from "./chart/marker-floor.js";
|
|
9
12
|
export { InlineRunner, WorkerRunner, createRunner, serveWorker, CancelledError, CHUNK } from "./runner.js";
|
|
10
13
|
export type { StudyRunner, RunRequest, RunResult, WorkerLike } from "./runner.js";
|
|
11
14
|
export { enableWasm, disableWasm } from "./wasm.js";
|
package/dist/types/runner.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FeedBar, FeedData } from "./engine/feed.js";
|
|
1
2
|
import type { BarColumns, InputValue, StudyDef } from "./types.js";
|
|
2
3
|
export declare const CHUNK: number;
|
|
3
4
|
export interface RunRequest {
|
|
@@ -5,6 +6,8 @@ export interface RunRequest {
|
|
|
5
6
|
params: Readonly<Record<string, InputValue>>;
|
|
6
7
|
/** Transferred to the runner when it is a worker: do not use afterwards. */
|
|
7
8
|
bars: BarColumns;
|
|
9
|
+
/** Outside series by key, each a copy the runner may keep or transfer. Only a runner that can run a study that reads them (a script) uses them. */
|
|
10
|
+
feeds?: Record<string, FeedData>;
|
|
8
11
|
}
|
|
9
12
|
export interface RunResult {
|
|
10
13
|
n: number;
|
|
@@ -22,6 +25,11 @@ export interface StudyRunner {
|
|
|
22
25
|
promise: Promise<RunResult>;
|
|
23
26
|
cancel(): void;
|
|
24
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* A live bar of outside series `key` for a study this runner holds state for; the runner answers through the channel
|
|
30
|
+
* its ticks use. Optional: a runner that keeps no per-study state (every batch starts afresh) does not have it.
|
|
31
|
+
*/
|
|
32
|
+
feedBar?(def: StudyDef, key: string, bar: FeedBar): void;
|
|
25
33
|
dispose(): void;
|
|
26
34
|
}
|
|
27
35
|
/** Main-thread fallback: same chunked evaluation, same cancellation. */
|
|
@@ -75,8 +83,9 @@ export declare class WorkerRunner implements StudyRunner {
|
|
|
75
83
|
/** Worker-side message handler: wire it to `self.onmessage` (see worker.ts). */
|
|
76
84
|
export declare function serveWorker(post: (msg: WorkerReply, transfer?: Transferable[]) => void, find: (id: string) => StudyDef | undefined): (data: unknown) => void;
|
|
77
85
|
/**
|
|
78
|
-
* A worker runner
|
|
79
|
-
*
|
|
86
|
+
* A worker runner on the worker `factory` creates, otherwise (no factory, or the worker would not start) the inline fallback.
|
|
87
|
+
* The package never guesses where its worker lives: the host's bundler spells the URL out,
|
|
88
|
+
* `() => new Worker(new URL("@alphacharts/indicators/worker", import.meta.url), { type: "module" })`.
|
|
80
89
|
*/
|
|
81
90
|
export declare function createRunner(builtinIds: ReadonlySet<string>, factory?: () => WorkerLike): StudyRunner;
|
|
82
91
|
export {};
|
|
@@ -12,3 +12,4 @@ export declare const anchoredVwap: import("../types.js").StudyDef;
|
|
|
12
12
|
export declare const pivotPoints: import("../types.js").StudyDef;
|
|
13
13
|
export declare const histVol: import("../types.js").StudyDef;
|
|
14
14
|
export declare const adr: import("../types.js").StudyDef;
|
|
15
|
+
export declare const barsPerYear: import("../types.js").StudyDef;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -29,10 +29,18 @@ export type PlotDef = (PlotBase & {
|
|
|
29
29
|
color: string;
|
|
30
30
|
width?: number;
|
|
31
31
|
style?: LineStyleName;
|
|
32
|
-
/** Shift in bars (positive = into the future). Negative shifts and `connect` draw on the overlay. */
|
|
33
|
-
offset?: number;
|
|
32
|
+
/** Shift in bars (positive = into the future). Negative shifts and `connect` draw on the overlay. A function is worked out from the study's inputs (`-right`). */
|
|
33
|
+
offset?: number | ((p: Params) => number);
|
|
34
34
|
/** Join across absent bars (drawn on the overlay). */
|
|
35
35
|
connect?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Per-point colour: where column `col` is present and not zero, the line segment arriving at that bar is drawn in
|
|
38
|
+
* `color` instead of the plot's own. The column is an ordinary one (a 0/1 condition), computed with the rest.
|
|
39
|
+
*/
|
|
40
|
+
colorBy?: {
|
|
41
|
+
col: string;
|
|
42
|
+
color: string;
|
|
43
|
+
};
|
|
36
44
|
}) | (PlotBase & {
|
|
37
45
|
kind: "histogram";
|
|
38
46
|
col: string;
|
|
@@ -73,10 +81,33 @@ export type PlotDef = (PlotBase & {
|
|
|
73
81
|
shape: MarkerShape;
|
|
74
82
|
position: "value" | "above" | "below" | "sign";
|
|
75
83
|
color: string;
|
|
76
|
-
/** Shift in bars (positive = into the future); Fractals confirm two bars late and shift back. */
|
|
77
|
-
offset?: number;
|
|
84
|
+
/** Shift in bars (positive = into the future); Fractals confirm two bars late and shift back. A function is worked out from the study's inputs (`-right`). */
|
|
85
|
+
offset?: number | ((p: Params) => number);
|
|
78
86
|
/** Draw the value as text (pattern scores) instead of a shape. */
|
|
79
87
|
text?: boolean;
|
|
88
|
+
/** Keep only the most recent `last` marked bars. Decided from the finished columns each time they are drawn, so a tick or a batch gives the same marks. */
|
|
89
|
+
last?: number;
|
|
90
|
+
/** Keep only marks on the final `within` bars. */
|
|
91
|
+
within?: number;
|
|
92
|
+
})
|
|
93
|
+
/**
|
|
94
|
+
* Colours the candles (or OHLC bars) of the study's source series on every bar where column `col` is present and
|
|
95
|
+
* not zero. Several barcolor plots (and several studies) compose: the latest one that applies to a bar wins; a bar none
|
|
96
|
+
* applies to keeps its up/down colours. Needs an OHLC source.
|
|
97
|
+
*/
|
|
98
|
+
| (PlotBase & {
|
|
99
|
+
kind: "barcolor";
|
|
100
|
+
col: string;
|
|
101
|
+
color: string;
|
|
102
|
+
})
|
|
103
|
+
/**
|
|
104
|
+
* Shades the background of the study's pane (the source's pane for an overlay) on every bar where column `col` is
|
|
105
|
+
* present and not zero. Takes no part in autoscale.
|
|
106
|
+
*/
|
|
107
|
+
| (PlotBase & {
|
|
108
|
+
kind: "bgcolor";
|
|
109
|
+
col: string;
|
|
110
|
+
color: string;
|
|
80
111
|
})
|
|
81
112
|
/** ZigZag: `price` at the confirmation bar and `back` bars to the pivot; joined by straight lines. */
|
|
82
113
|
| (PlotBase & {
|
|
@@ -97,6 +128,11 @@ export interface StudyDef {
|
|
|
97
128
|
needs: StudyNeeds;
|
|
98
129
|
/** Where it is drawn: on the source's pane or in a pane of its own. */
|
|
99
130
|
pane: "overlay" | "new";
|
|
131
|
+
/**
|
|
132
|
+
* Which price scale its series use: "right" (default) or the chart's "left" axis, so a series of another magnitude
|
|
133
|
+
* shares the pane without flattening the price. Either side needs the chart to show that axis to be read.
|
|
134
|
+
*/
|
|
135
|
+
scale?: "right" | "left";
|
|
100
136
|
/** Names of the computed columns, in the order `build` returns them. */
|
|
101
137
|
columns: readonly string[];
|
|
102
138
|
plots: readonly PlotDef[];
|
package/dist/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as e } from "./runner-
|
|
2
|
-
import { t } from "./all-
|
|
1
|
+
import { o as e } from "./runner-B53M0IsJ.js";
|
|
2
|
+
import { t } from "./all-_xzUPrL7.js";
|
|
3
3
|
//#region src/worker.ts
|
|
4
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
5
|
r.onmessage = (e) => i(e.data);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphacharts/indicators",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Technical studies for
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Technical studies for alphacharts: a typed study model, an incremental engine, a Web Worker runner and 211 studies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indicators",
|
|
7
7
|
"technical-analysis",
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|
|
28
|
-
"sideEffects":
|
|
28
|
+
"sideEffects": [
|
|
29
|
+
"./dist/worker.js",
|
|
30
|
+
"./src/worker.ts"
|
|
31
|
+
],
|
|
29
32
|
"main": "./dist/index.js",
|
|
30
33
|
"module": "./dist/index.js",
|
|
31
34
|
"types": "./dist/types/index.d.ts",
|
|
@@ -54,13 +57,13 @@
|
|
|
54
57
|
"@alphacharts/wasm": "0.1.0"
|
|
55
58
|
},
|
|
56
59
|
"peerDependencies": {
|
|
57
|
-
"@alphacharts/core": "^0.1.
|
|
60
|
+
"@alphacharts/core": "^0.1.1"
|
|
58
61
|
},
|
|
59
62
|
"devDependencies": {
|
|
60
63
|
"typescript": "5.9.3",
|
|
61
64
|
"vite": "8.3.1",
|
|
62
65
|
"vitest": "5.0.2",
|
|
63
|
-
"@alphacharts/core": "0.1.
|
|
66
|
+
"@alphacharts/core": "0.1.1"
|
|
64
67
|
},
|
|
65
68
|
"scripts": {
|
|
66
69
|
"build": "vite build && tsc -p tsconfig.build.json",
|