Introduction

Growth stocks refer to high-quality, successful companies whose earnings are expected to continue growing at an above-average rate relative to the market. Growth stocks generally have high price-to-earnings (P/E) ratios and high price-to-book (P/B) ratios. At times, growth stocks are considered expensive and overvalued. The value stocks refer to stocks which have high dividend payout ratios or low financial ratios such as P/E ratios and P/B ratios. The value stocks are often considered undervalued by the market. This algorithm will create the long-short positions based on the relation between investor sentiment and the performance of value stocks over growth stocks.

Method

The measure of investment sentiment

To measure investors' sentiment, we use gauges: the CBOE Equity put-call ratio and the market volatility (VIX) Index. The VIX Index is constructed using the implied volatilities on S&P 500 Index Options and shows the market's expectation of 30-day volatility. The CBOE Equity put-call ratio is calculated by dividing the trading volume of CBOE Equity put options by the trading volume of CBOE Equity call options. A rising put-call ratio means Equity traders are buying more puts than calls and indicates a bearish sentiment in the market while a falling put-call ratio is considered as the bullish market sentiment.

We import the daily VIX data from Quandl. CBOE provides the volume put-call ratio data from 11-01-2006 to present so we download the data from the CBOE website and import it into our algorithm.

class SentimentAndStyleRotationAlgorithm(QCAlgorithm):
  def initialize(self):
      self.set_start_date(2010, 1, 1)
      self.set_end_date(2018, 7, 1)
      self.set_cash(100000)
      self.add_data(CBOE, "VIX", Resolution.DAILY)
      self.add_data(PutCallRatio, "PutCallRatio", Resolution.DAILY)

class PutCallRatio(PythonData):
    '''Cboe Equity Volume Put/Call Ratios (11-01-2006 to 10-04-2019) Custom Data Class'''
    def get_source(self, config, date, isLiveMode):
        return SubscriptionDataSource("https://cdn.cboe.com/resources/options/volume_and_call_put_ratios/totalpc.csv", SubscriptionTransportMedium.REMOTE_FILE)

    def reader(self, config, line, date, isLiveMode):
        if not (line.strip() and line[0].isdigit()): return None
        index = CBOE()
        index.symbol = config.symbol

        try:
            # Example File Format:
            # DATE       CALL      PUT       TOTAL      P/C Ratio
            # 11/1/06    976510    623929    1600439    0.64
            data = line.split(',')
            index.time = datetime.strptime(data[0], "%m/%d/%Y").strftime("%Y-%m-%d")
            index.value = Decimal(data[4])

        except ValueError:
                return None

        return index

The Measure of the Growth and Value Stocks

All stocks on NYSE and NASDAQ are used as the investment universe. In the CoarseSelectionFunction, we eliminate ETFs which don't have fundamental data. In the FineSelectionFunction, stocks are sorted into deciles based on a size measure - market capitalization. We use only the first three size deciles for the algorithm to avoid potential problems with small illiquid stocks.

def fine_selection_function(self, fine):
    if self.month_start:
        self.selection = True

        fine = [i for i in fine if i.earning_reports.basic_average_shares.three_months>0
                                and i.earning_reports.basic_e_p_s.twelve_months>0
                                and i.valuation_ratios.pe_ratio>0
                                and i.valuation_ratios.p_b_ratio>0]
        # sort fine object by MarketCap
        sotrted_market_cap = sorted(fine, key = lambda x:x.market_cap, reverse=True)
        decile_top1 = sotrted_market_cap[:floor(len(sotrted_market_cap)/10)]
        decile_top2 = sotrted_market_cap[floor(len(sotrted_market_cap)/10):floor(len(sotrted_market_cap)*2/10)]
        decile_top3 = sotrted_market_cap[floor(len(sotrted_market_cap)*2/10):floor(len(sotrted_market_cap)*3/10)]

In the next step, we subdivide each size decile into five portfolios based on the P/B ratio. For each of the first three size deciles, the value portfolio consists of all firms included in the quintile with the lowest P/B ratio, and the growth portfolio consists stocks with the highest P/B ratio.

sorted_PB1 = sorted(decile_top1, key = lambda x: x.valuation_ratios.p_b_ratio)
sorted_PB2 = sorted(decile_top2, key = lambda x: x.valuation_ratios.p_b_ratio)
sorted_PB3 = sorted(decile_top3, key = lambda x: x.valuation_ratios.p_b_ratio)
# The value portfolio consists of all firms included in the quintile with the lowest P/B ratio
PB_bottom1 = sorted_PB1[:floor(len(decile_top1)/5)]
PB_bottom2 = sorted_PB2[:floor(len(decile_top2)/5)]
PB_bottom3 = sorted_PB3[:floor(len(decile_top3)/5)]
self.value_portfolio = [i.symbol for i in PB_bottom1 + PB_bottom2 + PB_bottom3]
# The growth portfolio consists of all firms included in the quintile with the highest P/B ratio
PB_top1 = sorted_PB1[-floor(len(decile_top1)/5):]
PB_top2 = sorted_PB2[-floor(len(decile_top2)/5):]
PB_top3 = sorted_PB3[-floor(len(decile_top3)/5):]
self.growth_portfolio = [i.symbol for i in PB_top1 + PB_top2 + PB_top3]

The Relation Between Investor Sentiment and Equity Style

According to the research paper from Lee and Song, When Do Value Stocks Outperform Growth Stocks?: Investor Sentiment and Equity Style Rotation Strategies, value stocks tend to outperform growth stocks when the CBOE Equity put-call ratio is relatively low, and the VIX is relatively high. The value portfolio significantly underperforms the growth portfolio when the put-call ratio and VIX are both high. To convert the daily put-call ratio and VIX data into monthly value, we take an average over the recent one month and the previous six months.

If the recent monthly average CBOE put-call ratio is lower than its six-month average and the one-month average of VIX is higher than its six-month average, the algorithm goes long on an equally weighted portfolio consisting of value stocks (the lowest P/B quintile) from the top three size deciles. If recent monthly average CBOE put-call ratio and the VIX index are both higher than their six-month average, the algorithm goes short the value stocks. Otherwise, the algorithm goes long both value stocks and growth stocks. The position holding period is three months, and the portfolio is rebalanced every three months.

stocks_invested = [x.key for x in self.portfolio if x.value.INVESTED]
for i in stocks_invested:
    if i not in self.value_portfolio+self.growth_portfolio:
        self.liquidate(i)

if self.vix_SMA_1.current.value > self.vix_SMA_6.current.value:
    if self.PCRatio_SMA_1.current.value < self.PCRatio_SMA_6.current.value:
        long_weight = 1/len(self.value_portfolio)
        for long in self.value_portfolio:
            self.set_holdings(long, long_weight)
    elif self.PCRatio_SMA_1.current.value > self.PCRatio_SMA_6.current.value:
        short_weight = 1/len(self.value_portfolio)
        for short in self.value_portfolio:
            self.set_holdings(short, -short_weight)
else:
    long_weight = 1/len(self.value_portfolio+self.growth_portfolio)
    for long in self.value_portfolio+self.growth_portfolio:
        self.set_holdings(long, long_weight)


Reference

  1. Quantpedia Premium - Sentiment and Style Rotation Effect in Stocks