Real-time Option Data

This API provides option market data on a websocket stream. This helps receive the most up to date market information that could help your trading strategy to act upon certain market movements. If you wish to access the latest pricing data, using the stream provides much better accuracy and performance than polling the latest historical endpoints.

You can find the general description of the real-time WebSocket Stream here. This page focuses on the option stream.

URL

The URL for the option stream is

wss://stream.data.alpaca.markets/v1beta1/{feed}

Sandbox URL:

wss://stream.data.sandbox.alpaca.markets/v1beta1/{feed}

Substitute indicative or opra to {feed} depending on your subscription. The difference between the two feeds is described here.

Any attempt to access a data feed not available for your subscription will result in an error during authentication.

Message format

🚧

Msgpack

Unlike the stock and crypto stream, the option stream is only available in msgpack format. The SDKs are using this format automatically. For readability, the examples in the rest of this documentation will still be in json format (because msgpack is binary encoded).

Channels

Trades

Schema

AttributeTypeNotes
Tstringmessage type, always “t”
Sstringsymbol
tstringRFC-3339 formatted timestamp with nanosecond precision
pnumbertrade price
sinttrade size
xstringexchange code where the trade occurred
cstringtrade condition

Example

{
  "T": "t",
  "S": "AAPL240315C00172500",
  "t": "2024-03-11T13:35:35.13312256Z",
  "p": 2.84,
  "s": 1,
  "x": "N",
  "c": "S"
}

Quotes

Schema

AttributeTypeNotes
Tstringmessage type, always “q”
Sstringsymbol
tstringRFC-3339 formatted timestamp with nanosecond precision
bxstringbid exchange code
bpnumberbid price
bsintbid size
axstringask exchange code
apnumberask price
asintask size
cstringquote condition

Example

{
  "T": "q",
  "S": "SPXW240327P04925000",
  "t": "2024-03-12T11:59:38.897261568Z",
  "bx": "C",
  "bp": 9.46,
  "bs": 53,
  "ax": "C",
  "ap": 9.66,
  "as": 38,
  "c": "A"
}

Errors

Other than the general stream errors, you may receive these option-specific errors during your session:

Error MessageDescription
[{"T":"error","code":412,"msg":"option messages are only available in MsgPack format"}]Use the Content-Type: application/msgpack header.
[{"T":"error","code":413,"msg":"star subscription is not allowed for option quotes"}]You cannot subscribe to * for option quotes (there are simply too many of them).