Types
Use these TypeScript types when chart data and configuration live outside the JSX. For example, declaring a feed result as OhlcCandle[] helps catch missing fields, while ChartPaneOptions[] checks a reusable pane configuration.
Public types below can be imported from react-native-trading-charts. Shared helper definitions are included to make the declarations readable. They describe the accepted shapes; the linked guides explain defaults, runtime validation and examples. Import ViewProps from React Native if you need to refer to the standard view props directly. Internal resolved configuration types are not required to use the library.
import type {
OhlcCandle,
ChartPaneOptions,
TradingChartsViewProps,
} from 'react-native-trading-charts';Data & selection
Use these shapes to describe the values you send and receive. The data guide covers history loading, timestamps and updates.
Selection items share these identity fields:
type CrosshairSeriesIdentity = Readonly<{
seriesId: string;
paneId: string;
priceScaleId: string;
}>;OhlcCandle
export type OhlcCandle = {
timestamp: number;
open: number;
high: number;
low: number;
close: number;
/** Traded volume. Packed as 0 when omitted, so native code and
* getCandles() cannot distinguish "no volume" from "zero volume". */
volume?: number;
};TradeEvent
export type TradeEvent = {
timestamp: number;
price: number;
size?: number;
};HistogramPoint
export type HistogramPoint = {
timestamp: number;
value: number;
};ChartSeriesDataPoint
export type ChartSeriesDataPoint = OhlcCandle | HistogramPoint;PriceLineOptions
export type PriceLineOptions = Readonly<{
id: string;
price: number;
label: string;
color: string;
}>;CrosshairSeriesValue
export type CrosshairSeriesValue =
| (CrosshairSeriesIdentity & Readonly<{
kind: 'boll';
seriesType: 'boll';
sourceType: 'ohlcvBoll';
upper: number | null;
middle: number | null;
lower: number | null;
}>)
| (CrosshairSeriesIdentity &
Readonly<{
kind: 'ohlc';
seriesType: 'candlestick' | 'hollowCandlestick' | 'bar';
candle: OhlcCandle | null;
}>)
| (CrosshairSeriesIdentity &
Readonly<{
kind: 'scalar';
seriesType: 'line' | 'area' | 'baseline' | 'histogram' | 'sar';
sourceType:
'data' | 'ohlcvVolume' | 'ohlcvRsi' | 'ohlcvSma' | 'ohlcvEma' | 'ohlcvSar';
value: number | null;
}>)
| (CrosshairSeriesIdentity &
Readonly<{
kind: 'macd';
seriesType: 'macd';
sourceType: 'ohlcvMacd';
macd: number | null;
signal: number | null;
histogram: number | null;
}>);Chart & series configuration
These options describe the view and its series. For sources, pane IDs and runtime setup, see Additional series.
The shared identity fields used by each additional-series variant are:
type AdditionalSeriesBase = {
seriesId: string;
paneId: string;
priceScaleId: string;
visible?: boolean;
};TradingChartsViewProps
export type TradingChartsViewProps = ViewProps & {
chartId: string;
resolution?: ChartResolution;
tradeAggregation?: TradeAggregationOptions;
initialVisibleCount?: number;
defaultScale?: number;
series?: ChartSeriesOptions;
panes?: ReadonlyArray<ChartPaneOptions>;
additionalSeries?: ReadonlyArray<AdditionalChartSeriesOptions>;
panesResizable?: boolean;
theme?: ChartTheme;
appearance?: ChartAppearance;
formatters?: ChartFormatters;
xAxis?: XAxisOptions;
yAxis?: YAxisOptions;
gestures?: GestureOptions;
currentPrice?: CurrentPriceOptions;
priceExtremes?: PriceExtremesOptions;
crosshair?: CrosshairOptions;
onVisibleRangeChange?: (event: VisibleRangeChangeEvent) => void;
onScaleChange?: (event: ScaleChangeEvent) => void;
onYAxisScaleChange?: (event: ScaleChangeEvent) => void;
onPaneResize?: (event: PaneResizeEvent) => void;
onPriceScaleChange?: (event: PriceScaleChangeEvent) => void;
onYAxisPress?: (event: YAxisPressEvent) => void;
onSelectedCandleChange?: (
candle: OhlcCandle | null,
seriesValues: ReadonlyArray<CrosshairSeriesValue>
) => void;
};ChartSeriesType
export type ChartSeriesType =
'candlestick' | 'hollowCandlestick' | 'bar' | 'line' | 'area' | 'baseline';ChartSeriesOptions
export type ChartSeriesOptions =
| {
type?: 'candlestick' | 'hollowCandlestick' | 'bar';
baseValue?: never;
source?: never;
gapThresholdMs?: never;
}
| {
type: 'line' | 'area';
baseValue?: never;
source?: OhlcValueSource;
gapThresholdMs?: number;
}
| {
type: 'baseline';
baseValue?: BaselineBaseValue;
source?: OhlcValueSource;
gapThresholdMs?: number;
};OhlcValueSource
export type OhlcValueSource = 'open' | 'high' | 'low' | 'close';ChartPaneOptions
export type ChartPaneOptions = {
paneId: string;
heightWeight: number;
minHeight?: number;
priceScale: ChartPanePriceScaleOptions;
};ChartPanePriceScaleOptions
export type ChartPanePriceScaleOptions = {
priceScaleId: string;
visible?: boolean;
scaleMargins?: PriceScaleMargins;
valueFormat?: YAxisValueFormat | VolumeValueFormat;
};AdditionalChartSeriesOptions
export type AdditionalChartSeriesOptions =
| AdditionalOhlcSeriesOptions
| HistogramSeriesOptions
| RsiSeriesOptions
| MovingAverageSeriesOptions
| MacdSeriesOptions
| BollSeriesOptions;AdditionalOhlcSeriesOptions
export type AdditionalOhlcSeriesOptions = AdditionalSeriesBase &
(
| { type: 'candlestick' | 'hollowCandlestick' | 'bar' }
| {
type: 'line';
source?: OhlcValueSource;
gapThresholdMs?: number;
appearance?: ChartLineAppearance;
}
| {
type: 'baseline';
source?: OhlcValueSource;
gapThresholdMs?: number;
baseValue?: BaselineBaseValue;
appearance?: ChartBaselineAppearance;
}
| {
type: 'area';
source?: OhlcValueSource;
gapThresholdMs?: number;
appearance?: ChartAreaAppearance;
}
);HistogramSeriesOptions
export type HistogramSeriesOptions = AdditionalSeriesBase & {
type: 'histogram';
source?: { type: 'ohlcvVolume'; seriesId: string } | { type: 'data' };
appearance?: {
color?: string;
upColor?: string;
downColor?: string;
};
};MovingAverageSeriesOptions
export type MovingAverageSeriesOptions = AdditionalSeriesBase & {
type: 'line';
source: {
type: 'ohlcvSma' | 'ohlcvEma';
seriesId: string;
period: number;
valueSource?: OhlcValueSource;
};
gapThresholdMs?: number;
appearance?: ChartLineAppearance;
};RsiSeriesOptions
export type RsiSeriesOptions = AdditionalSeriesBase & {
type: 'line';
source: {
type: 'ohlcvRsi';
seriesId: string;
period?: number;
};
levels?: RsiLevels;
gapThresholdMs?: number;
appearance?: RsiSeriesAppearance;
};RsiLevels
export type RsiLevels = {
oversold?: number;
overbought?: number;
};BollSeriesOptions and BollSeriesAppearance
export type BollSeriesAppearance = {
upperLine?: ChartLineAppearance;
middleLine?: ChartLineAppearance;
lowerLine?: ChartLineAppearance;
fill?: { enabled?: boolean; topColor?: string; bottomColor?: string };
};
export type BollSeriesOptions = AdditionalSeriesBase & {
type: 'boll';
source: {
type: 'ohlcvBoll';
seriesId: string;
period?: number;
stdDevMultiplier?: number;
valueSource?: OhlcValueSource;
};
gapThresholdMs?: number;
appearance?: BollSeriesAppearance;
};
export type NormalizedBollSeriesOptions = Omit<
BollSeriesOptions,
'visible' | 'source'
> & {
visible: boolean;
source: Required<BollSeriesOptions['source']>;
};See Bollinger Bands for calculation and rendering defaults.
SarSeriesOptions and SarSeriesAppearance
export type SarSeriesAppearance = {
upColor?: string;
downColor?: string;
reversalColor?: string;
};
export type SarSeriesOptions = AdditionalSeriesBase & {
type: 'sar';
source: {
type: 'ohlcvSar';
seriesId: string;
step?: number;
maximum?: number;
};
appearance?: SarSeriesAppearance;
};See Parabolic SAR for calculation, validation and rendering defaults.
MacdSeriesOptions
export type MacdSeriesOptions = AdditionalSeriesBase & {
type: 'macd';
source: {
type: 'ohlcvMacd';
seriesId: string;
fastPeriod?: number;
slowPeriod?: number;
signalPeriod?: number;
valueSource?: OhlcValueSource;
};
gapThresholdMs?: number;
appearance?: MacdSeriesAppearance;
};NormalizedAdditionalChartSeriesOptions
Describes the normalized shape used by addSeries: visibility and source defaults are filled in; appearance remains optional so native rendering can follow the current theme. Callers pass AdditionalChartSeriesOptions.
export type NormalizedAdditionalChartSeriesOptions =
| (AdditionalOhlcSeriesOptions & { visible: boolean })
| (Omit<RsiSeriesOptions, 'visible' | 'source' | 'levels'> & {
visible: boolean;
source: {
type: 'ohlcvRsi';
seriesId: string;
period: number;
};
levels: Required<RsiLevels>;
})
| (Omit<MovingAverageSeriesOptions, 'visible' | 'source'> & {
visible: boolean;
source: {
type: 'ohlcvSma' | 'ohlcvEma';
seriesId: string;
period: number;
valueSource: OhlcValueSource;
};
})
| (Omit<MacdSeriesOptions, 'visible' | 'source'> & {
visible: boolean;
source: {
type: 'ohlcvMacd';
seriesId: string;
fastPeriod: number;
slowPeriod: number;
signalPeriod: number;
valueSource: OhlcValueSource;
};
})
| (Omit<HistogramSeriesOptions, 'visible' | 'source'> & {
visible: boolean;
source: { type: 'ohlcvVolume'; seriesId: string } | { type: 'data' };
});Time & aggregation
These types describe intervals and market sessions. Time & trade aggregation explains how they group raw trades into candles.
ResolutionUnit
export type ResolutionUnit =
'second' | 'minute' | 'hour' | 'day' | 'week' | 'month';ChartResolution
export type ChartResolution =
| {
unit: ResolutionUnit;
multiplier?: number;
}
| {
unit: 'fixed';
durationMs: number;
};TradeAggregationOptions
export type TradeAggregationOptions = {
bucketOrigin?: 'epoch' | 'session' | { timestamp: number };
calendar?: TradingCalendar;
outsideSession?: 'ignore' | 'reject';
candleTimestamp?: 'bucketStart' | 'tradingDateUtc';
};TradingCalendar
export type TradingCalendar = {
timeZone: string;
sessions?: ReadonlyArray<TradingSession>;
holidays?: ReadonlyArray<string>;
overrides?: ReadonlyArray<TradingCalendarOverride>;
weekStartsOn?: 'monday' | 'sunday';
};TradingCalendarOverride
export type TradingCalendarOverride = {
date: string;
sessions: ReadonlyArray<TradingSessionSegment>;
};TradingSession
export type TradingSession = TradingSessionSegment & {
days: ReadonlyArray<TradingWeekday>;
};TradingSessionSegment
export type TradingSessionSegment = {
start: string;
end: string;
startDayOffset?: -1 | 0;
endDayOffset?: 0 | 1;
};TradingWeekday
export type TradingWeekday =
| 'monday'
| 'tuesday'
| 'wednesday'
| 'thursday'
| 'friday'
| 'saturday'
| 'sunday';Theme & appearance
Use these types for shared colors and styles on individual parts of the chart. See Themes & appearance for the defaults and override rules.
ChartTheme
export type ChartTheme = {
backgroundColor?: string;
gridColor?: string;
axisTextColor?: string;
upColor?: string;
downColor?: string;
crosshairColor?: string;
tooltipBackgroundColor?: string;
tooltipTextColor?: string;
};ChartAppearance
export type ChartAppearance = {
backgroundColor?: string;
grid?: {
color?: string;
opacity?: number;
};
candles?: {
upColor?: string;
downColor?: string;
radius?: number;
};
bars?: {
upColor?: string;
downColor?: string;
lineWidth?: number;
};
line?: ChartLineAppearance;
baseline?: ChartBaselineAppearance & { rounded?: boolean };
area?: ChartAreaAppearance;
xAxis?: { text?: ChartTextStyle };
yAxis?: { text?: ChartTextStyle };
priceExtremes?: {
text?: ChartTextStyle;
connectorColor?: string;
backgroundColor?: string;
};
currentPrice?: {
line?: {
upColor?: string;
downColor?: string;
};
label?: ChartDirectionalBadgeStyle;
};
priceLines?: {
label?: {
border?: Pick<ChartBorderStyle, 'radius'>;
};
};
crosshair?: {
line?: {
color?: string;
opacity?: number;
};
priceLabel?: ChartBadgeStyle;
timeLabel?: ChartBadgeStyle;
};
tooltip?: {
backgroundColor?: string;
backgroundOpacity?: number;
headerText?: ChartTextStyle;
labelText?: ChartTextStyle;
valueText?: ChartTextStyle;
positiveValueColor?: string;
negativeValueColor?: string;
border?: ChartBorderStyle;
};
};ChartLineStyle
export type ChartLineStyle = 'solid' | 'dashed';ChartLineAppearance
export type ChartLineAppearance = {
width?: number;
color?: string;
style?: ChartLineStyle;
gradient?: {
topColor: string;
bottomColor: string;
};
};ChartAreaAppearance
export type ChartAreaAppearance = ChartLineAppearance & {
fill?: {
topColor?: string;
bottomColor?: string;
};
};ChartTextStyle
export type ChartTextStyle = {
color?: string;
fontFamily?: string;
fontSize?: number;
fontWeight?: ChartFontWeight;
};ChartFontWeight
export type ChartFontWeight = 'regular' | 'medium' | 'semibold' | 'bold';ChartBorderStyle
export type ChartBorderStyle = {
color?: string;
width?: number;
radius?: number;
};ChartBadgeStyle
export type ChartBadgeStyle = {
backgroundColor?: string;
text?: ChartTextStyle;
border?: ChartBorderStyle;
};ChartDirectionalBadgeStyle
export type ChartDirectionalBadgeStyle = Omit<
ChartBadgeStyle,
'backgroundColor'
> & {
upBackgroundColor?: string;
downBackgroundColor?: string;
};RsiSeriesAppearance
export type RsiSeriesAppearance = ChartLineAppearance & {
textColor?: string;
levelLineColor?: string;
bandColor?: string;
};MacdSeriesAppearance
export type MacdSeriesAppearance = {
macdLine?: ChartLineAppearance;
signalLine?: ChartLineAppearance;
histogram?: MacdHistogramAppearance;
textColor?: string;
zeroLineColor?: string;
};MacdHistogramAppearance
export type MacdHistogramAppearance = {
positiveIncreasingColor?: string;
positiveDecreasingColor?: string;
negativeIncreasingColor?: string;
negativeDecreasingColor?: string;
};Axes & formatting
These options control scales and label text. Axes & formatting shows how to set precision and date formats for each label role.
XAxisOptions
export type XAxisOptions = {
visible?: boolean;
height?: number;
locale?: string;
timeZone?: string;
showSeconds?: boolean;
spacing?: 'time' | 'logical';
};YAxisOptions
export type YAxisOptions = {
visible?: boolean;
width?: number;
defaultScale?: number;
scaleMargins?: PriceScaleMargins;
valueFormat?: YAxisValueFormat;
};PriceScaleMargins
export type PriceScaleMargins = {
top: number;
bottom: number;
};YAxisValueFormat
export type YAxisValueFormat =
PriceValueFormat | CompactValueFormat | SignificantValueFormat;PriceValueFormat
export type PriceValueFormat = {
type: 'price';
precision?: number;
minMove?: number;
locale?: string;
currencySymbol?: string;
useGrouping?: boolean;
};CompactValueFormat
export type CompactValueFormat = {
type: 'compact';
precision?: number;
minMove?: number;
locale?: string;
currencySymbol?: string;
};SignificantValueFormat
export type SignificantValueFormat = {
type: 'significant';
significantDigits?: number;
minMove?: number;
locale?: string;
currencySymbol?: string;
useGrouping?: boolean;
};VolumeValueFormat
export type VolumeValueFormat = {
type: 'volume';
precision?: number;
locale?: string;
useGrouping?: boolean;
};PriceDisplayFormat
export type PriceDisplayFormat =
| Omit<PriceValueFormat, 'minMove'>
| (Omit<CompactValueFormat, 'minMove'> & { useGrouping?: boolean })
| Omit<SignificantValueFormat, 'minMove'>;ChartFormatters
export type ChartFormatters = {
date?: {
xAxis?: XAxisDateFormats;
crosshairTimeBadge?: DatePatternFormat;
tooltipHeader?: DatePatternFormat;
};
price?: {
yAxis?: YAxisValueFormat;
priceExtremes?: PriceDisplayFormat;
currentPrice?: PriceDisplayFormat;
crosshairPrice?: PriceDisplayFormat;
tooltip?: PriceDisplayFormat;
};
};DatePatternFormat
export type DatePatternFormat = {
pattern: string;
locale?: string;
timeZone?: string;
};XAxisDateFormats
export type XAxisDateFormats = {
locale?: string;
timeZone?: string;
seconds?: string;
time?: string;
day?: string;
month?: string;
year?: string;
};Interaction & overlays
These types configure gestures and the labels drawn over price data. See Crosshair & tooltips for selection behavior.
GestureOptions
export type GestureOptions = {
pan?: boolean;
zoom?: boolean;
yAxisScale?: boolean;
};CrosshairOptions
export type CrosshairOptions = {
enabled?: boolean;
showTooltip?: boolean;
showTooltipHeader?: boolean;
tooltipBackgroundOpacity?: number;
lineStyle?: CrosshairLineStyle;
tooltipFields?: ReadonlyArray<CrosshairTooltipField>;
tooltipLabels?: CrosshairTooltipLabels;
};CrosshairLineStyle
export type CrosshairLineStyle = ChartLineStyle;CrosshairTooltipField
export type CrosshairTooltipField =
| 'open'
| 'close'
| 'high'
| 'low'
| 'amplitude'
| 'changePercent'
| 'change'
| 'volume';CrosshairTooltipLabels
export type CrosshairTooltipLabels = {
open?: string;
close?: string;
high?: string;
low?: string;
amplitude?: string;
changePercent?: string;
change?: string;
volume?: string;
};CurrentPriceOptions
export type CurrentPriceOptions = {
visible?: boolean;
showLabel?: boolean;
pinToEdge?: boolean;
};PriceExtremesOptions
export type PriceExtremesOptions = {
visible?: boolean;
};Events
Use these payloads in view callbacks. The event reference explains when each callback runs.
VisibleRangeChangeEvent
export type VisibleRangeChangeEvent = Readonly<{
from: number;
to: number;
firstVisibleIndex: number;
lastVisibleIndex: number;
totalCount: number;
atStart: boolean;
atEnd: boolean;
}>;ScaleChangeEvent
export type ScaleChangeEvent = Readonly<{
scale: number;
}>;PaneResizeEvent
export type PaneResizeEvent = Readonly<{
firstPaneId: string;
firstHeightWeight: number;
secondPaneId: string;
secondHeightWeight: number;
finished: boolean;
}>;PriceScaleChangeEvent
export type PriceScaleChangeEvent = Readonly<{
paneId: string;
priceScaleId: string;
scale: number;
}>;YAxisPressEvent
export type YAxisPressEvent = Readonly<{
x: number;
y: number;
price: number;
paneId: string;
priceScaleId: string;
}>;Trade batching
The batcher accepts an interval and returns methods for managing queued trades. See Trade batcher for validation and teardown.
TradeBatcherOptions
export type TradeBatcherOptions = {
/** Flush interval in milliseconds. Defaults to 32. */
intervalMs?: number;
};TradeBatcher
export type TradeBatcher = {
/**
* Queue one trade. Validates synchronously, so invalid or out-of-order
* input throws in the caller's stack instead of inside the flush timer.
*/
add(trade: TradeEvent): void;
/** Send everything queued so far. */
flush(): void;
/** Permanently stop the batcher, drop queued trades, and cancel its timer. */
dispose(): void;
};BaselineBaseValue
export type BaselineBaseValue =
{ type: 'price'; value: number } | { type: 'percentage'; value: number };ChartBaselineAppearance
export type ChartBaselineAppearance = {
width?: number;
style?: ChartLineStyle;
topLineColor?: string;
bottomLineColor?: string;
topFill?: { topColor?: string; bottomColor?: string };
bottomFill?: { topColor?: string; bottomColor?: string };
baseLine?: {
visible?: boolean;
color?: string;
width?: number;
style?: ChartLineStyle;
};
};