openbroker 1.0.42 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to Open Broker will be documented in this file.
4
4
 
5
+ ## [1.0.44] - 2026-02-25
6
+
7
+ ### Added
8
+ - **Trade Fills**: New `fills` command to view trade fill history with prices, fees, and realized PnL
9
+ - **Order History**: New `orders` command to view all historical orders (filled, canceled, open, triggered, rejected)
10
+ - **Order Status**: New `order-status` command to check the status of a specific order by OID or CLOID
11
+ - **Fee Schedule**: New `fees` command to view fee tier, maker/taker rates, referral/staking discounts, and daily volumes
12
+ - **Candle Data**: New `candles` command to view OHLCV candlestick data with configurable intervals and bar counts
13
+ - **Funding History**: New `funding-history` command to view historical funding rates for any asset
14
+ - **Recent Trades**: New `trades` command to view the tape (time & sales) for an asset with buy/sell volume breakdown
15
+ - **Rate Limit**: New `rate-limit` command to check API rate limit usage, capacity, and cumulative volume
16
+ - **Cumulative Funding on Positions**: The `positions` command now shows cumulative funding received/paid per position
17
+ - **Client Extensions**: Added 9 new methods to HyperliquidClient
18
+ - `getUserFunding()` - Funding ledger updates
19
+ - `getUserFills()` - Trade fill history
20
+ - `getHistoricalOrders()` - All orders with statuses
21
+ - `getOrderStatus()` - Single order lookup
22
+ - `getUserFees()` - Fee schedule and volume
23
+ - `getCandleSnapshot()` - OHLCV candle data
24
+ - `getFundingHistory()` - Historical funding rates per asset
25
+ - `getRecentTrades()` - Recent trades for an asset
26
+ - `getUserRateLimit()` - API rate limit status
27
+ - **Plugin Tools**: Added 8 new OpenClaw plugin tools
28
+ - `ob_fills`, `ob_orders`, `ob_order_status`, `ob_fees`
29
+ - `ob_candles`, `ob_funding_history`, `ob_trades`, `ob_rate_limit`
30
+
5
31
  ## [1.0.37] - 2025-02-08
6
32
  - **Detailed Docs**: Adding detailed docs for all sub commands
7
33
 
package/README.md CHANGED
@@ -149,6 +149,111 @@ openbroker spot --top 20 # Top 20 by volume
149
149
  | `--top` | Limit to top N by volume | — |
150
150
  | `--verbose` | Show token metadata | — |
151
151
 
152
+ #### `fills` — Trade Fill History
153
+
154
+ View your trade executions with prices, fees, and realized PnL.
155
+
156
+ ```bash
157
+ openbroker fills # Recent fills
158
+ openbroker fills --coin ETH # ETH fills only
159
+ openbroker fills --coin BTC --side buy --top 50
160
+ ```
161
+
162
+ | Flag | Description | Default |
163
+ |------|-------------|---------|
164
+ | `--coin` | Filter by coin symbol | — |
165
+ | `--side` | Filter by side: `buy` or `sell` | — |
166
+ | `--top` | Number of recent fills to show | `20` |
167
+
168
+ #### `orders` — Order History
169
+
170
+ View all historical orders including filled, canceled, and rejected.
171
+
172
+ ```bash
173
+ openbroker orders # Recent orders
174
+ openbroker orders --coin ETH --status filled
175
+ openbroker orders --top 50
176
+ ```
177
+
178
+ | Flag | Description | Default |
179
+ |------|-------------|---------|
180
+ | `--coin` | Filter by coin symbol | — |
181
+ | `--status` | Filter by status (filled, canceled, open, triggered, etc.) | — |
182
+ | `--top` | Number of recent orders to show | `20` |
183
+
184
+ #### `order-status` — Check Order Status
185
+
186
+ Look up the status of a specific order by ID.
187
+
188
+ ```bash
189
+ openbroker order-status --oid 123456789 # By order ID
190
+ openbroker order-status --oid 0x1234... # By client order ID
191
+ ```
192
+
193
+ | Flag | Description | Default |
194
+ |------|-------------|---------|
195
+ | `--oid` | Order ID (number) or client order ID (hex string) | **required** |
196
+
197
+ #### `fees` — Fee Schedule
198
+
199
+ View your fee tier, maker/taker rates, discounts, and recent daily trading volumes.
200
+
201
+ ```bash
202
+ openbroker fees
203
+ ```
204
+
205
+ #### `candles` — OHLCV Candle Data
206
+
207
+ View candlestick chart data for an asset.
208
+
209
+ ```bash
210
+ openbroker candles --coin ETH # 24 hourly candles
211
+ openbroker candles --coin BTC --interval 4h --bars 48 # 48 four-hour bars
212
+ openbroker candles --coin SOL --interval 1d --bars 30 # 30 daily bars
213
+ ```
214
+
215
+ | Flag | Description | Default |
216
+ |------|-------------|---------|
217
+ | `--coin` | Asset symbol | **required** |
218
+ | `--interval` | Candle interval: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 3d, 1w, 1M | `1h` |
219
+ | `--bars` | Number of bars to fetch | `24` |
220
+
221
+ #### `funding-history` — Historical Funding Rates
222
+
223
+ View historical funding rate data for an asset.
224
+
225
+ ```bash
226
+ openbroker funding-history --coin ETH # Last 24h
227
+ openbroker funding-history --coin BTC --hours 168 # Last 7 days
228
+ ```
229
+
230
+ | Flag | Description | Default |
231
+ |------|-------------|---------|
232
+ | `--coin` | Asset symbol | **required** |
233
+ | `--hours` | Hours of history to fetch | `24` |
234
+
235
+ #### `trades` — Recent Trades (Tape)
236
+
237
+ View recent trades for an asset with buy/sell volume breakdown.
238
+
239
+ ```bash
240
+ openbroker trades --coin ETH # Last 30 trades
241
+ openbroker trades --coin BTC --top 50 # Last 50 trades
242
+ ```
243
+
244
+ | Flag | Description | Default |
245
+ |------|-------------|---------|
246
+ | `--coin` | Asset symbol | **required** |
247
+ | `--top` | Number of recent trades | `30` |
248
+
249
+ #### `rate-limit` — API Rate Limit
250
+
251
+ Check your API rate limit usage and capacity.
252
+
253
+ ```bash
254
+ openbroker rate-limit
255
+ ```
256
+
152
257
  ---
153
258
 
154
259
  ### Trading Commands
@@ -559,6 +664,113 @@ openbroker approve-builder --max-fee "0.05%" # Custom max fee
559
664
  | `--builder` | Custom builder address (advanced) | Open Broker |
560
665
  | `--verbose` | Show debug output | — |
561
666
 
667
+ ## OpenClaw Plugin
668
+
669
+ OpenBroker ships as an [OpenClaw](https://openclaw.ai) plugin. When installed via OpenClaw, it registers structured agent tools and a background position watcher — no Bash wrappers needed.
670
+
671
+ ### Install via OpenClaw
672
+
673
+ ```bash
674
+ openclaw plugins install openbroker
675
+ ```
676
+
677
+ Or install from a local checkout during development:
678
+
679
+ ```bash
680
+ openclaw plugins install -l ./open-broker-mvp
681
+ ```
682
+
683
+ After installation, run `openbroker setup` to configure your wallet (same onboarding as the standalone CLI).
684
+
685
+ ### Plugin Tools
686
+
687
+ When loaded, the plugin registers these agent tools:
688
+
689
+ | Category | Tool | Description |
690
+ |----------|------|-------------|
691
+ | Info | `ob_account` | Account balance, equity, margin, open orders |
692
+ | Info | `ob_positions` | Open positions with PnL, leverage, liquidation price |
693
+ | Info | `ob_fills` | Trade fill history with fees and realized PnL |
694
+ | Info | `ob_orders` | Order history (filled, canceled, open, etc.) |
695
+ | Info | `ob_order_status` | Check status of a specific order by ID |
696
+ | Info | `ob_fees` | Fee schedule, tier, maker/taker rates, volume |
697
+ | Info | `ob_funding` | Funding rates sorted by annualized rate |
698
+ | Info | `ob_funding_history` | Historical funding rates for an asset |
699
+ | Info | `ob_candles` | OHLCV candle data for an asset |
700
+ | Info | `ob_trades` | Recent trades (tape) for an asset |
701
+ | Info | `ob_markets` | Market data (price, volume, OI) |
702
+ | Info | `ob_search` | Search assets across perps, HIP-3, and spot |
703
+ | Info | `ob_spot` | Spot markets and token balances |
704
+ | Info | `ob_rate_limit` | API rate limit usage and capacity |
705
+ | Trading | `ob_buy` | Market buy |
706
+ | Trading | `ob_sell` | Market sell |
707
+ | Trading | `ob_limit` | Limit order (GTC, IOC, ALO) |
708
+ | Trading | `ob_trigger` | Trigger order (TP/SL) |
709
+ | Trading | `ob_tpsl` | Set TP/SL on existing position |
710
+ | Trading | `ob_cancel` | Cancel orders |
711
+ | Advanced | `ob_twap` | TWAP execution |
712
+ | Advanced | `ob_bracket` | Entry + TP + SL |
713
+ | Advanced | `ob_chase` | Chase price with ALO orders |
714
+ | Monitoring | `ob_watcher_status` | Background watcher state |
715
+
716
+ ### Background Position Watcher
717
+
718
+ The plugin runs a background service that polls your Hyperliquid account every 30 seconds and sends webhook notifications when:
719
+
720
+ - **Position opened** — new position detected
721
+ - **Position closed** — position removed
722
+ - **Size changed** — position increased or decreased
723
+ - **PnL threshold** — unrealized PnL changed by more than the configured % (default: 5%)
724
+ - **Margin warning** — margin usage exceeds threshold (default: 80%)
725
+
726
+ ### Plugin Configuration
727
+
728
+ Configure in your OpenClaw settings under `plugins.entries.openbroker.config`:
729
+
730
+ ```json
731
+ {
732
+ "privateKey": "0x...",
733
+ "accountAddress": "0x...",
734
+ "network": "mainnet",
735
+ "hooksToken": "your-hooks-secret",
736
+ "watcher": {
737
+ "enabled": true,
738
+ "pollIntervalMs": 30000,
739
+ "pnlChangeThresholdPct": 5,
740
+ "marginUsageWarningPct": 80,
741
+ "notifyOnPositionChange": true,
742
+ "notifyOnFunding": true
743
+ }
744
+ }
745
+ ```
746
+
747
+ All fields are optional — the plugin falls back to `~/.openbroker/.env` and environment variables.
748
+
749
+ ### OpenClaw Webhook Setup
750
+
751
+ For the position watcher to notify your agent, you need webhooks enabled in your OpenClaw gateway config:
752
+
753
+ ```yaml
754
+ hooks:
755
+ enabled: true
756
+ token: "your-hooks-secret" # Must match hooksToken in plugin config
757
+ ```
758
+
759
+ The watcher sends alerts to `POST /hooks/agent` with `wakeMode: "now"`, which triggers an immediate agent turn. The agent receives a message like:
760
+
761
+ ```
762
+ Position alert: ETH unrealized PnL changed from +$500 to -$200 (-140%).
763
+ ```
764
+
765
+ ### CLI Commands
766
+
767
+ The plugin also registers CLI commands accessible via the OpenClaw CLI:
768
+
769
+ ```bash
770
+ openclaw ob status # Show watcher state and current positions
771
+ openclaw ob watch # Run watcher in foreground (debugging)
772
+ ```
773
+
562
774
  ## Development
563
775
 
564
776
  For local development without global install:
package/SKILL.md CHANGED
@@ -4,8 +4,8 @@ description: Hyperliquid trading plugin with background position monitoring. Exe
4
4
  license: MIT
5
5
  compatibility: Requires Node.js 22+, network access to api.hyperliquid.xyz
6
6
  homepage: https://www.npmjs.com/package/openbroker
7
- metadata: {"author": "monemetrics", "version": "1.0.42", "openclaw": {"requires": {"bins": ["openbroker"], "env": ["HYPERLIQUID_PRIVATE_KEY"]}, "primaryEnv": "HYPERLIQUID_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "openbroker", "bins": ["openbroker"], "label": "Install openbroker (npm)"}]}}
8
- allowed-tools: ob_account ob_positions ob_funding ob_markets ob_search ob_spot ob_buy ob_sell ob_limit ob_trigger ob_tpsl ob_cancel ob_twap ob_bracket ob_chase ob_watcher_status Bash(openbroker:*)
7
+ metadata: {"author": "monemetrics", "version": "1.0.44", "openclaw": {"requires": {"bins": ["openbroker"], "env": ["HYPERLIQUID_PRIVATE_KEY"]}, "primaryEnv": "HYPERLIQUID_PRIVATE_KEY", "install": [{"id": "node", "kind": "node", "package": "openbroker", "bins": ["openbroker"], "label": "Install openbroker (npm)"}]}}
8
+ allowed-tools: ob_account ob_positions ob_funding ob_markets ob_search ob_spot ob_fills ob_orders ob_order_status ob_fees ob_candles ob_funding_history ob_trades ob_rate_limit ob_buy ob_sell ob_limit ob_trigger ob_tpsl ob_cancel ob_twap ob_bracket ob_chase ob_watcher_status Bash(openbroker:*)
9
9
  ---
10
10
 
11
11
  # Open Broker - Hyperliquid Trading CLI
@@ -111,6 +111,55 @@ openbroker spot --balances # Show your spot balances
111
111
  openbroker spot --top 20 # Top 20 by volume
112
112
  ```
113
113
 
114
+ ### Trade Fills
115
+ ```bash
116
+ openbroker fills # Recent fills
117
+ openbroker fills --coin ETH # ETH fills only
118
+ openbroker fills --coin BTC --side buy --top 50
119
+ ```
120
+
121
+ ### Order History
122
+ ```bash
123
+ openbroker orders # Recent orders (all statuses)
124
+ openbroker orders --coin ETH --status filled
125
+ openbroker orders --top 50
126
+ ```
127
+
128
+ ### Order Status
129
+ ```bash
130
+ openbroker order-status --oid 123456789 # Check specific order
131
+ openbroker order-status --oid 0x1234... # By client order ID
132
+ ```
133
+
134
+ ### Fee Schedule
135
+ ```bash
136
+ openbroker fees # Fee tier, rates, and volume
137
+ ```
138
+
139
+ ### Candle Data (OHLCV)
140
+ ```bash
141
+ openbroker candles --coin ETH # 24 hourly candles
142
+ openbroker candles --coin BTC --interval 4h --bars 48 # 48 four-hour bars
143
+ openbroker candles --coin SOL --interval 1d --bars 30 # 30 daily bars
144
+ ```
145
+
146
+ ### Funding History
147
+ ```bash
148
+ openbroker funding-history --coin ETH # Last 24h
149
+ openbroker funding-history --coin BTC --hours 168 # Last 7 days
150
+ ```
151
+
152
+ ### Recent Trades (Tape)
153
+ ```bash
154
+ openbroker trades --coin ETH # Last 30 trades
155
+ openbroker trades --coin BTC --top 50 # Last 50 trades
156
+ ```
157
+
158
+ ### Rate Limit
159
+ ```bash
160
+ openbroker rate-limit # API usage and capacity
161
+ ```
162
+
114
163
  ## Trading Commands
115
164
 
116
165
  ### Market Orders (Quick)
@@ -321,6 +370,53 @@ Run `openbroker setup` to create the global config interactively.
321
370
 
322
371
  The builder fee (1 bps / 0.01%) is hardcoded and not configurable.
323
372
 
373
+ ## OpenClaw Plugin (Optional)
374
+
375
+ This skill works standalone via Bash — every command above runs through the `openbroker` CLI. For enhanced features, the same `openbroker` npm package also ships as an **OpenClaw plugin** that you can enable alongside this skill.
376
+
377
+ ### What the plugin adds
378
+
379
+ - **Structured agent tools** (`ob_account`, `ob_buy`, `ob_limit`, etc.) — typed tool calls with proper input schemas instead of Bash strings. The agent gets structured JSON responses.
380
+ - **Background position watcher** — polls your Hyperliquid account every 30s and sends webhook alerts when positions open/close, PnL moves significantly, or margin usage gets dangerous.
381
+ - **CLI commands** — `openclaw ob status` and `openclaw ob watch` for inspecting the watcher.
382
+
383
+ ### Enable the plugin
384
+
385
+ The plugin is bundled in the same `openbroker` npm package. To enable it in your OpenClaw config:
386
+
387
+ ```yaml
388
+ plugins:
389
+ entries:
390
+ openbroker:
391
+ enabled: true
392
+ config:
393
+ hooksToken: "your-hooks-secret" # Required for watcher alerts
394
+ watcher:
395
+ enabled: true
396
+ pollIntervalMs: 30000
397
+ pnlChangeThresholdPct: 5
398
+ marginUsageWarningPct: 80
399
+ ```
400
+
401
+ The plugin reads wallet credentials from `~/.openbroker/.env` (set up by `openbroker setup`), so you don't need to duplicate `privateKey` in the plugin config unless you want to override.
402
+
403
+ ### Webhook setup for watcher alerts
404
+
405
+ For position alerts to reach the agent, enable hooks in your gateway config:
406
+
407
+ ```yaml
408
+ hooks:
409
+ enabled: true
410
+ token: "your-hooks-secret" # Must match hooksToken above
411
+ ```
412
+
413
+ Without hooks, the watcher still runs and tracks state (accessible via `ob_watcher_status`), but it can't wake the agent.
414
+
415
+ ### Using with or without the plugin
416
+
417
+ - **Skill only (no plugin):** Use Bash commands (`openbroker buy --coin ETH --size 0.1`). No background monitoring.
418
+ - **Skill + plugin:** The agent prefers the `ob_*` tools when available (structured data), falls back to Bash for commands not covered by tools (strategies, scale). Background watcher sends alerts automatically.
419
+
324
420
  ## Risk Warning
325
421
 
326
422
  - Always use `--dry` first to preview orders
package/bin/cli.ts CHANGED
@@ -23,6 +23,14 @@ const commands: Record<string, { script: string; description: string }> = {
23
23
  'all-markets': { script: 'info/all-markets.ts', description: 'View all markets (perps, HIP-3, spot)' },
24
24
  'search': { script: 'info/search-markets.ts', description: 'Search for assets across providers' },
25
25
  'spot': { script: 'info/spot.ts', description: 'View spot markets and balances' },
26
+ 'fills': { script: 'info/fills.ts', description: 'View trade fill history' },
27
+ 'orders': { script: 'info/orders.ts', description: 'View order history' },
28
+ 'order-status': { script: 'info/order-status.ts', description: 'Check status of a specific order' },
29
+ 'fees': { script: 'info/fees.ts', description: 'View fee schedule and volume' },
30
+ 'candles': { script: 'info/candles.ts', description: 'View OHLCV candle data' },
31
+ 'funding-history': { script: 'info/funding-history.ts', description: 'View historical funding rates' },
32
+ 'trades': { script: 'info/trades.ts', description: 'View recent trades for an asset' },
33
+ 'rate-limit': { script: 'info/rate-limit.ts', description: 'View API rate limit status' },
26
34
 
27
35
  // Operations
28
36
  'buy': { script: 'operations/market-order.ts', description: 'Market buy order' },
@@ -57,11 +65,19 @@ Setup:
57
65
  Info Commands:
58
66
  account View account balance, equity, and margin
59
67
  positions View open positions with PnL
68
+ fills View trade fill history
69
+ orders View order history (all statuses)
70
+ order-status Check status of a specific order
71
+ fees View fee schedule, tiers, and volume
60
72
  funding View funding rates (sorted by annualized rate)
73
+ funding-history View historical funding rates for an asset
74
+ candles View OHLCV candle data
75
+ trades View recent trades (tape) for an asset
61
76
  markets View market data for main perps
62
77
  all-markets View all markets (perps, HIP-3, spot)
63
78
  search Search for assets across all providers
64
79
  spot View spot markets and balances
80
+ rate-limit View API rate limit status
65
81
 
66
82
  Trading Commands:
67
83
  buy Market buy order
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openbroker",
3
3
  "name": "OpenBroker — Hyperliquid Trading",
4
- "version": "1.0.0",
4
+ "version": "1.0.44",
5
5
  "description": "Trade on Hyperliquid DEX with background position monitoring",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openbroker",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "Hyperliquid trading CLI - execute orders, manage positions, and run trading strategies",
5
5
  "type": "module",
6
6
  "bin": {