Exchange data and on-chain data available for backtesting.
Data Variables Reference
All variables available inside strategy scripts.
Exchange Data (OHLCV)
Available by default in isolated mode. In cross mode, access via get_data(ticker).
| Name | Type | Description |
|---|---|---|
open |
Series |
Open prices |
high |
Series |
High prices |
low |
Series |
Low prices |
close |
Series |
Close prices |
volume |
Series |
Trade volume |
price |
float |
Real-time tick price (live/tick mode). Falls back to close[-1] in candle mode. |
Timeframes: 1m, 5m, 15m, 1h, 4h, 1d, tick
get_data() return object: Has attributes .open, .high, .low, .close, `.volume.
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 |
unrealized_pnl |
float |
Unrealized profit/loss of the open position |
current_price |
float |
Current close price |
funding_rate |
float |
Current funding rate (perpetual contracts only, live only) |
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 |
Day of week (0=Monday, 6=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.