Data Variables Reference
All variables available inside strategy scripts.
Exchange Data (Price and OHLCV)
Availability depends on the strategy cadence. Candle strategies receive bare
OHLCV in isolated mode and can read another candle market through
get_data(ticker). Tick strategies receive the current scalar price; they
must name a candle timeframe when requesting OHLCV.
| Name | Type | Availability | Description |
|---|---|---|---|
open | Series | Candle strategy | Open prices |
high | Series | Candle strategy | High prices |
low | Series | Candle strategy | Low prices |
close | Series | Candle strategy | Close prices |
volume | Series | Candle strategy | Trade volume |
price | float | Live tick and candle evaluation | Current market observation; in candle mode it can fall back to the latest close when no fresher observation exists. |
Candle timeframes: 1m, 3m, 5m, 15m, 30m, 1h, 2h,
4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M. tick is live-only.
These are the generic DSL values; the requested exchange can support a subset
and can impose its own range limits.
get_data() return object: In a tick strategy, get_data(ticker) is a
current snapshot with .price and venue data such as .book; it has no OHLCV
series. get_data(ticker, '1m') returns candle data with .open, .high,
.low, .close, and .volume.
Polymarket: In tick mode, use price,
get_data(context['ticker']).price, and
get_data(context['ticker']).book. Use an explicit candle timeframe for
trade-built OHLCV, for example get_data(context['ticker'], '1m').close.
Backtests replay one historical outcome token, POLYMARKET:<token_id>/USDC
from polymarket_history market discovery, on stored 1m candles or recorded
orderbook ticks. Tick replay fills immediate orders only (Market IOC/FOK,
Limit IOC): quote-budget buys and sells of held tokens; resting orders and
managed protection are not simulated.
State Variables
Updated at each evaluation step. Available in both backtesting and live trading.
| Name | Type | Description |
|---|---|---|
position | float | Current position size (0.0 = no position) |
entry_count | int | Number of entries made into the current position |
avg_price | float | Weighted average entry price |
position_opened_at | int | None | Opening fill time of the current position (UTC ms); None while flat or unknown |
unrealized_pnl | float | Unrealized profit/loss of the open position |
current_price | float | Current evaluation price from the state observation (price); in candle mode it can use the latest close when no fresher observation exists. |
funding_rate | float | Current/applicable funding rate (perpetual contracts only; live from supported ticker/funding-info streams, backtest from historical funding data) |
balance | float | Free balance of the ticker's quote/settlement asset in the account that trades it |
mark_price | float | Venue mark price (0.0 when not published) |
index_price | float | Venue index price (0.0 when not published) |
Note: Scripts that reference any state variable automatically switch to step-based execution (evaluated bar-by-bar instead of vectorized). Use state variables only when needed for scaled entry or position management logic.
Context Variables
Available via the context dictionary.
| Name | Available In | Type | Description |
|---|---|---|---|
context['ticker'] | Isolated mode | str | Current full ticker being evaluated (e.g., BINANCE:BTC/USDT) |
context['tickers'] | Cross mode | List[str] | All full tickers in the universe |
Time Variables
Datetime components extracted from each bar's timestamp. Available in both backtesting and live trading.
| Name | Type | Description |
|---|---|---|
hour | Series | Hour of day in UTC (0-23) |
minute | Series | Minute of hour (0-59) |
weekday | Series | ISO day of week (1=Monday, 7=Sunday) |
Example — Trade only during specific hours:
# Only trade between 09:00-09:30 UTC
time_filter = (hour == 9) & (minute < 30)
emit(condition & time_filter, entry(...))
Example — Skip weekends:
weekday_only = weekday <= 5
emit(condition & weekday_only, entry(...))
On-Chain Data (Bitcoin)
Bitcoin network metrics sourced from the Blockchain.com charts API. Data is daily granularity and BTC-only.
Currency Statistics
| Name | Type | API Metric | Description |
|---|---|---|---|
total_bitcoins | Series | total-bitcoins | Total mined BTC in circulation |
market_price_usd | Series | market-price | USD market price |
market_cap | Series | market-cap | Market capitalization (USD) |
trade_volume_usd | Series | trade-volume | Exchange trade volume (USD) |
Block Details
| Name | Type | API Metric | Description |
|---|---|---|---|
blockchain_size | Series | blocks-size | Total blockchain size (bytes) |
avg_block_size | Series | avg-block-size | Average block size (bytes) |
n_transactions_per_block | Series | n-transactions-per-block | Average transactions per block |
median_confirmation_time | Series | median-confirmation-time | Median confirmation time (minutes) |
Mining Information
| Name | Type | API Metric | Description |
|---|---|---|---|
hash_rate | Series | hash-rate | Network hash rate (TH/s) |
difficulty | Series | difficulty | Mining difficulty |
miners_revenue | Series | miners-revenue | Total miner revenue (USD) |
transaction_fees | Series | transaction-fees | Total transaction fees (BTC) |
transaction_fees_usd | Series | transaction-fees-usd | Total transaction fees (USD) |
cost_per_transaction | Series | cost-per-transaction | Mining cost per transaction (USD) |
cost_per_transaction_percent | Series | cost-per-transaction-percent | Mining cost as % of transaction value |
Network Activity
| Name | Type | API Metric | Description |
|---|---|---|---|
n_unique_addresses | Series | n-unique-addresses | Unique addresses used per day |
n_transactions | Series | n-transactions | Daily confirmed transactions |
n_payments_per_day | Series | n-payments-per-day | Estimated daily payment count |
mempool_size | Series | mempool-size | Mempool size (bytes) |
utxo_count | Series | utxo-count | Unspent transaction output set size |
n_transactions_excluding_popular | Series | n-transactions-excluding-popular | Transactions excluding top 100 addresses |
estimated_transaction_volume_usd | Series | estimated-transaction-volume-usd | Estimated daily transaction volume (USD) |
Limitations
- Daily resolution only. On-chain metrics are published once per day regardless of strategy timeframe.
- Bitcoin only. No on-chain data for ETH or other chains.
- Backtest only. On-chain variables are currently available in backtesting only. Not yet available in live trading.