一键导入
bitmex-recipe-drawdown-circuit-breaker
Halt trading when portfolio drawdown exceeds threshold.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Halt trading when portfolio drawdown exceeds threshold.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
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.
基于 SOC 职业分类
| name | bitmex-recipe-drawdown-circuit-breaker |
| description | Halt trading when portfolio drawdown exceeds threshold. |
Monitor margin balance against a high-water mark and automatically flatten all positions when drawdown exceeds your configured threshold.
BITMEX_API_KEY and BITMEX_API_SECRET set.jq and bc installed.MAX_DRAWDOWN_PCT=5.Capture margin balance at the start of each session or daily. marginBalance (not walletBalance) is used here because it includes unrealisedPnl, so a large adverse price move will trigger the breaker even before positions are closed.
HIGH_WATER=$(bitmex account margin --currency XBt -o json | jq '.marginBalance')
echo "$HIGH_WATER" > /tmp/bitmex_hwm.txt
On subsequent checks, load it:
HIGH_WATER=$(cat /tmp/bitmex_hwm.txt)
CURRENT=$(bitmex account margin --currency XBt -o json | jq '.marginBalance')
Note: This circuit breaker covers XBt-denominated positions only. USDT positions require a separate check using
--currency USDt.
DRAWDOWN=$(echo "scale=4; ($HIGH_WATER - $CURRENT) / $HIGH_WATER * 100" | bc)
echo "Current drawdown: ${DRAWDOWN}%"
MAX_DRAWDOWN_PCT=5
if (( $(echo "$DRAWDOWN > $MAX_DRAWDOWN_PCT" | bc -l) )); then
echo "CIRCUIT BREAKER TRIPPED: ${DRAWDOWN}% drawdown exceeds ${MAX_DRAWDOWN_PCT}%"
# Cancel all open orders
bitmex order cancel-all --yes -o json
# Close all open positions
bitmex position list -o json \
| jq -r '[.[] | select(.currentQty != 0) | .symbol] | .[]' \
| while read -r SYM; do
bitmex order close-position "$SYM" -o json
done
echo "All positions closed. Manual review required before resuming."
exit 1
fi
if (( $(echo "$CURRENT > $HIGH_WATER" | bc -l) )); then
echo "$CURRENT" > /tmp/bitmex_hwm.txt
fi
--testnet before connecting to live funds.