@tidal-ts/core 0.1.2 → 0.2.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/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { applyDerived, applyDerivedReport, COMPARE_PREFIX, deriveId, deriveLinea
6
6
  export { joinUnderPrefix } from './join.js';
7
7
  export { columnExtent } from './extent.js';
8
8
  export { snapshotToTimeSeries, appendToRows, type PondSnapshot, type PondAppend, type PondValue, type WireColumnSpec, } from './columnar.js';
9
- export { exactSessionSegments, inferBarMs, sessionOpenLine, sessionSegments, shiftKeys, type Segment, type SessionSegmentOptions, } from './sessions.js';
9
+ export { exactSessionSegments, inferBarMs, sessionOpenLine, sessionSegments, shiftKeys, sliceBySegments, type Segment, type SessionSegmentOptions, } from './sessions.js';
10
10
  export { monthlyExpirations, thirdFriday } from './expirations.js';
11
11
  export { holdVolAcrossGrid } from './regrid.js';
12
12
  export { ADOPTED_STUDIES, adoptable, isBandShape, outputMark, studyNeedsColumns, } from './studyCatalog.js';
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ export { applyDerived, applyDerivedReport, COMPARE_PREFIX, deriveId, deriveLinea
6
6
  export { joinUnderPrefix } from './join.js';
7
7
  export { columnExtent } from './extent.js';
8
8
  export { snapshotToTimeSeries, appendToRows, } from './columnar.js';
9
- export { exactSessionSegments, inferBarMs, sessionOpenLine, sessionSegments, shiftKeys, } from './sessions.js';
9
+ export { exactSessionSegments, inferBarMs, sessionOpenLine, sessionSegments, shiftKeys, sliceBySegments, } from './sessions.js';
10
10
  export { monthlyExpirations, thirdFriday } from './expirations.js';
11
11
  export { holdVolAcrossGrid } from './regrid.js';
12
12
  // The corpus adoption (TDL-STUDYCAT). `ADOPTED_STUDIES` is exported so the
@@ -113,6 +113,30 @@ export declare function inferBarMs(times: readonly number[]): number | undefined
113
113
  * belongs behind a per-fetch memo, never in a render path.
114
114
  */
115
115
  export declare function shiftKeys(series: TimeSeries<SeriesSchema>, ms: number): TimeSeries<SeriesSchema>;
116
+ /**
117
+ * The series cut into one sub-series per live segment — `[start, end)` on the
118
+ * time key, empty segments dropped.
119
+ *
120
+ * For the layers pond gives no `sessionBreaks` of their own: `<BandChart>` and
121
+ * `<AreaChart>` (the prop is `<LineChart>`'s alone). A fill drawn across a
122
+ * collapsed overnight gap bridges seventeen hours of closed market in one
123
+ * confident sweep and contradicts the line drawn over it; one layer per segment
124
+ * ends the fill at the close and restarts it at the open, which is what that
125
+ * line already does. The cost is `segments.length` layers instead of one, so a
126
+ * caller asks only when the axis actually collapses.
127
+ *
128
+ * Pond does the cutting — `bisect` finds each edge in O(log n) on the packed key
129
+ * buffer and `slice` is positional and half-open — so nothing here is
130
+ * materialised or rebuilt. Segments must be ascending and non-overlapping, which
131
+ * is what `sessionSegments` / `exactSessionSegments` produce; no segments means
132
+ * nothing is known to be closed, and the series comes back whole.
133
+ *
134
+ * **Cut before you shift.** A series whose keys were moved to the bar's END
135
+ * (`shiftKeys`) puts every session's last point exactly ON its segment's end,
136
+ * which the half-open bound excludes — one close lost per session, at the seam,
137
+ * where it shows. Slice the raw series and shift each slice.
138
+ */
139
+ export declare function sliceBySegments(series: TimeSeries<SeriesSchema>, segments: readonly Segment[]): TimeSeries<SeriesSchema>[];
116
140
  /**
117
141
  * The price path a session actually traced: its **open**, then every close.
118
142
  *
package/dist/sessions.js CHANGED
@@ -178,6 +178,42 @@ export function shiftKeys(series, ms) {
178
178
  columns: { ...out.columns, [key]: shifted },
179
179
  });
180
180
  }
181
+ /**
182
+ * The series cut into one sub-series per live segment — `[start, end)` on the
183
+ * time key, empty segments dropped.
184
+ *
185
+ * For the layers pond gives no `sessionBreaks` of their own: `<BandChart>` and
186
+ * `<AreaChart>` (the prop is `<LineChart>`'s alone). A fill drawn across a
187
+ * collapsed overnight gap bridges seventeen hours of closed market in one
188
+ * confident sweep and contradicts the line drawn over it; one layer per segment
189
+ * ends the fill at the close and restarts it at the open, which is what that
190
+ * line already does. The cost is `segments.length` layers instead of one, so a
191
+ * caller asks only when the axis actually collapses.
192
+ *
193
+ * Pond does the cutting — `bisect` finds each edge in O(log n) on the packed key
194
+ * buffer and `slice` is positional and half-open — so nothing here is
195
+ * materialised or rebuilt. Segments must be ascending and non-overlapping, which
196
+ * is what `sessionSegments` / `exactSessionSegments` produce; no segments means
197
+ * nothing is known to be closed, and the series comes back whole.
198
+ *
199
+ * **Cut before you shift.** A series whose keys were moved to the bar's END
200
+ * (`shiftKeys`) puts every session's last point exactly ON its segment's end,
201
+ * which the half-open bound excludes — one close lost per session, at the seam,
202
+ * where it shows. Slice the raw series and shift each slice.
203
+ */
204
+ export function sliceBySegments(series, segments) {
205
+ if (segments.length === 0)
206
+ return [series];
207
+ const s = series;
208
+ const out = [];
209
+ for (const [start, end] of segments) {
210
+ const lo = s.bisect(start);
211
+ const hi = s.bisect(end);
212
+ if (hi > lo)
213
+ out.push(s.slice(lo, hi));
214
+ }
215
+ return out;
216
+ }
181
217
  /**
182
218
  * The price path a session actually traced: its **open**, then every close.
183
219
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-ts/core",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Financial time-series vocabulary on pond-ts: the study/derive seam, the vol schema, bar windows, the columnar adapter and session helpers.",
6
6
  "license": "MIT",