| name | market-data |
| description | Fetch market data from GRVT exchange — tickers, orderbooks, trades, candlesticks, funding rates. Use when the user wants price info, charts, or market analysis data. |
GRVT Market Data
When to Use
Use this skill when the user wants to:
- Check current prices, bid/ask spreads
- View orderbook depth
- Get recent trades
- Fetch candlestick/OHLCV data for analysis
- Check funding rates
- Discover available trading instruments
Prerequisites
pip install grvt-pysdk
Market data endpoints are public — no API key is needed for read-only data. However, if the user already has credentials configured, reuse their existing GrvtCcxt instance.
export GRVT_ENV="testnet"
SDK Setup
import os
from pathlib import Path
from pysdk.grvt_ccxt import GrvtCcxt
from pysdk.grvt_ccxt_env import GrvtEnv
env_file = Path(".env")
if env_file.exists():
for line in env_file.read_text().splitlines():
line = line.strip()
if line and not line.startswith("#") and "=" in line:
key, _, value = line.partition("=")
os.environ.setdefault(key.strip(), value.strip())
env = os.getenv("GRVT_ENV", "testnet")
api = GrvtCcxt(env=GrvtEnv.TESTNET if env == "testnet" else GrvtEnv.PRODUCTION)
Symbol Format
Perpetual symbols: {BASE}_{QUOTE}_Perp (e.g., BTC_USDT_Perp, ETH_USDT_Perp)
Instrument Discovery
markets = api.fetch_all_markets()
perps = [m for m in markets if m["kind"] == "PERPETUAL"]
for p in perps:
print(p["instrument"])
market = api.fetch_market("BTC_USDT_Perp")
Tickers (Current Prices)
ticker = api.fetch_mini_ticker("BTC_USDT_Perp")
print(f"Last: {ticker['last_price']}, Bid: {ticker['best_bid_price']}, Ask: {ticker['best_ask_price']}")
print(f"Mark: {ticker['mark_price']}, Index: {ticker['index_price']}")
ticker = api.fetch_ticker("BTC_USDT_Perp")
print(f"24h Buy Volume: {ticker['buy_volume_24h_b']} (base), {ticker['buy_volume_24h_q']} (quote)")
print(f"24h High: {ticker['high_price']}, Low: {ticker['low_price']}")
print(f"Funding Rate: {ticker['funding_rate']}")
print(f"Open Interest: {ticker['open_interest']}")
print(f"Long/Short Ratio: {ticker['long_short_ratio']}")
Orderbook
book = api.fetch_order_book("BTC_USDT_Perp", limit=10)
for bid in book["bids"][:5]:
print(f"Bid: {bid['price']} x {bid['size']} ({bid['num_orders']} orders)")
for ask in book["asks"][:5]:
print(f"Ask: {ask['price']} x {ask['size']} ({ask['num_orders']} orders)")
Available depth levels: 10, 50, 100, 500.
Recent Trades
trades = api.fetch_recent_trades("BTC_USDT_Perp", limit=20)
for t in trades:
side = "buy" if t["is_taker_buyer"] else "sell"
print(f"{side} {t['size']} @ {t['price']} (mark: {t['mark_price']})")
Candlestick / OHLCV Data
data = api.fetch_ohlcv(
symbol="BTC_USDT_Perp",
timeframe="1h",
limit=100,
params={"candle_type": "TRADE"},
)
for candle in data["result"][-5:]:
print(f"O:{candle['open']} H:{candle['high']} L:{candle['low']} C:{candle['close']} V:{candle['volume_b']}")
Candle types:
TRADE — Based on actual trade prices (default)
MARK — Based on mark price
INDEX — Based on index price
MID — Based on mid price
Funding Rates
data = api.fetch_funding_rate_history(
symbol="BTC_USDT_Perp",
limit=24,
)
for f in data["result"]:
print(f"Rate: {f['funding_rate']} at {f['funding_time']} (mark: {f['mark_price']})")
Working with DataFrames
For analysis tasks, convert to pandas:
import pandas as pd
data = api.fetch_ohlcv("BTC_USDT_Perp", timeframe="1h", limit=200)
df = pd.DataFrame(data["result"])
df["open_time"] = pd.to_datetime(df["open_time"].astype(float) / 1e9, unit="s")
df.set_index("open_time", inplace=True)
Important Notes
- Market data has ~3 months of historical retention
- Pagination is cursor-based and reverse chronological
- Use
GrvtEnv.PRODUCTION for real market data, GrvtEnv.TESTNET for testing
- Mini ticker is lighter weight than full ticker — use it when you only need price