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

Breakout/breakdown

"Kites rise highest against the wind—not with it."

– Winston Churchill

This is the oldest and simplest trend-following method. It works for both bull and bear markets. If the price makes a new high over x number of periods, the regime is bullish. If the price makes a fresh low over x number of periods, the regime is bearish. This method is computationally easy to implement.

Popular durations are 252 trading days (which works out as 52 weeks), and 100 and 50 trading days. Below, here is a simple rendition of this regime methodology:

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
 
ticker = '9984.T' # Softbank ticker...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Algorithmic Short Selling with Python
Published in: Sep 2021Publisher: PacktISBN-13: 9781801815192

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