Language Setting: Set LANG=en in your .env file to display the CLI interface in English.
A Bun-powered multi-exchange perpetuals workstation that ships an SMA30 trend engine, a Guardian stop sentinel, and two market-making modes. It offers instant restarts, realtime market data, structured logging, and an Ink-based CLI dashboard.
If you'd like to support this project and get fee discounts, please consider using these referral links:
- Lighter referral link
- Aster referral link
- StandX referral link
- Binance referral link
- GRVT referral link
- Nado referral link
- Backpack referral link
- edgex referral link
- Paradex referral link
- Apex referral link
ritmex-bot provides an agent-friendly command interface for exchange capability checks, market data, account/position queries, order operations, and strategy execution.
- It keeps the current environment-variable system intact: no renaming and no new required keys.
--symbolis passed through exactly as provided (no symbol normalization).- It supports
--dry-runsimulation and--jsonstructured output for automation.
npx skills add https://github.com/discountry/ritmex-bot --skill use-ritmex-botIf you need a specific branch/tag, append --ref <branch-or-tag>.
Full guide: ritmex-bot CLI User Guide (English)
- ritmex-bot CLI User Guide (English)
- ritmex-bot CLI 使用手册(中文)
- Beginner-friendly Quick Start
- Grid Trading Strategy Guide
- Live data & risk sync via websockets with REST fallbacks and full reconciliation on restart.
- Trend strategy featuring SMA30 entries, fixed stop loss, trailing stop, Bollinger bandwidth gate, and profit-lock stepping.
- Guardian strategy that never opens trades but mirrors your live exposure, ensuring every position has a synced stop loss and trailing stop.
- Market-making loop with dual-sided quote chasing, loss caps, and automatic order healing.
- Modular architecture decoupling engines, exchange adapters, and the Ink CLI for easy venue or strategy extensions.
| Exchange | Contract Type | Required Environment Variables | Notes |
|---|---|---|---|
| Aster | USDT perpetuals | ASTER_API_KEY, ASTER_API_SECRET |
Default venue; works with the bootstrap script |
| StandX | USD perpetuals | STANDX_TOKEN |
Uses JWT token auth; prefer websocket streams |
| GRVT | USDT perpetuals | GRVT_API_KEY, GRVT_API_SECRET, GRVT_SUB_ACCOUNT_ID |
Switch GRVT_ENV between prod and testnet |
| Lighter | zkLighter perpetuals | LIGHTER_ACCOUNT_INDEX, LIGHTER_API_PRIVATE_KEY |
Defaults to LIGHTER_ENV=testnet |
| Backpack | USDC perpetuals | BACKPACK_API_KEY, BACKPACK_API_SECRET, BACKPACK_PASSWORD |
Set BACKPACK_SANDBOX=true for the sandbox |
| Paradex | StarkEx perpetuals | PARADEX_PRIVATE_KEY, PARADEX_WALLET_ADDRESS |
Toggle PARADEX_SANDBOX=true for the testnet |
| Nado | USDC perpetuals | NADO_SIGNER_PRIVATE_KEY, NADO_SUBACCOUNT_OWNER |
Switch NADO_ENV between inkMainnet and inkTestnet |
- Bun >= 1.2 (both
bunandbunxon PATH) - macOS, Linux, or Windows via WSL (native Windows works but WSL is recommended)
- Node.js is optional unless your tooling requires it
curl -fsSL https://github.com/discountry/ritmex-bot/raw/refs/heads/main/setup.sh | bashThe script installs Bun, project dependencies, collects Aster API credentials, generates .env, and launches the CLI. Prepare the relevant exchange API keys before running it.
- Clone the repository
Alternatively, download the ZIP from GitHub and extract it manually.
git clone https://github.com/discountry/ritmex-bot.git cd ritmex-bot - Install Bun
- macOS / Linux:
curl -fsSL https://bun.sh/install | bash - Windows PowerShell:
powershell -c "irm bun.sh/install.ps1 | iex"Re-open the terminal and verifybun -vprints a version.
- macOS / Linux:
- Install dependencies
bun install
- Create your environment file
Edit
cp .env.example .env
.envwith the exchange credentials and overrides you plan to use. - Launch the CLI
Use the arrow keys to pick a strategy,
bun run index.ts
Enterto start,Escto go back, andCtrl+Cto exit.
.env.example captures all defaults; the most common settings are summarised below.
| Variable | Purpose |
|---|---|
EXCHANGE |
Choose the venue (aster / binance / standx / grvt / lighter / backpack / paradex / nado) |
TRADE_SYMBOL |
Contract symbol (defaults to BTCUSDT) |
TRADE_AMOUNT |
Order size in base asset units |
LOSS_LIMIT |
Max per-trade loss in USDT before forced close |
TRAILING_PROFIT / TRAILING_CALLBACK_RATE |
Trailing stop trigger (USDT) and pullback percentage |
PROFIT_LOCK_TRIGGER_USD / PROFIT_LOCK_OFFSET_USD |
Profit lock trigger and offset thresholds |
BOLLINGER_* |
Bollinger bandwidth filters for the trend engine |
PRICE_TICK / QTY_STEP |
Exchange precision filters for price and quantity |
POLL_INTERVAL_MS |
Trend engine polling cadence in milliseconds |
MAX_CLOSE_SLIPPAGE_PCT |
Allowed deviation vs mark price when closing |
MAKER_* |
Maker-specific knobs (quote offsets, refresh cadence, slippage guard, etc.) |
CLI flags override environment variables at runtime:
bun run index.ts --exchange grvt --strategy maker bun run index.ts -e lighter -s offset-maker --silent
- Keep
EXCHANGE=aster(default value). - Supply
ASTER_API_KEYandASTER_API_SECRET. - Adjust
TRADE_SYMBOL,PRICE_TICK, andQTY_STEPto match the requested market. - The bootstrap script auto-populates these variables; manual installs must maintain them.
- Set
EXCHANGE=binance. - Provide
BINANCE_API_KEYandBINANCE_API_SECRET. - Set market mode via
BINANCE_MARKET_TYPE:perp: perpetual futures (default)spot: spot marketauto: resolve by symbol (not recommended when both spot/perp share the same symbol)
- Set
BINANCE_SYMBOL(or fallback toTRADE_SYMBOL):- Perp recommended:
BTCUSDT_PERP(orBTCUSDTwithBINANCE_MARKET_TYPE=perp) - Spot recommended:
BTCUSDT(also acceptsBTCUSDT_SPOT)
- Perp recommended:
- For Basis arbitrage on Binance, explicitly split legs:
BASIS_FUTURES_SYMBOL=BTCUSDT_PERPBASIS_SPOT_SYMBOL=BTCUSDT
- Optional sandbox/custom endpoints:
BINANCE_SANDBOX=trueBINANCE_SPOT_REST_URL/BINANCE_FUTURES_REST_URLBINANCE_SPOT_WS_URL/BINANCE_FUTURES_WS_URL
The Binance adapter is WS-first by default (depth/ticker/kline/account/order streams), with REST used only for reconciliation and fallback.
In spot mode, some derivatives-only protective order capabilities are exchange-limited, and the strategy will degrade gracefully based on venue capabilities.
Example (perp maker)
EXCHANGE=binance BINANCE_MARKET_TYPE=perp BINANCE_SYMBOL=BTCUSDT_PERP bun run index.ts --strategy makerExample (spot grid)
EXCHANGE=binance BINANCE_MARKET_TYPE=spot BINANCE_SYMBOL=BTCUSDT bun run index.ts --strategy gridThe strategy requires a StandX API Token and signing private key to place orders.
How to obtain (using StandX's official API generation feature):
- Open the StandX official API creation page: https://standx.com/user/session
- Connect your wallet and log in
- Click the "Generate API Token" button
- The page will display the following information:
- Token (JWT string starting with
eyJ) → Fill inSTANDX_TOKEN - Ed25519 Private Key (Base58 format, like
HdsyJD7oWgT...) → Fill inSTANDX_REQUEST_PRIVATE_KEY - Creation date and Validity days → Used to configure token expiry reminders
- Token (JWT string starting with
The Ed25519 Private Key is an auto-generated signing key used only for trade request signatures. Your assets remain in your main wallet and are completely safe.
Please keep these credentials safe and do not share them with anyone.
Configuration steps:
- Set
EXCHANGE=standx. - Provide
STANDX_TOKEN(JWT token for perps API). - Provide
STANDX_REQUEST_PRIVATE_KEY(Ed25519 signing private key, Base58 format). - Set
STANDX_SYMBOL(defaults toBTC-USD) and alignPRICE_TICK/QTY_STEP. - Recommended: configure token expiry settings:
STANDX_TOKEN_CREATE_DATE(creation date, formatYYYY-MM-DD)STANDX_TOKEN_VALIDITY_DAYS(validity days)
- Optional:
STANDX_BASE_URL,STANDX_WS_URL, orSTANDX_SESSION_IDfor custom endpoints.
- Set
EXCHANGE=grvtinside.env. - Fill
GRVT_API_KEY,GRVT_API_SECRET, andGRVT_SUB_ACCOUNT_ID. - Use
GRVT_ENV=testnetwhen targeting the test environment, and alignGRVT_INSTRUMENT/GRVT_SYMBOL. - Optional: provide
GRVT_COOKIEor a customGRVT_SIGNER_PATHwhen reusing an existing session.
- Set
EXCHANGE=lighter. - Provide
LIGHTER_ACCOUNT_INDEXandLIGHTER_API_PRIVATE_KEY(40-byte hex private key).LIGHTER_ACCOUNT_INDEXis your account index, which you can find by opening DevTools (F12) on the official website and observing API requests.LIGHTER_API_PRIVATE_KEYis your API private key. - Switch
LIGHTER_ENVtomainnet,staging, ordevwhen necessary; overrideLIGHTER_BASE_URLif endpoints differ. LIGHTER_SYMBOLdefaults toBTCUSDT; override price/size decimals when markets differ.
- Set
EXCHANGE=backpack. - Populate
BACKPACK_API_KEY,BACKPACK_API_SECRET, andBACKPACK_PASSWORD; addBACKPACK_SUBACCOUNTif you trade from a subaccount (defaults to main account ID). - Toggle
BACKPACK_SANDBOX=truefor the sandbox environment and verifyBACKPACK_SYMBOLmatches the contract (defaults toBTC_USD_PERP). - Enable
BACKPACK_DEBUG=truefor verbose adapter logging.
- Set
EXCHANGE=paradex. - Provide
PARADEX_PRIVATE_KEY(EVM private key) andPARADEX_WALLET_ADDRESS. Note: These are your EVM wallet address and private key. It is recommended to create a brand new wallet and avoid storing unrelated assets in it. - The adapter connects to mainnet by default; enable
PARADEX_SANDBOX=trueand adjustPARADEX_SYMBOLfor testnet usage. - Advanced tuning: use
PARADEX_USE_PRO,PARADEX_RECONNECT_DELAY_MS, or debug flags as needed.
- Set
EXCHANGE=nado. - On the Nado web app (trading interface), open DevTools (F12) -> switch to the
Applicationtab ->Local Storage, locatenado.userSettings, then grab theprivateKeyfield from its JSON value and paste it into.envasNADO_SIGNER_PRIVATE_KEY. - Provide
NADO_SUBACCOUNT_OWNER(orNADO_EVM_ADDRESS). - Select network via
NADO_ENV=inkMainnet(mainnet) orinkTestnet(testnet). - Set
NADO_SYMBOLusing Nado product symbols likeBTC-PERP(it also acceptsBTCUSDT0and maps it toBTC-PERP).
bun run index.ts # Launch the CLI (default entrypoint)
bun run start # Alias for bun run index.ts
bun run dev # Development entrypoint
bun x vitest run # Execute the full Vitest suiteThe project now supports a standalone command mode with the command name ritmex-bot:
ritmex-bot doctor
ritmex-bot exchange list
ritmex-bot market ticker --exchange binance --symbol BTCUSDT
ritmex-bot order create --exchange binance --symbol BTCUSDT --side buy --type limit --quantity 0.01 --price 90000 --dry-run
ritmex-bot strategy run --strategy maker --exchange standx --silent --dry-run# Global install
npm install -g ritmex-bot
ritmex-bot doctor
# No install
npx ritmex-bot doctor
bunx ritmex-bot doctor--exchange: picks exchange using the existing env/config logic--symbol: passed through as-is (no symbol normalization)--dry-run: simulation mode (no real create/cancel side effects)--json: structured JSON output for AI agents--timeout: command timeout in milliseconds
Skip the Ink menu and start a strategy directly:
bun run index.ts --strategy trend --silent
bun run index.ts --strategy maker --silent
bun run index.ts --strategy offset-maker --silentCombine with --exchange/-e to pin the venue for that run.
Convenience aliases exposed via package.json:
bun run start:trend:silent
bun run start:maker:silent
bun run start:offset:silentInstall pm2 locally (e.g. bun add -d pm2) and launch the process:
bunx pm2 start bun --name ritmex-trend --cwd . --restart-delay 5000 -- run index.ts --strategy trend --silentYou can also call the bundled scripts:
bun run pm2:start:trend
bun run pm2:start:maker
bun run pm2:start:offsetRun pm2 save afterwards if you want the process list to survive reboots.
Powered by Vitest:
bun run test
bun x vitest --watch- Keep at least 50-100 USDT in the account before deploying a live strategy.
- Configure leverage on the exchange manually (~50x is recommended); the bot will not change it.
- Ensure your server or workstation clock is in sync to avoid signature errors.
- Accounts must run in one-way position mode.
- Env not loading: make sure
.envlives in the repo root and variable names are spelled correctly. - Permission rejected: confirm the API key has perpetual trading scopes enabled.
- Precision errors: align
PRICE_TICK,QTY_STEP, andTRADE_SYMBOLwith the exchange filters. See simple-readme.md for more detailed walkthroughs.
- Telegram: https://t.me/+4fdo0quY87o4Mjhh
- Issues and PRs are welcome for bug reports and feature requests
Algorithmic trading carries risk. Validate strategies with paper trading or small capital first, safeguard your API keys, and only grant the minimum required permissions.