# False Exit Analysis: Re-entry Success Rate (AGENTS.md v16.0)

## 1. SOURCE (Requirements)

**From README.md:**
- "복수 국면 OOS" with false exit detection
- Strategy robustness across market conditions

**From CLAUDE.md:**
- Non-value-loss sell requires ReentryWatch
- Activation gating validation includes false exit analysis

**Business Logic:**
- Identify portfolio exits (sell signals)
- Track re-entry attempts within 60-day window
- Calculate re-entry success rate (% profitably re-entered)
- Validate strategy doesn't exit prematurely

---

## 2. DEFINITIONS

**False Exit**: Sell signal → Price recovers > entry price within 60 days
**Successful Re-entry**: Exit → Re-entry → Position profitable at close
**Re-entry Success Rate**: Count(profitable re-entry) / Count(total exits)

---

## 3. CALCULATIONS

```
For each position exit in replay:
  1. Record exit price, date
  2. Look forward 60 trading days
  3. Find re-entry signal (if any)
  4. Compare exit price vs recovery price
  5. Mark: Success (if > entry) or Failure (if ≤ entry)

Metrics:
  - FalseExitCount: Total portfolio exits
  - ReentryCount: Exits with re-entry signal
  - ReentrySuccessCount: Re-entries profitable
  - ReentrySuccessRate = ReentrySuccessCount / ReentryCount
  - AverageDaysOutOfPosition = Mean(exit_date to re_entry_date)
```

---

## 4. IMPLEMENTATION

**FalseExitAnalysis Class**
```csharp
public sealed record FalseExitMetrics(
    int FalseExitCount,
    int ReentryCount,
    int ReentrySuccessCount,
    decimal ReentrySuccessRate,
    int AverageDaysOutOfPosition);

public sealed class FalseExitAnalyzer
{
    public static FalseExitMetrics Analyze(
        IReadOnlyList<ReplayEngine.Order> orders,
        IReadOnlyList<ReplayEngine.Signal> signals,
        IReadOnlyList<ReplayEngine.Portfolio> portfolioHistory)
    {
        // Implementation: Calculate metrics from order/signal history
    }
}
```

**Integration Point**
- ShadowRunJob Phase 4.5 (after metrics, before validation)
- Input: orders, signals, portfolio history from replay
- Output: FalseExitMetrics added to ShadowRunResult

---

## 5. TESTS

| Test | Scenario | Expected |
|------|----------|----------|
| NoExits | Portfolio never exits | FalseExitCount=0 |
| SingleExit_WithReentry | 1 exit, re-entry profitable | SuccessRate=100% |
| MultipleExits_Mixed | 3 exits: 2 successful, 1 failed | SuccessRate=66% |
| LongOOP | Re-entry takes 45 days | AverageDaysOutOfPosition≈45 |
| NoReentry | Exit, no re-entry signal in 60d | ReentryCount=0 |

---

## 6. GATES

**Validation Gate (Optional)**
- ReentrySuccessRate ≥ 70% recommended (not blocking)
- Alert if success rate < 50%

---

**Status:** `FALSE_EXIT_ANALYSIS_READY`
