Long/Short Hedge Strategy (US Market)
A protective approach for investors who are concerned about broad market declines but do not want to sell their value stocks. By going long cheap value stocks and shorting SPY (the S&P 500 ETF), this strategy hedges against systematic market risk.
Strategy Logic
- Long Positions (70%): Buy stocks in the lowest 20% by price-to-book ratio. These are the cheapest value stocks in the market. Use
quantile_rowto compute the cross-sectional percentile each day, then equal-weight the qualifying stocks and scale to 70% total long exposure. - Short Position (30%): Short SPY as a market hedge, with a fixed allocation of -30%.
The combined net exposure is 40% (70% - 30%), substantially reducing market risk compared to a long-only strategy.
Code
from finlab import data
from finlab import backtest
from finlab.market import USMarket
data.set_market('us')
close = data.get('price:adj_close')
close = close[close.index.dayofweek < 5] # remove weekends
pb = data.get('us_key_metrics:pbRatio')
# Lowest 20% by price-to-book ratio
position = pb < pb.quantile_row(0.2)
position /= position.sum(axis=1)
# Long positions total 70%
position *= 0.7
# Short SPY for 30% hedge
position['SPY'] = -0.3
report = backtest.sim(position, resample='Q', market=USMarket(), fee_ratio=0.001, tax_ratio=0)
report.display()
Key Parameters
pb < pb.quantile_row(0.2): Selects stocks whose price-to-book ratio is in the bottom 20th percentile across all stocks on each date. This is the classic "deep value" screen.position /= position.sum(axis=1): Normalizes long positions to equal weight. Each qualifying stock receives the same allocation.position *= 0.7: Scales the total long exposure to 70% of the portfolio.position['SPY'] = -0.3: Assigns a fixed -30% short position in SPY. SPY is used because it is the most liquid US equity ETF and closely tracks the broad market.resample='Q': Rebalances quarterly to keep turnover and transaction costs low.
Expected Behavior
- The long/short structure provides protection during market downturns: when the broad market falls, losses on the long side are partially offset by gains on the short SPY position.
- In strong bull markets, the short position will drag on returns, causing the strategy to underperform a fully invested long-only approach.
- The 40% net exposure means this strategy captures roughly 40% of market beta, making it significantly less volatile than the market.
- Value (low P/B) stocks have historically delivered a long-term premium, though the factor can experience extended periods of underperformance.
- This strategy is suitable for investors who want to maintain exposure to value stocks but desire downside protection against broad market declines.