---
title: "The Working Environment - 1"
description: "A Docker research environment for trading: Debian, Miniconda, JupyterLab and zipline-reloaded started with docker compose, plus datalake ingestion."
url: "https://pythonparatrading.com/en/docker-for-trading/"
lang: "en"
date: "2024-04-10"
updated: "2026-09-04"
image: "https://pythonparatrading.com/content/images/2025/04/dockertrading.png"
tags: ["Big Data"]
authors: ["Jesús Cuesta"]
---

# The Working Environment - 1

> A Docker container with Debian, Miniconda, JupyterLab and zipline-reloaded so the research environment starts with one command.

- Language: en (English)
- Published: 2024-04-10
- Updated: 2026-09-04
- Topics: Big Data
- Requires: Docker · Docker Compose · git
- Code: https://github.com/quantarmyz/quantstack
- Summary: In this new article, we cover how to create a professional environment for algorithmic quant trading. To do so, we use a stack of technologies that make deployment easier, allowing us to focus on pure research rather than infrastructure.

Key points:

- Why to package OS, environments and libraries in one image shared by the team.
- Project layout: Dockerfile, .env, Zipline and JupyterLab optimisations.
- Building and starting the stack with docker compose and opening JupyterLab on localhost:8888.
- Ingesting the datalake into Zipline with zipline ingest -b qa_datalake.

---

## Background

Within the field of financial engineering, we use a wide collection of tools and libraries that were never designed to be used together. Consequently, we need to package all the necessary libraries and avoid conflicts with other projects or enable portability.

If we add that team members do not use the same operating systems, etc., a blend of configurations is generated, and we need the development environment to be homogeneous for all team members. Consequently, we would also need to include the operating system and additional configurations within the package.

To solve this, we are going to create a Docker image, a container system that allows us to virtualize specific applications instead of an entire operating system.

The plan is to create a Docker container with the operating system, the Python environment and package manager, and the necessary tools for quant research.

Once the container is created and compiled, only a single command line will be needed to have the environment ready to access in less than 10 seconds.

## What's inside the stack?

Inside our Docker image, we will have a global configuration that will be used across all projects, and another configuration with a more project-specific setup.

For the global configuration, we will use Debian as the operating system. Why? Because it is stable and requires very little maintenance. Alpine is not an option because our goal is not to save resources, and any other operating system is automatically ruled out.

To manage environments and packages, we use miniconda, which provides a Python environment ready to run, along with other necessary libraries such as environment add-ons, JupyterLab itself, etc.

Within the project-specific part, we will install the necessary packages and customizations. In this case, we will create a simple initial configuration where we will use zipline-reloaded and pyfolio-reloaded.

We will create a "Hello World" within zipline, where once the entire environment is deployed, we run a basic backtest to verify the project works. Anyway, the project is under constant maintenance and improvements, since I personally use this same environment (in more advanced versions; here we release somewhat older methods).

Stack components summary:

-   Debian GNU Linux
-   Miniconda3
-   JupyterLab
-   Configuration files and JupyterLab configuration libraries
-   Configuration files, optimizations, and libraries to work with zipline.
-   Extras: Files such as research examples, code optimizations, a local datalake, or any other information needed for the stack.

## Final Advantage

Once the image is compiled, we will only need to run the command

```shell
docker compose up -d
```

to have the environment up and running.

## Creating a stack

First, we need to create the project structure, which consists of:

![Quantstack project explorer: DockerSource folder with Dockerfile, .env and req.txt, and docker-compose.yml](https://pythonparatrading.com/content/images/external/quantarmy.com/content/images/2024/01/image-13.png)

Two main folders. In the folder called DockerSource, we have everything related to building the image.

-   .env: Private environment data to connect to the datalake, etc.
-   Dockerfile: Docker image build instructions, where the specific steps that are automated up to the image creation are defined
-   extension.py: Zipline optimizations
-   overrides.json: JupyterLab optimizations
-   req.txt: Detailed list of packages needed to install in the environment via pip.
-   qa\_datalake.py: Datalake ingestion code into zipline.

Inside the second folder, we include the so-called workdirs, or working directories, which are the directories where the initial information that the researcher will interact with is stored.

In this case, we have a series of folders that group notebooks or documentation by themes that have been or will be relevant at some point.

![Quantstack project explorer: quantarmy_repo folder with the working directories (backtest, datalake, models…)](https://pythonparatrading.com/content/images/external/quantarmy.com/content/images/2024/01/image-14.png)

## Building the image

### 1 - Clone the repository

Download the latest version of the code from the repository.

```bash
    git clone https://github.com/quantarmyz/quantstack.git
```

### Create environment file .env

Create a `.env` file inside the `DockerSource` folder like:

`/quantstack/DockerSource/.env`

File format:

```bash
ENDPOINT=TuEndPoint.COM
DB=TuBucket
ACCESS_KEY=TuAccessKey
SECRET_KEY=TuSecretKey
```

### Building the image

From the terminal, in the `/quantstack` path, run:

```bash
docker compose build --no-cache
```

### Optional Docker Compose Configuration

Edit `/quantstack/docker-compose.yml` as needed (configuring the token is recommended).

### Start the stack

Run the following command for debug mode:

```bash
docker compose up
```

To run in the background:

```bash
docker compose up -d
```

### Accessing JupyterLab

If no modifications have been made, the address is:

```bash
localhost:8888
```

Password:

```bash
testing
```

### Adding a Data Feed to Zipline

From JupyterLab, open a terminal and run:

```bash
conda activate base
zipline ingest -b qa_datalake
```

This will connect to the datalake, download the data, and add it to the Zipline database.

## Backtesting Example

![Backtesting Example](https://pythonparatrading.com/content/images/external/quantarmy.com/content/images/2024/01/image-15.png)

In the image, you can see how we launched the default backtesting template in the qastack.

## Video

To make things easier, I recorded a video where I compile the image and run it. In less than 9 minutes, the stack can be up and running.

[Video: quantstackPoC.mp4](https://pythonparatrading.com/content/images/external/quantarmy.com/content/media/2024/01/quantstackPoC.mp4)

## Full Repository

> **[GitHub - quantarmyz/quantstack: QUANTARMY quantstack | One-click quantitative envoirment based in docker, debian, conda, jupyterlabs,zipline-reloaded and arcticdb](https://github.com/quantarmyz/quantstack.git)**
> QUANTARMY quantstack | One-click quantitative envoirment based in docker, debian, conda, jupyterlabs,zipline-reloaded and arcticdb - GitHub - quantarmyz/quantstack: QUANTARMY quantstack | One-click…

**Related posts:** [Big Data Management 3: Building a Datalake on the Nasdaq with ArcticDB](https://pythonparatrading.com/en/big-data-with-arcticdb/).
