This is a proof-of-concept for building a low-latency stream processing service on Raspberry-Pi with Docker. The project is deployed via docker-compose and builds a TimescaleDB record store, Grafana dashboard, and async websocket client that pulls market/crypto data from Alpaca. Feed latency is approximately 100ms, but could be massively improved with some simple code improvements.
- Replace the keys values in the secrets/*.env.placeholder files with your environment secrets/configs/tokens. The Alpaca API token will require you to set up a free account with Alpaca
- Install Docker and docker-compose on your Raspberry Pi
- Create a docker volume to match the docker-compose file (e.g. market-data)
- From the project directory, run
docker-compose build && docker-compose up -d
- The first time I ran the docker-compose script, I changed the
alpaca-client
entrypoint to"poetry run python /app/main.py reset-database"
to initialize the database tables. Once the tables are built, change the entrypoint back topython /app/main.py start_crypto_client
- The first time I ran the docker-compose script, I changed the
- Once deployed, grafana will start a service on
<machine_ip>:3000
.