Market Data Reference
HyperionX exposes bar data, tick updates, market data events, and depth snapshots to scripts.
Bar Data
Primary bar series:
OpenHighLowCloseVolumeDateTime
Ctx.MarketData.GetCandles(seriesIndex) returns candle objects for the primary or extra series.
var candles = Ctx.MarketData.GetCandles();
var extraCandles = Ctx.MarketData.GetCandles(1);
MarketDataEventArgs
OnMarketData(MarketDataEventArgs marketData) receives:
| Field | Meaning |
|---|---|
Instrument | Current instrument. |
Candle | Current candle. |
Tick | Tick candle/update when available. |
Time | Event time. |
Price | Event price. |
Volume | Event volume. |
BidVolume | Bid-side volume when available. |
AskVolume | Ask-side volume when available. |
TradeCount | Trade count when available. |
IsFirstTickOfBar | Whether this is the first tick of a bar. |
public override void OnMarketData(MarketDataEventArgs marketData)
{
if (marketData.IsFirstTickOfBar)
Print($"New bar: {marketData.Time}");
}
Market Depth
Ctx.MarketData exposes best bid/ask and depth snapshots.
double bid = Ctx.MarketData.Bid;
double ask = Ctx.MarketData.Ask;
double spread = Ctx.MarketData.Spread;
var depth = Ctx.MarketData.GetDepth(20);
Async version:
var depth = await Ctx.MarketData.GetDepthAsync(20);
Depth subscription:
Ctx.MarketData.SubscribeDepth(depth: 20, refreshMilliseconds: 1000);
Ctx.MarketData.UnsubscribeDepth();
MarketDepthSnapshot
| Field | Meaning |
|---|---|
Symbol | Snapshot symbol. |
Provider | Provider/connection name. |
ReceivedAt | UTC receive time. |
Bids | Bid levels. |
Asks | Ask levels. |
HasDepth | Whether bids or asks exist. |
BestBid | Top bid price. |
BestAsk | Top ask price. |
Each MarketDepthLevel includes:
PriceSizeOrderCount
OrderCount depends on provider support.
Provider Support Direction
Current provider work includes REST/WebSocket market data, historical candles, broker connection adapters, and depth providers for supported connections. Hyperliquid, KuCoin, Binance, and other providers can implement IMarketDepthProvider so scripts can use the same Ctx.MarketData.GetDepth(...) path.
Order-flow tools need two data classes:
- real trades: prints, aggressor side, volume, and timestamps where the provider exposes them
- book depth: bid/ask levels, sizes, and order counts where the provider exposes them
When provider data is missing, scripts should degrade cleanly and show no-depth/no-trade state rather than throwing.
Bar Timer Helpers
bool timeBased = Ctx.MarketData.IsTimeBasedSeries;
System.TimeSpan? remaining = Ctx.MarketData.GetTimeRemainingInBar();
These helpers return null for series that do not have a fixed time duration.