Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support websockets 14 #528

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading