Reader small image

You're reading from  Algorithmic Short Selling with Python

Product typeBook
Published inSep 2021
PublisherPackt
ISBN-139781801815192
Edition1st Edition
Right arrow
Author (1)
Laurent Bernut
Laurent Bernut
author image
Laurent Bernut

Laurent Bernut has 2 decades of experience in alternative investment space. After the US CPA, he compiled financial statements in Japanese and English for a Tokyo Stock Exchange-listed corporation. After serving as an analyst in two Tokyo-based hedge funds, he joined Fidelity Investments Japan as a dedicated quantitative short-seller. Laurent has built numerous portfolio management systems and developed several quantitative models across various platforms. He currently writes and runs algorithmic strategies and is an undisputed authority on short selling on Quora, where he was nominated top writer for 2017, 2018, and 2019.
Read more about Laurent Bernut

Right arrow

Preface

"There is nothing more powerful than an idea whose time has come."

– Victor Hugo

Market participants always want industries to become more efficient: "cut the middle man," "cost-reduction," "rationalization."  We are finally getting a taste of our own medicine. Markets average long-term returns of 8% per annum. Yet, roughly 60% of professional fund managers underperform their benchmark, year in year out. 90% of retail investors blow up. The way we trade has clearly not been working. Despite all the bravado, the emperors of money have been parading naked. We collectively need to evolve if we want to survive this market Darwinism. Evolution does not take prisoners.

Global warming is a reality in the financial services. The glacier of actively managed money is melting. Mutual funds face intense pressure from exchange traded funds to lower fees. Fortunately, there has been a solution right under our noses all along, a terra incognita where mankind has never set foot.

If we were to stack all books about investing, trading, markets, on top of each other, trips to the moon would be a sad ecological reality. Yet, if we were to line up books about short selling side by side on a dinner table, there would still be enough room for a bottle of Côte-Rôtie, a divine northern Rhône valley Shiraz-Viognier wine, and a few glasses. Short selling is the key to raising and maintaining assets under management. When the markets tank, those who still stand up, stand out. Money may temporarily flow (and ebb) to those who shine in bull markets, but it will always gravitate towards those who perform in down markets. Investors may forget unimpressive returns, yet they will not forgive drawdowns.

Short selling commands premium fees. Suppose you add a short book to your endangered long-only mutual fund. From that day on, you can command premium management fees and even demand steep performance fees. You will enjoy more freedom in your mandate to trade exotic instruments, freedom to keep a higher cash balance, freedom to selectively disclose your positions. And the price of freedom is to learn to sell short.

Who this book is for

This book is written by a practitioner for practitioners. It is for advanced to expert market participants. Even if you have never coded a line in Python, this book is still for you. It was originally written without the source code. This later addition is meant to help readers implement the concepts in real life. If you are an experienced coder but new to the markets, you will pick up concepts that will help you on your journey. You may however want to supplement your market education with further reading.

Even if you choose never to sell short, this book is still for you. The tools and techniques developed for the short side are built to withstand extreme conditions. If you can survive the arid environment of the short side, imagine how you will thrive on the long side. If you are in the long/short business, the question is not whether you should read this book or not. The real question is can you afford to not read this book. You may disagree with some ideas, but they will provoke thoughts and spark conversation. The ideas we originally resist are the ones that makes us grow, so welcome to the space beyond your comfort zone.

What this book covers

Part I, The Inner Game: Demystifying Short Selling

Chapter 1, The Stock Market Game, discusses a few questions: "Is the stock market an art or a science? What if it was just a game? How do you win an infinite complex random game?" This chapters sets the context of the rest of the book.

Chapter 2, 10 Classic Myths About Short Selling, dispels enduring myths about short selling. The most important question is: "do you want to retire on numbers or stories?" If the former, then short sellers are your pension's best friend.

Chapter 3, Take a Walk on the Wild Short Side, explains the arc of the long side mindset on the short side and its predictable failure. This chapter describes the three endemic challenges of the short side: market dynamics, scarcity mentality, and information asymmetry.

Part II, The Outer Game: Developing a Robust Trading Edge

Chapter 4, Long/Short Methodologies: Absolute and Relative, addresses idea generation. You will be able to consistently generate as many if not more ideas on the short side than on the long side.

Chapter 5, Regime Definition, explains several regime definition methodologies to reclassify stocks as bullish, bearish, or inconclusive.

Chapter 6, The Trading Edge is a Number, and Here is the Formula, aims to demystify the mythical, mystical, magical trading edge. Regardless of the asset class and timeframes, there are only two strategies. We explain the pros and cons of each one.

Chapter 7, Improve Your Trading Edge, outlines seven ways to improve the distribution of returns and build a robust trading edge.

Chapter 8, Position Sizing: Money is Made in the Money Management Module, proves that money is made in the money management module. We introduce a game changing approach to equity curve trading.

Chapter 9, Risk is a Number, introduces four risk metrics that unapologetically measure robustness. Short sellers are exceptional risk managers.

Part III, The Long/Short Game: Building a Long/Short Product

Chapter 10, Refining the Investment Universe, explains some common pitfalls to avoid, and investors' desires to address, in order to help distill a large population of stocks into an investable universe. This chapter paves the way to the final part of the book.

Chapter 11, The Long/Short Toolbox, dives into the four most important levers to manage a long/short portfolio. Now that we know what clients want, we look at the tools available to achieve those objectives.

Chapter 12, Signals and Execution, brings together concepts covered in previous chapters, and goes through signal processing, execution, and other vital components when constructing a long/short investment product.

Chapter 13, Portfolio Management System, looks at one of the most underrated tools in your arsenal. Now that you have added a relative short book, whatever tools you have been using so far are in dire need of a radical upgrade. This chapter goes over topics which will help when designing your own Portfolio Management System.

Appendix, Stock Screening, provides a stock screener tool that will address idea generation, the most pressing issue for market participants, and allow you to put everything you have learned into practice.

To get the most out of this book

Sometimes we win, sometimes we learn. The best disposition to get the maximum out of this book is to have lost money on the markets. This will put you in an open state of mind!

Intermediate knowledge of Python, specifically the use of numpy, pandas, and matplotlib will suffice. We will also use some non-standard Python libraries; yfinance and scipy. High school level competence in algebra and statistics is also necessary.

Download the example code files

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Algorithmic-Short-Selling-with-Python. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781801815192_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example; "From the rolling_profits and rolling_losses functions, calculate profit_ratio."

A block of code is set as follows:

# Import Libraries
import pandas as pd
import numpy as np
import yfinance as yf
%matplotlib inline
import matplotlib.pyplot as plt

Any command-line input or output is written as follows:

3.52

Bold: Indicates a new term, an important word, or words that you see on the screen, for example, in menus or dialog boxes, also appear in the text like this. For example: "Did the price beat the volume at weighted average price (VWAP) or not?"

Warnings or important notes appear like this.

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email feedback@packtpub.com, and mention the book's title in the subject of your message. If you have questions about any aspect of this book, please email us at questions@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book we would be grateful if you would report this to us. Please visit, http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packtpub.com.

Share your thoughts

Once you've read Algorithmic Short Selling with Python, we'd love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Algorithmic Short Selling with Python
Published in: Sep 2021Publisher: PacktISBN-13: 9781801815192
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Laurent Bernut

Laurent Bernut has 2 decades of experience in alternative investment space. After the US CPA, he compiled financial statements in Japanese and English for a Tokyo Stock Exchange-listed corporation. After serving as an analyst in two Tokyo-based hedge funds, he joined Fidelity Investments Japan as a dedicated quantitative short-seller. Laurent has built numerous portfolio management systems and developed several quantitative models across various platforms. He currently writes and runs algorithmic strategies and is an undisputed authority on short selling on Quora, where he was nominated top writer for 2017, 2018, and 2019.
Read more about Laurent Bernut