Welcome to our Knowledge Base

Illustration with Infantino’s PCA Strategy

You are here:
< last topic

Illustration with Infantino’s PCA Strategy

In this tutorial, we demonstrate some powerful features of AlgoQuant (which is backed by our SuanShu library) using Infantino’s PCA strategy as an example. All the code referenced in this tutorial can be found in algoquant/model/infantino2010 package and its demo.

Powerful Mathematical Support

AlgoQuant is backed by our numerical library (SuanShu), so computing strategy signals becomes a very simple task, and the code usually takes only a few lines. For example, Infantino’s strategy computes its buy/sell signals based on principal component analysis (PCA). Here is the code snipplet for the computation of matrix D for the “dimensionally reduced returns” (mentioned on pages 25 and 26 in the paper):

Quick Strategy Prototyping

With AlgoQuant, coding strategies for simulation can be done with minimal effort. A strategy class just needs to implement an interface, Strategy. Simulation in AlgoQuant is event-driven, so a strategy just needs to subscribe to the events it is interested, such as price changes, order executions, etc. By implementing the corresponding event handlers, the strategy is called back when the subscribed events happened. Here is the skeleton for Infantino Strategy which makes trade descisions upon price updates:

Convenient Data Loading

Historical price data from various sources (e.g., Bloomberg, Yahoo! Finance, Gain Capital, Compustat, etc.) can be loaded for simulation. For example, we use end-of-day data from Yahoo! Finance in our simulation. The following code snippet loads the data files cached in the harddrive or automatically downloads them from Yahoo! Finance website if the cache is absent.

Simple Simulation Setup

Simulator with various options can be configured easily. For example, we configure the simulator to update the strategy with synchronized views of product depths by this:

Flexible & Extendible Performance Measures for Analysis

There are plenty of performance measures available for you to analyze the performance of your strategy (see performance package for more details). You can also conveniently develop your own set of measures.

Parallelized Sensitivity Analysis and Monte Carlo Simulation

Usually, a strategy takes in a few parameters, and we want to find the optimal ones to trade with. In addition, we are also interested in how sensitive the strategy’s performance is to the change of these parameters. With parallelized SensitivityAnalyzer in AlgoQuant, you can find the answer in plots with a few lines of code (see Infantino2010ParamAnalysis):

The simulations on various parameters run in parallel by utilizing all the available CPU cores, so that results can be obtained multiple times faster. Besides, you can also run MCSimulation with customizable price models.

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Table of Contents

Leave a Reply

Your email address will not be published. Required fields are marked *