> ## Documentation Index
> Fetch the complete documentation index at: https://mathematicalcompany.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Stealth Execution

> Impact-aware execution algorithms: adaptive TWAP, randomized iceberg, sniper mode, and smart cross-exchange routing.

<Warning>
  **Ultra Feature.** Requires an Ultra subscription. [Get started at api.mathematicalcompany.com](https://api.mathematicalcompany.com)
</Warning>

# Stealth Execution

Institutional-grade execution for prediction markets. Estimate market impact before trading, route across venues, and execute with algorithms that minimise information leakage.

<CardGroup cols={2}>
  <Card title="Impact Estimation" icon="gauge">
    Kyle's lambda + spread + volatility to predict slippage before you trade.
  </Card>

  <Card title="Smart Routing" icon="route">
    Greedy cost-minimising allocation across Paper, Polymarket, and Kalshi.
  </Card>

  <Card title="Adaptive TWAP" icon="clock">
    Fill-rate adaptive time-slicing with spread-widening circuit breaker.
  </Card>

  <Card title="Sniper Mode" icon="crosshairs">
    Waits for tight spread + favourable imbalance, then fires instantly.
  </Card>
</CardGroup>

***

## Impact Estimation

```python theme={null}
import horizon as hz

engine = hz.Engine()
impact = hz.estimate_impact(engine, "0xcondition...", size=500)
print(impact.estimated_slippage_bps)   # e.g. 12.5
print(impact.recommended_strategy)      # "twap"
```

| Field                     | Description                                      |
| ------------------------- | ------------------------------------------------ |
| `estimated_slippage_bps`  | Predicted slippage in basis points               |
| `kyle_lambda`             | Kyle's lambda (price impact coefficient)         |
| `effective_spread_bps`    | Current effective spread                         |
| `recommended_strategy`    | `"market"`, `"twap"`, `"iceberg"`, or `"sniper"` |
| `estimated_duration_secs` | Recommended execution window                     |

***

## One-Call Execution

```python theme={null}
plan = hz.stealth_execute(
    engine, "0xcondition...",
    side=hz.Side.Yes,
    order_side=hz.OrderSide.Buy,
    size=500, price=0.55,
    strategy="auto",  # auto-selects based on impact
)
print(plan.strategy, plan.estimated_cost_bps)
```

***

## Pipeline Mode

```python theme={null}
hz.run(
    name="stealth-mm",
    markets=["0xcondition..."],
    pipeline=[
        hz.stealth_executor(config=hz.StealthConfig(
            patience_secs=60, randomize=True,
        )),
    ],
    interval=1.0,
)
```

The pipeline reads `ctx.params["stealth_requests"]` (a list of request dicts) and drives active algorithms each tick.

***

## Algorithms

### AdaptiveTWAP

Splits a parent order into time-slices with fill-rate feedback:

* Fill rate > 80% → slow down (multiply interval by 1.5)
* Fill rate \< 20% → speed up (multiply interval by 0.75)
* Spread widens > 2× → pause until it narrows
* Optional ±20% slice size randomisation

### IcebergPlus

Shows a random fraction of the total order:

* Visible size randomised in `[0.5×, 1.5×]` of base
* Capped at `max_visible_pct` of remaining quantity
* Random delay between refills

### SniperAlgo

Waits for optimal entry conditions:

* Monitors `effective_spread` and `lob_imbalance`
* Fires when spread \< target AND imbalance favours our side
* Patience mechanism progressively relaxes the threshold

***

## StealthConfig

| Parameter             | Default | Description                            |
| --------------------- | ------- | -------------------------------------- |
| `randomize`           | `True`  | Randomise slice sizes and delays       |
| `min_delay_secs`      | `0.5`   | Minimum delay between iceberg refills  |
| `max_delay_secs`      | `5.0`   | Maximum delay between iceberg refills  |
| `max_visible_pct`     | `0.10`  | Maximum visible fraction (iceberg)     |
| `impact_limit_bps`    | `50.0`  | Abort if estimated impact exceeds this |
| `patience_secs`       | `120.0` | Sniper patience window                 |
| `adaptive_aggression` | `True`  | Enable fill-rate adaptive behaviour    |
