# Preemptive Entry Validation

This document records the tests of the idea that deterministic calendar/time signals can be entered early by resting maker orders before the signal officially activates.

Scripts:

- Broad test: `src/research/preemptive-entry-validation.ts`
- Narrow test: `src/research/preemptive-narrow-validation.ts`

Commands:

```bash
npm run preempt:validate
npm run preempt:narrow
```

---

## Hypothesis

The strategy currently executes signals at the current bar when the composite score crosses the entry threshold and passes confirmation.

Some components are deterministic in advance:

- day-of-week weights,
- hour-of-day weights.

So the hypothesis was:

> If we know a deterministic signal will activate soon, can we rest a maker order early at a better liquidity level and improve entry quality?

---

## Leakage-safe rule

A valid preemptive test must not use future price-derived information.

Allowed for preempt trigger:

- future DOW component,
- future hour component.

Forbidden for preempt trigger:

- future BUYP / close-position pressure,
- future RSI,
- future US gap,
- future 24h reversion,
- future price levels derived after the trigger time.

The implemented tests therefore only project the deterministic DOW/hour score. All price-derived components are evaluated only when they are actually known.

---

## Broad test design

The broad script tested preemptive resting orders up to several hours before known deterministic activation.

Rules:

- project known-only DOW/hour score,
- rest one maker order at current L1,
- if filled before activation, SL is live immediately,
- at activation, require full actual score confirmation,
- if full actual signal fails, exit immediately as a false start,
- if not filled and activation fails, cancel,
- no cancel/recreate at the same price.

Parameters swept:

```text
lead:   15m, 30m, 60m, 120m, 240m
margin: 0, 5, 10, 20 score points above entry threshold
```

Modes:

```text
simple SL
realistic maker-SL
Bybit-like 4bps RT fees
MEXC/no-fee
```

---

## Broad test result

Broad preemptive entry was rejected.

Main failure mode:

> early fills often stop out before the actual signal activates.

Examples from broad MEXC/no-fee simple-SL test:

```text
lead=30 margin=10:
  preempt trades: 515
  false starts:   2
  pre-stops:      94

lead=60 margin=10:
  preempt trades: 628
  false starts:   4
  pre-stops:      150

lead=120 margin=10:
  preempt trades: 785
  false starts:   2
  pre-stops:      277
```

The problem was not mainly false starts. The problem was adverse selection: getting filled early often meant price was already moving against the future signal.

### Broad test conclusion

Do not implement broad preemptive entry.

---

## Narrow test design

After the broad test failed, a stricter version was tested.

Rules:

```text
only preempt 5–15 minutes before deterministic activation
known score margin >= 10 / 15 / 20
current momentum must already agree with future signal
L1 must be close: <=15 or <=30 bps from current price
cancel pending order at activation if not filled
```

Momentum filters swept:

```text
lookback: 15m / 30m / 60m
minimum:  0 / 5 / 10 bps in future signal direction
```

Modes:

```text
simple SL
realistic maker-SL
Bybit-like 4bps RT fees
MEXC/no-fee
```

---

## Narrow test result

The narrowed version fixed the worst operational issues:

- false starts were almost zero,
- pre-activation stops were much lower than the broad test,
- the preempt subset was sometimes positive.

But it still did not produce a strong enough edge under realistic execution.

---

## Bybit-like fees

Bybit-like fees make the preemptive edge too small.

Best-looking simple-SL Bybit variant:

```text
margin=15
L1 distance <=30 bps
15m momentum >=5 bps

baseline:
  moIR:   0.39
  actIR:  0.41
  maxDD:  62.7%
  months: 32/49

narrow preempt:
  moIR:   0.45
  actIR:  0.47
  maxDD:  63.7%
  months: 32/49
  preempt mean: +7.17 bps
  preempt t:    1.04
```

This is not enough after fees.

With realistic maker-SL, Bybit-like results remain poor.

### Bybit conclusion

Do not use preemptive entry on Bybit.

---

## MEXC/no-fee simple-SL results

Simple-SL mode is optimistic, but useful as a signal-quality check.

Best-looking variants:

### Variant A

```text
margin=15
L1 distance <=30 bps
15m momentum >=5 bps

baseline:
  moIR:   0.83
  actIR:  0.87
  maxDD:  42.2%
  months: 42/49

narrow preempt:
  moIR:   0.88
  actIR:  0.91
  maxDD:  41.7%
  months: 41/49
  preempt trades: 247
  preempt mean:   +11.17 bps
  preempt t:      1.62
  false starts:   0
  pre-stops:      24
```

### Variant B

```text
margin=10
L1 distance <=30 bps
30m momentum >=10 bps

moIR:          0.86
actIR:         0.95
maxDD:         43.0%
months:        43/49
preempt mean:  +7.85 bps
preempt t:     1.25
false starts:  1
pre-stops:     24
```

Simple-SL MEXC showed mild promise, but this is not the execution model we trust for live trading.

---

## MEXC/no-fee realistic maker-SL results

This is the important test.

Baseline:

```text
baseline maker-SL MEXC:
  moIR:   0.51
  actIR:  0.47
  maxDD:  55.0%
  months: 35/49
```

Best-looking narrow variants:

### Variant A

```text
margin=10
L1 distance <=30 bps
30m momentum >=10 bps

narrow preempt:
  moIR:   0.53
  actIR:  0.58
  maxDD:  55.0%
  months: 36/49
  preempt trades: 268
  preempt mean:   +4.19 bps
  preempt t:      0.63
  false starts:   1
  pre-stops:      22
```

### Variant B

```text
margin=15
L1 distance <=30 bps
15m momentum >=5 bps

narrow preempt:
  moIR:   0.53
  actIR:  0.52
  maxDD:  52.6%
  months: 35/49
  preempt trades: 246
  preempt mean:   +3.57 bps
  preempt t:      0.50
  false starts:   0
  pre-stops:      23
```

The portfolio improvement is tiny and the preempt subset is not statistically meaningful.

---

## Final conclusion

Do **not** implement preemptive entry in the live/demo runner.

Reasons:

1. Broad preemptive entry creates too much adverse-selection risk.
2. Narrow preemptive entry reduces the operational problems but leaves only a weak edge.
3. Under realistic maker-SL, the preempt subset has `t < 1.0`.
4. Portfolio-level improvement is too small to justify complexity.
5. Bybit fees erase the edge completely.

Current entry logic remains better.

---

## If revisited later

The only version worth future shadow-logging is:

```text
5–15m before deterministic activation
known score margin >= 15
L1 distance <= 30 bps
15m momentum >= 5 bps
cancel at activation if not filled
```

But this should be shadow-only, not traded.

Suggested live log event:

```text
[PREEMPT_SHADOW]
futureDir=LONG
activation=21:00
knownScore=+18
margin=+8
mom15=+6bps
L1=$...
dist=22bps
wouldRest=true
```

Track at least 50–100 shadow events before reconsidering.

---

## Current decision

```text
Production: no
MEXC candidate: no, not yet
Shadow logging: optional
Research status: rejected for now
```
