@luxalgo/vela-pinets 0.2.12 → 0.2.14

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/index.d.cts CHANGED
@@ -1,5 +1,64 @@
1
1
  import { ScriptingEngine, EngineCapabilities, InputValue, PreparedScript, ExecutionRequest, ExecutionHandlers, ExecutionSession } from '@luxalgo/vela/plugin';
2
2
 
3
+ /**
4
+ * The host-facing order-flow seam behind Pine's `request.footprint()`.
5
+ *
6
+ * Vela owns bars, never order flow — so a host that HAS per-bar volume footprints
7
+ * (a footprint-capable data provider) hands the engine a {@link FootprintSource},
8
+ * and the engine exposes it to PineTS as the optional `getFootprintData` surface of
9
+ * its virtual market-data provider. Without a source the surface is simply absent
10
+ * and every `request.footprint()` call answers `na`, exactly as PineTS specifies.
11
+ *
12
+ * The shapes below are structurally identical to PineTS's `FootprintBar` /
13
+ * `FootprintLevel` (declared here rather than imported so this package builds and
14
+ * types against any pinets version — the surface only becomes REACHABLE once the
15
+ * bundled pinets implements `request.footprint()`).
16
+ */
17
+ /** Executed volume at one price level of a bar, split by aggressor side. */
18
+ interface FootprintLevel {
19
+ /** Level price — the LOW edge of the price bucket this level covers. */
20
+ price: number;
21
+ /** Volume executed by buy-aggressors (ask lifts) at this level. */
22
+ buyVolume: number;
23
+ /** Volume executed by sell-aggressors (bid hits) at this level. */
24
+ sellVolume: number;
25
+ }
26
+ /**
27
+ * The volume footprint of ONE chart bar, keyed by the bar's open time. Levels may
28
+ * sit on any price grid: PineTS re-bins them into `ticks_per_row × mintick` rows
29
+ * itself, so a source serves its finest granularity and never needs the row size.
30
+ */
31
+ interface FootprintBar {
32
+ /** Bar open time, epoch ms — equals the matching bar's `time`. */
33
+ openTime: number;
34
+ /** Price step the levels were bucketed on. Informational only. */
35
+ tick?: number;
36
+ /** Price levels, any order; levels without volume may be omitted. */
37
+ levels: FootprintLevel[];
38
+ }
39
+ /** The window PineTS asks for — mirrors its `getMarketData(…, limit, sDate, eDate)` slots. */
40
+ interface FootprintRange {
41
+ /** First bar open time (epoch ms), inclusive. Absent on a bare tail poll. */
42
+ from?: number;
43
+ /** Exclusive end (epoch ms). Absent = "up to now". */
44
+ to?: number;
45
+ /** Bar count of the loaded history on the initial load; absent on tail polls. */
46
+ limit?: number;
47
+ }
48
+ /**
49
+ * Per-bar footprints of `(symbol, timeframe)` over `range`, plain symbol (chart-type
50
+ * modifiers never reach it: order flow is never derived). Usually the chart series,
51
+ * but a `request.footprint()` evaluated inside `request.security()` asks for THAT
52
+ * context's symbol and timeframe, which may differ from the chart's.
53
+ *
54
+ * Call pattern (PineTS's), per series: one call over the whole loaded history, then
55
+ * — whenever the market data changes (a live tick, new bars) — a call from the
56
+ * forming bar's open time onward. Returned bars REPLACE what PineTS holds for those
57
+ * open times, so a live source just answers with its current state for the tail.
58
+ * Bars the source cannot serve are omitted; the script reads `na` for them.
59
+ */
60
+ type FootprintSource = (symbol: string, timeframe: string, range: FootprintRange) => Promise<FootprintBar[]>;
61
+
3
62
  /**
4
63
  * Which scripts publish a declaration-props schema (the settings dialog's
5
64
  * "Properties" tab): every script, only `strategy()` scripts, or none.
@@ -35,6 +94,13 @@ interface PineEngineOptions {
35
94
  * source/spec values, and `setProps` still applies.
36
95
  */
37
96
  props?: PropsFilter;
97
+ /**
98
+ * Per-bar volume footprints for Pine's `request.footprint()`. Vela owns bars, not
99
+ * order flow, so a host with a footprint-capable data source supplies this; the
100
+ * engine exposes it to PineTS as its provider's optional `getFootprintData`
101
+ * surface. Absent ≡ `request.footprint()` answers `na` on every bar.
102
+ */
103
+ footprints?: FootprintSource;
38
104
  }
39
105
  /**
40
106
  * The in-process PineTS implementation of `ScriptingEngine`. Both the static run
@@ -48,6 +114,7 @@ declare class PineEngine implements ScriptingEngine {
48
114
  readonly capabilities: EngineCapabilities;
49
115
  private readonly defaultProps;
50
116
  private readonly propsVisibility;
117
+ private readonly footprints;
51
118
  constructor(opts?: PineEngineOptions);
52
119
  prepare(source: string, instanceId: string): Promise<PreparedScript>;
53
120
  execute(req: ExecutionRequest, handlers: ExecutionHandlers): ExecutionSession;
@@ -88,6 +155,14 @@ interface PineWorkerOptions {
88
155
  * source/spec values, and `setProps` still applies.
89
156
  */
90
157
  props?: PropsFilter;
158
+ /**
159
+ * Per-bar volume footprints for Pine's `request.footprint()`. Vela owns bars, not
160
+ * order flow, so a host with a footprint-capable data source supplies this; the
161
+ * worker exposes it to PineTS as its provider's optional `getFootprintData`
162
+ * surface and round-trips each call here (the source runs on the main thread,
163
+ * like `fetchSeries`). Absent ≡ `request.footprint()` answers `na` on every bar.
164
+ */
165
+ footprints?: FootprintSource;
91
166
  }
92
167
  /**
93
168
  * A worker-backed PineTS engine: identical Pine semantics to `PineEngine`, but the
@@ -110,6 +185,7 @@ declare class PineWorkerEngine implements ScriptingEngine {
110
185
  private readonly spawn;
111
186
  private readonly defaultProps;
112
187
  private readonly propsVisibility;
188
+ private readonly footprints;
113
189
  private readonly prepares;
114
190
  private readonly sessions;
115
191
  private reqId;
@@ -146,6 +222,12 @@ declare class PineWorkerEngine implements ScriptingEngine {
146
222
  * cache-backed gateway (same provider, neutral by (symbol, timeframe)).
147
223
  */
148
224
  private serveFetch;
225
+ /**
226
+ * Answer a worker's footprint request from the engine's `footprints` option. The
227
+ * worker only asks when `execute` flagged a source, so a missing one here is a
228
+ * host bug — answer empty rather than hang the script's await.
229
+ */
230
+ private serveFootprints;
149
231
  }
150
232
 
151
- export { PineEngine, type PineEngineOptions, PineWorkerEngine, type PineWorkerOptions, type PropsFilter, type PropsVisibility };
233
+ export { type FootprintBar, type FootprintLevel, type FootprintRange, type FootprintSource, PineEngine, type PineEngineOptions, PineWorkerEngine, type PineWorkerOptions, type PropsFilter, type PropsVisibility };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,64 @@
1
1
  import { ScriptingEngine, EngineCapabilities, InputValue, PreparedScript, ExecutionRequest, ExecutionHandlers, ExecutionSession } from '@luxalgo/vela/plugin';
2
2
 
3
+ /**
4
+ * The host-facing order-flow seam behind Pine's `request.footprint()`.
5
+ *
6
+ * Vela owns bars, never order flow — so a host that HAS per-bar volume footprints
7
+ * (a footprint-capable data provider) hands the engine a {@link FootprintSource},
8
+ * and the engine exposes it to PineTS as the optional `getFootprintData` surface of
9
+ * its virtual market-data provider. Without a source the surface is simply absent
10
+ * and every `request.footprint()` call answers `na`, exactly as PineTS specifies.
11
+ *
12
+ * The shapes below are structurally identical to PineTS's `FootprintBar` /
13
+ * `FootprintLevel` (declared here rather than imported so this package builds and
14
+ * types against any pinets version — the surface only becomes REACHABLE once the
15
+ * bundled pinets implements `request.footprint()`).
16
+ */
17
+ /** Executed volume at one price level of a bar, split by aggressor side. */
18
+ interface FootprintLevel {
19
+ /** Level price — the LOW edge of the price bucket this level covers. */
20
+ price: number;
21
+ /** Volume executed by buy-aggressors (ask lifts) at this level. */
22
+ buyVolume: number;
23
+ /** Volume executed by sell-aggressors (bid hits) at this level. */
24
+ sellVolume: number;
25
+ }
26
+ /**
27
+ * The volume footprint of ONE chart bar, keyed by the bar's open time. Levels may
28
+ * sit on any price grid: PineTS re-bins them into `ticks_per_row × mintick` rows
29
+ * itself, so a source serves its finest granularity and never needs the row size.
30
+ */
31
+ interface FootprintBar {
32
+ /** Bar open time, epoch ms — equals the matching bar's `time`. */
33
+ openTime: number;
34
+ /** Price step the levels were bucketed on. Informational only. */
35
+ tick?: number;
36
+ /** Price levels, any order; levels without volume may be omitted. */
37
+ levels: FootprintLevel[];
38
+ }
39
+ /** The window PineTS asks for — mirrors its `getMarketData(…, limit, sDate, eDate)` slots. */
40
+ interface FootprintRange {
41
+ /** First bar open time (epoch ms), inclusive. Absent on a bare tail poll. */
42
+ from?: number;
43
+ /** Exclusive end (epoch ms). Absent = "up to now". */
44
+ to?: number;
45
+ /** Bar count of the loaded history on the initial load; absent on tail polls. */
46
+ limit?: number;
47
+ }
48
+ /**
49
+ * Per-bar footprints of `(symbol, timeframe)` over `range`, plain symbol (chart-type
50
+ * modifiers never reach it: order flow is never derived). Usually the chart series,
51
+ * but a `request.footprint()` evaluated inside `request.security()` asks for THAT
52
+ * context's symbol and timeframe, which may differ from the chart's.
53
+ *
54
+ * Call pattern (PineTS's), per series: one call over the whole loaded history, then
55
+ * — whenever the market data changes (a live tick, new bars) — a call from the
56
+ * forming bar's open time onward. Returned bars REPLACE what PineTS holds for those
57
+ * open times, so a live source just answers with its current state for the tail.
58
+ * Bars the source cannot serve are omitted; the script reads `na` for them.
59
+ */
60
+ type FootprintSource = (symbol: string, timeframe: string, range: FootprintRange) => Promise<FootprintBar[]>;
61
+
3
62
  /**
4
63
  * Which scripts publish a declaration-props schema (the settings dialog's
5
64
  * "Properties" tab): every script, only `strategy()` scripts, or none.
@@ -35,6 +94,13 @@ interface PineEngineOptions {
35
94
  * source/spec values, and `setProps` still applies.
36
95
  */
37
96
  props?: PropsFilter;
97
+ /**
98
+ * Per-bar volume footprints for Pine's `request.footprint()`. Vela owns bars, not
99
+ * order flow, so a host with a footprint-capable data source supplies this; the
100
+ * engine exposes it to PineTS as its provider's optional `getFootprintData`
101
+ * surface. Absent ≡ `request.footprint()` answers `na` on every bar.
102
+ */
103
+ footprints?: FootprintSource;
38
104
  }
39
105
  /**
40
106
  * The in-process PineTS implementation of `ScriptingEngine`. Both the static run
@@ -48,6 +114,7 @@ declare class PineEngine implements ScriptingEngine {
48
114
  readonly capabilities: EngineCapabilities;
49
115
  private readonly defaultProps;
50
116
  private readonly propsVisibility;
117
+ private readonly footprints;
51
118
  constructor(opts?: PineEngineOptions);
52
119
  prepare(source: string, instanceId: string): Promise<PreparedScript>;
53
120
  execute(req: ExecutionRequest, handlers: ExecutionHandlers): ExecutionSession;
@@ -88,6 +155,14 @@ interface PineWorkerOptions {
88
155
  * source/spec values, and `setProps` still applies.
89
156
  */
90
157
  props?: PropsFilter;
158
+ /**
159
+ * Per-bar volume footprints for Pine's `request.footprint()`. Vela owns bars, not
160
+ * order flow, so a host with a footprint-capable data source supplies this; the
161
+ * worker exposes it to PineTS as its provider's optional `getFootprintData`
162
+ * surface and round-trips each call here (the source runs on the main thread,
163
+ * like `fetchSeries`). Absent ≡ `request.footprint()` answers `na` on every bar.
164
+ */
165
+ footprints?: FootprintSource;
91
166
  }
92
167
  /**
93
168
  * A worker-backed PineTS engine: identical Pine semantics to `PineEngine`, but the
@@ -110,6 +185,7 @@ declare class PineWorkerEngine implements ScriptingEngine {
110
185
  private readonly spawn;
111
186
  private readonly defaultProps;
112
187
  private readonly propsVisibility;
188
+ private readonly footprints;
113
189
  private readonly prepares;
114
190
  private readonly sessions;
115
191
  private reqId;
@@ -146,6 +222,12 @@ declare class PineWorkerEngine implements ScriptingEngine {
146
222
  * cache-backed gateway (same provider, neutral by (symbol, timeframe)).
147
223
  */
148
224
  private serveFetch;
225
+ /**
226
+ * Answer a worker's footprint request from the engine's `footprints` option. The
227
+ * worker only asks when `execute` flagged a source, so a missing one here is a
228
+ * host bug — answer empty rather than hang the script's await.
229
+ */
230
+ private serveFootprints;
149
231
  }
150
232
 
151
- export { PineEngine, type PineEngineOptions, PineWorkerEngine, type PineWorkerOptions, type PropsFilter, type PropsVisibility };
233
+ export { type FootprintBar, type FootprintLevel, type FootprintRange, type FootprintSource, PineEngine, type PineEngineOptions, PineWorkerEngine, type PineWorkerOptions, type PropsFilter, type PropsVisibility };