@barchart/chart-lib 2.260.0 → 2.260.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.
@@ -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,42 @@ 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
+ }
585
619
 
586
620
  /** A range of values, values are typically inclusive. */
587
621
  interface Range {
@@ -785,7 +819,7 @@ declare module "@barchart/chart-lib" {
785
819
 
786
820
  export type DataModel = {
787
821
  /** The way the data is aggregated across time. */
788
- aggregation: Aggregation;
822
+ aggregation: AggregationModel;
789
823
  /** 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
824
  maxDataPoints?: number;
791
825
  /** If set, the range of time the historical data will be limited to (if supported by the historical server). */
@@ -1034,14 +1068,12 @@ declare module "@barchart/chart-lib" {
1034
1068
  target?: Field;
1035
1069
  };
1036
1070
 
1037
- export type ValueType = "Number" | "String" | "Date";
1038
-
1039
1071
  export type FieldModel = {
1040
1072
  id: string;
1041
- type: ValueType;
1042
- category: FieldCategory;
1073
+ type: keyof typeof FieldValueType;
1074
+ category: keyof typeof FieldCategory;
1043
1075
  name?: string;
1044
- format: FieldFormat;
1076
+ format: keyof typeof FieldFormat;
1045
1077
  shortName?: string;
1046
1078
  };
1047
1079
 
@@ -1080,6 +1112,31 @@ declare module "@barchart/chart-lib" {
1080
1112
  studyProvider?: StudyProvider;
1081
1113
  };
1082
1114
 
1115
+ export function makeStudy(studyId: string, options: StudyOptions, innerSeries: TimeSeries): StudySeries;
1116
+ export function getStudyOptions(
1117
+ model: StudyPlotModel & { target: string },
1118
+ agg: Aggregation,
1119
+ curves?: Curve[]
1120
+ ): StudyOptions;
1121
+
1122
+ export enum ExpressionMissingBar {
1123
+ UsePrevious,
1124
+ UseNext,
1125
+ UseNone,
1126
+ }
1127
+
1128
+ export enum ExpressionRecompute {
1129
+ Minimum,
1130
+ Everything,
1131
+ Manual,
1132
+ }
1133
+
1134
+ export enum ExpressionNoDataApproach {
1135
+ NoAction,
1136
+ IgnoreTimelineOnly,
1137
+ ModelTransformRequired,
1138
+ }
1139
+
1083
1140
  /** The configuration is extensively documented at our documentation site. */
1084
1141
  interface Config {
1085
1142
  environment?: Environment;
@@ -1321,7 +1378,7 @@ declare module "@barchart/chart-lib" {
1321
1378
 
1322
1379
  export interface AggregationAccessor {
1323
1380
  id: string;
1324
- context: Aggregation;
1381
+ context: AggregationModel;
1325
1382
  }
1326
1383
 
1327
1384
  export interface PeriodAccessor {
@@ -1762,13 +1819,13 @@ declare module "@barchart/chart-lib" {
1762
1819
  popupElement: HTMLElement;
1763
1820
  constructor(view: any);
1764
1821
  /** Initial DOM setup; override if you need any additional initialization */
1765
- initialize();
1822
+ initialize(): void;
1766
1823
  /** Called when a value needs to be "shown"; basically means you should populate the DOM with the
1767
1824
  * content, won't be called if the @member value doesn't change
1768
1825
  */
1769
- showValue();
1826
+ showValue(): void;
1770
1827
  /** Called when hiding the popup, in case you need to do anything (most often you don't) */
1771
- hideValue();
1828
+ hideValue(): void;
1772
1829
  }
1773
1830
 
1774
1831
  /**
@@ -1846,15 +1903,15 @@ declare module "@barchart/chart-lib" {
1846
1903
  /** Does again the last change undone to an annotation */
1847
1904
  redo(): void;
1848
1905
  /** Pause the undo/redo mechanism */
1849
- pauseUndoRedo();
1906
+ pauseUndoRedo(): void;
1850
1907
  /** Resume the undo/redo mechanism
1851
1908
  * @param acceptLastChange Apply the last change while the undo/redo was paused
1852
1909
  * */
1853
- resumeUndoRedo(acceptLastChange: boolean);
1910
+ resumeUndoRedo(acceptLastChange: boolean): void;
1854
1911
  /** Starts (or resets) the interactive zoom */
1855
- zoom(zoomIn: boolean);
1912
+ zoom(zoomIn: boolean): void;
1856
1913
  /** Resets the chart to default template and re-applies current main plot */
1857
- reset(preserveTheme: boolean = true): void;
1914
+ reset(preserveTheme: boolean): void;
1858
1915
  /** Reserved for internal use. */
1859
1916
  activate(): void;
1860
1917
  }
@@ -2010,17 +2067,29 @@ declare module "@barchart/chart-lib" {
2010
2067
  Tail,
2011
2068
  }
2012
2069
 
2013
- export type FieldValueType = "Number" | "String" | "Date";
2070
+ export enum FieldValueType {
2071
+ Number,
2072
+ String,
2073
+ Date,
2074
+ }
2014
2075
 
2015
- export type FieldCategory =
2016
- | "Common"
2017
- | "Study"
2018
- | "BalanceSheet"
2019
- | "IncomeStatement"
2020
- | "Forward"
2021
- | "Seasonal";
2076
+ export enum FieldCategory {
2077
+ Common,
2078
+ Study,
2079
+ BalanceSheet,
2080
+ IncomeStatement,
2081
+ Forward,
2082
+ Seasonal,
2083
+ Event,
2084
+ Option,
2085
+ }
2022
2086
 
2023
- export type FieldFormat = "FromMetaData" | "AsInteger" | "UseMetricUnit" | "AsPercent";
2087
+ export enum FieldFormat {
2088
+ FromMetaData,
2089
+ AsInteger,
2090
+ UseMetricUnit,
2091
+ AsPercent,
2092
+ }
2024
2093
 
2025
2094
  /** A field is a descriptor/tag of the price, a 'kind' of price. Without the concept of fields, we wouldn't be able to distinguish different prices because they'd all be just numbers. */
2026
2095
  export interface Field {
@@ -2084,6 +2153,7 @@ declare module "@barchart/chart-lib" {
2084
2153
  * @returns A string representation of the price.
2085
2154
  */
2086
2155
  format(price: number, field: Field, options: any): string;
2156
+ shutdown(): void;
2087
2157
  }
2088
2158
 
2089
2159
  export interface IMetaDataSource {
@@ -2223,12 +2293,14 @@ declare module "@barchart/chart-lib" {
2223
2293
  */
2224
2294
  function parseExpression(text: string, useCache?: boolean): ExpressionSuccess | ExpressionError;
2225
2295
 
2296
+ export type ValueProviderFunc = (symbol: string, field?: string) => number | null;
2297
+
2226
2298
  /** If you would like to evaluate an expression yourself.
2227
2299
  * @param model Same as @see model property of the @see ExpressionSuccess
2228
2300
  * @param valueProvider A function which, given a symbol name, returns a price.
2229
2301
  * @returns The computed value of the expression.
2230
2302
  */
2231
- function evaluateExpression(model: ExpressionInternalModel, valueProvider: (string) => number): number;
2303
+ function evaluateExpression(model: ExpressionInternalModel, valueProvider: ValueProviderFunc): number;
2232
2304
 
2233
2305
  interface StudyMetaRange {
2234
2306
  min: number;