2025-09-23 16:33:40 +08:00
2025-09-23 01:26:49 +08:00
2025-09-23 01:26:49 +08:00
2025-09-23 16:25:15 +08:00
2025-09-23 16:00:51 +08:00
2025-09-23 16:33:40 +08:00
2025-09-23 02:01:55 +08:00
2025-09-23 01:26:49 +08:00
2025-09-23 01:26:49 +08:00
2025-09-23 01:26:49 +08:00
2025-09-23 02:10:27 +08:00
2025-09-23 16:33:40 +08:00
2025-09-23 01:26:49 +08:00

快速上手(小白友好版)

  1. 安装 Bun ≥ 1.2,并执行 bun install 下载安装依赖。
  2. 复制 .env.example.env 并填入你的 Aster API Key/Secret,例如:
    cp .env.example .env
    
    然后修改 .env 中的配置项(交易对、下单量、风控等)。
  3. 运行机器人:
    bun run index.ts
    
    在终端中按 ↑/↓ 选择 “趋势策略” 或 “做市策略”,回车启动。按 Esc 可返回选择菜单,Ctrl+C 退出。
  4. 仿真/测试环境建议先设置极小仓位;真实资金请确保 API 仅开启所需权限,并先在低金额下验证策略行为。

ritmex-bot

A Bun-powered trading workstation for Aster perpetual contracts. The project ships two production strategies—an SMA30 trend follower and a dual-sided maker—that share a modular gateway, UI, and persistence layer. Everything runs in the terminal via Ink, with live websocket refresh and automatic recovery from restarts or network failures.

Features

  • Live data over websockets with REST fallbacks and automatic re-sync after reconnects.
  • Trend strategy: SMA30 crossover entries, automated stop-loss / trailing-stop, and P&L tracking.
  • Maker strategy: adaptive bid/ask chasing, risk stops, and target order introspection.
  • Extensibility: exchange gateway, engines, and UI components are modular for new venues or strategies.

Requirements

  • Bun ≥ 1.2
  • Node.js (optional, only if you prefer npm tooling)
  • Valid Aster API credentials with futures access

Installation

bun install

Configuration

Create an .env (or export environment variables) with at least:

ASTER_API_KEY=your_key
ASTER_API_SECRET=your_secret
TRADE_SYMBOL=BTCUSDT        # optional, defaults to BTCUSDT
TRADE_AMOUNT=0.001          # position size used by both strategies
LOSS_LIMIT=0.03             # per-trade USD loss cap

Additional maker-specific knobs (MAKER_*) live in src/config.ts and may be overridden via env vars.

Running the CLI

bun run index.ts   # or: bun run dev / bun run start

Pick a strategy with the arrow keys. Press Esc to return to the menu. The dashboard shows live order books, holdings, pending orders, and recent events. 状态完全以交易所数据为准,重新启动时会自动同步账户和挂单。

Testing

bun run test        # bun x vitest run
bun run test:watch  # stay in watch mode

Current tests cover the order coordinator utilities and strategy helpers; add unit tests beside new modules as you extend the system.

Project Layout

  • src/config.ts shared runtime configuration
  • src/core/ trend & maker engines plus order coordination
  • src/exchanges/ Aster REST/WS gateway and adapters
  • src/ui/ Ink components and strategy dashboards
  • src/utils/ math helpers, persistence, strategy utilities
  • tests/ Vitest suites for critical modules

Troubleshooting

  • Websocket reconnect loops: ensure outbound access to wss://fstream.asterdex.com/ws and REST endpoints.
  • 429 or 5xx responses: the gateway backs off automatically, but check your rate limits and credentials.
  • CLI input errors: run in a real TTY; non-interactive shells disable keyboard shortcuts but the UI still renders.

Contributing

Issues and PRs are welcome. When adding strategies or exchanges, follow the modular patterns in src/core and add tests under tests/.

S
Description
No description provided
Readme
67 MiB
Languages
TypeScript 98.6%
Python 1.1%
Shell 0.3%