INNER CODE UNIT · Python

participation_stats

jialuechen/flowforge · flowforge/diagnostics/flow.py:43

def participation_stats(orders: pd.DataFrame) -> dict:
    """Cross-sectional relations used to validate simulated flow realism.

    Returns Spearman correlations of order notional (%ADV) with
    participation and with market cap, plus a tail-exponent estimate of the
    participation distribution (Hill estimator on the top decile).
    """
    o = orders.dropna(subset=["participation", "notional", "adv", "market_cap"])
    if len(o) < 100:
        raise ValueError("need at least 100 orders")
    size_pct_adv = o["notional"] / o["adv"]

    def _spearman(a: pd.Series, b: pd.Series) -> float:
        return float(a.rank().corr(b.rank()))

    part = o["participation"].to_numpy(dtype=float)
    tail = np.sort(part[part > 0])
    k = max(len(tail) // 10, 10)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…