lightweight-charts-indicators 0.13.0 → 0.13.2

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,3 +1,11 @@
1
+ /**
2
+ * Adapter: fits the oakscriptjs candlestick port (PatternDef + patternScript)
3
+ * to this repo's `calculate(bars, inputs, chart): IndicatorResult` registry convention.
4
+ *
5
+ * Each pattern runs through `executeScript(() => patternScript(def), bars, inputs)`, which returns the
6
+ * IndicatorResult shape of this package (markers, bgColors, barColors); the result is passed through.
7
+ */
8
+ import { type AlertConditionConfig } from 'oakscriptjs/script';
1
9
  import type { ChartContext } from '../chart-context';
2
10
  import type { Bar, IndicatorResult, InputConfig, PlotConfig } from 'oakscriptjs';
3
11
  import type { BarColorData, BgColorData, MarkerData } from '../types';
@@ -16,6 +24,8 @@ export interface PortIndicator {
16
24
  inputConfig: InputConfig[];
17
25
  plotConfig: PlotConfig[];
18
26
  defaultInputs: Record<string, unknown>;
27
+ /** The script's alertcondition() declarations; the result's `alerts` gives the bars on which each one is true. */
28
+ alertConditions: AlertConditionConfig[];
19
29
  calculate: (bars: Bar[], inputs?: Record<string, unknown>, chart?: ChartContext) => PortResult;
20
30
  }
21
31
  export interface PortEntry {
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/candlestick-port/adapter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAKtE,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACzC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,YAAY,E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AG,eAAe,GAAG;IACzC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B,CAAC;AAQF,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAClE,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,kHAAkH;IAClH,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,YAAY,KAAK,UAAU,CAAC;CAChG;AAkFD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,CAAC;AAE3E,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,EAAE,SAAS,EAK5C,CAAC;AAEH,gHAAgH;AAChH,eAAO,MAAM,0BAA0B,EAAE,SAIxC,CAAC"}
package/dist/index.cjs CHANGED
@@ -48236,6 +48236,7 @@ function buildIndicator(body, shortName) {
48236
48236
  inputConfig: probe.inputConfig,
48237
48237
  plotConfig: probe.plotConfig,
48238
48238
  defaultInputs: probe.defaultInputs,
48239
+ alertConditions: probe.alertConfig,
48239
48240
  calculate: (bars, inputs = {}, chart) => convert((0, import_script30.executeScript)(body, bars, inputs, chart))
48240
48241
  };
48241
48242
  }
@@ -303005,6 +303006,7 @@ function candlestickEntries(pairs) {
303005
303006
  inputConfig: ind.inputConfig,
303006
303007
  plotConfig: ind.plotConfig,
303007
303008
  defaultInputs: { ...ind.defaultInputs },
303009
+ ...ind.alertConditions?.length ? { alertConditions: ind.alertConditions } : {},
303008
303010
  calculate: ind.calculate
303009
303011
  }));
303010
303012
  }
@@ -325095,4 +325097,4 @@ var registryPart11 = [
325095
325097
  }
325096
325098
  ];
325097
325099
  var indicatorRegistry = [...registryPart1, ...registryPart11, ...registryPart2, ...registryPart3, ...registryPart4, ...registryPart5, ...registryPart6, ...registryPart7, ...registryPart8, ...registryPart9, ...registryPart10];
325098
- var version = "0.13.0";
325100
+ var version = "0.13.2";
package/dist/index.d.ts CHANGED
@@ -3348,6 +3348,15 @@ export interface IndicatorRegistryEntry {
3348
3348
  * `MissingSymbolDataError` that lists the same requests.
3349
3349
  */
3350
3350
  requiredSymbols?: (inputs: any, chart?: ChartContext) => SymbolRequest[];
3351
+ /**
3352
+ * The alert conditions the indicator declares (PineScript `alertcondition()`): id, title and default message. The
3353
+ * result of `calculate` has an `alerts` array with, per condition id, the times of the bars on which it is true.
3354
+ */
3355
+ alertConditions?: {
3356
+ id: string;
3357
+ title: string;
3358
+ message?: string;
3359
+ }[];
3351
3360
  /** `chart`: what the caller knows about the chart and its symbol (tick, time zone, ...), see ChartContext */
3352
3361
  calculate: (bars: Bar[], inputs?: any, chart?: ChartContext) => any;
3353
3362
  }
@@ -3356,5 +3365,5 @@ export type { ChartContext, VisibleRange, SymbolRequest, SymbolInfo } from './ch
3356
3365
  export { MissingSymbolDataError, symbolBarsOf } from './chart-context';
3357
3366
  export { mintickOf, timezoneOf, tickeridOf, tickerOf, symbolTypeOf, currencyOf, basecurrencyOf, rootOf, foregroundColorOf, backgroundColorOf, lastBarConfirmedOf, nowOf, visibleRangeOf, } from './chart-context';
3358
3367
  export { securityOther, securityOtherValues, securityLowerTf, otherSymbolChart, spreadSymbols, spreadBars, spreadOptions, type OtherSymbolOptions, type OtherSymbolChart, type SymbolCalendar, } from './other-symbol';
3359
- export declare const version = "0.13.0";
3368
+ export declare const version = "0.13.2";
3360
3369
  //# sourceMappingURL=index.d.ts.map