Long-short portfolio on Hyperliquid from prediction market prices
An autonomous agent queries PolyBridge at price thresholds, reconstructs market-implied distributions, and sizes a long-short book for Hyperliquid 1x perps.
Install PolyBridge MCP for Claude Desktop from the MCP release.
Verify by asking Claude: Use PolyBridge Forecast: Will BTC exceed $70,000 on July 31, 2026?
You should see a probability, confidence range, and source-market metadata.
Ask for threshold prices, not a directional view
The prompt asks the agent to collect all 20 Forecast probabilities first, then execute the sizing script.
You have access to the PolyBridge MCP tool (polybridge_forecast).
Assets and spot prices:
BTC $74,000 · SPX $7,580 · OP $0.12 · BERA $0.38 · WTI $87
For each asset, query PolyBridge Forecast at four price thresholds
(0.60×, 0.85×, 1.15×, 1.50× spot), all resolving July 31, 2026.
Round thresholds: to nearest $100 if spot ≥ $1,000; to nearest $1
if spot ≥ $10; to nearest $0.01 otherwise.
Question format: "Will {ASSET} exceed ${T} on July 31, 2026?"
Collect all 20 probabilities first. Then write and execute a Python
script that:
1. Enforces monotonicity (clip so P(> Tᵢ₊₁) ≤ P(> Tᵢ)).
2. Reconstructs a piecewise price distribution per asset:
Below T₁: prob = 1 − P(> T₁), midpoint = T₁ / 2
Between Tᵢ and Tᵢ₊₁: prob = P(> Tᵢ) − P(> Tᵢ₊₁), midpoint = (Tᵢ + Tᵢ₊₁) / 2
Above T₄: prob = P(> T₄), midpoint = (T₄ + 1.5 × T₄) / 2
3. Computes per asset:
E[price] = Σ midpoint × prob
E[return] = (E[price] − spot) / spot
Vol = √(Σ midpoint² × prob − E[price]²) / spot
4. Sizes via half-Kelly:
weight = 0.5 × E[return] / Vol²
notional = weight × $50,000
Constraints:
Gross notional ≤ $50,000
No single position > $20,000 (40%)
Scale all positions proportionally if gross exceeds budget
Round to nearest $100
Direction = sign of E[return]
Output:
1. Survival probability table per asset
2. Expected returns, implied vols, and sized position table
3. Hyperliquid 1× perp order instructions as JSONWhat the agent does
The four threshold factors place two thresholds below and two above the current price for each asset.
| Asset | Spot | 0.60x | 0.85x | 1.15x | 1.50x |
|---|---|---|---|---|---|
| BTC | $74,000 | $44,400 | $62,900 | $85,100 | $111,000 |
| SPX | $7,580 | $4,500 | $6,400 | $8,700 | $11,400 |
| OP | $0.12 | $0.07 | $0.10 | $0.14 | $0.18 |
| BERA | $0.38 | $0.23 | $0.32 | $0.44 | $0.57 |
| WTI | $87 | $52 | $74 | $100 | $131 |
Snapshot output
This public article uses the May 31 snapshot. Results change with live probabilities.
Snapshot 2026-05-31. Results change with live probabilities.
Asset Dir E[r] Vol Notional
──────────────────────────────────────────
BTC LONG +6.40% 33.70% $8,600
SPX LONG +7.86% 23.30% $12,200
OP SHORT -6.00% 31.90% $9,000
BERA SHORT -11.05% 30.00% $12,200
WTI LONG +2.78% 23.00% $8,000
Gross: $50,000 / $50,000How half-Kelly turns distributions into notionals
Each survival probability P(price > T) is a point on the asset's implied cumulative distribution. Four points define five probability bands. Expected price is the probability-weighted sum of band midpoints; comparing expected price to spot gives expected return. Half-Kelly converts expected return and implied volatility into a position weight.
| Threshold | P(BTC > T) |
|---|---|
| $44,400 | 96% |
| $62,900 | 78% |
| $85,100 | 30% |
| $111,000 | 8% |
- P(BTC between $62.9K and $85.1K) = 0.78 - 0.30 = 0.48
- midpoint = $74,000
- lower tail below $44.4K has probability 0.04 and midpoint $22,200
- upper tail above $111K has probability 0.08 and midpoint $138,750
- E[price] = $78,736
- E[return] = +6.40%
- Vol = 33.7%
- Half-Kelly weight = 0.5 x 0.0640 / 0.337^2 = 0.282
- Raw notional = $14,100 LONG
- After caps and proportional scaling, BTC final notional = $8,600
Sized long-short book
The final gross notional is $50,000, with no single position above $20,000 or 40% of the book.
| Asset | Dir | E[r] | Vol | Notional |
|---|---|---|---|---|
| BTC | LONG | +6.40% | 33.70% | $8,600 |
| SPX | LONG | +7.86% | 23.30% | $12,200 |
| OP | SHORT | -6.00% | 31.90% | $9,000 |
| BERA | SHORT | -11.05% | 30.00% | $12,200 |
| WTI | LONG | +2.78% | 23.00% | $8,000 |
Hyperliquid order instructions JSON
The generated JSON is notional-only by design; routing code should verify instruments, margin, and exchange constraints before placing real orders.
{
"generated_at": "2026-05-31T14:00:00Z",
"horizon": "July 31, 2026",
"venue": "Hyperliquid",
"instrument": "1x_perp",
"orders": [
{
"asset": "BTC",
"direction": "LONG",
"notional_usd": 8600
},
{
"asset": "SPX",
"direction": "LONG",
"notional_usd": 12200
},
{
"asset": "OP",
"direction": "SHORT",
"notional_usd": 9000
},
{
"asset": "BERA",
"direction": "SHORT",
"notional_usd": 12200
},
{
"asset": "WTI",
"direction": "LONG",
"notional_usd": 8000
}
]
}What this example does not solve
- Assets are sized independently; no correlation model.
- Upper-tail ceiling is arbitrary: above T4 midpoint uses 1.5 x T4.
- Prediction market prices are risk-neutral-ish and may include liquidity/risk premia.
- Four thresholds create a coarse distribution, not a full option surface.
- If raw survival probabilities are non-monotonic or based on weak proxy markets, monotonicity clipping makes the math coherent but does not make the signal reliable.
- Hyperliquid instruments must exist and be checked before routing real orders.
- Informational example only. Not financial advice.
Run the threshold workflow.
Connect Hosted MCP or open the Colab notebook and run all cells.
Read the MCP docs →