Skip to content

Commit c7267e0

Browse files
authored
Merge pull request #4 from BitMEX-private/docs/agent-discoverability
docs: agent discoverability + fix install script
2 parents b9adc47 + eb9f15e commit c7267e0

46 files changed

Lines changed: 428 additions & 328 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Paste this into your AI agent to get set up:
2222
Set up bitmex-cli for my BitMEX trading account.
2323
2424
## Install
25-
Run: curl -sSfL https://raw.githubusercontent.com/BitMEX/bitmex-cli/master/install.sh | sh
25+
Run: tmpfile="$(mktemp)" && curl -sSfL https://raw.githubusercontent.com/BitMEX/bitmex-cli/master/install.sh -o "$tmpfile" && sh "$tmpfile"
2626
2727
## Account Setup
2828
If I don't have a BitMEX account yet, walk me through:
@@ -33,8 +33,9 @@ If I don't have a BitMEX account yet, walk me through:
3333
## API Key
3434
Guide me to https://www.bitmex.com/app/apiKeys to create an API key with
3535
"Order" and "Account" permissions (add "Withdraw" only if I need withdrawals).
36-
Ask me for the key and secret, then run:
37-
bitmex auth set --api-key <KEY> --api-secret <SECRET>
36+
Ask me to choose:
37+
- Share my key and secret with you, and run: bitmex auth set --api-key <KEY> --api-secret <SECRET>
38+
- Or keep keys private: ask me to open a terminal and run `bitmex auth add` myself (do NOT run this for me — it requires an interactive terminal)
3839
3940
## Verify
4041
Run: bitmex account me -o json
@@ -67,10 +68,10 @@ And suggest starting with --testnet to practice safely before using real funds.
6768
### Install script (recommended)
6869

6970
```bash
70-
curl -sSfL https://raw.githubusercontent.com/BitMEX/bitmex-cli/master/install.sh | sh
71+
tmpfile="$(mktemp)" && curl -sSfL https://raw.githubusercontent.com/BitMEX/bitmex-cli/master/install.sh -o "$tmpfile" && sh "$tmpfile"
7172
```
7273

73-
Downloads a pre-built binary for your platform (macOS/Linux, x86_64/arm64), verifies the SHA256 checksum, and installs to `/usr/local/bin`. No Rust or build tools needed. Requires `curl`, `tar`, and `sha256sum` (or `shasum`). May prompt for `sudo` if `/usr/local/bin` is not writable.
74+
Downloads a pre-built binary for your platform (macOS/Linux, x86_64/arm64), verifies the SHA256 checksum, and installs to `~/.local/bin`. No Rust or build tools needed. No `sudo` required. Requires `curl`, `tar`, and `sha256sum` (or `shasum`). Override the install location with `BITMEX_INSTALL_DIR`.
7475

7576
### GitHub Releases
7677

install.sh

Lines changed: 111 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
22
set -e
33

4-
REPO_URL="https://github.com/BitMEX/bitmex-cli"
4+
REPO="BitMEX-private/bitmex-cli" # TEMP: pre-launch, revert to BitMEX/bitmex-cli
55
BINARY="bitmex"
6-
INSTALL_DIR="/usr/local/bin"
6+
INSTALL_DIR="${BITMEX_INSTALL_DIR:-$HOME/.local/bin}"
77

88
get_target() {
99
os=$(uname -s)
@@ -27,37 +27,101 @@ get_target() {
2727
*)
2828
echo "Unsupported OS: $os" >&2
2929
echo "For Windows, download the binary manually from:" >&2
30-
echo " ${REPO_URL}/releases" >&2
30+
echo " https://github.com/${REPO}/releases" >&2
3131
exit 1
3232
;;
3333
esac
3434
}
3535

36+
on_path() {
37+
case ":$PATH:" in
38+
*":$1:"*) return 0 ;;
39+
*) return 1 ;;
40+
esac
41+
}
42+
43+
install_skills() {
44+
src_tarball="$1"
45+
skills_tmpdir=$(mktemp -d)
46+
trap 'rm -rf "$skills_tmpdir"' EXIT
47+
48+
# Extract skills/ from source tarball (top-level dir varies, strip it)
49+
tar xzf "$src_tarball" -C "$skills_tmpdir" --strip-components=1 2>/dev/null || return 1
50+
skills_src="$skills_tmpdir/skills"
51+
[ -d "$skills_src" ] || return 1
52+
53+
installed=""
54+
55+
# OpenClaw
56+
if [ -d "$HOME/.openclaw" ]; then
57+
mkdir -p "$HOME/.openclaw/skills"
58+
for skill in "$skills_src"/bitmex-*/; do
59+
cp -r "$skill" "$HOME/.openclaw/skills/"
60+
done
61+
installed="${installed} OpenClaw"
62+
fi
63+
64+
# Claude Code
65+
if [ -d "$HOME/.claude" ]; then
66+
mkdir -p "$HOME/.claude/commands"
67+
for skill in "$skills_src"/bitmex-*/; do
68+
name=$(basename "$skill")
69+
cp "$skill/SKILL.md" "$HOME/.claude/commands/${name}.md"
70+
done
71+
installed="${installed} Claude"
72+
fi
73+
74+
# Hermes
75+
if [ -d "$HOME/.hermes" ]; then
76+
mkdir -p "$HOME/.hermes/skills"
77+
for skill in "$skills_src"/bitmex-*/; do
78+
cp -r "$skill" "$HOME/.hermes/skills/"
79+
done
80+
installed="${installed} Hermes"
81+
fi
82+
83+
echo ""
84+
if [ -n "$installed" ]; then
85+
echo "Installed bitmex skills for:${installed}"
86+
echo "Start a new conversation in your AI tool for skills to be recognized."
87+
else
88+
echo "No AI agents detected. To install skills manually:"
89+
echo " OpenClaw : cp -r skills/bitmex-* ~/.openclaw/skills/"
90+
echo " Claude : for s in skills/bitmex-*; do cp \"\$s/SKILL.md\" ~/.claude/commands/\$(basename \$s).md; done"
91+
echo " Hermes : cp -r skills/bitmex-* ~/.hermes/skills/"
92+
fi
93+
}
94+
3695
main() {
3796
target=$(get_target)
3897

39-
tag=$(curl -sSf "https://raw.githubusercontent.com/BitMEX/bitmex-cli/master/Cargo.toml" | grep '^version' | head -1 | cut -d'"' -f2)
98+
# TEMP: pre-launch, repo is private — use `gh` for auth.
99+
# Revert this block to the curl version (see git history) once public.
100+
if ! command -v gh >/dev/null 2>&1; then
101+
echo "Error: 'gh' CLI required for pre-launch install (repo is private)" >&2
102+
exit 1
103+
fi
104+
tag=$(gh release view --repo "$REPO" --json tagName --jq .tagName)
40105
if [ -z "$tag" ]; then
41-
echo "Error: could not determine latest version" >&2
106+
echo "Error: could not determine latest release" >&2
42107
exit 1
43108
fi
44-
version="v${tag}"
45-
tag="cli-${version}"
46109

47-
tarball="bitmex-${version}-${target}.tar.gz"
48-
url="${REPO_URL}/releases/download/${tag}/${tarball}"
49-
checksums_url="${REPO_URL}/releases/download/${tag}/checksums.txt"
110+
tarball="bitmex-cli-${target}.tar.gz"
111+
checksums="sha256.sum"
50112

51-
echo "Installing ${BINARY} ${version} (${target})..."
113+
echo "Installing ${BINARY} ${tag} (${target}) to ${INSTALL_DIR}..."
52114
echo ""
53115

54116
tmpdir=$(mktemp -d)
55117
trap 'rm -rf "$tmpdir"' EXIT
56118

57-
curl -sSfL "$url" -o "$tmpdir/$tarball"
58-
curl -sSfL "$checksums_url" -o "$tmpdir/checksums.txt"
119+
# TEMP: pre-launch, use `gh release download` instead of curl.
120+
gh release download "$tag" --repo "$REPO" \
121+
--pattern "$tarball" --pattern "$checksums" \
122+
--dir "$tmpdir" >/dev/null
59123

60-
expected_hash=$(grep "$tarball" "$tmpdir/checksums.txt" | awk '{print $1}')
124+
expected_hash=$(grep "$tarball" "$tmpdir/$checksums" | awk '{print $1}')
61125
if [ -z "$expected_hash" ]; then
62126
echo "Error: no checksum found for $tarball" >&2
63127
exit 1
@@ -82,16 +146,43 @@ main() {
82146
echo "Checksum verified."
83147
tar xzf "$tmpdir/$tarball" -C "$tmpdir"
84148

85-
if [ -w "$INSTALL_DIR" ]; then
86-
mv "$tmpdir/$BINARY" "$INSTALL_DIR/$BINARY"
87-
chmod +x "$INSTALL_DIR/$BINARY"
88-
else
89-
sudo mv "$tmpdir/$BINARY" "$INSTALL_DIR/$BINARY"
90-
sudo chmod +x "$INSTALL_DIR/$BINARY"
149+
# cargo-dist nests the binary inside <name>-<target>/
150+
src="$tmpdir/bitmex-cli-${target}/$BINARY"
151+
if [ ! -f "$src" ]; then
152+
echo "Error: binary not found at $src" >&2
153+
exit 1
91154
fi
92155

156+
mkdir -p "$INSTALL_DIR"
157+
mv "$src" "$INSTALL_DIR/$BINARY"
158+
chmod +x "$INSTALL_DIR/$BINARY"
159+
93160
echo ""
94161
echo "Installed ${BINARY} to ${INSTALL_DIR}/${BINARY}"
162+
163+
if ! on_path "$INSTALL_DIR"; then
164+
echo ""
165+
echo "Note: ${INSTALL_DIR} is not on your PATH. Add it with:"
166+
case "${SHELL##*/}" in
167+
zsh) echo " echo 'export PATH=\"${INSTALL_DIR}:\$PATH\"' >> ~/.zshrc && source ~/.zshrc" ;;
168+
bash) echo " echo 'export PATH=\"${INSTALL_DIR}:\$PATH\"' >> ~/.bashrc && source ~/.bashrc" ;;
169+
fish) echo " fish_add_path ${INSTALL_DIR}" ;;
170+
*) echo " export PATH=\"${INSTALL_DIR}:\$PATH\"" ;;
171+
esac
172+
fi
173+
174+
# Install skills (non-fatal if it fails)
175+
src_tarball="$tmpdir/source.tar.gz"
176+
# TEMP: use gh api for private repo. When public, replace with:
177+
# curl -sSfL "https://github.com/${REPO}/archive/refs/tags/${tag}.tar.gz" -o "$src_tarball"
178+
if gh api "repos/${REPO}/tarball/${tag}" > "$src_tarball" 2>/dev/null; then
179+
install_skills "$src_tarball" || echo "Warning: skill installation failed (skipping)"
180+
else
181+
echo ""
182+
echo "Warning: could not download skills — skipping skill installation."
183+
fi
184+
185+
echo ""
95186
echo "Run 'bitmex --help' to get started."
96187
}
97188

skills/INDEX.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,43 +88,43 @@ Multi-step workflows combining multiple skills.
8888

8989
| Skill | Description |
9090
|-------|-------------|
91-
| [recipe-start-dca-bot](./recipe-start-dca-bot/SKILL.md) | Set up and run a DCA bot from testnet validation to live. |
92-
| [recipe-launch-grid-bot](./recipe-launch-grid-bot/SKILL.md) | Deploy a grid trading bot with testnet validation. |
93-
| [recipe-trailing-stop-runner](./recipe-trailing-stop-runner/SKILL.md) | Ride a trend with a trailing stop that locks in profits on reversal. |
94-
| [recipe-basis-trade-entry](./recipe-basis-trade-entry/SKILL.md) | Enter a perp-futures basis trade when premium exceeds threshold. |
95-
| [recipe-futures-hedge-spot](./recipe-futures-hedge-spot/SKILL.md) | Hedge a long position with a short perpetual. |
96-
| [recipe-funding-rate-scan](./recipe-funding-rate-scan/SKILL.md) | Scan perpetual contracts for funding rate carry opportunities. |
97-
| [recipe-testnet-strategy-backtest](./recipe-testnet-strategy-backtest/SKILL.md) | Validate a strategy across multiple testnet sessions before going live. |
91+
| [bitmex-recipe-start-dca-bot](./bitmex-recipe-start-dca-bot/SKILL.md) | Set up and run a DCA bot from testnet validation to live. |
92+
| [bitmex-recipe-launch-grid-bot](./bitmex-recipe-launch-grid-bot/SKILL.md) | Deploy a grid trading bot with testnet validation. |
93+
| [bitmex-recipe-trailing-stop-runner](./bitmex-recipe-trailing-stop-runner/SKILL.md) | Ride a trend with a trailing stop that locks in profits on reversal. |
94+
| [bitmex-recipe-basis-trade-entry](./bitmex-recipe-basis-trade-entry/SKILL.md) | Enter a perp-futures basis trade when premium exceeds threshold. |
95+
| [bitmex-recipe-futures-hedge-spot](./bitmex-recipe-futures-hedge-spot/SKILL.md) | Hedge a long position with a short perpetual. |
96+
| [bitmex-recipe-funding-rate-scan](./bitmex-recipe-funding-rate-scan/SKILL.md) | Scan perpetual contracts for funding rate carry opportunities. |
97+
| [bitmex-recipe-testnet-strategy-backtest](./bitmex-recipe-testnet-strategy-backtest/SKILL.md) | Validate a strategy across multiple testnet sessions before going live. |
9898

9999
### Portfolio Recipes
100100

101101
| Skill | Description |
102102
|-------|-------------|
103-
| [recipe-weekly-rebalance](./recipe-weekly-rebalance/SKILL.md) | Weekly rebalance to maintain target position allocations. |
104-
| [recipe-daily-pnl-report](./recipe-daily-pnl-report/SKILL.md) | Daily realised P&L summary from trades and wallet history. |
105-
| [recipe-portfolio-snapshot-csv](./recipe-portfolio-snapshot-csv/SKILL.md) | Export portfolio snapshot with balances and positions to CSV. |
106-
| [recipe-subaccount-capital-rotation](./recipe-subaccount-capital-rotation/SKILL.md) | Rotate capital between subaccounts based on strategy performance. |
107-
| [recipe-fee-tier-progress](./recipe-fee-tier-progress/SKILL.md) | Track trading volume and commission rates. |
103+
| [bitmex-recipe-weekly-rebalance](./bitmex-recipe-weekly-rebalance/SKILL.md) | Weekly rebalance to maintain target position allocations. |
104+
| [bitmex-recipe-daily-pnl-report](./bitmex-recipe-daily-pnl-report/SKILL.md) | Daily realised P&L summary from trades and wallet history. |
105+
| [bitmex-recipe-portfolio-snapshot-csv](./bitmex-recipe-portfolio-snapshot-csv/SKILL.md) | Export portfolio snapshot with balances and positions to CSV. |
106+
| [bitmex-recipe-subaccount-capital-rotation](./bitmex-recipe-subaccount-capital-rotation/SKILL.md) | Rotate capital between subaccounts based on strategy performance. |
107+
| [bitmex-recipe-fee-tier-progress](./bitmex-recipe-fee-tier-progress/SKILL.md) | Track trading volume and commission rates. |
108108

109109
### Market Data Recipes
110110

111111
| Skill | Description |
112112
|-------|-------------|
113-
| [recipe-morning-market-brief](./recipe-morning-market-brief/SKILL.md) | Morning summary: prices, funding, positions, and wallet. |
114-
| [recipe-multi-pair-breakout-watch](./recipe-multi-pair-breakout-watch/SKILL.md) | Monitor multiple symbols for price breakouts. |
115-
| [recipe-track-orderbook-depth](./recipe-track-orderbook-depth/SKILL.md) | Monitor order book depth and bid-ask imbalance for liquidity signals. |
116-
| [recipe-price-level-alerts](./recipe-price-level-alerts/SKILL.md) | Set up price level alerts for key levels. |
113+
| [bitmex-recipe-morning-market-brief](./bitmex-recipe-morning-market-brief/SKILL.md) | Morning summary: prices, funding, positions, and wallet. |
114+
| [bitmex-recipe-multi-pair-breakout-watch](./bitmex-recipe-multi-pair-breakout-watch/SKILL.md) | Monitor multiple symbols for price breakouts. |
115+
| [bitmex-recipe-track-orderbook-depth](./bitmex-recipe-track-orderbook-depth/SKILL.md) | Monitor order book depth and bid-ask imbalance for liquidity signals. |
116+
| [bitmex-recipe-price-level-alerts](./bitmex-recipe-price-level-alerts/SKILL.md) | Set up price level alerts for key levels. |
117117

118118
### Risk Recipes
119119

120120
| Skill | Description |
121121
|-------|-------------|
122-
| [recipe-emergency-flatten](./recipe-emergency-flatten/SKILL.md) | Cancel all orders and close all positions immediately. |
123-
| [recipe-drawdown-circuit-breaker](./recipe-drawdown-circuit-breaker/SKILL.md) | Halt trading when portfolio drawdown exceeds threshold. |
122+
| [bitmex-recipe-emergency-flatten](./bitmex-recipe-emergency-flatten/SKILL.md) | Cancel all orders and close all positions immediately. |
123+
| [bitmex-recipe-drawdown-circuit-breaker](./bitmex-recipe-drawdown-circuit-breaker/SKILL.md) | Halt trading when portfolio drawdown exceeds threshold. |
124124

125125
### Funding Recipes
126126

127127
| Skill | Description |
128128
|-------|-------------|
129-
| [recipe-withdrawal-to-cold-storage](./recipe-withdrawal-to-cold-storage/SKILL.md) | Safely withdraw funds to a pre-approved cold storage address. |
130-
| [recipe-staking-yield-compare](./recipe-staking-yield-compare/SKILL.md) | Compare staking yields across instruments to find the best rate. |
129+
| [bitmex-recipe-withdrawal-to-cold-storage](./bitmex-recipe-withdrawal-to-cold-storage/SKILL.md) | Safely withdraw funds to a pre-approved cold storage address. |
130+
| [bitmex-recipe-staking-yield-compare](./bitmex-recipe-staking-yield-compare/SKILL.md) | Compare staking yields across instruments to find the best rate. |

skills/bitmex-basis-trading/SKILL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ A positive basis (futures above perp) typically reflects cost-of-carry. The stra
2727
```bash
2828
# Perpetual
2929
PERP=$(bitmex market instrument --symbol XBTUSD -o json 2>/dev/null | \
30-
jq -r '.lastPrice')
30+
jq -r '.[0].lastPrice')
3131

3232
# Nearest quarterly future (example: XBTM25)
3333
FUT=$(bitmex market instrument --symbol XBTM25 -o json 2>/dev/null | \
34-
jq -r '.lastPrice')
34+
jq -r '.[0].lastPrice')
3535

3636
echo "Perp: $PERP | Future: $FUT"
3737
```
@@ -44,7 +44,7 @@ echo "Basis: ${BASIS}%"
4444

4545
# Days to expiry for annualized estimate
4646
SETTLE=$(bitmex market instrument --symbol XBTM25 -o json 2>/dev/null | \
47-
jq -r '.settle')
47+
jq -r '.[0].settle')
4848
echo "Settlement: $SETTLE"
4949
```
5050

@@ -86,8 +86,8 @@ bitmex order sell XBTM25 $QTY --price "$FUT" \
8686

8787
```bash
8888
# Check current basis
89-
PERP_NOW=$(bitmex market instrument --symbol XBTUSD -o json 2>/dev/null | jq -r '.lastPrice')
90-
FUT_NOW=$(bitmex market instrument --symbol XBTM25 -o json 2>/dev/null | jq -r '.lastPrice')
89+
PERP_NOW=$(bitmex market instrument --symbol XBTUSD -o json 2>/dev/null | jq -r '.[0].lastPrice')
90+
FUT_NOW=$(bitmex market instrument --symbol XBTM25 -o json 2>/dev/null | jq -r '.[0].lastPrice')
9191
BASIS_NOW=$(echo "scale=6; ($FUT_NOW - $PERP_NOW) / $PERP_NOW * 100" | bc -l)
9292
echo "Current basis: ${BASIS_NOW}%"
9393

skills/bitmex-dca-strategy/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export BITMEX_API_SECRET="testnet-secret"
3535
# Run 3 testnet cycles to verify logic
3636
for i in 1 2 3; do
3737
PRICE=$(bitmex --testnet market orderbook XBTUSD --depth 1 -o json 2>/dev/null | \
38-
jq '.bids[0][0]')
38+
jq '[.[] | select(.side == "Buy")] | .[0].price')
3939
bitmex --testnet order buy XBTUSD 100 --price "$PRICE" \
4040
--order-type Limit --exec-inst ParticipateDoNotInitiate \
4141
-o json 2>/dev/null | jq '{orderID, price, ordStatus}'
@@ -72,7 +72,7 @@ while true; do
7272

7373
# 3. Place limit order at best bid
7474
BID=$(bitmex market orderbook $SYMBOL --depth 1 -o json 2>/dev/null | \
75-
jq '.bids[0][0]')
75+
jq '[.[] | select(.side == "Buy")] | .[0].price')
7676
echo "DCA buy $QTY $SYMBOL @ $BID"
7777
bitmex order buy $SYMBOL $QTY \
7878
--price "$BID" \

skills/bitmex-fee-optimization/SKILL.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ BitMEX charges taker fees and pays maker rebates. The difference is meaningful a
2121
| Maker | Rebate | You earn (negative fee) |
2222
| Taker | Fee | You pay |
2323

24-
Check your current fee schedule:
24+
Check your current fee schedule (returns a map of symbol → fees):
2525

2626
```bash
27+
# All symbols
28+
bitmex account commission -o json 2>/dev/null
29+
30+
# Single symbol
2731
bitmex account commission -o json 2>/dev/null | \
28-
jq '{makerFee, takerFee, settlementFee}'
32+
jq '.XBTUSD | {makerFee, takerFee, settlementFee}'
2933
```
3034

3135
## Default: Post-Only Limit Orders
@@ -60,7 +64,7 @@ Market orders always pay taker fees. Use limit orders at aggressive prices (insi
6064

6165
```bash
6266
# Instead of market buy, use aggressive limit:
63-
ASK=$(bitmex market orderbook XBTUSD --depth 1 -o json 2>/dev/null | jq '.asks[0][0]')
67+
ASK=$(bitmex market orderbook XBTUSD --depth 1 -o json 2>/dev/null | jq '[.[] | select(.side=="Sell") | .price][0]')
6468
bitmex order buy XBTUSD 100 \
6569
--price "$ASK" \
6670
--order-type Limit \
@@ -85,12 +89,12 @@ bitmex order buy XBTUSD 100 \
8589
Higher 30-day trading volume unlocks lower fees:
8690

8791
```bash
88-
# Check your 30-day volume
92+
# Check your 30-day volume (returns array; first element has the totals)
8993
bitmex account volume -o json 2>/dev/null | \
90-
jq '{advUsd, advXBt}'
94+
jq '.[0] | {advUsd, advUsdContract, advUsdSpot}'
9195

92-
# Cross-reference with commission tiers
93-
bitmex account commission -o json 2>/dev/null
96+
# Cross-reference with commission tiers (returns map of symbol → fees)
97+
bitmex account commission -o json 2>/dev/null | jq '.XBTUSD'
9498
```
9599

96100
## Fee Audit from Trade History

skills/bitmex-funding-carry/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Only enter if the annualized yield exceeds transaction costs and risk premium. A
4444

4545
```bash
4646
# Annualized carry threshold check (e.g., > 10% annualized)
47-
RATE=$(bitmex market funding --symbol XBTUSD -o json 2>/dev/null | \
47+
RATE=$(bitmex market funding --symbol XBTUSD --count 1 --reverse -o json 2>/dev/null | \
4848
jq -r '.[0].fundingRate // 0')
4949
ANNUALIZED=$(echo "$RATE * 3 * 365 * 100" | bc -l)
5050
echo "Annualized funding yield: ${ANNUALIZED}%"
@@ -101,7 +101,7 @@ bitmex position list --symbol XBTUSD -o json 2>/dev/null | \
101101

102102
```bash
103103
# Check if rate has converged toward zero
104-
RATE=$(bitmex market funding --symbol XBTUSD -o json 2>/dev/null | \
104+
RATE=$(bitmex market funding --symbol XBTUSD --count 1 --reverse -o json 2>/dev/null | \
105105
jq -r '.[0].fundingRate // 0')
106106
EXIT_THRESHOLD=0.0001 # < 0.01% per 8h no longer worth holding
107107

0 commit comments

Comments
 (0)