@tidal-ts/core 0.11.0 → 0.12.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/dist/derive.d.ts CHANGED
@@ -374,10 +374,9 @@ export interface PairPart {
374
374
  * Such a leg has no single metric to name, so the panel degrades to rendering
375
375
  * it flat rather than inventing a decomposition.
376
376
  *
377
- * "Study" here means a WINDOWED op ({@link opHasPeriod}) — the same
378
- * discriminator the config layer uses (`isStudySeries`). A single-input op with
379
- * no period (`realizedVol`) is a derived METRIC and terminates the walk, so
380
- * `RV · SMA(20)` reads as one metric with one study rather than two studies.
377
+ * "Study" here is {@link isStudyOp} — the same discriminator the config layer
378
+ * uses (`isStudySeries`). A derived METRIC (`realizedVol`) terminates the walk,
379
+ * so `RV · SMA(20)` reads as one metric with one study rather than two studies.
381
380
  */
382
381
  export declare function readPart(input: DeriveInput): PairPart | null;
383
382
  /**
@@ -474,6 +473,17 @@ export interface OpParam {
474
473
  /** The useful range a control should be drawn on, when narrower than legal. */
475
474
  suggest?: readonly [number, number];
476
475
  }
476
+ /**
477
+ * Whether an op is a STUDY — something laid on a series and read as such —
478
+ * rather than a derived METRIC (the realized-vol line, a catalog entry).
479
+ *
480
+ * A corpus study is a study even with nothing to tune. "Has it params?" was the
481
+ * test, and it read the twelve parameterless corpus studies (a Price Momentum
482
+ * Oscillator, an OBV, Typical Price…) as metrics: named after their family
483
+ * ("Price"), never nested under the series they study, and offered nothing in
484
+ * their properties but "Nothing to set on Price" (Peter, 2026-10-13).
485
+ */
486
+ export declare function isStudyOp(op: DeriveOp): boolean;
477
487
  /**
478
488
  * An op's numeric params, in declaration order.
479
489
  *
@@ -595,6 +605,23 @@ export declare function studyPick(spec: DeriveSpec): StudyPick | undefined;
595
605
  /** `spec` reading `output` of its multi-output source instead — the same spec
596
606
  * when it has none ({@link studyPick}). A bare nested source becomes a pick. */
597
607
  export declare function withStudyOutput(spec: DeriveSpec, output: string): DeriveSpec;
608
+ /** A bar's price columns — what a price DATA node offers a study besides the
609
+ * one it draws: a Bollinger of the high is still a study of that price. */
610
+ export declare const BAR_PRICE_COLUMNS: readonly string[];
611
+ /**
612
+ * The raw COLUMN a study reads as its TARGET — `close` for a Bollinger of the
613
+ * close — or `undefined` when it has none to switch: a study of a study, a
614
+ * pair, or a study of a SERIES (an ATR's `high`/`low`/`close` are bar roles,
615
+ * not a target — re-pointing one would compute nonsense under the same name).
616
+ * The data node's output picker's question: which column drives the chain.
617
+ */
618
+ export declare function studyColumn(spec: DeriveSpec): {
619
+ index: number;
620
+ column: string;
621
+ } | undefined;
622
+ /** `spec` reading `column` of its source instead — the same spec when it reads
623
+ * no raw column ({@link studyColumn}). */
624
+ export declare function withStudyColumn(spec: DeriveSpec, column: string): DeriveSpec;
598
625
  /**
599
626
  * The pick at the BOTTOM of a study chain — the multi-output source a chain
600
627
  * of single-output studies ultimately reads, and which of its outputs.
package/dist/derive.js CHANGED
@@ -453,10 +453,9 @@ function unCompare(input) {
453
453
  * Such a leg has no single metric to name, so the panel degrades to rendering
454
454
  * it flat rather than inventing a decomposition.
455
455
  *
456
- * "Study" here means a WINDOWED op ({@link opHasPeriod}) — the same
457
- * discriminator the config layer uses (`isStudySeries`). A single-input op with
458
- * no period (`realizedVol`) is a derived METRIC and terminates the walk, so
459
- * `RV · SMA(20)` reads as one metric with one study rather than two studies.
456
+ * "Study" here is {@link isStudyOp} — the same discriminator the config layer
457
+ * uses (`isStudySeries`). A derived METRIC (`realizedVol`) terminates the walk,
458
+ * so `RV · SMA(20)` reads as one metric with one study rather than two studies.
460
459
  */
461
460
  export function readPart(input) {
462
461
  const studies = [];
@@ -470,7 +469,7 @@ export function readPart(input) {
470
469
  // multi-output study can be picked from, and a MACD's knobs are
471
470
  // `fastPeriod`/`slowPeriod`/`signalPeriod`. Requiring `period` left a pair
472
471
  // over an SMA of a MACD's Line rendering flat (tidal #210 review).
473
- if (!isSpecLike(node) || (!picked && !opHasPeriod(node.op))) {
472
+ if (!isSpecLike(node) || (!picked && !isStudyOp(node.op))) {
474
473
  if (picked)
475
474
  return null; // a pick of garbage: refuse, as below
476
475
  break;
@@ -637,6 +636,20 @@ export function applyDerived(series, specs, units) {
637
636
  export function opHasPeriod(op) {
638
637
  return TIDAL_OPS.describe().some((d) => d.name === op && 'period' in d.params);
639
638
  }
639
+ /**
640
+ * Whether an op is a STUDY — something laid on a series and read as such —
641
+ * rather than a derived METRIC (the realized-vol line, a catalog entry).
642
+ *
643
+ * A corpus study is a study even with nothing to tune. "Has it params?" was the
644
+ * test, and it read the twelve parameterless corpus studies (a Price Momentum
645
+ * Oscillator, an OBV, Typical Price…) as metrics: named after their family
646
+ * ("Price"), never nested under the series they study, and offered nothing in
647
+ * their properties but "Nothing to set on Price" (Peter, 2026-10-13).
648
+ */
649
+ export function isStudyOp(op) {
650
+ return opParams(op).length > 0 || CORPUS_OPS.has(op);
651
+ }
652
+ const CORPUS_OPS = new Set(ADOPTED_STUDIES.map((d) => d.name));
640
653
  /**
641
654
  * An op's numeric params, in declaration order.
642
655
  *
@@ -834,6 +847,33 @@ export function withStudyOutput(spec, output) {
834
847
  inputs[pick.index] = { from: pick.from, output };
835
848
  return { ...spec, inputs };
836
849
  }
850
+ /** A bar's price columns — what a price DATA node offers a study besides the
851
+ * one it draws: a Bollinger of the high is still a study of that price. */
852
+ export const BAR_PRICE_COLUMNS = ['open', 'high', 'low', 'close'];
853
+ /**
854
+ * The raw COLUMN a study reads as its TARGET — `close` for a Bollinger of the
855
+ * close — or `undefined` when it has none to switch: a study of a study, a
856
+ * pair, or a study of a SERIES (an ATR's `high`/`low`/`close` are bar roles,
857
+ * not a target — re-pointing one would compute nonsense under the same name).
858
+ * The data node's output picker's question: which column drives the chain.
859
+ */
860
+ export function studyColumn(spec) {
861
+ if (!isSpecLike(spec) || isPairOp(spec.op))
862
+ return undefined;
863
+ const roles = opInputs(spec.op);
864
+ const index = (spec.inputs ?? []).findIndex((i, k) => typeof i === 'string' && TARGET_ROLES.has(roles[k]?.role ?? ''));
865
+ return index < 0 ? undefined : { index, column: spec.inputs[index] };
866
+ }
867
+ /** `spec` reading `column` of its source instead — the same spec when it reads
868
+ * no raw column ({@link studyColumn}). */
869
+ export function withStudyColumn(spec, column) {
870
+ const at = studyColumn(spec);
871
+ if (!at)
872
+ return spec;
873
+ const inputs = [...spec.inputs];
874
+ inputs[at.index] = column;
875
+ return { ...spec, inputs };
876
+ }
837
877
  /**
838
878
  * The pick at the BOTTOM of a study chain — the multi-output source a chain
839
879
  * of single-output studies ultimately reads, and which of its outputs.
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { BAR_INTERVAL_MS, type Instrument, type InstrumentKind, type BarInterval
2
2
  export { generatePriceSeries, buildPriceSeries, DEMO_INSTRUMENTS, PRICE_SCHEMA, type PriceSeriesOptions, type PriceSeries, type PriceRow, } from './fixture.js';
3
3
  export { generateVolSeries, buildVolSeries, VOL_SCHEMA, VOL_TENORS, DEFAULT_VOL_TENOR, impliedCol, hvCol, rvCol, rvCenCol, skewCol, type VolSeries, type VolColumns, type VolTenor, type VolSeriesOptions, } from './vol.js';
4
4
  export { aggregateColumn, floorToWindow, liveWindowMs, ohlcWindow, sessionGrid, WINDOW_MS, WINDOW_LADDER, MIN_BAR_PX, autoBarWindow, type BarReducer, type SeriesWindow, } from './aggregate.js';
5
- export { applyDerived, applyDerivedReport, COMPARE_PREFIX, deriveId, deriveLineage, inputNames, substituteInput, hasPairOp, isBrokenId, isPairOp, isValidSpec, opHasPeriod, PERIOD_BOUNDS, readNumericColumn, partStudyLabel, readPart, readPairParts, specUnit, studyCatalog, TIDAL_OPS, BAND_OUTPUTS, opParams, studyTag, opIsBand, opInputs, opIsMulti, opOutputs, primaryOutput, studyInputOf, studyPick, fanPick, withFanOutput, withStudyOutput, type StudyPick, isPickedInput, opNeedsColumns, TARGET_ROLES, opSharesSourceAxis, type OpParam, usesCompare, type DeriveSkip, type PairPart, type PartStudy, type StudyOption, type NumericColumnReader, DEFAULT_PERIOD, type DeriveInput, type PickedDeriveOutput, type DeriveSpec, type DeriveOp, type TidalOp, type PairOp, } from './derive.js';
5
+ export { applyDerived, applyDerivedReport, COMPARE_PREFIX, deriveId, deriveLineage, inputNames, substituteInput, hasPairOp, isBrokenId, isPairOp, isValidSpec, opHasPeriod, PERIOD_BOUNDS, readNumericColumn, partStudyLabel, readPart, readPairParts, specUnit, studyCatalog, TIDAL_OPS, BAND_OUTPUTS, opParams, isStudyOp, studyTag, opIsBand, opInputs, opIsMulti, opOutputs, primaryOutput, studyInputOf, studyPick, fanPick, withFanOutput, withStudyOutput, studyColumn, BAR_PRICE_COLUMNS, withStudyColumn, type StudyPick, isPickedInput, opNeedsColumns, TARGET_ROLES, opSharesSourceAxis, type OpParam, usesCompare, type DeriveSkip, type PairPart, type PartStudy, type StudyOption, type NumericColumnReader, DEFAULT_PERIOD, type DeriveInput, type PickedDeriveOutput, type DeriveSpec, type DeriveOp, type TidalOp, type PairOp, } from './derive.js';
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';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ export { BAR_INTERVAL_MS, } from './types.js';
2
2
  export { generatePriceSeries, buildPriceSeries, DEMO_INSTRUMENTS, PRICE_SCHEMA, } from './fixture.js';
3
3
  export { generateVolSeries, buildVolSeries, VOL_SCHEMA, VOL_TENORS, DEFAULT_VOL_TENOR, impliedCol, hvCol, rvCol, rvCenCol, skewCol, } from './vol.js';
4
4
  export { aggregateColumn, floorToWindow, liveWindowMs, ohlcWindow, sessionGrid, WINDOW_MS, WINDOW_LADDER, MIN_BAR_PX, autoBarWindow, } from './aggregate.js';
5
- export { applyDerived, applyDerivedReport, COMPARE_PREFIX, deriveId, deriveLineage, inputNames, substituteInput, hasPairOp, isBrokenId, isPairOp, isValidSpec, opHasPeriod, PERIOD_BOUNDS, readNumericColumn, partStudyLabel, readPart, readPairParts, specUnit, studyCatalog, TIDAL_OPS, BAND_OUTPUTS, opParams, studyTag, opIsBand, opInputs, opIsMulti, opOutputs, primaryOutput, studyInputOf, studyPick, fanPick, withFanOutput, withStudyOutput, isPickedInput, opNeedsColumns, TARGET_ROLES, opSharesSourceAxis, usesCompare, DEFAULT_PERIOD, } from './derive.js';
5
+ export { applyDerived, applyDerivedReport, COMPARE_PREFIX, deriveId, deriveLineage, inputNames, substituteInput, hasPairOp, isBrokenId, isPairOp, isValidSpec, opHasPeriod, PERIOD_BOUNDS, readNumericColumn, partStudyLabel, readPart, readPairParts, specUnit, studyCatalog, TIDAL_OPS, BAND_OUTPUTS, opParams, isStudyOp, studyTag, opIsBand, opInputs, opIsMulti, opOutputs, primaryOutput, studyInputOf, studyPick, fanPick, withFanOutput, withStudyOutput, studyColumn, BAR_PRICE_COLUMNS, withStudyColumn, isPickedInput, opNeedsColumns, TARGET_ROLES, opSharesSourceAxis, usesCompare, DEFAULT_PERIOD, } from './derive.js';
6
6
  export { joinUnderPrefix } from './join.js';
7
7
  export { columnExtent } from './extent.js';
8
8
  export { snapshotToTimeSeries, appendToRows, } from './columnar.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-ts/core",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
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",