Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.

Commit 2a48ccd

Browse files
committed
docs: add Pulse trader and enhance Threshold Guard documentation
- Introduced detailed documentation for the new Pulse trader feature, including setup, quick start instructions, and operational commands. - Expanded the Threshold Guard section to clarify its role in single-pool trading and its relationship with the Pulse trader. - Updated links in the overview to direct users to the new Pulse trader documentation for better navigation.
1 parent 33700fc commit 2a48ccd

2 files changed

Lines changed: 107 additions & 2 deletions

File tree

docs/agents-and-bds/bds-agent-headless.md

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,114 @@ The key difference from the hosted server:
308308

309309
For laptop use in Cursor or Claude Code, the stdio path is adequate. For agents running in remote environments or frameworks that cannot spawn child processes, use the hosted server.
310310

311+
## Pulse trader (`bds-agent trade`)
312+
313+
**Pulse** is a self-contained momentum trader: it subscribes to the BDS **`/mpp/stream/allTrades`** SSE feed, scores each epoch with **price + volume + flow** confluence, and (when not in dry-run) swaps on **Ethereum mainnet** via Uniswap V3 SwapRouter. Production setups use **`--multi-pool`** and the **USD Price Feed** (`--price-source usd`, default) so alt USDC pairs are not drowned out by flat trade-implied prices on WETH/USDC.
314+
315+
**Prerequisites:** same as the rest of this guide — profile with `api_key`, `bds-agent config init`, and credits. Trading uses a **separate** wallet from billing.
316+
317+
| File (profile `pulse`) | Purpose |
318+
|------------------------|---------|
319+
| `profiles/pulse.json` | API key, `bds_base_url`, catalog URLs |
320+
| `profiles/pulse.evm.env` | **Billing**`signup-pay`, on-chain credit top-up |
321+
| `profiles/pulse.trade.env` | **Trading** — swaps only (`trade setup-evm`) |
322+
| `profiles/pulse.trader.json` | Open positions (one LONG per pool) |
323+
| `profiles/pulse.trades.jsonl` | Trade log |
324+
325+
Use the same `--profile` on every command. **Do not** swap from the billing wallet.
326+
327+
### Quick start (dry-run → live)
328+
329+
```bash
330+
# After signup + config init (sections above)
331+
bds-agent trade setup-evm --profile pulse
332+
333+
# Phase 1 — paper trades, no on-chain swaps
334+
bds-agent trade run --profile pulse --dry-run --multi-pool --verbose
335+
336+
# Phase 2 — live (fund trading wallet: USDC for size + ETH for gas)
337+
bds-agent trade run --profile pulse --multi-pool --price-source usd --size 25
338+
```
339+
340+
Fund **`profiles/<name>.trade.env`** only. First live swap per token may need a one-time ERC-20 **approve** before the router swap.
341+
342+
### Multi-pool mode (`--multi-pool`)
343+
344+
Each BDS epoch (~12s on ETH mainnet):
345+
346+
1. Ingest per-pool trades from the shared `allTrades` stream
347+
2. Run Pulse on each watchlist pool (USD window when `--price-source usd`)
348+
3. Open up to **`--max-open-positions`** concurrent LONGs (default **5** with `--multi-pool`, **1** without) — **one position per pool**
349+
4. **Live:** USDC ↔ base token on each selected pool (not WETH-only)
350+
351+
Watchlist comes from **`GET /mpp/dailyActivePools`** (default top **40** pools, 5m interval) and refreshes about every **30 epochs**.
352+
353+
```bash
354+
bds-agent trade run --profile pulse --dry-run --multi-pool --verbose \
355+
--active-pool-limit 40 --active-interval 300 --price-source usd --max-open-positions 5
356+
```
357+
358+
### Entry signal defaults
359+
360+
| Flag | Default | Meaning |
361+
|------|---------|---------|
362+
| `--price-source` | `usd` | `usd` = `/mpp/tokenPrices/...` per epoch; `trades` = swap-implied only |
363+
| `--price-move` | `0.15` | Min price change % in the lookback window |
364+
| `--volume-burst` | `2.0` | Short-window volume vs trailing baseline |
365+
| `--flow-imbalance` | `30` | Directional flow as % of volume |
366+
| `--window-minutes` | `5` | Signal lookback |
367+
| `--size` | (required live) | USDC notional per entry |
368+
| `--slippage` | `0.01` | Uniswap `amountOutMinimum` floor (no silent relax to zero) |
369+
| `--max-open-positions` | auto | `0` = 5 with `--multi-pool`, else 1 |
370+
| `--daily-loss-limit` | `50` | Block new entries if today realized P/L ≤ −$50 (UTC) |
371+
| `--reentry-cooldown-minutes` | `0` | Optional: block all new entries N minutes after a **live** exit |
372+
| `--signal-cooldown-minutes` | `0` | Optional: per-pool spacing after a LONG fires |
373+
374+
**Dry-run → live:** paper positions do not block live startup; starting **live** clears paper state. Use **`--verbose`** during validation — one heartbeat line per epoch (gates, `px=`, burst, imbalance, position state).
375+
376+
### Exit strategies (defaults on)
377+
378+
Disable any rule with `--no-exit-*`. First match wins: **stop-loss → take-profit → trailing-stop → time-based → signal-reversal**.
379+
380+
| Flag | Default | Role |
381+
|------|---------|------|
382+
| `--exit-stop-loss-pct` | `2.0` | Cut if price falls X% below entry |
383+
| `--exit-take-profit-pct` | `1.0` | Take if price rises X% above entry |
384+
| `--exit-trailing-pct` | `2.0` | Exit X% below peak since entry |
385+
| `--exit-hold-minutes` | `10` | Max hold time |
386+
| `--exit-signal-reversal` | on | Exit on Pulse SHORT on the entry pool |
387+
388+
### Metering (Pulse)
389+
390+
| Route | When |
391+
|-------|------|
392+
| `/mpp/stream/allTrades` | Once per `trade run` session (per SSE connection) |
393+
| `/mpp/tokenPrices/...` | Each epoch per watched token when `--price-source usd` |
394+
| `/mpp/dailyActivePools` | Watchlist refresh (~every 30 epochs) |
395+
396+
There is **no** separate “Pulse fee” — only catalog-priced BDS routes. See [Metering & API Keys → How much each call costs](./metering-and-api-keys.md#how-much-each-call-costs). On **HTTP 402** (credits exhausted), USD fetches fail fast with a top-up hint; the trader stops rather than using stale prices.
397+
398+
```bash
399+
bds-agent credits balance
400+
bds-agent credits usage by-endpoint --days 7 --limit 50
401+
```
402+
403+
### Ops commands
404+
405+
```bash
406+
bds-agent trade setup-evm --profile pulse
407+
bds-agent trade status --profile pulse
408+
bds-agent trade history --profile pulse
409+
bds-agent trade pnl --profile pulse
410+
bds-agent trade exit --profile pulse # all open
411+
bds-agent trade exit --profile pulse --pool 0x… # one pool
412+
```
413+
414+
**Full CLI reference** (verbose heartbeat legend, risk controls, guard composition): [`bds-agent-py``docs/TRADE.md`](https://github.com/powerloom/bds-agent-py/blob/main/docs/TRADE.md).
415+
311416
## Threshold Guard (`bds-agent guard`)
312417

313-
Bracket trading on **one** USDC-quoted Uniswap V3 pool using BDS **spot USD** prices (`GET /mpp/token/price/{token}/{pool}`). Complements the **Pulse** trader (`bds-agent trade run`), which uses the live trade stream and multi-pool confluence. Guard is for a single pool with percent take-profit / stop-loss and optional dip re-entry.
418+
Bracket trading on **one** USDC-quoted Uniswap V3 pool using BDS **spot USD** prices (`GET /mpp/token/price/{token}/{pool}`). Complements **Pulse** above: Guard is single-pool percent brackets and optional dip re-entry; Pulse is stream confluence across many pools.
314419

315420
**Setup:** same profile API key and swap wallet as Pulse — `bds-agent trade setup-evm --profile NAME` writes `profiles/<NAME>.trade.env`.
316421

docs/agents-and-bds/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ This path is optimized for fast time-to-first-alert: the agent uses MCP tools ex
8080

8181
The **`bds-agent`** CLI (install: **`pip install bds-agent`** or **`uv tool install bds-agent`**, package [`bds-agent` on PyPI](https://pypi.org/project/bds-agent/), source [`powerloom/bds-agent-py`](https://github.com/powerloom/bds-agent-py)) does **not** require an MCP server. It translates natural-language queries to structured YAML recipes and executes them directly against the metered resolver routes. It supports wallet-funded automated signup and top-up, making it suitable for agent sandboxes and external orchestration frameworks (LangGraph, CrewAI, and others) where spawning an MCP subprocess is impractical.
8282

83-
Beyond **`run`** / **`query`**, the CLI includes a **Pulse** trader (`trade run` — stream confluence, multi-pool) and **Threshold Guard** (`guard run` — one pool, percent take-profit/stop-loss, optional idle exit in USDC for composed agent loops). See [`Headless CLI`](./bds-agent-headless.md#threshold-guard-bds-agent-guard).
83+
Beyond **`run`** / **`query`**, the CLI includes a **Pulse** trader (`trade run` — stream confluence, multi-pool) and **Threshold Guard** (`guard run` — one pool, percent take-profit/stop-loss, optional idle exit in USDC for composed agent loops). See [`Headless CLI` → Pulse](./bds-agent-headless.md#pulse-trader-bds-agent-trade) and [`Threshold Guard`](./bds-agent-headless.md#threshold-guard-bds-agent-guard).
8484

8585
**Best fit:** headless agents, external orchestration, programmatic wallet-based signup, any environment where the MCP process model is not viable.
8686

0 commit comments

Comments
 (0)