How to Leverage the Cloud for Algorithmic Trading

by Nitikesh Pattanayak
McKlayne Marshall

Understanding the accessible cloud technologies available in the market and when to use the different services for the variety of types of algorithmic trading

Co-authored with Isaac Rhea

Photo by Dallas Reedy on Unsplash

The combination of computers and massive amounts of market data has made algorithmic trading the norm. Around 80% of trades in the US stock market are done by computers and algorithms. 80% of the stock market is now on autopilot (cnbc.com). Wall Street has been taking advantage of these tools for some time because they had the monetary resources to leverage technology that was relatively expensive and not available to the public.

The compute and data landscape has been changing over the last decade with the cloud (AWS, Google Cloud, Azure, etc.) and APIs (Yahoo Finance, AlpacaDB, Alpha Vantage). The biggest hurdle for those who are new to algorithmic trading is understanding the different terms, technicalities, and nuances of these new technologies. This article will focus primarily on cloud technologies and some things to consider when deciding which of the many (100+) services to use.

Before solutioning and jumping into AWS (Amazon cloud offering) or GCP (Google’s cloud offering) to find the correct tool, it is crucial to understand the different types of strategies and ways of algorithmically trading. It is also key to assess the variety of markets, the risks associated with trading with algorithms, etc. For example, if you are hoping to algorithmically trade equities in the US stock market, there are certain trading regulations such as day trading; whereas, the cryptocurrency market does not have any day trading regulations but rather charges a fee per trade.

There are thousands of different trading strategies that can be automated, but there are three different methods used to automate: continuous, event-based, and a hybrid of continuous and event-based

Continuous

The most popular method of automating any trading strategy is by continuously monitoring market data and running it through rules and logic. When the certain parameters are met, the trades will be placed automatically.

Event-Based

Event-based trading is when a certain moment in time, market or news signals a trading strategy to run. A simple example of this would be triggering a trading process to run an hour after the market opens and running on the hour until the market closes.

Hybrid

A hybrid approach may be advantageous when a combination of continuous processes can be used to trigger parallel event-based trading strategies. A good example of this methodology would be continuously monitoring several data sources such as twitter and google trends, that when certain parameters have been met, trigger an event-based trading strategy.

Next, we will explore how a few specific cloud technologies and infrastructures can be leveraged to accomplish each method of algorithmic trading.

Server

Cloud computing was built off of making servers accessible to others via the internet. There are certain fixed costs associated with running on a server and oftentimes you aren’t using the full capacity of the server. This is where companies such as Amazon, Google, and Microsoft entered and started building large data centers and started selling that extra capacity to others. The convenience is the fixed costs vanish and you pay for what you use.

Serverless

Serverless is where the cloud provider takes care of the servers and allows for certain types of execution models to run on the server when prompted or desired by the user. The most common example is when a small chunk of code needs to be run for a short amount of time and at a specific time.

A continuous trading strategy, like monitoring cryptocurrency data using a websocket and then trading based on logic, would be best accomplished by leveraging a server in the cloud like AWS EC2.

An event-based trading strategy, such as checking the price of a stock at the top of the hour and then trading based on logic, would be best accomplished by a serverless option like AWS Lambda and applying a cron job with a service like EventBridge to trigger the lambda to run. Depending on the complexity of the logic and what packages you need to do the logic, there are different ways of setting up a lambda.

A hybrid between continuous and event-based methodologies is made possible by leveraging a server that could then trigger a serverless module to run the logic for the trade. This would allow for more robust orchestration and being able to run processes in parallel. But this would also require a more advanced understanding of cloud services such as EC2 and Lambda.

When it comes to leveraging computers for trading, the accessibility of cloud technologies is changing the game.

The key is understanding the variety of strategies and methodologies before getting lost in all of the different cloud services out there. Once that is defined, there are many ways to accomplish the “how”. Continuously monitoring a certain cryptocurrency and making trades directly on a server, or triggering a lambda to run certain trading logic an hour into the market, or maybe you will monitor r/wallstreetbets with an EC2 instance and trigger a lambda to run when a certain number of people are talking about a specific stock.

The cloud is a powerful tool that can help actualize any algorithmic trading strategy. The most difficult part is being creative and intentional about how it is leveraged. Hopefully these thoughts and ideas are helpful to get started.

Happy building!

More content at plainenglish.io

You may also like

Leave a Reply