Skip to content

Mock Datafeed

Load historical and realtime OHLCV data via the UDF-inspired adapter.

Scroll ~60 bars · keep latest in view · 0 bars ·

Modes

ModeBehavior
Fixed windowKeep a constant time span (~60 bars). New bars scroll the view so the latest stays on the right (autoScroll).
Expand XGrow the X domain to fit all history (previous default).
typescript
import { createMockDatafeed, barsToOhlc } from 'velo-plot/trading'

const feed = createMockDatafeed({ seed: 42 })
const bars = await feed.getBars({ symbol: 'MOCK', resolution: '1', from, to })
const ohlc = barsToOhlc(bars)

// Fixed scrolling window
chart.setAutoScroll(true)
chart.updateXAxis({ auto: false })

chart.updateSeries('ohlc', { ...nextBar, append: true })
// → view keeps the same width and follows the latest candle

Released under the MIT License.