behavioral-finance
This skill translates behavioral finance theories into actionable trading signals by quantifying how market participants systematically deviate from rational decision-making. Use it to build momentum and reversal strategies, generate contrarian signals during sentiment extremes, construct debiased portfolios, and capture behavior-driven patterns specific to retail-heavy China A-share markets through frameworks like underreaction momentum effects and overreaction reversal patterns.
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading /tmp/behavioral-finance && cp -r /tmp/behavioral-finance/agent/src/skills/behavioral-finance ~/.claude/skills/behavioral-financeSKILL.md
# Behavioral Finance Applications
## Overview
Translate behavioral-finance theory into quantifiable trading signals and risk-control rules. Core assumption: market participants systematically deviate from rational decision-making, and these biases can be predicted and exploited.
Applicable scenarios:
- Behavioral interpretation and parameter optimization for momentum / reversal strategies
- Contrarian signals when market sentiment becomes extreme
- Debiasing mechanisms in portfolio construction
- Capturing behavior patterns specific to retail-driven China A-share markets
## Core Concepts
### Overreaction and Underreaction
**Underreaction** → momentum effect:
```
Mechanism: anchoring bias + conservatism
Investors anchor on old information and update insufficiently to new information
After an earnings beat, the stock price digests it gradually rather than all at once
China A-share evidence:
- Earnings-guidance beats still produce 3-5% excess return over the following 20 days
- After analyst rating upgrades, momentum often persists for 1-3 months
Quant signal:
SUE (standardized unexpected earnings) > 2σ -> buy and hold for 60 days
Top 10% 20-day return -> continue holding for 20 days (China A-share momentum cycles are shorter)
```
**Overreaction** → reversal effect:
```
Mechanism: representativeness heuristic + availability bias
Investors extrapolate recent trends too aggressively and ignore mean reversion
Panic / euphoria drives reactions beyond what fundamentals support
China A-share evidence:
- Rebounds after consecutive limit-downs (after 3 limit-downs, the average 20-day rebound is 8%)
- Big annual losers often earn 5-10% excess return the next year
Quant signal:
Bottom 10% of 250-day return -> buy and hold for 250 days
RSI(5) < 10 -> short-term rebound signal (5-10 days)
```
**Key distinction**:
| Dimension | Underreaction (Momentum) | Overreaction (Reversal) |
|------|------------------|------------------|
| Time scale | 1-12 months | <1 week or >12 months |
| Information type | Clear events (earnings / announcements) | Ambiguous information (sentiment / trend) |
| Best China A-share window | 20-60 days | 5-10 days (short term) / 1 year (long term) |
### Cognitive Bias Checklist
**Individual decision biases**:
| Bias | Manifestation | Quant Detection | Debiasing Strategy |
|------|------|----------|------------|
| Loss aversion | Hold losing stocks, sell winners too early | Holding period: losing positions > winning positions by 2-3x | Pre-set stop-loss line and execute mechanically |
| Overconfidence | Overtrading, concentrated positions | Monthly turnover > 100%, single-stock weight > 30% | Limit the number of trades per month |
| Anchoring effect | Anchoring to entry price / historical highs | Abnormal volume expansion near the entry price | Use relative valuation instead of absolute price |
| Confirmation bias | Focus only on information that supports the existing view | Single-source information, ignoring bearish news | Force reading the opposing view |
| Recency bias | Overweight recent events | Recent gains/losses have too much influence on position size | Lengthen the evaluation window (≥60 days) |
| Framing effect | Same information framed differently leads to different decisions | Decision differences between return format and absolute-PnL format | Evaluate consistently in return space |
**Group behavior biases**:
| Bias | Manifestation | China A-share Characteristics | Quant Indicator |
|------|------|---------|----------|
| Herding | Chasing rallies and panic-selling together | Extremely fast sector rotation (3-5 days) | Intra-sector stock correlation > 0.8 |
| Information cascades | Ignoring private information and following public signals | Sector follow-through after a leader stock hits limit-up | Sector return on the day after leader-stock limit-up |
| Attention effect | Buying stocks that attract attention | Explosive turnover in limit-up / news-driven stocks | Abnormal turnover > 3x average |
### Investor Sentiment Cycle
```
Fear -> Caution -> Optimism -> Excitement -> Euphoria -> Denial -> Panic -> Fear
| | | | | | |
Bottom Recovery Mid-uptrend Pre-top Top Early selloff Pre-bottom
Quant sentiment indicators:
1. Closed-end fund discount: discount > 15% -> extreme fear -> buy signal
2. Margin-financing growth: monthly growth > 20% -> euphoria -> reduce position
3. New account openings: weekly openings > 2x average -> overheated market
4. Turnover ratio: All-A daily turnover > 3% -> euphoric; < 0.5% -> deeply depressed
5. Number of limit-up stocks: > 100 -> euphoric; < 10 -> weak
```
## Analysis Framework
### 1. Disposition-Effect Signal
**Principle**: investors tend to sell winners and hold losers. Once winning positions are largely cleared, selling pressure eases; when trapped holders are deeply underwater, selling pressure can also ease.
```
China A-share application:
Compute the profit ratio in the chip-distribution structure:
- Profit ratio > 90% and shrinking volume -> winners are reluctant to sell -> may continue rising
- Profit ratio > 90% and expanding volume -> winners are exiting -> topping signal
- Profit ratio < 10% and shrinking volume -> low willingness to cut losses -> bottom stabilization
- Profit ratio < 10% and expanding volume -> panic selling -> short-term oversold
Quant implementation:
capital_gain_overhang = (current_price - avg_cost) / avg_cost
where avg_cost is approximated by 60-day VWAP
CGO > 0.2 -> strong unrealized gains, watch for disposition-effect selling pressure
CGO < -0.3 -> deeply trapped holders, selling pressure may actually ease
```
### 2. Composite Sentiment Indicator
```python
# Multi-dimensional sentiment score (0-100, 50 = neutral)
sentiment_components = {
'turnover_ratio': normalize(all_a_turnover, historical_percentile), # weight 25%
'margin_growth': normalize(monthly_margin_growth, hisProfessional finance research toolkit — backtesting (7 engines + benchmark comparison panel), factor analysis, Alpha Zoo (452 pre-built alphas across qlib158/alpha101/gtja191/academic), options pricing, 77 finance skills, 29 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 7 data sources (tushare, yfinance, okx, akshare, mootdx, ccxt, futu).
ADR/H-share/A-share cross-listing premium analysis — track pricing gaps between US-listed ADRs, HK-listed H-shares, and A-shares for arbitrage signals, dual-listing valuation, and delisting risk assessment.
AKShare financial data aggregator (18k+ stars). Free, no API key. Covers A-shares, US, HK, futures, macro, forex. Primary fallback for tushare and yfinance.
Browse and bench the bundled alpha zoos — prebuilt cross-sectional factor libraries (Kakushadze 101, GTJA 191, Qlib 158, Fama-French / Carhart). Use when the user asks "which alphas exist", wants metadata on a named alpha, or wants to run IC/IR on a whole zoo over a universe.
A 股 ST/*ST 风险预测框架 — 基于最新中报/三季报或业绩预告/快报,预测下一财年是否会因营收、利润、净资产、分红不达标而被风险警示,并将新浪监管处罚记录作为独立证据面纳入风险等级。仅适用于 A 股,不预测财务造假。
Asset allocation theory and optimizer usage — MPT / Black-Litterman / risk budgeting / all-weather strategy, including guides for 4 optimizers and rebalancing rules.
Diagnose failed or underperforming backtests, locate the root cause, and fix the issue
Candlestick pattern recognition engine, pure pandas vectorized implementation of 15 classic candlestick patterns (5 single-candle + 5 double-candle + 4 triple-candle + 1 trend confirmation), generating a composite signal from bullish/bearish pattern scores.