Curated shell-script examples for agents and automation built on top of bybit-cli.
These scripts are examples, not a framework. Review them before use, especially anything that places, amends, or cancels real orders.
- Prefer
--testnetfor all first runs and validation. - Read-only scripts are safest to publish and reuse.
- State-changing scripts can place, amend, or cancel orders and may use
-yfor unattended execution. risk-guardian.shdefaults to testnet and refuses mainnet unless you passLIVE=1 TESTNET=0.- Bybit testnet may reject
trade cancel-afterwithHTTP 403on some accounts or environments; this affectsdead-mans-switch.shand the optional timer step inrisk-guardian.sh. - The scripts in this directory assume current CLI JSON output shapes, not the old wrapped
.result...format.
Most scripts assume:
bybitonPATHjqbash
earn-brief.sh and earn-cycle.sh also accept BYBIT_BIN=/path/to/bybit and, when run from the repo, prefer target/debug/bybit(.exe) automatically so local development can use the current build instead of an older installed release.
earn-cycle.sh is intentionally interactive because Earn currently has no dry-run flag.
Some scripts also require:
python3sqlite3
| Script | Type | Risk | Notes |
|---|---|---|---|
earn-brief.sh |
Read-only | Low | Summarizes available Earn products, positions, order history, and yield history for a coin/category. Defaults to testnet. |
earn-cycle.sh |
Interactive Earn | High | Prompts for action, coin, product, and amount, then runs a real earn stake or earn redeem. Defaults to testnet and asks for its own final confirmation before executing with -y. |
breakout-detector.sh |
Read-only | Low | Detects simple volatility-expansion breakout setups from kline range structure, ATR compression/expansion, volume spike, and orderbook imbalance. |
price-level-alert.sh |
Read-only | Low | Watches a symbol for simple price/level conditions like above, below, near, or live crossing events, with one-shot and watch modes. |
risk-snapshot.sh |
Read-only | Low | AI-facing summary of account balance, positions, open orders, margin state, and options greeks with best-effort section-level error handling. |
trade-plan-builder.sh |
Read-only | Low | Turns a thesis, entry, stop, and target into a sized trade plan with reward/risk, exchange minimum checks, and --validate preview commands. |
signal-watch.sh |
Read-only | Low | Combines breakout and regime analysis into a compact signal object for one-shot use or watch-mode alerting. |
journal-capture.sh |
Local journal | Low | Appends a local JSONL journal entry with note/thesis plus live risk snapshot, signal watch, and optional trade plan context. SIGNAL_INTERVAL and SIGNAL_LIMIT let you align the embedded signal snapshot with the trade timeframe. |
morning-brief.sh |
Read-only | Low | Account, positions, orders, and market summary for LLM briefings. |
market-regime-monitor.sh |
Read-only | Low | Summarizes ticker, order book depth, and recent candle behavior into a simple market regime label. |
options-opportunity-scanner.sh |
Read-only | Low | Scans BTC/ETH option chains, scores contracts, and emits structured option candidates by strategy type. Defaults to mainnet data and supports view/risk/DTE filters. |
options-strategy-advisor.sh |
Read-only | Low | Opinionated layer on top of the scanner that returns the best single-leg idea, best spread, best hedge, and contracts to avoid for a view/risk/holding profile. |
options-protective-put.sh |
Read-only | Low | Suggests protective put candidates for BTC/ETH exposure, with estimated hedge notional and premium cost. Supports manual sizing or best-effort auto exposure discovery from wallet balance plus linear BASEUSDT positions. |
options-covered-call-finder.sh |
Read-only | Low | Ranks OTM call candidates for covered-call income on BTC/ETH spot exposure, with assignment-risk and premium-yield context. Supports manual sizing or best-effort auto exposure discovery. |
options-iv-skew-monitor.sh |
Read-only | Low | Compares call/put IV across comparable absolute-delta buckets within each expiry to highlight call-rich and put-rich skew distortions with basic liquidity and spread filters. |
options-greeks-risk-report.sh |
Read-only | Low | Estimates single-leg option greek impact and, when auth is available, projects current portfolio greeks before and after the proposed trade. Supports advisor-driven selection or SYMBOL=... override. |
paper-session.sh |
Paper trading | Low | End-to-end paper session: init, buy, limit order, cancel, sell, report. |
conditional-order.sh |
Trading | High | Polls live price and submits a market buy when a threshold is hit. |
dca-buy.sh |
Trading | High | Places repeated market buys on a timer. |
batch-limit-ladder.sh |
Trading | High | Builds and submits a batch of limit buy orders below market. |
dead-mans-switch.sh |
Risk control | Medium | Repeatedly refreshes trade cancel-after until stopped. |
close-all-positions.sh |
Trading | Very high | Cancels orders and closes all open positions in a category. |
risk-guardian.sh |
Risk control | High | Applies TP/SL and optional trailing stops to open positions, then arms cancel-after. Defaults to testnet. |
For public examples in docs or demos, prefer:
earn-brief.shbreakout-detector.shprice-level-alert.shrisk-snapshot.shtrade-plan-builder.shsignal-watch.shjournal-capture.shmarket-regime-monitor.shoptions-opportunity-scanner.shoptions-strategy-advisor.shoptions-protective-put.shoptions-covered-call-finder.shoptions-iv-skew-monitor.shoptions-greeks-risk-report.shmorning-brief.shpaper-session.sh
For advanced operator workflows, keep these clearly marked as dangerous:
earn-cycle.shconditional-order.shdca-buy.shbatch-limit-ladder.shclose-all-positions.shrisk-guardian.sh
./earn-brief.sh USDT FlexibleSaving 5./earn-cycle.sh./breakout-detector.sh BTCUSDT linear 60 48 | jq./breakout-detector.sh ETHUSDT linear 15 64 | jq./price-level-alert.sh BTCUSDT 66000 above linear | jqMODE=watch POLL_SECONDS=15 PRICE_SOURCE=mark ./price-level-alert.sh ETHUSDT 2050 cross_below linearTOLERANCE_PCT=0.2 ./price-level-alert.sh BTCUSDT 66500 near linear | jq./risk-snapshot.sh | jq./risk-snapshot.sh USDT BTC,ETH | jq./trade-plan-builder.sh BTCUSDT buy market 65000 70000 50 linear | jqRISK_PCT=0.5 THESIS="Fade resistance breakout failure" ./trade-plan-builder.sh ETHUSDT sell 2050 2100 1950 0 linear | jq./signal-watch.sh BTCUSDT linear 60 48 | jqMODE=watch POLL_SECONDS=60 ./signal-watch.sh ETHUSDT linear 15 64NOTE="Watching for reclaim follow-through" ./journal-capture.sh note BTCUSDT linear | jqPLAN_SIDE=buy PLAN_ENTRY=market PLAN_STOP=65000 PLAN_TARGET=70000 PLAN_RISK_USD=50 THESIS="Breakout retest" ./journal-capture.sh planned BTCUSDT linear | jqSIGNAL_INTERVAL=15 SIGNAL_LIMIT=64 NOTE="Lower-timeframe continuation watch" ./journal-capture.sh note ETHUSDT linear | jq./market-regime-monitor.sh BTCUSDT linear 60 20 | jq./options-opportunity-scanner.sh BTC bullish defined_risk 7 45 3 | jqTESTNET=true ./options-opportunity-scanner.sh ETH neutral income 14 60 5 | jq./options-strategy-advisor.sh BTC bullish defined_risk none 7 45 3 | jq./options-strategy-advisor.sh ETH neutral income spot 14 60 3 | jq./options-protective-put.sh BTC 1 7 45 3 | jq./options-protective-put.sh ETH auto 14 60 3 | jq./options-covered-call-finder.sh BTC 1 7 45 3 | jq./options-covered-call-finder.sh ETH auto 14 60 3 | jq./options-iv-skew-monitor.sh BTC 7 45 5 | jq./options-iv-skew-monitor.sh ETH 14 60 8 | jq./options-greeks-risk-report.sh BTC bullish defined_risk none 1 buy 7 45 | jqSYMBOL='<OPTION_SYMBOL>' ./options-greeks-risk-report.sh ETH bearish hedge spot 2 buy 14 60 | jqTESTNET=true ./risk-guardian.sh 3 1.5 250 linear 60LIVE=1 TESTNET=0 ./risk-guardian.sh 2 1 0 linear 30