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

The Trading Edge is a Number, and Here is the Formula

In this chapter, we will unveil one of the most well-guarded secrets in the finance industry: behind the curtain is not an old man, but a simple formula. Then, we will decompose this formula into two distinct modules: signal and money management.

Within the signal module, we will explore how to time entries and exits, and the properties of the two strategy types that seem to provide a trading edge; trend following and mean reversion. We will continue this discussion in Chapter 7, Improve Your Trading Edge, before covering the money management module in more depth in Chapter 8, Position Sizing: Money is Made in the Money Management Module.

Along the way, we will cover the following topics:

  • Importing libraries
  • The trading edge formula: arithmetic and geometric gain expectancy
  • A trading edge is not a story
  • Regardless of the asset class, there are only two strategies

You can access...

Importing libraries

For this chapter and the rest of the book, we will be working with the pandas, numpy, yfinance, and matplotlib libraries. So, please remember to import them first:

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

The trading edge formula

"Information is not knowledge."

– Albert Einstein, patent clerk

Who said that science fiction hasn't found its way into the austere world of finance? Ask any hedge fund manager about their edge and you will enter a world of crusaders against corporate cabals, financial Sherlock Holmeses patiently piecing the information puzzle together, and visionaries investing in the next new [insert the next disruptive technological buzzword here…].

Everyone in the trading business will say that you need an edge to make money. Yet, they will never tell you how to build a sustainable one, presumably for fear that dissemination could erode theirs. Understandably, the trading edge has been this mysterious secret sauce.

There are only three common types of edge: technological, information, and statistical, which will be considered over the next few sections.

Technological edge

Any retail trader today...

A trading edge is not a story

"If you can't measure it, you can't improve it."

– Peter Drucker

A trading edge is not a story. A trading edge is a number, and the formula is composed of a few functions:

  1. Arithmetic gain expectancy: In execution trader English, this is how often you win multiplied by how much you make on average minus how often you lose times how much you lose on average. This function is the classic arithmetic expectancy, present in every middle school introduction to statistics and absent in a Finance MBA. When talking about trading edges or gain expectancy, market participants default to the arithmetic gain expectancy. It is easy to grasp and calculate. The simplicity of this formula imposes itself, even to those who do not understand its sophistication.
    # Expectancy formula, win_rate is your Hit ratio, avg_win is the average gain per trade, and avg_loss is the average loss per trade
    def expectancy...

Regardless of the asset class, there are only two strategies

Jack Schwager often points out that there is no universal holy grail. Market wizards come in all shapes and forms, sometimes even with contradicting strategies. They have one thing in common though. They excel at managing risk and controlling losses. They consistently focus on the downside. Winning positions take care of themselves. Market participants' job is to take care of losers.

Market participants usually define themselves by "what" they trade (asset class, markets, time horizon), rarely "how" they trade. Regardless of the asset class, there are only two types of strategies: trend following and mean reversion. The reason why there are only two strategies is not entries but exits. How you choose to close a trade determines your dominant trading style. The mean reversion camp closes early when inefficiencies are corrected. The trend-following crowd loves to ride their winners. A classic example...

Summary

Let's recap. The mysterious, mystical, mythical, magical trading edge is nothing but a little formula we learned back in school called gain expectancy. Now, it turns out that strategies with a positive trading edge tend to fall into two buckets. This happens regardless of time frames, asset classes, instrument, and market phases. Market participants expect inefficiencies to either correct and revert to the mean, or to persist and form trends. Those strategies are mutually exclusive. They have opposite payoffs and risk profiles.

We then took time to understand the properties of each strategy type so that we can come up with better ways to engineer a superior trading edge. Now that we understand how those strategies behave, the next step is to roll up our sleeves, pop the hood, and tune up the signal engine.

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