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: remove f-string for enum #385

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

hiohiohio
Copy link
Contributor

@hiohiohio hiohiohio commented Dec 4, 2023

fixes #383

Context:

  • there is 404 error when subscribe crypto data feed

Changes:

  • avoid using f-string for enum

Ref:

  • log indicates that enum value is used for f-string replacement for this issue. CryptoFeed.US should be us in the very last line of the below.
>>> wss_client.run()
DEBUG:asyncio:Using selector: EpollSelector
INFO:alpaca.common.websocket:started data stream
INFO:alpaca.common.websocket:starting data websocket connection
DEBUG:websockets.client:= connection is CONNECTING
DEBUG:websockets.client:> GET /v1beta3/crypto/CryptoFeed.US HTTP/1.1

You can test this by

$ docker run -it --entrypoint bash python:3.12-slim
$ apt-get update && apt-get install git -y
$ pip install git+https://github.com/hiohiohio/alpaca-py.git@fix-stream-url-not-found
$ python3

import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

API_KEY=''
SECRET=''
from alpaca.data.live import CryptoDataStream
wss_client = CryptoDataStream(API_KEY, SECRET)

async def bars_data_handler(data):
    print(data)

wss_client.subscribe_bars(bars_data_handler, "BTC/USD")
wss_client.run()

@hiohiohio hiohiohio merged commit a126123 into alpacahq:master Dec 5, 2023
5 checks passed
@hiohiohio hiohiohio deleted the fix-stream-url-not-found branch December 5, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Data WebSocket Error: Restarting Connection Due to Server Rejected WebSocket Connection (HTTP 404)
2 participants