Skip to main content
Use client.vwap() when you need volume-weighted average price data for execution benchmarking and price smoothing. This method calculates VWAP over fixed time intervals.

Method signature

vwap(source, market, from_, to, interval, limit=1000)

Parameters

ParameterTypeRequiredNotes
sourcestrYesSource ID
marketstrYesNormalized market or instrument ID
from_str/datetime/date/intYesInclusive start time (ISO 8601, datetime, date, or epoch microseconds)
tostr/datetime/date/intYesExclusive end time (same formats as from_)
intervalstrYesDuration token such as 1m, 5m, 1h
limitintNoPage size (default: 1000)
Note: API key required for historical ranges. Set POLARIS_API_KEY environment variable or pass api_key to PolarisClient().

Return value

List of bucketed VWAP series rows.

Example response

[
    {
        'timestamp': 1704067200000000,
        'venue': 'binance',
        'symbol': 'BTC-USDT',
        'vwap': 43252.35,
        'volume': 125.5,
        'interval': '1m'
    }
]

Fields

VWAP records include:
  • timestamp: bucket start time in UTC microseconds since the Unix epoch
  • venue: exchange identifier
  • symbol: normalized instrument symbol
  • vwap: volume-weighted average price for the interval
  • volume: total traded base volume for the interval
  • interval: duration token such as 1m, 5m, or 1h
VWAP is calculated as the sum of (price × quantity) divided by total quantity for all trades in the interval.

Example

from datetime import datetime, timedelta, timezone
from polaris_data import PolarisClient

end = datetime.now(timezone.utc)
start = end - timedelta(hours=6)

with PolarisClient() as client:
    vwap_data = client.vwap(
        source="hyperliquid",
        market="SPX",
        from_=start,
        to=end,
        interval="5m",
    )

print(vwap_data[:2])

How it works

client.vwap() calculates VWAP from standardized trade data using snapshot-first replay. The SDK queries the /snapshots endpoint for historical data, reads from local cached files when available, and derives VWAP from the underlying trade events. For more details on snapshot-based queries, see Snapshots.