This project demonstrates how you can use Redis Stack to create a real-time stock watchlist application. It uses several different features of Redis:
- Sets
- Pub/Sub
- Hashes -Redis Time Series
- RedisBloom
- Redis JSON
- Redis Search
- Install Docker
Set the following environment variables in a .env file in the root directory of the project:
APCA_API_KEY_ID
: Your Alpaca API Key found on the Alpaca dashboardAPCA_API_SECRET_KEY
: Your Alpaca API Secret found on the Alpaca dashboard
$ docker-compose --env-file ./.env up -d
After the containers are up and running (for the first time), go into the data
directory and run:
$ pip install -r requirements.txt
$ python main.py
- python 3.6+
- pip
Create a .env
file in the root directory of the project and set the following environment variables:
APCA_API_KEY_ID=<your-api-key>
APCA_API_SECRET_KEY=<your-api-secret>
REDIS_URL=<redis-url>
REDIS_OM_URL=<redis-url>
Create a .env
file in the ui
directory of the project and set the following envionrment variables:
NEXT_PUBLIC_API_URL=http://localhost:8000/api/1.0
NEXT_PUBLIC_WS_URL=ws://localhost:8000
From the root directory, run the following commands:
$ python -m venv ./.venv
Run the following commands in the stream
directory:
$ pip install -r requirements.txt
$ python main.py
Run the following commands in the api
directory:
$ pip install -r requirements.txt
$ uvicorn main:app
Run the following commands in the web
directory:
$ npm install
$ npm run dev
- There is a known issue with the Alpaca websocket API thread safety. You will find a workaround in the alpaca.py file.
Redis offers managed hosting for Redis Stack for free, and you can even get $200 in credits towards a paid subscription by using code TIGER200.