openalgo-charts 2.3.2 → 2.4.5

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.
@@ -1,4 +1,4 @@
1
- import { IndicatorDescriptor, ChartDataContext, IndicatorSettings, Bar, IndicatorInput, IndicatorPlot, IndicatorLevel } from 'openalgo-charts';
1
+ import { IndicatorDescriptor, ChartDataContext, IndicatorSettings, Bar, IndicatorBarsRequest, IndicatorInput, IndicatorPlot, IndicatorValues, IndicatorStore, IndicatorCalcContext, IndicatorLevel } from 'openalgo-charts';
2
2
 
3
3
  declare const SMA: IndicatorDescriptor;
4
4
  declare const WMA: IndicatorDescriptor;
@@ -57,6 +57,18 @@ declare const VOLUME: IndicatorDescriptor;
57
57
  declare const OBV: IndicatorDescriptor;
58
58
  declare const ADL: IndicatorDescriptor;
59
59
 
60
+ /** Per-bar position levels from the instrument itself, with no external alignment. */
61
+
62
+ /** A missing observation breaks the line; it is not an empty position. */
63
+ declare const OPEN_INTEREST: IndicatorDescriptor;
64
+ /** Adjacent observations only: a gap cannot support a bar-on-bar change. */
65
+ declare const OPEN_INTEREST_CHANGE: IndicatorDescriptor;
66
+ /**
67
+ * Price and position changes describe a regime, not a second price series.
68
+ * Publish candle colors only, so the study cannot distort the instrument axis.
69
+ */
70
+ declare const OPEN_INTEREST_BUILDUP: IndicatorDescriptor;
71
+
60
72
  /**
61
73
  * The source is hard-coded to `close` in the reference (`source = close`,
62
74
  * not an `input`), so there is no source setting to expose.
@@ -1074,7 +1086,7 @@ declare function valueWhen(cond: readonly boolean[], source: readonly number[],
1074
1086
 
1075
1087
  /**
1076
1088
  * Tier-2 contract — indicators whose data is **not** derived from the chart's
1077
- * OHLCV: open interest, cumulative volume delta, PCR, an external analytics
1089
+ * OHLCV: cumulative volume delta, PCR, an external analytics
1078
1090
  * feed. Where a Tier-1 descriptor is a pure `calc(bars, settings)`, a Tier-2
1079
1091
  * descriptor owns a fetch / subscribe / merge lifecycle and its own series.
1080
1092
  *
@@ -1106,6 +1118,12 @@ interface Tier2Context {
1106
1118
  /** UTC seconds of the first and last source bar (0 when there are none). */
1107
1119
  from: number;
1108
1120
  to: number;
1121
+ /**
1122
+ * The host's bar provider, when the runtime supplies one, so a `fetch` that
1123
+ * needs another instrument's candles asks the host rather than carrying its
1124
+ * own transport and credentials. Rejects when the host registered none.
1125
+ */
1126
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
1109
1127
  }
1110
1128
  interface Tier2Descriptor {
1111
1129
  id: string;
@@ -1114,6 +1132,22 @@ interface Tier2Descriptor {
1114
1132
  placement: 'onchart' | 'pane';
1115
1133
  inputs: readonly IndicatorInput[];
1116
1134
  plots: readonly IndicatorPlot[];
1135
+ /**
1136
+ * External columns to align besides the plots, by key. A point may carry
1137
+ * more than what is drawn: a benchmark close that `calc` divides by, an
1138
+ * open-interest figure a ratio is built from. Anything not named here or in
1139
+ * `plots` is dropped at alignment.
1140
+ */
1141
+ series?: readonly string[];
1142
+ /**
1143
+ * Combine the aligned external columns with the chart's own bars. Without
1144
+ * it the aligned columns are the result, one per plot, exactly as before.
1145
+ * With it, `external` holds every plot and `series` key aligned onto the
1146
+ * bars (last-known-value, `null` before the first point), and the return is
1147
+ * what the plots draw: a relative strength, a beta, a spread. Pure in its
1148
+ * arguments, like any `calc`.
1149
+ */
1150
+ calc?(bars: readonly Bar[], external: IndicatorValues, settings: Readonly<IndicatorSettings>, store: IndicatorStore, ctx?: IndicatorCalcContext): IndicatorValues;
1117
1151
  /** A host/provider can explicitly decline data it cannot supply. */
1118
1152
  supports?(ctx: Tier2Context): boolean;
1119
1153
  /** Load the series for the current window. */
@@ -1138,18 +1172,79 @@ interface Tier2Descriptor {
1138
1172
  * Wrap a Tier-2 descriptor as a normal `IndicatorDescriptor`.
1139
1173
  *
1140
1174
  * ```ts
1141
- * export const OPEN_INTEREST = createTier2Indicator({
1142
- * id: 'open-interest', name: 'Open Interest', placement: 'pane',
1175
+ * export const POSITION_INDEX = createTier2Indicator({
1176
+ * id: 'external-position-index', name: 'Position Index', placement: 'pane',
1143
1177
  * inputs: [{ key: 'symbol', type: 'text', label: 'Symbol', default: '' }],
1144
- * plots: [{ key: 'oi', type: 'line', title: 'OI' }],
1178
+ * plots: [{ key: 'position', type: 'line', title: 'Position' }],
1145
1179
  * refetchOn: ['symbol'],
1146
- * fetch: async ({ settings, from, to }) => loadOi(settings.symbol, from, to),
1180
+ * fetch: async ({ settings, from, to }) => loadPositionIndex(settings.symbol, from, to),
1147
1181
  * });
1148
- * registerIndicator(OPEN_INTEREST);
1182
+ * registerIndicator(POSITION_INDEX);
1149
1183
  * ```
1150
1184
  */
1151
1185
  declare function createTier2Indicator(d: Tier2Descriptor): IndicatorDescriptor;
1152
1186
 
1187
+ /**
1188
+ * A higher-timeframe view of the chart's own bars, one value per source bar.
1189
+ *
1190
+ * A study written for a script language asks for the daily high on a 5-minute
1191
+ * chart and gets a column the same length as the chart. The engine has no
1192
+ * such call, and every port that needed one folded the bars by hand, each a
1193
+ * little differently: some anchored an hourly bucket to midnight and some to
1194
+ * the session open, some read the bucket as it stood and some read its final
1195
+ * values. This is the one fold, with the three readings named:
1196
+ *
1197
+ * - `offset: 0` (the default) reads the bucket **as it stood at that bar**:
1198
+ * its open so far, high and low so far, the bar's own close, volume so far.
1199
+ * It is what the live bar sees and it never uses a later bar.
1200
+ * - `offset: k` reads the bucket that completed `k` buckets before, held
1201
+ * constant across the current one. The classic non-repainting reference,
1202
+ * `close[1]` on the higher timeframe.
1203
+ * - `lookahead: true` reads the current bucket's **final** values on every one
1204
+ * of its bars. It uses bars that had not happened yet, which is what the
1205
+ * source it is porting did; it is here so that can be reproduced, not
1206
+ * recommended.
1207
+ *
1208
+ * Buckets follow the chart's calendar: a day is a day in `timezone`, a week
1209
+ * starts on Monday there, and a sub-day interval is anchored to the epoch, or
1210
+ * to the session open when `session` is given, which is how an exchange cuts
1211
+ * its hourly bars.
1212
+ */
1213
+
1214
+ interface SecurityOptions {
1215
+ /** The calendar the buckets are cut in. Defaults to the shipped default zone. */
1216
+ timezone?: string;
1217
+ /** Read each bucket's final values on all of its bars. Default false. */
1218
+ lookahead?: boolean;
1219
+ /** Read the bucket completed this many buckets ago. Default 0, the current one. */
1220
+ offset?: number;
1221
+ /**
1222
+ * A session window, `'0915-1530'`, that anchors sub-day buckets to the
1223
+ * session open instead of the epoch. Without it a 30-minute bucket on a
1224
+ * 09:15 open runs 09:00 to 09:30; with it, 09:15 to 09:45.
1225
+ */
1226
+ session?: string;
1227
+ }
1228
+ interface SecuritySeries {
1229
+ open: (number | null)[];
1230
+ high: (number | null)[];
1231
+ low: (number | null)[];
1232
+ close: (number | null)[];
1233
+ /** Null on a bucket none of whose bars carried volume. */
1234
+ volume: (number | null)[];
1235
+ /**
1236
+ * Open interest as at the last source bar of the bucket, null where no bar in
1237
+ * it carried any. A level rather than a flow, so it is the latest reading and
1238
+ * never the sum the way `volume` is.
1239
+ */
1240
+ oi: (number | null)[];
1241
+ /** Time of the first source bar in the bucket being read, UTC seconds. */
1242
+ bucketStart: (number | null)[];
1243
+ /** True on the first source bar of each bucket. */
1244
+ isNew: boolean[];
1245
+ }
1246
+ declare function securitySeries(bars: readonly Bar[], interval: string, options?: SecurityOptions): SecuritySeries;
1247
+
1153
1248
  declare const INDICATORS_TIER: "indicators";
1154
1249
  /** Every built-in descriptor, in picker order. */
1155
1250
  declare const BUILTIN_INDICATORS: readonly IndicatorDescriptor[];
@@ -1160,4 +1255,4 @@ declare const BUILTIN_INDICATORS: readonly IndicatorDescriptor[];
1160
1255
  */
1161
1256
  declare function registerBuiltinIndicators(): void;
1162
1257
 
1163
- export { ADAPTIVE_INDICATORS, ADL, ADX, ALLIGATOR, ALMA, ALPHATREND, AROON, AROON_OSCILLATOR, ATR, AVERAGE_DAILY_RANGE, AVERAGE_INDICATORS, AWESOME_OSCILLATOR, BALANCE_OF_POWER, BB_TREND, BOLLINGER, BOLLINGER_BANDWIDTH, BOLLINGER_PERCENT_B, BUILTIN_INDICATORS, CCI, CHAIKIN_MONEY_FLOW, CHAIKIN_OSCILLATOR, CHAIKIN_VOLATILITY, CHANDELIER_EXIT, CHANDE_KROLL_STOP, CHANDE_MOMENTUM, CHOPPINESS_INDEX, CHOP_ZONE, CONNORS_RSI, CONSOLIDATION_BREAKOUT, COPPOCK_CURVE, CPR, DEMA, DONCHIAN, DPO, EASE_OF_MOVEMENT, ELDER_FORCE_INDEX, EMA, ENVELOPE, FISHER_TRANSFORM, FLOW_INDICATORS, HALFTREND, HISTORICAL_VOLATILITY, HMA, HULL_SUITE, ICHIMOKU, INDEX_INDICATORS, INDICATORS_TIER, KAMA, KELTNER_CHANNEL, KLINGER_OSCILLATOR, KNOW_SURE_THING, LINREG_SLOPE, LSMA, MACD, MASS_INDEX, MA_CHANNEL, MA_CROSS, MA_RIBBON, MCGINLEY_DYNAMIC, MEDIAN, MFI, MOMENTUM, NET_VOLUME, NVI, OBV, OSCILLATOR_INDICATORS, OVERLAY_INDICATORS, PARABOLIC_SAR, PPO, PVI, PVO, PVT, RANGE_ANALYSIS, RANGE_INDICATORS, RELATIVE_VIGOR_INDEX, RELATIVE_VOLATILITY_INDEX, ROC, RSI, RSI_DIVERGENCE, SEASONALITY, SEASONALITY_INDICATORS, SIGNAL_INDICATORS, SMA, SMI, SMI_ERGODIC_INDICATOR, SMI_ERGODIC_OSCILLATOR, SMMA, SPECIAL_K, STANDARD_DEVIATION, STANDARD_ERROR, STANDARD_ERROR_BANDS, STOCHASTIC, STOCHASTIC_RSI, STRENGTH_INDICATORS, STUDY_INDICATORS, SUPERTREND, T3, TEMA, TREND_STRENGTH_INDEX, TRIX, TSI, TWAP, type Tier2Context, type Tier2Descriptor, type Tier2Point, ULCER_INDEX, ULTIMATE_OSCILLATOR, VOLATILITY_INDICATORS, VOLATILITY_STOP, VOLUME, VORTEX, VWAP, VWMA, WAVETREND, WAVETREND_INDICATORS, WILLIAMS_FRACTALS, WILLIAMS_PERCENT_R, WILLIAMS_VIX_FIX, WMA, WOODIES_CCI, alma, barsSince, cci, change, connorsStreak, correlation, createTier2Indicator, cumulative, dev, highest, highestBars, linreg, lowest, lowestBars, nulls, percentRank, percentileNearestRank, pivotHigh, pivotLow, registerBuiltinIndicators, rma, roc, rollingSum, sma, smaSeededEma, stdev, stoch, swma, valueWhen, vwma, wma };
1258
+ export { ADAPTIVE_INDICATORS, ADL, ADX, ALLIGATOR, ALMA, ALPHATREND, AROON, AROON_OSCILLATOR, ATR, AVERAGE_DAILY_RANGE, AVERAGE_INDICATORS, AWESOME_OSCILLATOR, BALANCE_OF_POWER, BB_TREND, BOLLINGER, BOLLINGER_BANDWIDTH, BOLLINGER_PERCENT_B, BUILTIN_INDICATORS, CCI, CHAIKIN_MONEY_FLOW, CHAIKIN_OSCILLATOR, CHAIKIN_VOLATILITY, CHANDELIER_EXIT, CHANDE_KROLL_STOP, CHANDE_MOMENTUM, CHOPPINESS_INDEX, CHOP_ZONE, CONNORS_RSI, CONSOLIDATION_BREAKOUT, COPPOCK_CURVE, CPR, DEMA, DONCHIAN, DPO, EASE_OF_MOVEMENT, ELDER_FORCE_INDEX, EMA, ENVELOPE, FISHER_TRANSFORM, FLOW_INDICATORS, HALFTREND, HISTORICAL_VOLATILITY, HMA, HULL_SUITE, ICHIMOKU, INDEX_INDICATORS, INDICATORS_TIER, KAMA, KELTNER_CHANNEL, KLINGER_OSCILLATOR, KNOW_SURE_THING, LINREG_SLOPE, LSMA, MACD, MASS_INDEX, MA_CHANNEL, MA_CROSS, MA_RIBBON, MCGINLEY_DYNAMIC, MEDIAN, MFI, MOMENTUM, NET_VOLUME, NVI, OBV, OPEN_INTEREST, OPEN_INTEREST_BUILDUP, OPEN_INTEREST_CHANGE, OSCILLATOR_INDICATORS, OVERLAY_INDICATORS, PARABOLIC_SAR, PPO, PVI, PVO, PVT, RANGE_ANALYSIS, RANGE_INDICATORS, RELATIVE_VIGOR_INDEX, RELATIVE_VOLATILITY_INDEX, ROC, RSI, RSI_DIVERGENCE, SEASONALITY, SEASONALITY_INDICATORS, SIGNAL_INDICATORS, SMA, SMI, SMI_ERGODIC_INDICATOR, SMI_ERGODIC_OSCILLATOR, SMMA, SPECIAL_K, STANDARD_DEVIATION, STANDARD_ERROR, STANDARD_ERROR_BANDS, STOCHASTIC, STOCHASTIC_RSI, STRENGTH_INDICATORS, STUDY_INDICATORS, SUPERTREND, type SecurityOptions, type SecuritySeries, T3, TEMA, TREND_STRENGTH_INDEX, TRIX, TSI, TWAP, type Tier2Context, type Tier2Descriptor, type Tier2Point, ULCER_INDEX, ULTIMATE_OSCILLATOR, VOLATILITY_INDICATORS, VOLATILITY_STOP, VOLUME, VORTEX, VWAP, VWMA, WAVETREND, WAVETREND_INDICATORS, WILLIAMS_FRACTALS, WILLIAMS_PERCENT_R, WILLIAMS_VIX_FIX, WMA, WOODIES_CCI, alma, barsSince, cci, change, connorsStreak, correlation, createTier2Indicator, cumulative, dev, highest, highestBars, linreg, lowest, lowestBars, nulls, percentRank, percentileNearestRank, pivotHigh, pivotLow, registerBuiltinIndicators, rma, roc, rollingSum, securitySeries, sma, smaSeededEma, stdev, stoch, swma, valueWhen, vwma, wma };