Machine Learning for Algorithmic Trading
上QQ阅读APP看书,第一时间看更新

4 Financial Feature Engineering – How to Research Alpha Factors

Algorithmic trading strategies are driven by signals that indicate when to buy or sell assets to generate superior returns relative to a benchmark, such as an index. The portion of an asset's return that is not explained by exposure to this benchmark is called alpha, and hence the signals that aim to produce such uncorrelated returns are also called alpha factors.

If you are already familiar with ML, you may know that feature engineering is a key ingredient for successful predictions. This is no different in trading. Investment, however, is particularly rich in decades of research into how markets work, and which features may work better than others to explain or predict price movements as a result. This chapter provides an overview as a starting point for your own search for alpha factors.

This chapter also presents key tools that facilitate computing and testing alpha factors. We will highlight how the NumPy, pandas, and TA-Lib libraries facilitate the manipulation of data and present popular smoothing techniques like the wavelets and the Kalman filter, which help reduce noise in data.

We will also preview how you can use the trading simulator Zipline to evaluate the predictive performance of (traditional) alpha factors. We will discuss key alpha factor metrics like the information coefficient and factor turnover. An in-depth introduction to backtesting trading strategies that use machine learning follows in Chapter 6, The Machine Learning Process, which covers the ML4T workflow that we will use throughout this book to evaluate trading strategies.

In particular, this chapter will address the following topics:

  • Which categories of factors exist, why they work, and how to measure them
  • Creating alpha factors using NumPy, pandas, and TA-Lib
  • How to denoise data using wavelets and the Kalman filter
  • Using Zipline offline and on Quantopian to test inpidual and multiple alpha factors
  • How to use Alphalens to evaluate predictive performance and turnover using, among other metrics, the information coefficient (IC)

You can find the code samples for this chapter and links to additional resources in the corresponding directory of the GitHub repository. The notebooks include color versions of the images. The Appendix, Alpha Factor Library, contains additional information on financial feature engineering, including more than 100 worked examples that you can leverage for your own strategy..