Redpanda University is a series of courses that will teach you the basics of event streaming, and will help you gain hands-on experience with a new data streaming platform called Redpanda.
This course and the corresponding code were created for illustrative purposes only, and neither Redpanda nor the contributors to this course are recommending any specific trading strategies, stocks, or cryptocurrencies. Our intent is to help you explore this exciting field by creating a fun and foundational project to help you learn. It's up to you to test your strategies fully before deploying them to a live trading environment.
This repository contains code examples for the Algorithmic Trading course from Redpanda University. The following chapters are included:
- Chapter 1: Flink intro (creating Redpanda-backed Flink pipelines)
- Chapter 2: Data Collection
- Chapter 3: Strategy Testing
There are three steps you need to get started. It should take < 5 minutes.
- Setup a Python environment
- Start the Docker services
- Get an Alpaca API key
See the follow sections for detailed instructions.
A Python environment is needed to run the producer scripts to get the financial and market news data into Redpanda, and for running a separate consumer to process trade signals.
Create a Python virtual environment and install all dependencies.
# create a virtual environment
python3 -m venv .
# activate the environment
source bin/activate
# install dependencies
pip install -r requirements.txt
We need a Redpanda cluster to store the data, and a Flink cluster to create trade signals using Flink SQL. To start the Redpanda and Flink clusters, run the following commands:
docker-compose build
docker-compose up -d
Once the clusters are running, Redpanda console will be available at: http://localhost:8080.
To interact with Redpanda from the commandline, set the following alias so that any invocation of rpk
uses the pre-installed version in your local Redpanda cluster:
alias rpk="docker exec -ti redpanda-1 rpk"
From here, you can use rpk
to interact with the Redpanda cluster:
rpk cluster info
The Flink web interface will be available at: http://localhost:8081.
To start a Flink SQL client, run the following command:
docker-compose run sql-client
You can verify that everything is running properly in the Flink cluster by running the following SQL statements from the prompt:
SET 'pipeline.name' = 'Hello, Flink';
SELECT
CONCAT('Hello, ', name) as greeting
FROM
(VALUES ('Flink'), ('Redpanda'), ('Alpaca')) AS NameTable(name)
GROUP BY name;
Each chapter will contain a set of queries for you to execute. Please see in the individual chapters for more information.
We're using Alpaca as the source for market data.
-
Create an API key from the Alpaca Paper Trading dashboard.
-
Replace the following lines in the .env file with your API key and secret
ALPACA_API_KEY="<YOUR_ALPACA_KEY_ID>" ALPACA_SECRET_KEY="<YOUR_ALPACA_SECRET_KEY>"