Python SDK Reference¶
Install: pip install hypquant — Python ≥ 3.10, polars ≥ 0.20.
For pandas output: pip install "hypquant[pandas]" (requires pyarrow).
MarketData (synchronous)¶
Constructor¶
Use as a context manager (recommended):
Or call .close() explicitly when done.
md.ohlcv()¶
md.ohlcv(
symbol: str,
exchange: str,
timeframe: str,
start: str | datetime,
end: str | datetime | None = None,
limit: int = 1000,
as_pandas: bool = False,
) -> pl.DataFrame | pd.DataFrame
Returns OHLCV candles. Columns: time (Datetime UTC), open, high, low, close, volume (all Float64).
Parameters:
| Parameter | Description |
|---|---|
symbol | Trading pair, e.g. "BTC-USDC" |
exchange | "hyperliquid" or "binance" |
timeframe | "1m", "5m", "15m", "1h", "4h", "1d" |
start | Start time — ISO8601 string or timezone-aware datetime |
end | End time. Defaults to now |
limit | Max rows (1–10,000). Default: 1,000 |
as_pandas | Return pd.DataFrame instead of pl.DataFrame |
md.funding()¶
md.funding(
symbol: str,
exchange: str,
start: str | datetime,
end: str | datetime | None = None,
normalized: bool = False,
as_pandas: bool = False,
) -> pl.DataFrame | pd.DataFrame
Returns funding rates. Columns: time, rate, and optionally rate_normalized, premium.
| Parameter | Description |
|---|---|
normalized | If True, add rate_normalized (z-score) and premium (spot/perp basis) |
md.features()¶
md.features(
symbol: str,
exchange: str,
timeframe: str,
features: list[str],
start: str | datetime,
end: str | datetime | None = None,
as_pandas: bool = False,
) -> pl.DataFrame | pd.DataFrame
Returns wide-format feature values. Columns: time plus one column per requested feature.
| Parameter | Description |
|---|---|
timeframe | "1m", "5m", "15m", "1h", "4h", "1d", or "funding" |
features | List of feature names, e.g. ["rsi_14", "macd", "bb_upper"] |
md.multi_asset()¶
md.multi_asset(
symbols: list[str],
exchange: str,
timeframe: str,
field: str,
start: str | datetime,
end: str | datetime | None = None,
as_pandas: bool = False,
) -> pl.DataFrame | pd.DataFrame
Returns wide-format data for multiple symbols. Columns: time plus one column per symbol.
| Parameter | Description |
|---|---|
symbols | List of trading pairs |
field | "open", "high", "low", "close", "volume", "funding_rate", or any feature name |
md.available_features()¶
Returns the full feature catalogue. Each dict has keys name, description, category.
md.quality()¶
Returns DQS breakdown. See Data Quality API for the response schema.
AsyncMarketData (async)¶
Constructor¶
Same signature as MarketData. Use as an async context manager:
Or call await md.aclose() explicitly.
Methods¶
All methods mirror MarketData with await:
await md.ohlcv(...)
await md.funding(...)
await md.features(...)
await md.multi_asset(...)
await md.available_features()
await md.quality(...)
Exceptions¶
| Exception | When | Extra attributes |
|---|---|---|
hypquant.HypQuantError | Base class — any other HTTP error | status_code, request_id |
hypquant.AuthenticationError | Invalid or missing API key (HTTP 401) | — |
hypquant.TierLimitError | Request exceeds tier limits (HTTP 403) | upgrade_url |
hypquant.RateLimitError | Daily or per-minute quota exhausted (HTTP 429) | retry_after_secs |
hypquant.SymbolNotFoundError | Symbol or resource not found (HTTP 404) | — |
hypquant.InvalidParameterError | Invalid request parameter (HTTP 400) | — |
hypquant.ServiceUnavailableError | Backend temporarily unavailable (HTTP 503) | — |
ImportError | as_pandas=True but pandas/pyarrow not installed | — |
from hypquant import MarketData, TierLimitError, RateLimitError, AuthenticationError
try:
with MarketData(api_key="qp_...") as md:
df = md.ohlcv("BTC-USDC", exchange="hyperliquid", timeframe="1m", start="2024-01-01")
except TierLimitError as e:
print(f"Upgrade needed: {e}")
print(f"Upgrade at: {e.upgrade_url}")
except RateLimitError as e:
print(f"Rate limited, retry after: {e.retry_after_secs}s")
except AuthenticationError:
print("Invalid API key — check your credentials")