Streamz with websocket not steaming any data
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- pandas, python
- Ambito
- stream-processing
Direzione di ricerca
Start at the WebSocket callbacks, update_dataframe, source.emit, and source.map(print_result) shown in the issue. Trace whether messages reach source.emit and whether the mapped consumer runs; done means identifying the missing connection or usage detail that prevents received data from being printed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am trying to figure out a right way of streaming data using streamz with websocket. My streaming data is loaded using websocket but not streaming anything.
import config
import websocket, json
import pandas as pd
from streamz.dataframe import DataFrame
from streamz import Stream
import time
ticker_list = ["SCHG"]
# Create DataFrame with specified columns and ticker_list as index
df = pd.DataFrame(columns=['Bid', 'Ask', 'Time'], index=ticker_list)
source = Stream()
def update_dataframe(json_message, df):
ticker_data = json_message[0]
ticker_symbol = ticker_data['S']
df.loc[ticker_symbol, 'Bid'] = ticker_data['bp']
df.loc[ticker_symbol, 'Ask'] = ticker_data['ap']
df.loc[ticker_symbol, 'Time'] = pd.to_datetime(ticker_data['t'], unit='s').tz_localize('UTC').tz_convert('America/New_York').strftime('%Y-%m-%d %H:%M:%S%z')
source.emit(df.copy()) # Emit the updated DataFrame to the stream
def on_open(ws):
print("opened connection")
# Authentication
auth_data = {"action":"auth","key": config.API_KEY,"secret": config.SECRET_KEY}
# Subscribe
ws.send(json.dumps(auth_data))
listen_message = {"action":"subscribe","quotes":ticker_list}
ws.send(json.dumps(listen_message))
print('subscribed')
def on_message(ws, message):
json_message = json.loads(message)
# Update the DataFrame and emit it to the stream
update_dataframe(json_message, df)
def on_close(ws):
print("closed connection")
def print_result(x):
print(x)
sink = source.map(print_result) # Set up a sink to consume and process the emitted data
socket = "wss://stream.data.alpaca.markets/v2/iex"
ws = websocket.WebSocketApp(socket, on_open=on_open, on_message=on_message, on_close=on_close)
ws.run_forever()
- Lingua principale
- Python
- Stelle
- 1.3k
- Fork
- 149
- Merge medio
- 17h 39m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-streamz/streamz
-
pkg_resources warning Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
python-streamz/streamz#481 · 4 commenti ·
-
Combining the streamz.Stream.filenames() and streamz.Stream.from_textfile() using dask scatter? Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
python-streamz/streamz#480 · 2 commenti ·
-
Compile the code into c++ Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
python-streamz/streamz#479 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
python-streamz/streamz#478 · 6 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 10/100
python-streamz/streamz#476 · 17 commenti · 2 reazioni ·
Tutte le issue di python-streamz/streamz
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/skills#1811 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speaches-ai/speaches#678 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
datalayer/mcp-compose#42 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UKGovernmentBEIS/inspect_evals#2523 ·