import { DXLinkChannel, DXLinkClient, DXLinkChannelState, DXLinkChannelStateChangeListener, DXLinkLogLevel } from '@dxfeed/dxlink-core'; interface DXLinkIndiChartIndicator { readonly lang: string; readonly content: string; } interface DXLinkIndiChartIndicators { readonly [key: string]: DXLinkIndiChartIndicator; } type JSONNumber = number | 'NaN' | 'Infinity' | '-Infinity'; interface DXLinkIndiChartSubscription { readonly symbol: string; readonly fromTime: number; } interface DXLinkIndiChartIndicatorsParameters { readonly [key: string]: { readonly [key: string]: number | string | boolean; }; } interface DXLinkIndiChartDoubleParameterMeta { readonly name: string; readonly type: 'DOUBLE'; readonly defaultValue: JSONNumber; readonly value?: JSONNumber; readonly options?: (JSONNumber | string)[]; readonly min?: number; readonly max?: number; readonly step?: number; } interface DXLinkIndiChartStringParameterMeta { readonly name: string; readonly type: 'STRING'; readonly defaultValue: string; readonly value?: string; readonly options?: string[]; } interface DXLinkIndiChartBoolParameterMeta { readonly name: string; readonly type: 'BOOL'; readonly defaultValue: boolean; readonly value?: boolean; } interface DXLinkIndiChartColorParameterMeta { readonly name: string; readonly type: 'COLOR'; readonly defaultValue: DXLinkIndiChartColor; readonly value?: DXLinkIndiChartColor; } interface DXLinkIndiChartSourceParameterMeta { readonly name: string; readonly type: 'SOURCE'; readonly defaultValue: string; readonly value?: string; readonly options?: string[]; } interface DXLinkIndiChartSessionParameterMeta { readonly name: string; readonly type: 'SESSION'; readonly defaultValue: string; readonly value?: string; readonly options?: string[]; readonly timeZone?: string; } interface DXLinkIndiChartEnumParameterMeta { readonly name: string; readonly type: 'ENUM'; readonly defaultValue: string; readonly value?: string; readonly options?: string[]; } type DXLinkIndiChartIndicatorParameterMeta = DXLinkIndiChartDoubleParameterMeta | DXLinkIndiChartStringParameterMeta | DXLinkIndiChartBoolParameterMeta | DXLinkIndiChartColorParameterMeta | DXLinkIndiChartSourceParameterMeta | DXLinkIndiChartSessionParameterMeta | DXLinkIndiChartEnumParameterMeta; interface DXLinkIndiChartIndicatorEnabled { readonly enabled: true; readonly inParameters: DXLinkIndiChartIndicatorParameterMeta[]; readonly outParameters: DXLinkIndiChartIndicatorParameterMeta[]; } interface ScriptStackFrame { column: number; functionName: string; line: number; } interface ScriptError { endColumn: number; endLine: number; message: string; scriptName: string; scriptStack: ScriptStackFrame[]; startColumn: number; startLine: number; type: string; } interface DXLinkIndiChartIndicatorDisabled { enabled: false; scriptError?: ScriptError; internalErrorMessage?: string; } type DXLinkIndiChartIndicatorState = DXLinkIndiChartIndicatorEnabled | DXLinkIndiChartIndicatorDisabled; interface DXLinkIndiChartIndicatorsStates { readonly [key: string]: DXLinkIndiChartIndicatorState; } interface DXLinkIndiChartSetup { readonly acceptAggregationPeriod: number; readonly acceptDataFormat: 'FULL'; readonly acceptCandleFields: string[]; } interface DXLinkIndiChartConfig { readonly aggregationPeriod: number; readonly dataFormat: 'FULL'; readonly candleFields: string[]; } interface DXLinkIndiChartCandle { readonly eventSymbol: string; readonly index: number; readonly time: number; readonly open: JSONNumber; readonly high: JSONNumber; readonly low: JSONNumber; readonly close: JSONNumber; readonly volume: JSONNumber; } interface DXLinkIndiChartColor { readonly value: string; readonly alpha?: number; } /** * Drawing style of a {@link DXLinkIndiChartSplinePoint}. * * The listed literals are the values currently produced by the server. The `(string & {})` * fallback keeps editor autocomplete for the known values while still allowing clients to * handle any future style the server may introduce. */ type DXLinkIndiChartSplineStyle = 'LINE' | 'STEPLINE' | 'HISTOGRAM' | 'CROSS' | 'AREA' | 'COLUMNS' | 'CIRCLES' | 'LINE_BREAK' | 'AREA_BREAK' | 'STEPLINE_BREAK' | (string & {}); /** * Drawing style of a {@link DXLinkIndiChartShapePoint}. * * The listed literals are the values currently produced by the server. The `(string & {})` * fallback keeps editor autocomplete for the known values while still allowing clients to * handle any future style the server may introduce. */ type DXLinkIndiChartShapeStyle = 'TAG' | 'ARROW_UP' | 'ARROW_DOWN' | 'XCROSS' | 'CROSS' | 'BEACON' | 'CIRCLE' | (string & {}); /** * Anchor location of a {@link DXLinkIndiChartShapePoint} on the chart. * * The listed literals are the values currently produced by the server. The `(string & {})` * fallback keeps editor autocomplete for the known values while still allowing clients to * handle any future location the server may introduce. */ type DXLinkIndiChartShapeLocation = 'ABOVE_BAR' | 'BELOW_BAR' | 'TOP' | 'BOTTOM' | 'ABSOLUTE' | (string & {}); interface DXLinkIndiChartSplinePoint { readonly value: JSONNumber; readonly style?: DXLinkIndiChartSplineStyle; readonly offset?: number; readonly title?: string; readonly color?: DXLinkIndiChartColor; readonly overlay?: boolean; } /** * Point of a `shape` series of a {@link DXLinkIndiChartCalculationResult}. */ interface DXLinkIndiChartShapePoint { readonly value: JSONNumber; readonly color?: DXLinkIndiChartColor; readonly textColor?: DXLinkIndiChartColor; readonly text?: string; readonly style?: DXLinkIndiChartShapeStyle; readonly offset?: number; readonly title?: string; readonly location?: DXLinkIndiChartShapeLocation; readonly overlay?: boolean; } /** * Point of a `backgroundColor` or `barColor` series of a {@link DXLinkIndiChartCalculationResult}. * `color` is always present but may be `null` when the script produced no color for this point. */ interface DXLinkIndiChartColorPoint { readonly color: DXLinkIndiChartColor | null; readonly offset?: number; readonly title?: string; readonly numberOfLast?: number; readonly overlay?: boolean; } /** * Result of an indicator calculation. Each series maps a series name to an array of points * that is index-aligned with the candles. Missing/padding points are represented as `null`. */ interface DXLinkIndiChartCalculationResult { readonly output?: { [seriesName: string]: (JSONNumber | null)[]; }; readonly spline?: { [seriesName: string]: (DXLinkIndiChartSplinePoint | null)[]; }; readonly backgroundColor?: { [seriesName: string]: (DXLinkIndiChartColorPoint | null)[]; }; readonly barColor?: { [seriesName: string]: (DXLinkIndiChartColorPoint | null)[]; }; readonly shape?: { [seriesName: string]: (DXLinkIndiChartShapePoint | null)[]; }; } interface DXLinkIndiChartIndicatorsData { readonly [indicatorName: string]: DXLinkIndiChartCalculationResult; } interface DXLinkIndiChartCandleSnapshotMessage { readonly type: 'INDICHART_CANDLE_SNAPSHOT'; readonly reset: boolean; readonly pending: boolean; readonly candles: DXLinkIndiChartCandle[]; } interface DXLinkIndiChartIndicatorsSnapshotMessage { readonly type: 'INDICHART_INDICATORS_SNAPSHOT'; readonly pending: boolean; readonly indicators: DXLinkIndiChartIndicatorsData; } interface DXLinkIndiChartUpdateMessage { readonly type: 'INDICHART_UPDATE'; readonly pending: boolean; readonly candles: DXLinkIndiChartCandle[]; readonly indicators: DXLinkIndiChartIndicatorsData; } type DXLinkIndiChartUpdateListener = (candles: DXLinkIndiChartCandle[], indicators: DXLinkIndiChartIndicatorsData, pending: boolean) => void; type DXLinkIndiChartCandleSnapshotListener = (candles: DXLinkIndiChartCandle[], reset: boolean, pending: boolean) => void; type DXLinkIndiChartIndicatorsSnapshotListener = (indicators: DXLinkIndiChartIndicatorsData, pending: boolean) => void; type DXLinkIndiChartIndicatorsStateListener = (indicators: DXLinkIndiChartIndicatorsStates) => void; interface DXLinkIndiChartSubscriptionState { subscription: DXLinkIndiChartSubscription; indicatorsParameters: DXLinkIndiChartIndicatorsParameters; } /** * dxLink Chart service. */ interface DXLinkIndiChartRequester { /** * Unique identifier of the Chart channel. */ readonly id: number; /** * Get current channel of the Chart. * Note: inaproppriate usage of the channel can lead to unexpected behavior. * @see {DXLinkChannel} */ getChannel(): DXLinkChannel; setSubscription(subscription: DXLinkIndiChartSubscription, indicatorsParameters: DXLinkIndiChartIndicatorsParameters): void; getSubscription(): DXLinkIndiChartSubscriptionState | null; setup(setup: DXLinkIndiChartSetup): void; getConfig(): DXLinkIndiChartConfig | null; getIndicators(): DXLinkIndiChartIndicatorsStates | null; /** * Add a listener for the Chart data updates (INDICHART_UPDATE). */ addUpdateListener(listener: DXLinkIndiChartUpdateListener): void; /** * Remove a listener for the Chart data updates. */ removeUpdateListener(listener: DXLinkIndiChartUpdateListener): void; /** * Add a listener for the Chart candle snapshots (INDICHART_CANDLE_SNAPSHOT). */ addCandleSnapshotListener(listener: DXLinkIndiChartCandleSnapshotListener): void; /** * Remove a listener for the Chart candle snapshots. */ removeCandleSnapshotListener(listener: DXLinkIndiChartCandleSnapshotListener): void; /** * Add a listener for the Chart indicator snapshots (INDICHART_INDICATORS_SNAPSHOT). */ addIndicatorsSnapshotListener(listener: DXLinkIndiChartIndicatorsSnapshotListener): void; /** * Remove a listener for the Chart indicator snapshots. */ removeIndicatorsSnapshotListener(listener: DXLinkIndiChartIndicatorsSnapshotListener): void; /** * Add a listener for the Chart indicators state changes received from the channel. */ addIndicatorsStateChangeListener(listener: DXLinkIndiChartIndicatorsStateListener): void; /** * Remove a listener for the Chart indicators state changes received from the channel. */ removeIndicatorsStateChangeListener(listener: DXLinkIndiChartIndicatorsStateListener): void; /** * Close the Chart channel. */ close(): void; } /** * Options for the {@link DXLinkIndiChart} instance. */ interface DXLinkIndiChartOptions { /** * Log level for the Chart. */ logLevel: DXLinkLogLevel; } /** * dxLink Indi Chart service implementation. */ declare class DXLinkIndiChart implements DXLinkIndiChartRequester { /** * Unique identifier of the Chart channel. */ readonly id: number; private readonly updateListeners; private readonly candleSnapshotListeners; private readonly indicatorsSnapshotListeners; private readonly indicatorsStateListeners; private readonly logger; private readonly channel; private lastSubscriptionState; private lastSetup; private lastConfig; private indicators; /** * Allows to create {@link DXLinkIndiChart} instance with the specified {@link ChartContract} for the given {@link DXLinkWebSocketClient}. */ constructor(client: DXLinkClient, indicators: DXLinkIndiChartIndicators); getChannel: () => DXLinkChannel; getState: () => DXLinkChannelState; addStateChangeListener: (listener: DXLinkChannelStateChangeListener) => void; removeStateChangeListener: (listener: DXLinkChannelStateChangeListener) => void; addIndicatorsStateChangeListener: (listener: DXLinkIndiChartIndicatorsStateListener) => Set; removeIndicatorsStateChangeListener: (listener: DXLinkIndiChartIndicatorsStateListener) => boolean; setup: (setup: DXLinkIndiChartSetup) => void; getConfig: () => DXLinkIndiChartConfig | null; getIndicators: () => DXLinkIndiChartIndicatorsStates | null; close: () => void; setSubscription: (subscription: DXLinkIndiChartSubscription, indicatorsParameters: DXLinkIndiChartIndicatorsParameters) => void; getSubscription: () => DXLinkIndiChartSubscriptionState | null; removeIndicators: (indicators: string[]) => void; addUpdateListener: (listener: DXLinkIndiChartUpdateListener) => void; removeUpdateListener: (listener: DXLinkIndiChartUpdateListener) => void; addCandleSnapshotListener: (listener: DXLinkIndiChartCandleSnapshotListener) => void; removeCandleSnapshotListener: (listener: DXLinkIndiChartCandleSnapshotListener) => void; addIndicatorsSnapshotListener: (listener: DXLinkIndiChartIndicatorsSnapshotListener) => void; removeIndicatorsSnapshotListener: (listener: DXLinkIndiChartIndicatorsSnapshotListener) => void; /** * Process message received in the channel. */ private processMessage; /** * Process data updates received from the channel. */ private processUpdate; /** * Process candle snapshot received from the channel. */ private processCandleSnapshot; /** * Process indicators snapshot received from the channel. */ private processIndicatorsSnapshot; /** * Process channel status changes from the channel. */ private processStatus; /** * Process error received from the channel. */ private processError; /** * Reconfigure the CHART channel after the channel re-open. */ private reconfigure; /** * Updates the indicators parameters without changing the subscription. * @param indicatorsParameters New indicators parameters. */ updateIndicatorsParameters: (indicatorsParameters: DXLinkIndiChartIndicatorsParameters) => void; } export { DXLinkIndiChart, type DXLinkIndiChartCalculationResult, type DXLinkIndiChartCandle, type DXLinkIndiChartCandleSnapshotListener, type DXLinkIndiChartCandleSnapshotMessage, type DXLinkIndiChartColor, type DXLinkIndiChartColorPoint, type DXLinkIndiChartConfig, type DXLinkIndiChartIndicator, type DXLinkIndiChartIndicatorDisabled, type DXLinkIndiChartIndicatorEnabled, type DXLinkIndiChartIndicatorParameterMeta, type DXLinkIndiChartIndicatorState, type DXLinkIndiChartIndicators, type DXLinkIndiChartIndicatorsData, type DXLinkIndiChartIndicatorsParameters, type DXLinkIndiChartIndicatorsSnapshotListener, type DXLinkIndiChartIndicatorsSnapshotMessage, type DXLinkIndiChartIndicatorsStates, type DXLinkIndiChartOptions, type DXLinkIndiChartRequester, type DXLinkIndiChartSetup, type DXLinkIndiChartShapeLocation, type DXLinkIndiChartShapePoint, type DXLinkIndiChartShapeStyle, type DXLinkIndiChartSplinePoint, type DXLinkIndiChartSplineStyle, type DXLinkIndiChartSubscription, type DXLinkIndiChartUpdateListener, type DXLinkIndiChartUpdateMessage, type JSONNumber };