@tidal-ts/core 0.11.0 → 0.12.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/derive.d.ts CHANGED
@@ -595,6 +595,23 @@ export declare function studyPick(spec: DeriveSpec): StudyPick | undefined;
595
595
  /** `spec` reading `output` of its multi-output source instead — the same spec
596
596
  * when it has none ({@link studyPick}). A bare nested source becomes a pick. */
597
597
  export declare function withStudyOutput(spec: DeriveSpec, output: string): DeriveSpec;
598
+ /** A bar's price columns — what a price DATA node offers a study besides the
599
+ * one it draws: a Bollinger of the high is still a study of that price. */
600
+ export declare const BAR_PRICE_COLUMNS: readonly string[];
601
+ /**
602
+ * The raw COLUMN a study reads as its TARGET — `close` for a Bollinger of the
603
+ * close — or `undefined` when it has none to switch: a study of a study, a
604
+ * pair, or a study of a SERIES (an ATR's `high`/`low`/`close` are bar roles,
605
+ * not a target — re-pointing one would compute nonsense under the same name).
606
+ * The data node's output picker's question: which column drives the chain.
607
+ */
608
+ export declare function studyColumn(spec: DeriveSpec): {
609
+ index: number;
610
+ column: string;
611
+ } | undefined;
612
+ /** `spec` reading `column` of its source instead — the same spec when it reads
613
+ * no raw column ({@link studyColumn}). */
614
+ export declare function withStudyColumn(spec: DeriveSpec, column: string): DeriveSpec;
598
615
  /**
599
616
  * The pick at the BOTTOM of a study chain — the multi-output source a chain
600
617
  * of single-output studies ultimately reads, and which of its outputs.
package/dist/derive.js CHANGED
@@ -834,6 +834,33 @@ export function withStudyOutput(spec, output) {
834
834
  inputs[pick.index] = { from: pick.from, output };
835
835
  return { ...spec, inputs };
836
836
  }
837
+ /** A bar's price columns — what a price DATA node offers a study besides the
838
+ * one it draws: a Bollinger of the high is still a study of that price. */
839
+ export const BAR_PRICE_COLUMNS = ['open', 'high', 'low', 'close'];
840
+ /**
841
+ * The raw COLUMN a study reads as its TARGET — `close` for a Bollinger of the
842
+ * close — or `undefined` when it has none to switch: a study of a study, a
843
+ * pair, or a study of a SERIES (an ATR's `high`/`low`/`close` are bar roles,
844
+ * not a target — re-pointing one would compute nonsense under the same name).
845
+ * The data node's output picker's question: which column drives the chain.
846
+ */
847
+ export function studyColumn(spec) {
848
+ if (!isSpecLike(spec) || isPairOp(spec.op))
849
+ return undefined;
850
+ const roles = opInputs(spec.op);
851
+ const index = (spec.inputs ?? []).findIndex((i, k) => typeof i === 'string' && TARGET_ROLES.has(roles[k]?.role ?? ''));
852
+ return index < 0 ? undefined : { index, column: spec.inputs[index] };
853
+ }
854
+ /** `spec` reading `column` of its source instead — the same spec when it reads
855
+ * no raw column ({@link studyColumn}). */
856
+ export function withStudyColumn(spec, column) {
857
+ const at = studyColumn(spec);
858
+ if (!at)
859
+ return spec;
860
+ const inputs = [...spec.inputs];
861
+ inputs[at.index] = column;
862
+ return { ...spec, inputs };
863
+ }
837
864
  /**
838
865
  * The pick at the BOTTOM of a study chain — the multi-output source a chain
839
866
  * 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, 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, 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.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",