Skip to content

Commit

Permalink
fix: Support websockets 14 (#528)
Browse files Browse the repository at this point in the history
* fix: support websockets 14

* chore: fix black
  • Loading branch information
hiohiohio authored Nov 26, 2024
1 parent e6edb1e commit c564495
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion alpaca/data/live/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions alpaca/trading/stream.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c564495

Please sign in to comment.