Every stock portfolio is an implicit bet on macro outcomes. PolyHedge makes those bets explicit — mapping your holdings to live Polymarket prediction markets and sizing hedges where your TradFi positions disagree with the crowd.
1. Factor decomposition Each holding is regressed against 18 economic factors (equity style, rates, inflation, credit, commodities, yield curve) via OLS. This produces a beta — sensitivity to each factor — per holding.
2. Portfolio factor profile Per-holding betas are dollar-weighted into a single portfolio factor profile. The output is a dollar exposure: how many dollars you gain or lose per 1-sigma move in each factor.
3. Polymarket mapping Each factor maps to Polymarket categories through a static keyword taxonomy. For each matched market, an implied probability is derived from how your TradFi holdings have moved since a baseline date:
p_implied = tanh(sigma_move × 0.5) × 0.48 + 0.50
4. Signal classification Gaps between the TradFi-implied probability and the current Polymarket price are classified:
| Gap | Label |
|---|---|
< 8pp |
Noise — no action |
8–15pp |
Hedge signal |
> 15pp |
Strong signal |
5. Position sizing Quarter-Kelly criterion with a 3% single-position cap and 10% total cap. Positions on correlated factors are reduced to avoid double-counting the same exposure.
| Layer | Tools |
|---|---|
| Market data | yfinance, fredapi |
| Factor regression | statsmodels OLS |
| Prediction markets | Polymarket REST API |
| Numerics | numpy, pandas, scipy, scikit-learn |
pip install -r requirements.txt
python3 -m polyhedge.pipeline --portfolio portfolio_example.jsonSet FRED_API_KEY in your environment (free at fred.stlouisfed.org).
{
"total_implicit_pm_exposure": 142000,
"largest_single_factor_bet": "Will the Fed cut rates before July?",
"net_directional_lean": "long YES",
"markets": [
{
"question": "Will the Fed cut rates before July?",
"implicit_direction": "long YES",
"gross_notional": 54000,
"pm_price": 0.42,
"tradfi_implied": 0.61,
"divergence": 0.19,
"hedge": {
"effective_edge": 0.14,
"insurance_cost_pct": 2.1
}
}
]
}| Field | Meaning |
|---|---|
implicit_direction |
Whether your portfolio benefits if the market resolves YES |
divergence |
tradfi_implied − pm_price — positive means TradFi thinks YES is more likely than Polymarket does |
effective_edge |
Confidence-discounted divergence used for sizing |
insurance_cost_pct |
Hedge position cost as % of the factor exposure being covered |
correlated_factors |
Other factors measuring the same risk — positions are reduced accordingly |