GPL-licensed software integrations in QuantRocket

QuantRocket's satellite service lets you integrate arbitrary Python or Debian packages and execute arbitrary commands via the client library. The usage guide shows an example of integrating the open-source backtesting framework backtrader.

We fielded a concern suggesting that integrating backtrader might not be permissible under backtrader's license terms (GPLv3), so we wanted to provide transparency about how the integration works in order to assure users that there's no license infringement.

Bottom line: By maintaining proper separation between QuantRocket components and GPL-licensed backtrader code, QuantRocket doesn't violate backtrader’s GPLv3 license.

How the satellite service integrates user-installed packages

The GPL requires you to make your source code available if you combine it with GPL software. Combining means combining them into one executable or running them in the same process (for example, using import in the context of Python).

QuantRocket is a mix of open-source and proprietary components in a microservices architecture. For example, when you import the quantrocket package, you're importing QuantRocket's open-source client library. The client library makes HTTP requests to the various web apps that make up your QuantRocket deployment. These web apps run as binaries inside Docker containers, alongside many other packages and binaries. The web apps constitute QuantRocket's proprietary code.

QuantRocket’s proprietary code never imports backtrader or any other GPL-licensed code. When you run backtrader in QuantRocket as in the example docs, you instruct QuantRocket to execute your backtrader script (or any other script or executable) via the command line.

quantrocket satellite exec 'python /codeload/backtrader/dual_moving_average.py' --return-file '/tmp/backtrader-plot.pdf' --outfile 'backtrader-plot.pdf'

This command uses the (open-source) client library to connect to the (proprietary) web app inside the satellite Docker container and instruct the web app to execute the command you provide. In this case you're telling it to execute your Python script which contains your backtrader strategy (python /codeload/backtrader/dual_moving_average.py); you could also execute any other arbitrary command including common GPL-licensed Linux programs like cat, rm, or ls. The command is executed via Python's subprocess module, which spawns a new process. The fact that backtrader (or other script or executable) runs in a separate process is a key point, as discussed in the next section.

You may note that the demo backtrader script itself imports the quantrocket package and wonder if this means QuantRocket and backtrader are running in the same process. The answer is that the demo script only imports QuantRocket's open-source client library. When called, the client library makes HTTP requests to other Docker containers running other (proprietary) QuantRocket web apps. Once again, backtrader and proprietary QuantRocket code are kept completely separate—in this case separated by an HTTP request-response cycle—and never execute in the same process.

The GPL and "Mere Aggregation"

To understand why this design is permissible under the GPL, you must understand the GPL's concept of "mere aggregation". Because QuantRocket's proprietary web app code only communicates with backtrader via a separate subprocess, QuantRocket and backtrader are "merely aggregated" in GPL terminology rather than being combined into one program. The GPL FAQ on Mere Aggregation explains:

pipes, sockets and command-line arguments are communication mechanisms normally used between two separate programs. So when they are used for communication, the modules normally are separate programs.

The GPL FAQ on plugins makes a similar point. Here you can think of QuantRocket as the main program and backtrader or other user-installed packages as the plugins:

A main program that uses simple fork and exec to invoke plug-ins and does not establish intimate communication between them results in the plug-ins being a separate program.

Because QuantRocket and backtrader communicate as separate programs, QuantRocket itself need not be be issued under a GPL-compatible license:

if they are separate works then the license of the plug-in makes no requirements about the main program.

Viewing GPL source code

Should you wish to access the source code of user-installed Python packages in the satellite container, you can easily do so by opening a shell into the container then listing the packages:

$ docker compose exec satellite bash
root@74d5086cf3de:/# ls /opt/conda/lib/python3.6/site-packages/backtrader

Further reading

More on open source in QuantRocket

QuantRocket takes open source licenses seriously and tracks all open source libraries utilized within QuantRocket. For a full-list of open source software used in QuantRocket, see our open source notices page. Please address any questions regarding open source software in QuantRocket to opensource@quantrocket.nobots.com.