# White Paper #2: TWO-KEY Confluence Gating

---

## One-line summary

A trade requires both a goal-derived signal AND a market-direction signal to co-fire before the cognitive loop even considers ACT.

---

## The Trigger-Happy Problem in Algo Trading

Most algorithmic trading systems fire on a single indicator. RSI divergence. MACD crossover. Break of structure. These are all unary signals: one condition, one trade.

The problem is not false positives alone. It's **premature commitment**. Without confluence, the system expresses "opinion" before establishing "context."

The market is full of bots that chase every signal because they lack a principle of refusal. They are trigger-happy, not deliberative.

---

## The Agentic Alternative: Default is STAY_SILENT

Cognitive Trader inverts this: the system's default state is silence. A trade only proceeds when two independent conditions align:

1. **Goal Signal** — LLM-derived thesis alignment (`trading_goal` ≥ 0.50)
2. **Momentum Signal** — Deterministic market direction check (`sign(24h_change_pct)`, threshold 1.5%)

Both must co-fire. This is confluence gating, not indicator stacking.

The "Two-Key" name is intentional: like turning two keys simultaneously to launch a nuclear missile, both signals must be present for the agent to act.

---

## Decision Flow Diagram

```
┌──────────────────┐     ┌──────────────────┐
│   Goal Signal    │     │  Momentum Signal   │
│ (LLM thesis,     │     │ (Rules engine:     │
│  priority ≥ 0.50) │     │  24h_change > 1.5%)│
└────────┬─────────┘     └────────┬───────────┘
         │                      │
         └──────────┬───────────┘
                    │
                    ▼
           TWO-KEY GATE CHECK
                    │
          ┌─────────┴─────────┐
          │                 │
          ▼                 ▼
    NO COINCIDENCE    COINCIDENCE
          │                 │
          ▼                 ▼
    STAY_SILENT    ──▶ Memory Retrieval
                            │
                            ▼
                    TWO-KEY VETO BY MEMORY?
                            │
                    ┌───────┴───────┐
                    │               │
                    ▼               ▼
               REFUSE          LLM DECISION
               STAY_SILENT         │
                                   ▼
                                ACT or NO_ACT
```

The Two-Key Gate operates **before** memory retrieval. This prevents wasteful LLM calls on misaligned setups. Why ask the model to decide when the rules engine already knows the setup is invalid?

---

## Priority Math

Symbol priority is computed as:

```
priority = base_priority * momentum_alignment * watchlist_multiplier

# Watchlist multiplier
if symbol NOT in watchlist:
    priority *= 0.7

# Example:
# BTCUSDT: goal_signal=0.70, momentum=+0.65, in_watchlist=true
# priority = 0.70 * 0.65 * 1.0 = 0.455

# BTCUSDT: goal_signal=0.70, momentum=+0.65, NOT in watchlist
# priority = 0.70 * 0.65 * 0.7 = 0.319
```

The 0.7 multiplier ensures watchlist symbols dominate suggestion processing. Non-watchlist symbols must show stronger signals to proceed.

Priority feeds into the ActionThreshold comparison:

```
if priority >= action_threshold:
    proceed_to_veto_check()
```

Thus, a high-priority signal from a watchlist symbol can exceed threshold more easily than the same priority from a non-watchlist symbol.

---

## Memory-Veto Interaction

The Two-Key Gate and Memory-Veto operate at different layers:

| Layer | Gate | Source | Outcome |
|-------|------|--------|---------|
| **Key 1** | Signal alignment | Rules engine | Pass/Fail |
| **Key 2** | Momentum check | 24h regime | Pass/Fail |
| **Veto** | Refusal authority | Memory retrieval | Proceed/Refuse |

Log messages reflect this explicit interaction:

```
TWO-KEY CHECK: goal=0.70, momentum=0.65 → NO COINCIDENCE
TWO-KEY SUGGESTION ADDED TO SIGNALS
TWO-KEY VETO BY MEMORY: 3/5 similar trades lost
```

The "TWO-KEY CHECK" indicates gate evaluation. "TWO-KEY SUGGESTION ADDED" means both keys aligned. "TWO-KEY VETO" is the memory layer refusing despite alignment.

Note that veto can still fire after coincidence. The gate is necessary but not sufficient.

---

## Why This is Agentic

Single-indicator firing is reactive. The system responds to what the market does.

Confluence gating is deliberative. The system waits for its **own** signals to align with market context. It can sit out regimes where thesis and momentum diverge.

This creates the core agentic behavior: **the system chooses when to participate, not just what to do once in**.

Most bots are reactive algorithms. Cognitive Trader is a participant in the market. There's a difference.

---

## Default Silence Statistics

Observed behavior across validation runs:

- ~65% of cycles result in STAY_SILENT (no two-key coincidence)
- ~25% of coincident signals get vetoed by memory
- ~10% of coincident, non-vetoed signals proceed to LLM decision

The system is designed to be selective by default. This is the opposite of trigger-happy algos that trade every signal.

The silence is not empty — it's full of market data being watched, lessons being learned, thresholds being calibrated.

---

## Implementation Status

The Two-Key Gate is implemented in the signal evaluation layer, logged as:

- `TWO-KEY CHECK` — Gate evaluation results
- `TWO-KEY SUGGESTION ADDED TO SIGNALS` — Coincidence achieved
- `TWO-KEY VETO BY MEMORY` — Memory refused despite coincidence

Visible in every cycle log. Visible in the architecture diagram (§01 — reference node at 855x260, labeled "VETO").

The gate structure is visible in the SVG workflow diagram, where the two converging flows (telegram signal + market stream) must both activate before the cognitive cycle node receives input.

---

## Why This Matters

Two-Key gating is the structural difference between:

- **Algorithmic trading**: Execute when indicator fires
- **Agentic trading**: Only execute when internal state aligns with market state

The first is a rule. The second is a decision. This is why we call the system "cognitive" — it deliberates, it doesn't just react.

The gate can evolve — we could add a third key (volatility regime, liquidity check, etc.) — but the principle remains: confluence beats single-source signals.