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

Moving average crossover

Moving averages are another popular regime definition method. This method is so simple and prevalent that even the most hardcore fundamental analysts who claim never to look at charts still like to have a 200-day simple moving average. This method is also computationally easy. There may be further refinements as to the type of moving averages from simple to exponential, triangular, adaptive. Yet, the principle is the same. When the faster moving average is above the slower one, the regime is bullish. When it is below the slower one, the regime is bearish. The code below shows how to calculate the regime with two moving averages using simple and exponential moving averages (SMA and EMA respectively):

#### Regime SMA EMA ####
def regime_sma(df,_c,st,lt):
    '''
    bull +1: sma_st >= sma_lt , bear -1: sma_st <= sma_lt
    '''
    sma_lt = df[_c].rolling(lt).mean()
    sma_st = df[_c].rolling(st).mean()
    rg_sma...
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