@barchart/chart-lib 2.260.1 → 2.260.3

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.
@@ -537,33 +537,32 @@ declare module "@barchart/chart-lib" {
537
537
  | "IncomeStatement"
538
538
  | "Seasonal";
539
539
 
540
- export type AggregationUnit = "Tick" | "Intraday" | "Day" | "Week" | "Month" | "Quarter" | "Year";
541
- export type AggregationSpec =
542
- | "None"
543
- | "Nearest"
544
- | "Continue"
545
- | "FormT"
546
- | "PerCount"
547
- | "PerVolume"
548
- | "PerRange"
549
- | "PerSeconds";
550
-
551
- export type Aggregation = {
540
+ export enum AggregationUnit {
541
+ Tick,
542
+ Intraday,
543
+ Day,
544
+ Week,
545
+ Month,
546
+ Quarter,
547
+ Year,
548
+ }
549
+
550
+ export enum AggregationSpec {
551
+ None,
552
+ Nearest,
553
+ Continue,
554
+ FormT,
555
+ PerCount,
556
+ PerVolume,
557
+ PerRange,
558
+ PerSeconds,
559
+ }
560
+
561
+ interface AggregationCommon {
552
562
  /** Number of days/weeks etc. the data is aggregated over
553
563
  * @default 1
554
564
  */
555
565
  size?: number;
556
- /** The unit (or time period) of aggregation
557
- * @default "Day"
558
- */
559
- unit?: AggregationUnit;
560
- /** Additional info about the aggregation
561
- * @default "None"
562
- */
563
- spec?: AggregationSpec;
564
- /** If the volume is per contract or total (futures only)
565
- * @default false
566
- */
567
566
  isContractVolume?: boolean;
568
567
  /** Turn off (false) or on (true) dividends adjustment for stock data.
569
568
  * @default false
@@ -581,7 +580,52 @@ declare module "@barchart/chart-lib" {
581
580
  * @default "combined"
582
581
  */
583
582
  contractRoll?: "expiration" | "combined";
584
- };
583
+ }
584
+
585
+ export interface AggregationModel extends AggregationCommon {
586
+ /** The unit (or time period) of aggregation
587
+ * @default "Day"
588
+ */
589
+ unit?: keyof typeof AggregationUnit;
590
+ /** Additional info about the aggregation
591
+ * @default "None"
592
+ */
593
+ spec?: keyof typeof AggregationSpec;
594
+ /** If the volume is per contract or total (futures only)
595
+ * @default false
596
+ */
597
+ }
598
+
599
+ export class Aggregation implements AggregationCommon {
600
+ constructor(
601
+ unit: AggregationUnit,
602
+ size: number,
603
+ spec: AggregationSpec,
604
+ isContractVolume: boolean,
605
+ dividendsAdjust: boolean,
606
+ backAdjust: boolean,
607
+ daysToExpiration: number,
608
+ contractRoll: string
609
+ );
610
+ unit: AggregationUnit;
611
+ spec: AggregationSpec;
612
+ size: number;
613
+ isContractVolume: boolean;
614
+ dividendsAdjust: boolean;
615
+ backAdjust: boolean;
616
+ daysToExpiration: number;
617
+ contractRoll: "expiration" | "combined";
618
+ duplicate(): Aggregation;
619
+ getHashKey(): string;
620
+ toShortString(): string;
621
+ unitToString(): string;
622
+ describe(): string;
623
+ hasSpec: boolean;
624
+ isEndOfDay: boolean;
625
+ isTick: boolean;
626
+ isIntraday: boolean;
627
+ isMultiContract: boolean;
628
+ }
585
629
 
586
630
  /** A range of values, values are typically inclusive. */
587
631
  interface Range {
@@ -785,7 +829,7 @@ declare module "@barchart/chart-lib" {
785
829
 
786
830
  export type DataModel = {
787
831
  /** The way the data is aggregated across time. */
788
- aggregation: Aggregation;
832
+ aggregation: AggregationModel;
789
833
  /** Maximum number of data points to load in a first chunk (sent as-is to historical server); there is no default in the model, internally defaults to 640. */
790
834
  maxDataPoints?: number;
791
835
  /** If set, the range of time the historical data will be limited to (if supported by the historical server). */
@@ -1078,6 +1122,61 @@ declare module "@barchart/chart-lib" {
1078
1122
  studyProvider?: StudyProvider;
1079
1123
  };
1080
1124
 
1125
+ export function makeStudy(studyId: string, options: StudyOptions, innerSeries: TimeSeries): StudySeries;
1126
+ export function getStudyOptions(
1127
+ model: StudyPlotModel & { target: string },
1128
+ agg: Aggregation,
1129
+ curves?: Curve[]
1130
+ ): StudyOptions;
1131
+
1132
+ export enum ExpressionMissingBar {
1133
+ UsePrevious,
1134
+ UseNext,
1135
+ UseNone,
1136
+ }
1137
+
1138
+ export enum ExpressionRecompute {
1139
+ Minimum,
1140
+ Everything,
1141
+ Manual,
1142
+ }
1143
+
1144
+ export enum ExpressionNoDataApproach {
1145
+ NoAction,
1146
+ IgnoreTimelineOnly,
1147
+ ModelTransformRequired,
1148
+ }
1149
+
1150
+ export type Operator = "+" | "-" | "*" | "/" | "^" | "sym" | "num" | "grp";
1151
+
1152
+ export type ExprNodeOrVal = ExprNode | NodeValue;
1153
+
1154
+ export type ExprNode = {
1155
+ op: Operator;
1156
+ left: ExprNodeOrVal;
1157
+ right: ExprNodeOrVal;
1158
+ };
1159
+
1160
+ type NodeValue = string | number | null;
1161
+
1162
+ export type ExprPolicy = {
1163
+ mapper: (series: TimeSeries) => string;
1164
+ loadMoreData: boolean;
1165
+ recompute: ExpressionRecompute;
1166
+ missing: ExpressionMissingBar;
1167
+ stretch: (symbol: string) => boolean;
1168
+ fieldMap: Map<Field, Field>;
1169
+ noDataApproach: ExpressionNoDataApproach;
1170
+ modelTransform: (withData: string[], withoutData: string[]) => ExprNode | null;
1171
+ skipLeadingEmpty: boolean;
1172
+ };
1173
+
1174
+ export function makeExpression(
1175
+ model: ExprNode,
1176
+ innerSeries: TimeSeries[],
1177
+ policy: ExprPolicy
1178
+ ): CalculableTimeSeries;
1179
+
1081
1180
  /** The configuration is extensively documented at our documentation site. */
1082
1181
  interface Config {
1083
1182
  environment?: Environment;
@@ -1319,7 +1418,7 @@ declare module "@barchart/chart-lib" {
1319
1418
 
1320
1419
  export interface AggregationAccessor {
1321
1420
  id: string;
1322
- context: Aggregation;
1421
+ context: AggregationModel;
1323
1422
  }
1324
1423
 
1325
1424
  export interface PeriodAccessor {
@@ -1760,13 +1859,13 @@ declare module "@barchart/chart-lib" {
1760
1859
  popupElement: HTMLElement;
1761
1860
  constructor(view: any);
1762
1861
  /** Initial DOM setup; override if you need any additional initialization */
1763
- initialize();
1862
+ initialize(): void;
1764
1863
  /** Called when a value needs to be "shown"; basically means you should populate the DOM with the
1765
1864
  * content, won't be called if the @member value doesn't change
1766
1865
  */
1767
- showValue();
1866
+ showValue(): void;
1768
1867
  /** Called when hiding the popup, in case you need to do anything (most often you don't) */
1769
- hideValue();
1868
+ hideValue(): void;
1770
1869
  }
1771
1870
 
1772
1871
  /**
@@ -1844,13 +1943,13 @@ declare module "@barchart/chart-lib" {
1844
1943
  /** Does again the last change undone to an annotation */
1845
1944
  redo(): void;
1846
1945
  /** Pause the undo/redo mechanism */
1847
- pauseUndoRedo();
1946
+ pauseUndoRedo(): void;
1848
1947
  /** Resume the undo/redo mechanism
1849
1948
  * @param acceptLastChange Apply the last change while the undo/redo was paused
1850
1949
  * */
1851
- resumeUndoRedo(acceptLastChange: boolean);
1950
+ resumeUndoRedo(acceptLastChange: boolean): void;
1852
1951
  /** Starts (or resets) the interactive zoom */
1853
- zoom(zoomIn: boolean);
1952
+ zoom(zoomIn: boolean): void;
1854
1953
  /** Resets the chart to default template and re-applies current main plot */
1855
1954
  reset(preserveTheme: boolean): void;
1856
1955
  /** Reserved for internal use. */
@@ -1858,7 +1957,7 @@ declare module "@barchart/chart-lib" {
1858
1957
  }
1859
1958
 
1860
1959
  export enum SeriesKind {
1861
- Normal = 0,
1960
+ Normal,
1862
1961
  Forward,
1863
1962
  HistoricalForward,
1864
1963
  Study,
@@ -2003,7 +2102,7 @@ declare module "@barchart/chart-lib" {
2003
2102
 
2004
2103
  /** Describes the chunk of the timeseries data. If specified, `Head` means older in time (first in a "list" of chunks) and `Tail` means newer in time (last in a "list" of chunks). */
2005
2104
  export enum ChunkPart {
2006
- Unspecified = 0,
2105
+ Unspecified,
2007
2106
  Head,
2008
2107
  Tail,
2009
2108
  }
@@ -2094,6 +2193,7 @@ declare module "@barchart/chart-lib" {
2094
2193
  * @returns A string representation of the price.
2095
2194
  */
2096
2195
  format(price: number, field: Field, options: any): string;
2196
+ shutdown(): void;
2097
2197
  }
2098
2198
 
2099
2199
  export interface IMetaDataSource {
@@ -2233,12 +2333,14 @@ declare module "@barchart/chart-lib" {
2233
2333
  */
2234
2334
  function parseExpression(text: string, useCache?: boolean): ExpressionSuccess | ExpressionError;
2235
2335
 
2336
+ export type ValueProviderFunc = (symbol: string, field?: string) => number | null;
2337
+
2236
2338
  /** If you would like to evaluate an expression yourself.
2237
2339
  * @param model Same as @see model property of the @see ExpressionSuccess
2238
2340
  * @param valueProvider A function which, given a symbol name, returns a price.
2239
2341
  * @returns The computed value of the expression.
2240
2342
  */
2241
- function evaluateExpression(model: ExpressionInternalModel, valueProvider: (string) => number): number;
2343
+ function evaluateExpression(model: ExpressionInternalModel, valueProvider: ValueProviderFunc): number;
2242
2344
 
2243
2345
  interface StudyMetaRange {
2244
2346
  min: number;