Skip to main content

Bitnxs shares a Grok Bot template with read-only snapshots and dry-run trading scripts

DEV.toDEV.tobitnxs2026-11-20

ResearchGetting startedTutorial or promotionRead first
DEV.toDEV.tobitnxs2026-11-20

Open original

Overview

Bitnxs released a MIT Grok Bot template for its USDC-margin perpetuals DEX, with three skill files and two Python scripts. The tutorial shows a local read-only market check, how agents use skills, and a dry-run trading guard.

Workflow

Trigger: The author identifies as the Bitnxs team, a USDC-margin perpetuals DEX and template maintainer. The deliberately small MIT repo github.com/Bitnxs-Labs/bitnxs-grokbot has three skills (bitnxs-getting-started, bitnxs-market-brief, and bitnxs-trading) and two Python scripts (snapshot.py and trade_min.py). The author says all commands ran on the live API during writing. Skills are Markdown the agent reads. Scripts are what it executes and can run independently. Background from the author: BTC, ETH, and SOL perpetuals, up to 50x BTC/ETH and 20x SOL, hourly funding, 0.02% maker and 0.05% taker.

  1. By hand: Give the model a read-only JSON snapshot tool (portable method 1). snapshot.py uses Python's standard library without an API key. The examples clone the repo, list all markets or selected assets, and output machine-readable rows.

    ``bash git clone https://github.com/Bitnxs-Labs/bitnxs-grokbot cd bitnxs-grokbot ``

    ``bash python3 scripts/snapshot.py # every listed market python3 scripts/snapshot.py BTC ETH # just these python3 scripts/snapshot.py --json # machine-readable rows ``

    One table row per asset shows mark price, 24-hour change, hourly and annualized funding, open interest, 24-hour volume, and best bid/ask spread in bp. The last line shows minutes to hourly settlement. All POSTs go to https://api.bitnxs.com/info: meta for listings, allMids for prices, and marketSummary and l2Book per asset. Two pitfalls: Set User-Agent because Python urllib's default returns HTTP 403 and any custom string works. Check meta before a specific asset because unknown assets return all-zero summaries. The script checks assetToId and marks absent ones not listed. Funding is an hourly percentage, so 0.0100 means 0.01% per hour. Multiply by 24×365 to annualize for comparison rather than forecasting.

  2. Bot: Record API rules in the system prompt or skill (portable method 2, bitnxs-market-brief). Three skill roles:
    • bitnxs-getting-started starts the first conversation with a live snapshot, asks for assets, briefing preference and timing, and alerts at price, 24-hour percentage change, or funding thresholds. Save to memory and create two Routines for brief and alert, with silence when there is no trigger.
    • bitnxs-market-brief is read-only with no orders or keys. Public reads POST to /info with type. Missing Content-Type: application/json returns 415. Decimals are strings, timestamps UTC milliseconds, errors plain text. Candles require startTime and endTime in integer milliseconds and camelCase. Unknown interval silently falls back to 5m. recentTrades needs limit up to 500. No public liquidation feed, so label liquidation figures as estimates. The author says documenting APIs prevents guessed arguments and recurring 415 debugging.
    • bitnxs-trading alone touches accounts: place, edit, and cancel orders, change leverage, and set TP/SL. Users create a key under More > API Keys and provide it in a masked secret field, never in chat. README's Import Bitnxs Bot opens getting-started.
  3. By hand: Keep account writes separate with dry run, and make all Routines read-only (portable method 3). Routines never place orders. The minimal trade_min.py client needs only eth-account>=0.13. The examples set up a venv and run offline checks.

    ``bash python3 -m venv .venv .venv/bin/pip install "eth-account>=0.13" .venv/bin/python scripts/trade_min.py selftest ``

    selftest signs an example challenge with a throwaway key, recovers the address, and checks decimal formats. Expected output is selftest ok. Subcommands are account, place, cancel, cancel-all, leverage, tpsl, cancel-trigger, and selftest. Live use reads BITNXS_API_KEY and BITNXS_USER (main wallet address) from environment, with global flags before subcommands. The example dry-runs an unsent limit order.

    ``bash export BITNXS_USER=0xYourMainWallet export BITNXS_API_KEY=0xYourApiKey .venv/bin/python scripts/trade_min.py --dry-run place BTC buy 0.001 --price 50000 ``

    --dry-run only prints the /session/order body with sessionId, asset, isBuy true, limitPx 50000, sz 0.001, reduceOnly false, and orderType limit/Gtc. A write without --dry-run or --yes stops with live request: add --yes or --dry-run. The platform has no testnet and --yes creates real orders. Authentication uses a delegated signing key derived from the wallet. Get a challenge from /session/start, sign raw keccak rather than personal_sign, and send to /session/complete for a sessionId. No bearer or HMAC. The script revokes its own session when done.

Check: The author reports running all commands on the live API while writing. The source gives no further author checks or actual Grok Bot chat records or results. "selftest ok" is the expected output readers should see.

Key points and results

  • The template deliberately stays small. Three skills are Markdown instructions, and two scripts are the actual tools. They run without an agent, which the author calls the easiest way to see its data.
  • Write API quirks into the skill. The author says it prevents guessing parameters and repeatedly debugging the same 415. The source gives no comparison figures.
  • Guard every write. A write without --dry-run or --yes exits. With no testnet, --yes orders are real. Scheduled Routines are read-only and never trade.
  • Keep API keys out of chat. Create a key on the site and enter in a masked secret field.
  • There is no public liquidation data. Give clearly labeled estimates when asked rather than claiming real liquidation flows.
  • Annualized funding is for comparison. Multiply hourly funding by 24×365. The author explicitly distinguishes it from a forecast.
  • The platform has a separate experimental agent panel. bitnxs.com/#/agent works with OpenAI-compatible endpoints and applies the same idea separately from this template.
  • The author's closing risk notes: Leveraged perps can lose all margin rapidly. An agent does not change that and confidence is no evidence of a good trade. The post is not investment advice. Bitnxs excludes restricted territories including the US, Canada, UK, and mainland China. Withdrawals undergo about five minutes of review and can be held or denied. GitHub issues and PRs are welcome. For market data see www.bitnxs.com.
  • Grok Bot results are untested. This is the team's tutorial and promotion. Apart from the author's report of running commands, there are no actual template chats, results, or comparison figures (author's claim, not reproduced).

Source

Platform
DEV.to
Author
bitnxs
Published
Categories
Research, Getting started

What this evidence label means

Tutorial or promotion

This is a tutorial, or the content includes promotion. Examples in a tutorial are not a results report.

Read the editorial and evidence policy

Other cases in this scenario

This unofficial community project is independent of xAI. xAI has neither approved nor endorsed it. No sign-up. The methods and figures come from the original authors.