Cloud or Local: Where to Run Your Quant Trading?Wed Nov 29 2023 by Brian Stanley
Is it better to run your quant trading in the cloud or locally? In this article, I outline the pros and cons of each approach and explain why running locally is often better for research while running in the cloud is better for live trading.
Don't assume the cloud is better
It's common to imagine that every serious workload should run in the cloud. We associate the cloud with modern, forward-looking companies and products. However, quants should analyze their use case and not make assumptions. Many commonly cited benefits of the cloud apply more to medium and large companies than to quant researchers working alone or in small teams. Articles touting the benefits of the cloud usually position the cloud as an alternative to an in-house data center. But for most quant researchers, the more applicable contrast is between the cloud and a local workstation.
The cloud is more expensive and less powerful than your local workstation
Companies often move to the cloud to save money, as they can rent compute resources for cheaper than they can pay in-house IT staff to manage an on-premise data center. But for a quant, the cloud is usually the more expensive option. Most quants already own a powerful workstation or laptop which is well-suited for quantitative research. The cloud introduces an additional expense.
Even if your workstation needs upgrading, buying a new workstation is usually a better deal than renting the equivalent machine in the cloud. A powerful workstation costs a few thousand dollars, while renting a comparably powerful cloud instance costs a few hundred dollars a month. This means that renting will become more expensive than buying within less than a year. And you can use the purchased workstation for multiple purposes, not just quant research.
If you run in the cloud, the high cost may lead you to skimp on resources and choose a less powerful machine than your local workstation, which will lessen the cost differential but slow down your research. Choosing a machine with ample CPU and memory is one of the most important things you can do to ensure a productive and enjoyable research experience.
One scenario where the cloud is cheaper than running locally is when you need specialized compute resources for a temporary workload, like training a machine learning model that requires more GPU than your local workstation offers. In this case, the temporary nature of the workload makes renting cheaper than buying.
The cloud provides an isolated environment, but so can Docker
Historically, an advantage of the cloud over a local workstation was that it provides an isolated environment that you can customize with the exact packages you need for your research. If you mess up the environment, you can destroy the cloud instance and start over with a fresh instance. In contrast, since you use your local workstation for multiple purposes, you can't as easily or safely wipe out your environment and start over.
This advantage of the cloud is less relevant today because of Docker. With Docker, you can create a custom environment for your research that runs on your local workstation yet is isolated from the rest of your operating system. You can destroy the environment and start over just as you would with a cloud instance. In fact, Docker is more flexible than the cloud alone because Docker allows you to deploy the same application to the cloud or to your local workstation without any changes to the application. This makes it easy to migrate back and forth between your workstation and the cloud or to deploy to both environments. Docker is the technology QuantRocket uses to support both local and cloud deployments.
The cloud is more reliable than your home office
Cloud providers have redundant power supplies and internet connections, as well as teams of engineers on call to fix problems. This is an area where the cloud handily beats a local workstation running in your home office. Unless you have a long-running generator and a backup internet connection, running locally makes you more vulnerable to outages than running in the cloud.
However, the superior uptime of the cloud is only relevant to live trading and other unattended processes. It doesn't help with research or anything interactive: a local outage that takes down your workstation will also take down your ability to access the cloud, disrupting your activity either way.
Can you use a local machine for live trading?
Using a local workstation for live trading is possible if your trading strategy trades infrequently enough that you can recover from temporary outages. For example, a strategy that trades once a day after the close can recover from a temporary outage because you can simply re-run the trades when power is restored. In contrast, outages are more disruptive for a strategy that trades every minute as they will cause you to miss time-sensitive opportunities.
Use a different machine for research and live trading
Whether you run locally or in the cloud, use a dedicated machine for live trading, not the same machine you use for research or other purposes. Your own research activities, if performed on the same computer as your live trading, are much more likely to crash your live trading than an occasional power outage or lost internet connection. Every time you load a large dataset into memory or run a CPU-intensive analysis, you will jeopardize the ability of your live trading to run smoothly.
Quants deciding where to run their infrastructure should weigh the cost and performance benefits of running locally against the reliability benefits of running in the cloud. A basic rule of thumb is to run your research locally and run your live trading in the cloud.
QuantRocket is a Python-based platform for researching, backtesting, and trading quantitative strategies. It provides a JupyterLab environment, offers a suite of data integrations, and supports multiple backtesters: Zipline, the open-source backtester that originally powered Quantopian; Alphalens, an alpha factor analysis library; Moonshot, a vectorized backtester based on pandas; and MoonshotML, a walk-forward machine learning backtester. Built on Docker, QuantRocket can be deployed locally or to the cloud and has an open architecture that is flexible and extensible.