Skip to main content

Module massive

Module massive 

Source
Expand description

Massive (formerly Polygon.io) market data (behind massive feature). Massive (formerly Polygon.io) market data connectors.

Provides access to institutional-grade market data across all major asset classes: stocks, options, indices, forex, crypto, and futures.

§Data licensing — redistribution prohibited

This crate’s code is MIT-licensed; the data it retrieves is not. Massive’s Market Data Terms of Service (§5(c)) prohibit redistributing the data to third parties. Use it for your own purposes only, and do not commit it, publish it, or serve it onward.

§Testing Status

Partially integration-tested. We have a currencies subscription (crypto + forex) but not stocks, options, indices, or futures subscriptions. Verified endpoints:

  • ✅ REST aggregates (crypto, forex, stocks, options, futures via free tier)
  • ✅ REST tick trades (crypto)
  • ✅ REST quotes (forex)
  • ✅ WebSocket streaming (crypto, forex)
  • ✅ Reference data (tickers, exchanges, market status, holidays)
  • ✅ Corporate actions (dividends, splits)
  • ✅ Options contracts reference data (free tier)
  • ❌ Options snapshots with Greeks — requires Options Starter subscription
  • ❌ REST aggregates (indices) — requires indices subscription
  • ❌ REST tick trades (stocks) — requires stocks subscription
  • ❌ REST quotes (stocks) — requires stocks subscription
  • ❌ WebSocket (stocks, options) — requires a stocks or options subscription

Unit tests for JSON transformation live inline in reference.rs, options.rs, transformer.rs and message.rs. Live API integration tests are in tests/massive_integration.rs.

§Architecture

§Authentication

Requires MASSIVE_API_KEY environment variable from an active Massive subscription. Get your API key from: https://massive.com/dashboard/api-keys

§One connection per cluster

Massive allows a key a fixed number of WebSocket connections per cluster — stocks, options, forex and crypto count separately — one on an individual plan. Past the limit it closes the older connection. Every stream a MassiveSubscriber and its clones open on a cluster therefore shares one socket to it. Pass clones of one subscriber to every stream on the key; see connection for the details.

§Symbol Conventions

Important: REST API and WebSocket use different symbol formats!

§REST API Symbols

  • X:BTCUSD — Crypto
  • C:EURUSD — Forex
  • O:AAPL251219C00150000 — Options
  • I:SPX — Indices
  • AAPL — Stocks

§WebSocket Symbols

The connectors spell these from each instrument; see MassiveSymbols.

  • BTC-USD — Crypto (hyphenated)
  • EUR/USD — Forex (slashed: the cluster accepts EUR-USD too, but delivers its data as EUR/USD)
  • O:AAPL251219C00150000 — Options
  • AAPL — Stocks

§Supported Streams

KindStocks / OptionsCryptoForex
PublicTradesTXT— (no trades)
Quotes, OrderBooksL1QXQC
Candles at Sec1AXASCAS
Candles at Min1AMXACA

Massive aggregates at no other interval, so a Candles subscription at any other is refused before anything is sent. Forex quotes carry no sizes, so their amounts are zero, and forex candles report no volume: Massive builds them from quote updates, not trades. Only crypto’s trade conditions say which side took liquidity, so a stock or option trade has no side.

§Examples

§REST Client

ⓘ
use rustrade_data::exchange::massive::MassiveRestClient;

let client = MassiveRestClient::from_env()?;
let candles = client.fetch_aggregates("X:BTCUSD", 1, "minute", from, to).await?;

§WebSocket Streams

ⓘ
use rustrade_data::exchange::massive::{MassiveCrypto, MassiveSubscriber};
use rustrade_data::streams::Streams;
use rustrade_data::subscription::trade::PublicTrades;
use rustrade_instrument::instrument::market_data::kind::MarketDataInstrumentKind;

// Load the key at construction time (fails fast if the variable is missing)
let subscriber = MassiveSubscriber::from_env()?;

let streams = Streams::<PublicTrades>::builder()
    .subscribe(
        subscriber,
        [(MassiveCrypto::default(), "btc", "usd", MarketDataInstrumentKind::Spot, PublicTrades)],
    )
    .init()
    .await?;

Modules§

channel
The Massive WebSocket channel each subscription kind reads.
connection
One WebSocket per Massive cluster, shared by every stream a MassiveSubscriber and its clones open on it.
market
How each Massive cluster spells a market on its WebSocket.
message
Massive WebSocket market data messages, and the transformer turning them into market events.
stream
The Massive market stream.

Structs§

Address
Company address.
CurrencyStatus
Currency market status.
Dividend
Dividend information.
DividendQuery
Filter parameters for the /v3/reference/dividends endpoint.
Exchange
Exchange information.
FairMarketValue
Fair Market Value - a calculated mid-price from Massive.
MarketHoliday
Market holiday information.
MarketStatus
Current market status.
Massive
Generic Massive WebSocket connector, one per cluster.
MassiveCredentials
The API key authenticating to Massive’s WebSocket.
MassiveOptionContract
Option contract from the Massive contracts endpoint.
MassiveOptionSnapshot
Option snapshot with Greeks and market data from Massive.
MassiveRestClient
REST client for Massive historical and intraday market data.
MassiveServerCrypto
The crypto cluster.
MassiveServerForex
The forex cluster.
MassiveServerOptions
The options cluster.
MassiveServerStocks
The stocks cluster.
MassiveStatus
A Massive status message: {"ev":"status","status":"success","message":"subscribed to: XT.BTC-USD"}.
MassiveSubResponse
A Massive frame of status messages, as a subscribe is answered.
MassiveSubscriber
Massive market data subscriber: authenticates, and shares one connection per cluster among every stream it and its clones open.
OptionContractQuery
Filter parameters for the /v3/reference/options/contracts endpoint.
OptionDayBar
Daily OHLCV bar for an option contract.
OptionQuote
Option quote (bid/ask).
OptionSnapshotQuery
Filter parameters for option snapshot endpoints.
OptionTrade
Option trade.
SplitQuery
Filter parameters for the /v3/reference/splits endpoint.
StockSplit
Stock split information.
Ticker
Ticker summary from the tickers list endpoint.
TickerDetails
Detailed ticker information from the ticker details endpoint.
TickerQuery
Filter parameters for the /v3/reference/tickers endpoint.
UnderlyingAsset
Underlying asset data included in option snapshots.

Enums§

DividendFrequency
Dividend payment frequency.
MassiveError
Massive-specific errors.
SortOrder
Sort order for paginated results.

Constants§

WEBSOCKET_URL_CRYPTO
Crypto WebSocket URL.
WEBSOCKET_URL_FOREX
Forex WebSocket URL.
WEBSOCKET_URL_OPTIONS
Options WebSocket URL.
WEBSOCKET_URL_STOCKS
Stocks WebSocket URL.

Type Aliases§

MassiveCrypto
Massive crypto connector.
MassiveForex
Massive forex connector. Forex publishes no trades, so it serves no PublicTrades.
MassiveOptions
Massive options connector (untested — requires an options subscription).
MassiveStocks
Massive stocks connector.