Skip to content

WebSocket

adasThePrime edited this page Apr 11, 2026 · 1 revision

WebSocket

Synchronous WebSocket client for real-time Yahoo Finance price streaming. Incoming data is Protocol Buffer (protobuf) encoded and base64-wrapped, Pyahoo decodes it automatically into PricingData objects for easy consumption.

from pyahoo import WebSocket
# or
from pyahoo.websocket import WebSocket

Constructor

WebSocket(
    *,
    url: str = STREAMER_URL,
    version: int = STREAMER_VERSION,
    reconnect: bool = True,
    reconnect_base: float = STREAMER_RECONNECT_BASE,
    reconnect_max: float = STREAMER_RECONNECT_MAX,
    max_reconnect_attempts: int | None = None,
    proxy: str | None = None,
    queue_size: int = 10_000
)

Parameters

  • url (str, optional): WebSocket URL, by default "wss://streamer.finance.yahoo.com/".
  • version (int, optional): API version parameter, by default 2.
  • reconnect (bool, optional): Whether to auto-reconnect on disconnection, by default True.
  • reconnect_base (float, optional): Base delay for exponential backoff (seconds), by default 1.0.
  • reconnect_max (float, optional): Maximum reconnect delay (seconds), by default 60.0.
  • max_reconnect_attempts (int, optional): Maximum reconnection attempts, or None for unlimited.
  • proxy (str, optional): Proxy URL.
  • queue_size (int, optional): Maximum number of ticks buffered for iteration, by default 10_000.

Clone this wiki locally