@tidal-ts/core 0.3.0 → 0.4.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 +22 -0
- package/dist/derive.js +37 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/derive.d.ts
CHANGED
|
@@ -573,6 +573,28 @@ export declare function opIsMulti(op: DeriveOp): boolean;
|
|
|
573
573
|
* catalog's — a declared primary is asked for as F-charts-29 (2).
|
|
574
574
|
*/
|
|
575
575
|
export declare function primaryOutput(op: DeriveOp): string | undefined;
|
|
576
|
+
/** Where a study's pick sits: the input's position and the output it reads. */
|
|
577
|
+
export interface StudyPick {
|
|
578
|
+
/** Index into the spec's top-level `inputs`. */
|
|
579
|
+
index: number;
|
|
580
|
+
/** The multi-output spec the output belongs to. */
|
|
581
|
+
from: DeriveSpec;
|
|
582
|
+
/** The output read — a declared suffix of `from.op`. */
|
|
583
|
+
output: string;
|
|
584
|
+
/** False when the input is a BARE nested multi-output spec (a layout saved
|
|
585
|
+
* before 0.3.0): it reads its first-declared output, said here, and
|
|
586
|
+
* {@link withStudyOutput} turns it into a pick. */
|
|
587
|
+
explicit: boolean;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Which output of a multi-output source a study reads, or `undefined` when it
|
|
591
|
+
* reads no multi-output source (a raw column, a single-output study). The
|
|
592
|
+
* output picker's question: the choices are `opOutputs(pick.from.op)`.
|
|
593
|
+
*/
|
|
594
|
+
export declare function studyPick(spec: DeriveSpec): StudyPick | undefined;
|
|
595
|
+
/** `spec` reading `output` of its multi-output source instead — the same spec
|
|
596
|
+
* when it has none ({@link studyPick}). A bare nested source becomes a pick. */
|
|
597
|
+
export declare function withStudyOutput(spec: DeriveSpec, output: string): DeriveSpec;
|
|
576
598
|
/**
|
|
577
599
|
* What a study of `source` reads: the source itself, or — for a multi-output
|
|
578
600
|
* source — its {@link primaryOutput}, PICKED. Never a bare nested multi-output
|
package/dist/derive.js
CHANGED
|
@@ -466,10 +466,13 @@ export function readPart(input) {
|
|
|
466
466
|
// which output the chain reads on from it (`BOLLINGER(20, 2) · Middle`).
|
|
467
467
|
const picked = isPickedInput(cur) ? cur : undefined;
|
|
468
468
|
const node = picked ? picked.from : cur;
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
// A PICKED source is a study whether or not it declares a `period`: only a
|
|
470
|
+
// multi-output study can be picked from, and a MACD's knobs are
|
|
471
|
+
// `fastPeriod`/`slowPeriod`/`signalPeriod`. Requiring `period` left a pair
|
|
472
|
+
// over an SMA of a MACD's Line rendering flat (tidal #210 review).
|
|
473
|
+
if (!isSpecLike(node) || (!picked && !opHasPeriod(node.op))) {
|
|
471
474
|
if (picked)
|
|
472
|
-
return null;
|
|
475
|
+
return null; // a pick of garbage: refuse, as below
|
|
473
476
|
break;
|
|
474
477
|
}
|
|
475
478
|
const inputs = node.inputs ?? [];
|
|
@@ -800,6 +803,37 @@ export function primaryOutput(op) {
|
|
|
800
803
|
return PRIMARY_SUFFIX;
|
|
801
804
|
return outs[0];
|
|
802
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Which output of a multi-output source a study reads, or `undefined` when it
|
|
808
|
+
* reads no multi-output source (a raw column, a single-output study). The
|
|
809
|
+
* output picker's question: the choices are `opOutputs(pick.from.op)`.
|
|
810
|
+
*/
|
|
811
|
+
export function studyPick(spec) {
|
|
812
|
+
// A PAIR is not a study: its legs may be picks (a band leg reads its
|
|
813
|
+
// Middle), but which output a leg reads is the pair's construction, and one
|
|
814
|
+
// picker over two legs would only ever reach the first.
|
|
815
|
+
if (!isSpecLike(spec) || isPairOp(spec.op))
|
|
816
|
+
return undefined;
|
|
817
|
+
const inputs = spec.inputs ?? [];
|
|
818
|
+
for (let index = 0; index < inputs.length; index++) {
|
|
819
|
+
const i = inputs[index];
|
|
820
|
+
if (isPickedInput(i))
|
|
821
|
+
return { index, from: i.from, output: i.output, explicit: true };
|
|
822
|
+
if (isSpecLike(i) && opOutputs(i.op).length > 1)
|
|
823
|
+
return { index, from: i, output: opOutputs(i.op)[0], explicit: false };
|
|
824
|
+
}
|
|
825
|
+
return undefined;
|
|
826
|
+
}
|
|
827
|
+
/** `spec` reading `output` of its multi-output source instead — the same spec
|
|
828
|
+
* when it has none ({@link studyPick}). A bare nested source becomes a pick. */
|
|
829
|
+
export function withStudyOutput(spec, output) {
|
|
830
|
+
const pick = studyPick(spec);
|
|
831
|
+
if (!pick)
|
|
832
|
+
return spec;
|
|
833
|
+
const inputs = [...spec.inputs];
|
|
834
|
+
inputs[pick.index] = { from: pick.from, output };
|
|
835
|
+
return { ...spec, inputs };
|
|
836
|
+
}
|
|
803
837
|
/**
|
|
804
838
|
* What a study of `source` reads: the source itself, or — for a multi-output
|
|
805
839
|
* source — its {@link primaryOutput}, PICKED. Never a bare nested multi-output
|
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, 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, 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';
|
|
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, 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, withStudyOutput, 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.
|
|
3
|
+
"version": "0.4.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",
|