with one click
bitmex-recipe-futures-hedge-spot
Hedge a long position with a short perpetual.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Hedge a long position with a short perpetual.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Price, funding, liquidation, and balance alerts using polling and WebSocket on bitmex-cli.
Autonomy progression for bitmex-cli agents: from read-only market data to autonomous fund management.
Delta-neutral basis trading between BitMEX perpetuals and fixed-date futures: entry, monitoring, and exit.
Dollar cost averaging on bitmex-cli: testnet-first, fixed qty per interval, limit orders, and position cap enforcement.
Error category handling, duplicate order prevention, retry logic, and partial fill management for bitmex-cli.
Minimize trading fees on bitmex-cli: maker vs taker, post-only orders, commission tiers, and fee audit.
| name | bitmex-recipe-futures-hedge-spot |
| description | Hedge a long position with a short perpetual. |
If you hold spot BTC and want to neutralise downside risk without selling, open a short position on the XBTUSD perpetual sized to match your spot exposure.
BITMEX_API_KEY and BITMEX_API_SECRET set.jq and bc installed.SPOT_BTC=0.5).SPOT_BTC=0.5
MARK=$(bitmex market instrument --symbol XBTUSD -o json | jq '.[0].markPrice')
HEDGE_QTY=$(echo "scale=0; $SPOT_BTC * $MARK / 1" | bc)
echo "Need to short $HEDGE_QTY contracts of XBTUSD to hedge $SPOT_BTC BTC"
XBTUSD is inverse: 1 contract = 1 USD of BTC exposure at current price.
bitmex position list -o json \
| jq '[.[] | {symbol, currentQty, unrealisedPnl, liquidationPrice}]'
bitmex order sell XBTUSD $HEDGE_QTY --order-type Limit \
--price $(echo "$MARK * 0.9999" | bc | xargs printf "%.0f") \
--validate -o json
If validate output is correct:
bitmex order sell XBTUSD $HEDGE_QTY --order-type Limit \
--price $(echo "$MARK * 0.9999" | bc | xargs printf "%.0f") \
--yes -o json | jq '{orderID, side, price, orderQty}'
After the hedge fills, positions should offset your spot exposure:
bitmex position list -o json \
| jq '[.[] | select(.symbol == "XBTUSD") | {currentQty, unrealisedPnl}]'
If spot = 0.5 BTC long and hedge = 50000 USD short at 100 000, the net delta is approximately zero.
Recalculate HEDGE_QTY when BTC price moves more than 5%, then add or remove contracts:
# Add more short if price dropped (contract value fell)
bitmex order sell XBTUSD <adjustment_qty> --order-type Market --yes -o json
lotSize and multiplier from bitmex market instrument --symbol <SYMBOL> before sizing a linear hedge.