This repository contains the example code for a tutorial about how to send alerts to Slack based on changes in market data streamed to QuestDB. Stock prices are fetched from the IexFinance API using the iexfinance Python package, streamed into QuestDB, a time series database, and alerts are set up in Grafana based on the metrics we care about.
- Docker
- Python 3.7+
- IexFinance account with an API key, free plans are available
- Slack workspace
./docker-compose.yml
: starts QuestDB and Grafana./python/
: holds Python files used in the tutorial:mock_stock_data_example.py
: generate mock datastock_data_TSLA_example.py
: polls IexFinance API and publishes records to QuestDB.env
file for storing our API key
-
Obtain an API key from IexFinance console
-
In the
./python
directory, create a file named.env
-
Place the API key in this file in the following format:
API_KEY=ncp2syw...
-
Run docker compose:
docker-compose up
The following services are now running:
Install the necessary packages:
pip install -r requirements.txt
Poll the IexFinance API and send Tesla prices to QuestDB
cd python
python stock_data_TSLA_example.py
(Optional) Run the script to send mock API data to QuestDB:
cd python
python mock_stock_data_example.py