diff --git a/alpaca/data/live/websocket.py b/alpaca/data/live/websocket.py index c8966abe..f29ce780 100644 --- a/alpaca/data/live/websocket.py +++ b/alpaca/data/live/websocket.py @@ -7,6 +7,7 @@ import msgpack import websockets from pydantic import BaseModel +from websockets.legacy import client as websockets_legacy from alpaca import __version__ from alpaca.common.types import RawData @@ -94,7 +95,7 @@ async def _connect(self) -> None: } log.info(f"connecting to {self._endpoint}") - self._ws = await websockets.connect( + self._ws = await websockets_legacy.connect( self._endpoint, extra_headers=extra_headers, **self._websocket_params, diff --git a/alpaca/trading/stream.py b/alpaca/trading/stream.py index 78a2374c..7f67cf46 100644 --- a/alpaca/trading/stream.py +++ b/alpaca/trading/stream.py @@ -1,11 +1,12 @@ -import json -import queue -from typing import Optional, Dict, Callable, Union import asyncio -import websockets +import json import logging +import queue +from typing import Callable, Dict, Optional, Union +import websockets from pydantic import BaseModel +from websockets.legacy import client as websockets_legacy from alpaca.common import RawData from alpaca.common.enums import BaseURL @@ -56,7 +57,9 @@ def __init__( self._websocket_params = websocket_params async def _connect(self): - self._ws = await websockets.connect(self._endpoint, **self._websocket_params) + self._ws = await websockets_legacy.connect( + self._endpoint, **self._websocket_params + ) async def _auth(self): await self._ws.send(