@barchart/chart-lib 2.387.2 → 2.388.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.
@@ -887,10 +887,16 @@ declare module "@barchart/chart-lib" {
887
887
  export type AnnotationModel = {
888
888
  /** A unique identifier of the annotation. */
889
889
  id: AnnotationId;
890
+ /** A unique instance identifier; generated during normalization when not provided. */
891
+ uid?: string;
890
892
  /** Whether the annotation is visible or not.
891
893
  * @default true
892
894
  */
893
895
  visible?: boolean;
896
+ /** When `true` the annotation cannot be moved or edited interactively.
897
+ * @default false
898
+ */
899
+ locked?: boolean;
894
900
  /** Annotation's visual properties like line color, stroke width, fill color etc. */
895
901
  traits?: AnnotationTraitsModel;
896
902
  /** Each annotation has one or more anchors, which are points the user can move around and arrange. For example, Line annotation has two - start and end of the line. Note that the point's coordinates are (time, price). */
@@ -1149,7 +1155,7 @@ declare module "@barchart/chart-lib" {
1149
1155
  refresh(): void;
1150
1156
  shutdown(): void;
1151
1157
  isCached?: boolean;
1152
- record?: Record;
1158
+ record?: IRecord;
1153
1159
  };
1154
1160
 
1155
1161
  export type CalcCtx = {
@@ -2142,6 +2148,10 @@ declare module "@barchart/chart-lib" {
2142
2148
  annotate(id?: string, traits?: AnnotationTraits, annParam?: any): void;
2143
2149
  /** Cancel the (interactive) annotation creation and go back to the default (typically pan and zoom) tool */
2144
2150
  cancelAnnotation(): void;
2151
+ /** Replaces **all** annotations of the main axis — including any user-created ones — with the given models. Intended for fully programmatically-driven charts (strike/breakeven markers etc.) where users don't draw their own annotations. No-op for headless charts or before a main plot exists. */
2152
+ setMainAxisAnnotations(annotations: AnnotationModel[]): void;
2153
+ /** Converts pixel coordinates (relative to the chart) into the main axis' data coordinates; `time` is `undefined` when the x position cannot be mapped to the series. Returns `null` for headless charts or before a main plot exists. */
2154
+ toMainAxisPoint(p: { x: number; y: number }): { price?: number; time?: Date } | null;
2145
2155
  /** Helper method to return back the default template, the same one you've provided during the feed's @see init call. */
2146
2156
  getDefaultTemplate(): string;
2147
2157
  /** Main API entry point. Please check out online documentation for details. */
@@ -2207,11 +2217,14 @@ declare module "@barchart/chart-lib" {
2207
2217
  cacheMe?: boolean;
2208
2218
  }
2209
2219
 
2220
+ /** A pair of range boundaries: `[from, to]`; either end can be `null` for an open-ended range. */
2221
+ export type RangePair = [number | Date | null, number | Date | null];
2222
+
2210
2223
  interface NormalTimeSeriesQuery extends BaseTimeSeriesQuery {
2211
2224
  /** Aggregation of the data. */
2212
2225
  aggregation: Aggregation;
2213
2226
  /** Limit returned data to a given time span. */
2214
- range?: Range;
2227
+ range?: RangePair;
2215
2228
  /** Should we apply the splits (`true` by default) to the data? */
2216
2229
  splits?: boolean;
2217
2230
  /** Should we pad the data (`false` by default) with almost empty values - for holidays - to make sure that
@@ -2220,7 +2233,25 @@ declare module "@barchart/chart-lib" {
2220
2233
  }
2221
2234
 
2222
2235
  export class TimeSeriesQuery implements NormalTimeSeriesQuery {
2223
- constructor(symbol: string, agg: Aggregation);
2236
+ constructor(symbol: string, agg: Aggregation, seriesKind?: SeriesKind, range?: RangePair);
2237
+ /** Symbol name to load the data for. */
2238
+ symbol: string;
2239
+ /** Aggregation of the data. */
2240
+ aggregation: Aggregation;
2241
+ /** A kind of series we're loading, @see SeriesKind. */
2242
+ seriesKind: SeriesKind;
2243
+ /** Should the chart cache the result; used _only_ when the data feed supports caching. */
2244
+ cacheMe: boolean;
2245
+ /** Limit returned data to a given time span. */
2246
+ range?: RangePair;
2247
+ /** Should we apply the splits (`true` by default) to the data? */
2248
+ splits: boolean;
2249
+ /** Should we pad the data (`false` by default) with almost empty values - for holidays. */
2250
+ padded: boolean;
2251
+ /** How many bars to fetch when no explicit @see range is given. */
2252
+ barsToFetch: number;
2253
+ /** When `true` the @see barsToFetch value is honored even when a @see range is present. */
2254
+ alwaysUseBarsToFetch: boolean;
2224
2255
  }
2225
2256
 
2226
2257
  interface EventsTimeSeriesQuery extends BaseTimeSeriesQuery {
@@ -2457,7 +2488,7 @@ declare module "@barchart/chart-lib" {
2457
2488
  export type FieldValueArray = number[] | Date[] | string[] | null;
2458
2489
 
2459
2490
  /** Please treat as opaque for now. */
2460
- export interface Record {
2491
+ export interface IRecord {
2461
2492
  ready(): Promise<boolean>;
2462
2493
  hasField(field: Field): boolean;
2463
2494
  getValue(field: Field): FieldValue;
@@ -2465,7 +2496,7 @@ declare module "@barchart/chart-lib" {
2465
2496
 
2466
2497
  /** Please treat as opaque for now. */
2467
2498
  export interface IRecordSource extends BaseRecordSource {
2468
- getRecord(symbol: string): Record;
2499
+ getRecord(symbol: string): IRecord;
2469
2500
  }
2470
2501
 
2471
2502
  /** A common implementation used by all data feeds. Please note that the implementation contains several more methods, none of which are essential nor need to be used/overridden thus we don't document them. */
@@ -2522,7 +2553,28 @@ declare module "@barchart/chart-lib" {
2522
2553
  connection?: any;
2523
2554
  }
2524
2555
 
2525
- export function adaptOpenFeedClient(client: any, listener: any): any;
2556
+ /** Implement to receive raw OpenFeed events when driving the chart through your own OpenFeed client. */
2557
+ export interface IOpenFeedListener {
2558
+ onConnected(): void;
2559
+ onDisconnected(): void;
2560
+ onHeartBeat(heartBeat: any): void;
2561
+ onUpdate(update: any, symbol: string): void;
2562
+ onSnapshot(snapshot: any, symbol: string): void;
2563
+ }
2564
+
2565
+ /** Adapter over an external OpenFeed client, @see adaptOpenFeedClient. */
2566
+ export interface IOpenFeedClientAdapter {
2567
+ subscribeToRealTime(symbol: string): void;
2568
+ unsubscribeFromRealTime(symbol: string): void;
2569
+ shutdown(): void;
2570
+ ready(): Promise<boolean>;
2571
+ getInstrument(request: any): Promise<any[]>;
2572
+ addListener(listener: IOpenFeedListener): void;
2573
+ removeListener(listener: IOpenFeedListener): void;
2574
+ }
2575
+
2576
+ /** Wraps an externally-created OpenFeed SDK client for use by the @see OpenFeed feed. The parameters are SDK types (`IOpenFeedClient`, `OpenFeedListeners`) left as `any` here so this declaration file does not require `@openfeed/sdk-js` to be installed. */
2577
+ export function adaptOpenFeedClient(client: any, listener: any): IOpenFeedClientAdapter;
2526
2578
 
2527
2579
  class OpenFeed extends BaseDataFeed {
2528
2580
  setAdapter(adapter?: any): void;
@@ -3039,6 +3091,11 @@ declare module "@barchart/chart-lib" {
3039
3091
 
3040
3092
  export function optionValueToDate(value: number): Date;
3041
3093
 
3094
+ export function dateToOptionValue(date: Date): number;
3095
+
3096
+ /** True if the study can be used as the basis of a seasonal chart (single-field based studies only). */
3097
+ export function canBeBasedOnSeasonal(study: StudyModel): boolean;
3098
+
3042
3099
  export {
3043
3100
  initFeed,
3044
3101
  getFeed,