Building algorithmic trading strategies with Amazon SageMaker

 Building algorithmic trading strategies with Amazon SageMaker

Financial institutions invest heavily to automate their decision-making for trading and portfolio management. In the US, the majority of trading volume is generated through algorithmic trading. [1]

With cloud computing, vast amounts of historical data can be processed in real time and fed into sophisticated machine learning (ML) models. This allows market participants to discover and exploit new patterns for trading and asset managers to use ML models to construct better investment portfolios.

In this post, we explain how to use Amazon SageMaker to deploy algorithmic trading strategies using ML models for trade decisions. In the following sections, we go over the high-level concepts. The GitHub repo has the full source code in Python.

Solution overview

The key ingredients for our solution are the following components:

  • SageMaker on-demand notebooks to explore trading strategies and historical market data
  • Training and inference of ML models in a built-in container with Amazon SageMaker
  • Backtrader, an open-source Python framework, for backtesting trading strategies and for writing reusable strategies, indicators, and analyzers

Architecture for building and backtesting of trading strategies

We use Jupyter notebooks as our central interface for exploring and backtesting new trading strategies. Amazon SageMaker allows you to set up Jupyter notebooks and integrate them with AWS CodeCommit to store different versions of strategies and share them with other team members.

Because we want to focus on ML-based strategies, we need a scalable data store, so we use Amazon Simple Storage Service (Amazon S3) to store historical market data, model artifacts, and backtesting results.

For our trading strategies, we create Docker containers that contain the required libraries for backtesting and the strategy itself. These containers follow the SageMaker Docker container structure in order to run them inside of SageMaker along with the ML models. For more information about the structure of SageMaker containers, see Using the SageMaker Training and Inference Toolkits.

An advantage to this approach is that we can use the same APIs and the SageMaker management console for ML and backtesting.

The following diagram illustrates this architecture.

The following diagram illustrates this architecture.

Architecture for hosting of trading strategies

For live trading, we assume that we can run trading strategies in a container that connects to a broker that provides market data, takes orders, and notifies about trades. To host the containers, we can use SageMaker or AWS Fargate. SageMaker can host the ML models that we use for trade decisions.

The following diagram illustrates this architecture.

The following diagram illustrates this architecture.

In the following sections, we focus on backtesting and ML for algorithmic trading strategies. 

Backtesting trading str

[...]

Source - Continue Reading: https://aws.amazon.com/blogs/machine-learning/building-algorithmic-trading-strategies-with-amazon-sagemaker/

webmaster

Related post