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, equal-weight the qualifying stocks, and allocate 70% of capital to this leg. - Short Position (30%): Short SPY as a market hedge with the remaining 30% of capital. SPY is an ETF, so it is backtested in the
us_fundmarket and the two legs are combined withPortfolio.
Net exposure is 40% (70% - 30%) — much less market risk than a long-only book.
Code
from finlab import data
from finlab import backtest
from finlab.portfolio import Portfolio
# Long leg: lowest 20% by price-to-book ratio
data.set_market('us')
market_value = data.get('etl:us_market_value')
equity = data.get('us_balance_sheet:total_stockholders_equity')
pb = market_value / equity
pb = pb[pb > 0] # Negative equity is distress, not value
long_position = pb < pb.quantile_row(0.2)
long_report = backtest.sim(long_position, resample='Q')
# Hedge leg: short SPY (ETFs trade in the us_fund market)
data.set_market('us_fund')
spy = data.get('price:adj_close')[['SPY']]
short_position = -spy.notna().astype(float)
short_report = backtest.sim(short_position, resample='Q')
# 70% long value stocks, 30% short SPY
portfolio = Portfolio(
{
'long value': (long_report, 0.7),
'short SPY': (short_report, 0.3),
}
)
portfolio.display()
Key Parameters
market_value / equity: Price-to-book ratio from daily market value and quarterly stockholders' equity (aligned to each SEC filing date). Non-positive values are dropped.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.sim()equal-weights the selected stocks.-spy.notna().astype(float): A -100% SPY position for the hedge leg. SPY is used because it is the most liquid US equity ETF and closely tracks the broad market.Portfolio({...: (report, weight)}): Allocates 70% of capital to the long leg and 30% to the short-SPY leg, giving a fixed -30% SPY hedge.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.
- At 40% net exposure, the strategy runs at roughly 0.4 market beta with correspondingly lower volatility than the index.
- 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.