Show HN: FastAPI Realtime Stock Monitor with Python worker threads
I built a real-time stock monitoring demo that simulates market data streams to show how to handle multiple real-time updates in Python without complex dependencies like Celery.
Key concepts:
- Worker threads for background processing
- Event-driven architecture with emitter-listener pattern
- WebSocket for real-time updates
- Clean separation of concerns
The application uses PynneX (a lightweight Python library) to implement:
1. Signal/slot pattern for event handling
2. Worker thread management
3. Thread-safe task queuing
Technical stack:
- FastAPI for the web framework
- WebSocket for real-time communication
- ag-Grid for interactive data display
- eCharts for candlestick visualization
No message brokers, no task queues, no complex setup - just Python's built-in threading and asyncio with a thin event-driven layer.
Quick start:
pip install pynnex fastapi python-socketio uvicorn
python examples/fastapi_socketio_stock_monitor.py
Then open http://localhost:8000
Code: https://github.com/nexconnectio/pynnex/blob/main/examples/fa...
reply