Skip to main content

MesoLive Data Hub

Use MesoLiveDataHubClient for live quotes/greeks/PnL snapshots and server-streaming updates.

Snapshot vs stream

Most Data Hub APIs have both forms:

  • Snapshot (get_*_snapshot): one response (point-in-time)
  • Stream (stream_*_data): async iterator yielding incremental updates until cancelled/disconnected

For monitoring loops, streams are convenient, but not lossless (see “Streaming semantics”).

Include and fields

Most endpoints let you choose:

  • which blocks to include: LiveDataInclude.Prices, Greeks, PnL (or All)
  • which quote bases to include inside a block: LiveQuoteFields.Bid, Ask, Last, Mark (or All)

If you don’t include a block, its corresponding payload field is None.

Provider selection

Provider behavior differs by endpoint:

  • Position-/leg-bound endpoints can infer a default provider from the position. Provider=None is usually fine:
    • StreamPositionData, GetPositionSnapshot
    • StreamLegData, GetLegSnapshot
    • StreamLegsData, GetLegsSnapshot
  • Free-standing endpoints require an explicit provider (server-side requirement):
    • StreamUnderlyingData, GetUnderlyingSnapshot
    • StreamContractData, GetContractSnapshot
    • StreamComboContractsData, GetComboContractsSnapshot

If you omit Provider for a provider-required endpoint, you should expect a request failure (typically surfaced as a MesoLiveSignalRError for streams or MesoLiveApiException for snapshots).

Streaming semantics

Streams are optimized for “latest value” delivery:

  • The server coalesces bursts of underlying market-data ticks into a small time window.
  • Server stream channels are bounded and configured to drop older items when the client is slow.
  • The SDK also uses a bounded queue per stream; if you don’t consume quickly enough, it may drop items locally.

Design implication: do not treat streams as “every tick”. Treat them as “keep me up to date”.

Practical patterns:

  • If you need hard resync, call a snapshot endpoint periodically.
  • Consider LivePrices.*AgeMs to detect stale data.

Common recipes

Stream position prices + greeks

python -m mesolive_sdk_examples.data_example position stream --position-id 789 --seconds 30

Snapshot a position

python -m mesolive_sdk_examples.data_example position snapshot --position-id 789

Stream an underlying

python -m mesolive_sdk_examples.data_example underlying snapshot --symbol SPX --provider IBKR
python -m mesolive_sdk_examples.data_example underlying stream --symbol SPX --provider IBKR --seconds 30

Stream an arbitrary option combo

Use this when you want quotes for a candidate structure that is not yet a position.

args = models.StreamComboContractsDataArgs(
Provider=models.DataProviderType.IBKR,
Include=models.LiveDataInclude.Prices,
PriceFields=models.LiveQuoteFields.Bid | models.LiveQuoteFields.Ask | models.LiveQuoteFields.Mark,
ComboLegs={
"L1": models.ComboLegSpec(Contract=leg1_contract, Qty=1),
"L2": models.ComboLegSpec(Contract=leg2_contract, Qty=-1),
},
)

async for entry in data.stream_combo_contracts_data(args):
print("combo mark=", entry.ComboPrices.Mark)

Operational troubleshooting

When a stream fails early, the most common causes are:

  • missing/invalid Provider for provider-required endpoints
  • the selected provider’s agent is not connected or cannot resolve the requested contract/underlying
  • missing market data entitlements → quotes may be None or stale

For general troubleshooting patterns, see Troubleshooting.