# Example data

The Deephaven TradingView Lightweight package includes built-in example tables. Each function returns a fresh `deephaven.table.Table` generated from a fixed seed, so the same call always produces the same rows.

Import the module under the `tvl` alias and call any of the functions below.

## Ticking and static tables

Every function takes a `ticking` argument, default `True`. A ticking table starts with a static seed block and then appends one new row per second, so an example updates live on its own. `yields` and `options_chain` refresh in place instead: their values move while the row count stays flat.

Pass `ticking=False` to any of them for a static table holding only the seed block.

```python
import deephaven.plot.tradingview_lightweight as tvl

live = tvl.data.values()  # 90 seed rows, then one row per second
snapshot = tvl.data.values(ticking=False)  # the 90 seed rows only
```

## The `Index` column

Each time-series fixture has an `Index` column: a `long` row counter that starts at zero and keeps counting as rows tick in. Read it when a formula needs a row position. The query-language `ii` pseudo-column is not refresh-safe on a ticking table.

```python
import deephaven.plot.tradingview_lightweight as tvl

values = tvl.data.values()
weekly = values.where("Index % 7 == 0")
```

The `yields` and `options_chain` snapshots are keyed by tenor and strike rather than by row, so they have no `Index` column.

## ohlc

90 daily OHLCV bars starting 2024-01-01, plus a precomputed `Ema` column (a 20-tick EMA of `Close`).

Columns: `Timestamp`, `Open`, `High`, `Low`, `Close`, `Volume`, `Ema`, `Index`.

```python
import deephaven.plot.tradingview_lightweight as tvl

ohlc = tvl.data.ohlc()
```

Each row represents one calendar day starting 2024-01-01. The price path
is a smoothed random walk (windowed cumulative sum of Gaussian steps
plus an EMA), giving visible trends and reversals instead of a pure sine.
High/Low straddle Open/Close by an absolute-Gaussian intra-bar range, and
volume swells with absolute return so big moves print big bars.

**Returns:** `A deephaven.table.Table with columns` Timestamp (Instant): daily timestamps from 2024-01-01.

Open (double): opening price.

High (double): high price, ≥ max(Open, Close).

Low (double): low price, ≤ min(Open, Close).

Close (double): closing price.

Volume (long): bar volume; correlates with return.

Ema (double): 20-tick EMA of Close.

Index (long): incrementing row counter, for row-position formulas.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "ohlc", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), the seed block is followed by one new candle per second. If false, only the static seed is returned.", "default": "True"}]}} />

## stocks

360 trade-style rows across three symbols (`AAA`, `BBB`, `CCC`), 120 each, interleaved round-robin. Every symbol has its own price level and volatility, so a `by="Sym"` chart draws three clearly separate series.

Columns: `Timestamp`, `Sym`, `Price`, `Size`, `Index`.

```python
import deephaven.plot.tradingview_lightweight as tvl

stocks = tvl.data.stocks()
```

Three symbols (AAA, BBB, CCC) tick in round-robin. Each
symbol has an independent random walk anchored at a distinct base
price (90, 140, 60) with its own volatility, so a by="Sym" chart
shows three visually distinct series.

**Returns:** `A deephaven.table.Table with columns` Timestamp (Instant): daily timestamps from 2024-01-01.

Sym (string): one of "AAA", "BBB", "CCC".

Price (double): symbol-dependent price walk.

Size (long): trade size; lognormal, median ~55.

Index (long): incrementing row counter, for row-position formulas.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "stocks", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), trades tick in once per second after an initial 360-row seed. If false, only the static seed is returned.", "default": "True"}]}} />

## volume

60 daily volume bars starting 2024-01-01, on a repeating cycle of heavier and lighter days so a histogram of it has visible structure.

Columns: `Timestamp`, `Volume`, `Index`.

```python
import deephaven.plot.tradingview_lightweight as tvl

volume = tvl.data.volume()
```

The volume curve is a lognormal
base scaled by a five-row cycle of weekday multipliers (heaviest on the
first and fifth), so the histogram has visible structure beyond pure noise.

**Returns:** `A deephaven.table.Table with columns` Timestamp (Instant): daily timestamps from 2024-01-01.

Volume (long): daily volume, lognormal with a five-row cycle.

Index (long): incrementing row counter, for row-position formulas.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "volume", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), one new bar ticks in per second after the 60-row seed. If false, only the static seed is returned.", "default": "True"}]}} />

## yields

An 11-point Treasury yield curve: 3M, 6M, 1Y, 2Y, 3Y, 5Y, 7Y, 10Y, 20Y, 30Y, and 40Y, emitted in months (3, 6, 12, 24, 36, 60, 84, 120, 240, 360, 480), which is the unit LWC’s yield-curve axis expects. The curve slopes upward, steeply at the short end and flattening out past ten years.

Columns: `Tenor`, `Yield`.

```python
import deephaven.plot.tradingview_lightweight as tvl

yields = tvl.data.yields()
```

In ticking mode one tenor is replaced each second, so the curve turns over
every 11 seconds; each sweep re-draws the factors with a small Gaussian
jitter. last_by("Tenor") keeps the row count flat.

**Returns:** `A deephaven.table.Table with columns` Tenor (double): months to maturity.

Yield (double): yield in percent.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "yields", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), one tenor of the curve updates per second. If false, a single static snapshot is returned.", "default": "True"}]}} />

## options_chain

A 21-strike options chain with call and put quotes, stepping by 5 from 50 to 150 (at-the-money = 100). Calls fall and puts rise across the strikes, forming an “X” when plotted, and spreads widen at the wings.

Columns: `Strike`, `CallBid`, `CallAsk`, `PutBid`, `PutAsk`.

```python
import deephaven.plot.tradingview_lightweight as tvl

options_chain = tvl.data.options_chain()
```

In ticking mode one strike is replaced each second, so the chain turns
over every 21 seconds; the spot takes one smoothed-random-walk step per
sweep, sliding the smile and intrinsic legs together.

**Returns:** `A deephaven.table.Table with columns` Strike (double): strike price, 50..150 by 5.

CallBid (double): call bid price.

CallAsk (double): call ask price.

PutBid (double): put bid price.

PutAsk (double): put ask price.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "options_chain", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), one strike of the chain updates per second. If false, a single static snapshot at spot=100 is returned.", "default": "True"}]}} />

## values

90 daily rows of a single `Value` column moving around 100, starting 2024-01-01.

Columns: `Timestamp`, `Value`, `Index`.

```python
import deephaven.plot.tradingview_lightweight as tvl

values = tvl.data.values()
```

The series is a smoothed random walk (Gaussian steps + EMA), so it
has runs, reversals, and consolidations.

**Returns:** `A deephaven.table.Table with columns` Timestamp (Instant): daily timestamps from 2024-01-01.

Value (double): smoothed walk centered at ~100.

Index (long): incrementing row counter, for row-position formulas.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "values", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), one new sample ticks in per second after the 90-row seed. If false, only the static seed is returned.", "default": "True"}]}} />

## large_prices

A 1,000,000-row price series spanning ~10 years, one row every ~315 seconds from 2020-01-01. The price moves at two scales, a slow drift and a fast wiggle, so the downsampler has something to thin out.

Columns: `Timestamp`, `Price`, `Index`.

```python
import deephaven.plot.tradingview_lightweight as tvl

large_prices = tvl.data.large_prices()
```

Timestamps step uniformly so 1M rows cover ~10 years (~315 seconds per
row). The price curve combines a low-frequency drift (cumulative sum of
small Gaussians) with a higher-frequency wiggle, giving the downsampler
structure to thin without making the chart look noisy.

**Returns:** `A deephaven.table.Table with columns` Timestamp (Instant): ~315-second spaced timestamps from 2020-01-01.

Price (double): smoothed walk centered at ~100.

Index (long): incrementing row counter, for row-position formulas.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.data.", "name": "large_prices", "parameters": [{"name": "ticking", "type": "bool", "description": "If true (default), additional rows tick in once per second after the 1M-row seed. If false, only the static seed is returned.", "default": "True"}]}} />
