# Public Inference and Funding Fragility

Replication code for the paper **"Public Inference and Funding Fragility"** (Aryan Ayyar, 2026).

The paper studies how the same public order flow that prices an asset also resets the continuation margin on a leveraged position. The code in this repository numerically verifies every quantitative claim in the paper: the wedge equilibrium and its closed-form identities, the Kyle neutrality benchmark, the discovery-funding tradeoff, the iso-dispersion primitive path, the constructed binding equilibrium with its amplification threshold, and the welfare analysis of margin sensitivity.

## Contents

| Path | Reproduces |
| --- | --- |
| `code/wedge_equilibrium.py` | Lemma 1 (wedge equilibrium and identities), Proposition 2 (Kyle neutrality), Theorem 2 (discovery-funding tradeoff), Figure 3 curve data |
| `code/iso_dispersion_path.py` | Lemma 3 (iso-dispersion primitive path: half-tail scale exactly constant while the adverse-selection share varies) |
| `code/constructed_equilibrium.py` | Proposition 5 (stationary binding equilibrium), Table 1, Figure 4 slopes, and the amplification threshold |
| `code/welfare.py` | Numerical properties behind Proposition 8 (constrained-efficient margin sensitivity and its comparative statics) |
| `code/run_all.py` | Runs the full suite; every script asserts agreement with the values reported in the paper |
| `paper/` | Current working-paper PDF |

## Requirements

Python 3.9 or later with `numpy` and `scipy`:

```bash
pip install -r requirements.txt
```

## Reproduce

```bash
python code/run_all.py
```

Each module prints its tables and raises an `AssertionError` if any number disagrees with the paper. The final line should read `ALL REPLICATION CHECKS PASSED`. Individual modules can also be run directly, for example `python code/constructed_equilibrium.py`.

## Headline numbers verified

- Wedge equilibrium identity `chi* = (1 - g zeta*)/2`, with `chi* = 1/2` invariant to all primitives at `gamma = 0` (neutrality).
- With `gamma > 0`, informativeness, the adverse-selection share, and the margin statistic all rise as noise trading declines (tradeoff).
- Iso-dispersion path: `a+` constant at 0.3385 while `tau` runs from 0.20 to 0.48.
- Constructed equilibrium (Table 1): spectral radius 0.572 / 0.851 / 1.007 / 1.109 at `alpha_1 = 0, 0.30, 0.60, 0.90`; amplification threshold `alpha_1_bar = 0.582`.
- Welfare: planner optimum `psi_hat* = 0.555 < psi_A = 1`, decreasing in the externality price and the inference sensitivity.

## Citation

```bibtex
@unpublished{Ayyar2026PublicInference,
  author = {Ayyar, Aryan},
  title  = {Public Inference and Funding Fragility},
  year   = {2026},
  note   = {Working paper}
}
```

## License

MIT. See `LICENSE`.
