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

Long/Short 2.0: the relative weakness method

"Truth is by nature self-evident. As soon as you remove the cobwebs of ignorance that surround it, it shines clear."

– Mahatma Gandhi

Indices such as S&P 500, Nasdaq 100, FTSE 100, and Topix are the market capitalization weighted average of their constituents. Roughly half the stocks will do better and the rest worse than the index over any timeframe. There are many more stocks to pick from the large contingent of relative underperformers than the few and far between stocks that drop in absolute value.

Below is the source code to calculate relative series:

def relative(df,_o,_h,_l,_c, bm_df, bm_col, ccy_df, ccy_col, dgt, start, end,rebase=True):
    '''
    df: df
    bm_df, bm_col: df benchmark dataframe & column name
    ccy_df,ccy_col: currency dataframe & column name
    dgt: rounding decimal
    start/end: string or offset
    rebase: boolean rebase to...