PolyBridgePolyBridge APIBeta
Demo
APICookbooksLong-short Hyperliquid portfolio

Long-short Hyperliquid portfolio

Query Forecast price thresholds, reconstruct market-implied price distributions, size via half-Kelly, and output Hyperliquid 1x perp order instructions.

Cookbook 2

Long-short Hyperliquid portfolio

Query four Forecast price thresholds for BTC, SPX, OP, BERA, and WTI; reconstruct market-implied price distributions; size via half-Kelly; and output Hyperliquid 1x perp order instructions.

Run in Colab

Open the notebook and run all cells. The notebook returns survival probabilities, expected return / implied volatility sizing, and Hyperliquid order instructions JSON.

Run locally

zsh
git clone https://github.com/crowdvector/polybridge-cookbooks.git
cd polybridge-cookbooks/longshort-portfolio

bash setup.sh

python3 portfolio.py

Run with Claude + MCP

The same threshold workflow can be driven from an MCP client once polybridge_forecast is available.

steps
Hosted MCP:

1. Connect a supported MCP client to https://mcp.polybridge.ai/mcp.
2. No API key is required at anonymous limits.

Local MCPB:

1. Download polybridge-mcp-v0.3.1.mcpb from the MCP release.
2. Install it in Claude Desktop.
3. No API key is required at anonymous limits.
4. Add POLYBRIDGE_API_KEY only for higher usage.

After the connection is available, paste the prompt below into the chat.
prompt
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 JSON

Source