Data Types
This page is the single reference for the core data shapes used by ChartSpire.
For DataFeed behavior, subscriptions, and implementation guidance, see Data Access.
What belongs here
- Type shapes used across symbols, intervals, candles, order book, and trades
- Canonical field names and value formats
- Copy-paste-safe TypeScript examples
Interval
Interval defines chart timeframe metadata.
typescript
interface Interval {
multiplier: number
timespan: string
text: string
}Common examples:
{ multiplier: 1, timespan: 'minute', text: '1m' }{ multiplier: 15, timespan: 'minute', text: '15m' }{ multiplier: 1, timespan: 'day', text: 'D' }{ multiplier: 1, timespan: 'week', text: 'W' }
Symbol
Symbol represents a tradable instrument.
typescript
interface Symbol {
symbol: string
type: SYMBOL_TYPE | 'UNKNOWN'
name?: string
shortName?: string
exchange?: string
market?: string
pricePrecision?: number
volumePrecision?: number
priceCurrency?: string
logo?: string
}Example:
typescript
const btc: Symbol = {
symbol: 'BTCUSDT',
type: SYMBOL_TYPE.CRYPTO,
name: 'Bitcoin',
shortName: 'BTC',
exchange: 'binance',
priceCurrency: 'USDT',
pricePrecision: 2,
volumePrecision: 6
}SYMBOL_TYPE
SYMBOL_TYPE is used for asset classification.
typescript
enum SYMBOL_TYPE {
STOCKS = 'stocks',
CRYPTO = 'crypto',
FOREX = 'forex',
FUTURES = 'futures',
INDICES = 'indices',
COMMODITIES = 'commodities',
ETF = 'etf',
CURRENCY = 'currency',
BONDS = 'bonds',
OTHER = 'other',
ALL = 'all'
}Notes:
- Use concrete types (
stocks,crypto, etc.) forSymbol.type. SYMBOL_TYPE.ALLis a filter category (for search/filter UI), not an instrument type.
CandleStickData (OHLCV)
CandleStickData is an alias of KLineData from @chartspire/chartspire-chart.
typescript
interface CandleStickData {
timestamp: number
open: number
high: number
low: number
close: number
volume?: number
turnover?: number
[key: string]: unknown
}OrderBookData
typescript
interface OrderBookData {
bids: Array<[string, string]> // [price, quantity]
asks: Array<[string, string]> // [price, quantity]
timestamp: number
}TradeData and TradeDataCollection
typescript
interface TradeData {
id: string
price: string
quantity: string
timestamp: number
side: 'buy' | 'sell'
tradeType?: string
}
interface TradeDataCollection {
trades: TradeData[]
symbol: string
exchange?: string
lastUpdated: number
}Related Docs
- Data Access - DataFeed contract, subscriptions, and custom feed implementation
- Default DataFeed - Production-ready feed configuration and transport behavior