Reading notes for the book Python for Algorithmic Trading.

Python For Algo Trading Book Cover

Chapter 1 Python and Algorithmic Trading

The Python programming language originated in 1991 and quick became widely adopted in 2011. The finance industry was mostly built on C and C++ which are really fast at execution as they are complied. In 2006, Numpy was released, which uses specialization to avoid overhead and achieved as good and fast as possible in certain scenarios. Then came Scipy and Pandas, all of which contributed to its success of Python in finance.

Algorithmic Trading

Algorithmic trading, on a basic level, refers to the trading of financial instruments based on an algorithm.

The objective of financial trading includes but not limited to the following:

  • Beta trading: Earning market risk premia by investing in, for instance, ETFs that replicate the performance that of the S&P 500.
  • Alpha generation: Earning risk premia independent of the market by longing and shorting at the same time.
  • Static hedging: Hedging against market risks by buying, for example, out-of-the-money put options on the S&P 500.
  • Dynamic hedging: Hedging against market risks affecting options.
  • Asset-liability management: Trading S&P 500 stocks and ETFs to be able to cover liabilities resulting from, for example, writing life insurance policeys.
  • Market making: Providing, for exmaple, liquidity to options on the S&P 500 by buying and selling options at different bid and ask prices.

The book focuses on algorithmic trading in the context of alpha generating strategies. alpha is seen as the difference between a trading strategy’s return over some period of time and the return of the benchmark (single stock, index, etc).

There are other areas where trading-related algorithms play an important role. One is the high frequency trading (HFT) space, where speed is key. Another one is trade execution, where algorithms are deployed to optimally execute certain nonstandard trades.

Trading Strategies

Four different algorithmic trading strategies are used as examples in the book. All these strategies can be classified as mainly alpha seeking strategies, since their main objective is to generate positive, above-market returns independent of the market direction.

  • Simple Moving Averages
  • Momentum
  • Mean Reversion
  • Machine and Deep Learning

Chapter 2 Python Infrastructure

to be continued