Book Image

Algorithmic Short Selling with Python

By : Laurent Bernut
Book Image

Algorithmic Short Selling with Python

By: Laurent Bernut

Overview of this book

If you are in the long/short business, learning how to sell short is not a choice. Short selling is the key to raising assets under management. This book will help you demystify and hone the short selling craft, providing Python source code to construct a robust long/short portfolio. It discusses fundamental and advanced trading concepts from the perspective of a veteran short seller. This book will take you on a journey from an idea (“buy bullish stocks, sell bearish ones”) to becoming part of the elite club of long/short hedge fund algorithmic traders. You’ll explore key concepts such as trading psychology, trading edge, regime definition, signal processing, position sizing, risk management, and asset allocation, one obstacle at a time. Along the way, you’ll will discover simple methods to consistently generate investment ideas, and consider variables that impact returns, volatility, and overall attractiveness of returns. By the end of this book, you’ll not only become familiar with some of the most sophisticated concepts in capital markets, but also have Python source code to construct a long/short product that investors are bound to find attractive.
Table of Contents (17 chapters)
14
Other Books You May Enjoy
15
Index

Comparing position-sizing algorithms

Let's take an example to further illustrate the principle. Let's use the exact same signals and starting capital. Then, let's use various position-sizing algorithms. Let's compute the equity curve for each position-sizing algorithm. The objective is to see how much position sizing impacts returns.

For demonstration purposes, we will recycle our go-to Softbank in absolute with Turtle for dummies, along with our regime_breakout() function from Chapter 5, Regime Definition. Once again, please do not do this at home, as it is too simplistic to be deployed in a professional investment product:

def regime_breakout(df,_h,_l,window):
    hl =  np.where(df[_h] == df[_h].rolling(window).max(),1,
                                np.where(df[_l] == df[_l].rolling(window).min(), -1,np.nan))
    roll_hl = pd.Series(index= df.index, data= hl).fillna(method= 'ffill')
    return roll_hl
 
def turtle_trader(df, _h, _l, slow...