HeyTraders Documentation

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.

NameTypeAvailabilityDescription
openSeriesCandle strategyOpen prices
highSeriesCandle strategyHigh prices
lowSeriesCandle strategyLow prices
closeSeriesCandle strategyClose prices
volumeSeriesCandle strategyTrade volume
pricefloatLive tick and candle evaluationCurrent 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.

NameTypeDescription
positionfloatCurrent position size (0.0 = no position)
entry_countintNumber of entries made into the current position
avg_pricefloatWeighted average entry price
position_opened_atint | NoneOpening fill time of the current position (UTC ms); None while flat or unknown
unrealized_pnlfloatUnrealized profit/loss of the open position
current_pricefloatCurrent evaluation price from the state observation (price); in candle mode it can use the latest close when no fresher observation exists.
funding_ratefloatCurrent/applicable funding rate (perpetual contracts only; live from supported ticker/funding-info streams, backtest from historical funding data)
balancefloatFree balance of the ticker's quote/settlement asset in the account that trades it
mark_pricefloatVenue mark price (0.0 when not published)
index_pricefloatVenue 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.

NameAvailable InTypeDescription
context['ticker']Isolated modestrCurrent full ticker being evaluated (e.g., BINANCE:BTC/USDT)
context['tickers']Cross modeList[str]All full tickers in the universe

Time Variables

Datetime components extracted from each bar's timestamp. Available in both backtesting and live trading.

NameTypeDescription
hourSeriesHour of day in UTC (0-23)
minuteSeriesMinute of hour (0-59)
weekdaySeriesISO 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

NameTypeAPI MetricDescription
total_bitcoinsSeriestotal-bitcoinsTotal mined BTC in circulation
market_price_usdSeriesmarket-priceUSD market price
market_capSeriesmarket-capMarket capitalization (USD)
trade_volume_usdSeriestrade-volumeExchange trade volume (USD)

Block Details

NameTypeAPI MetricDescription
blockchain_sizeSeriesblocks-sizeTotal blockchain size (bytes)
avg_block_sizeSeriesavg-block-sizeAverage block size (bytes)
n_transactions_per_blockSeriesn-transactions-per-blockAverage transactions per block
median_confirmation_timeSeriesmedian-confirmation-timeMedian confirmation time (minutes)

Mining Information

NameTypeAPI MetricDescription
hash_rateSerieshash-rateNetwork hash rate (TH/s)
difficultySeriesdifficultyMining difficulty
miners_revenueSeriesminers-revenueTotal miner revenue (USD)
transaction_feesSeriestransaction-feesTotal transaction fees (BTC)
transaction_fees_usdSeriestransaction-fees-usdTotal transaction fees (USD)
cost_per_transactionSeriescost-per-transactionMining cost per transaction (USD)
cost_per_transaction_percentSeriescost-per-transaction-percentMining cost as % of transaction value

Network Activity

NameTypeAPI MetricDescription
n_unique_addressesSeriesn-unique-addressesUnique addresses used per day
n_transactionsSeriesn-transactionsDaily confirmed transactions
n_payments_per_daySeriesn-payments-per-dayEstimated daily payment count
mempool_sizeSeriesmempool-sizeMempool size (bytes)
utxo_countSeriesutxo-countUnspent transaction output set size
n_transactions_excluding_popularSeriesn-transactions-excluding-popularTransactions excluding top 100 addresses
estimated_transaction_volume_usdSeriesestimated-transaction-volume-usdEstimated 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.