openbroker 1.0.33

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 ADDED
@@ -0,0 +1,94 @@
1
+ # Changelog
2
+
3
+ All notable changes to Open Broker will be documented in this file.
4
+
5
+ ## [1.0.3] - 2025-02-05
6
+
7
+ ### Added
8
+ - **CLI Package**: Now installable as global CLI via `npm install -g openbroker`
9
+ - Single `openbroker` command with subcommands
10
+ - Shortcuts: `openbroker buy`, `openbroker sell` for quick market orders
11
+ - Full help: `openbroker --help`
12
+ - **All Markets View**: New `all-markets.ts` script to view markets across all venues
13
+ - Shows main perps, HIP-3 perps, and spot markets in one view
14
+ - Filter by type: `--type perp`, `--type hip3`, `--type spot`
15
+ - Sort by 24h volume
16
+ - **Market Search**: New `search-markets.ts` script to find assets across providers
17
+ - Search by coin name: `--query GOLD`, `--query BTC`
18
+ - Shows funding comparison when same asset available on multiple HIP-3 providers
19
+ - Displays price, volume, funding, and open interest
20
+ - **Spot Markets**: New `spot.ts` script for spot market info
21
+ - View all spot trading pairs with prices and volumes
22
+ - Check spot token balances with `--balances`
23
+ - Filter by coin: `--coin PURR`
24
+ - **Client Extensions**: Added new methods to HyperliquidClient
25
+ - `getPerpDexs()` - Get all perp DEXs including HIP-3
26
+ - `getAllPerpMetas()` - Get all perp markets across venues
27
+ - `getSpotMeta()` - Spot market metadata
28
+ - `getSpotMetaAndAssetCtxs()` - Spot metadata with prices/volumes
29
+ - `getSpotBalances()` - User's spot token balances
30
+ - `getTokenDetails()` - Token info by ID
31
+ - `getPredictedFundings()` - Predicted funding rates across venues
32
+
33
+ ## [1.0.2] - 2025-02-05
34
+
35
+ ### Added
36
+ - **Trigger Orders**: New `trigger-order.ts` script for standalone stop loss and take profit orders
37
+ - **Set TP/SL**: New `set-tpsl.ts` script to add TP/SL to existing positions
38
+ - Supports absolute prices (`--tp 40`)
39
+ - Supports percentage from entry (`--tp +10%`, `--sl -5%`)
40
+ - Supports breakeven (`--sl entry`)
41
+ - Validates TP/SL make sense for position direction
42
+ - Calculates and displays risk/reward ratio
43
+ - **Order Types Documentation**: Clear explanation of limit orders vs trigger orders in SKILL.md
44
+
45
+ ### Fixed
46
+ - TIF case sensitivity issue in `limit-order.ts` and `scale.ts` (SDK expects "Gtc" not "GTC")
47
+ - Path resolution for `.env` file when packaged as skill
48
+ - Suppressed dotenv logging noise with `DOTENV_CONFIG_QUIET`
49
+
50
+ ## [1.0.1] - 2025-02-05
51
+
52
+ ### Added
53
+ - **Automated Onboarding**: New `onboard.ts` script for one-command setup
54
+ - Prompts user to use existing key or generate new wallet
55
+ - Creates `.env` file automatically
56
+ - Approves builder fee (free, no funds needed)
57
+ - Displays wallet address for funding
58
+ - Interactive wallet setup flow for AI agents
59
+
60
+ ### Changed
61
+ - Updated SKILL.md and README.md with simplified onboarding instructions
62
+ - Config now gracefully handles missing `.env` file with helpful error messages
63
+
64
+ ## [1.0.0] - 2025-02-04
65
+
66
+ ### Added
67
+ - **Core Trading**
68
+ - Market orders with slippage protection
69
+ - Limit orders (GTC, IOC, ALO)
70
+ - Order cancellation
71
+ - Position management
72
+
73
+ - **Advanced Execution**
74
+ - TWAP (Time-Weighted Average Price)
75
+ - Scale in/out with price distribution
76
+ - Bracket orders (entry + TP + SL)
77
+ - Chase orders (follow price with ALO)
78
+
79
+ - **Trading Strategies**
80
+ - Funding arbitrage
81
+ - Grid trading
82
+ - DCA (Dollar Cost Averaging)
83
+ - Market making (spread and maker-only)
84
+
85
+ - **Info Scripts**
86
+ - Account overview
87
+ - Position details
88
+ - Funding rates
89
+ - Market data
90
+
91
+ - **Builder Fee Support**
92
+ - 1 bps (0.01%) fee on trades
93
+ - One-time approval flow
94
+ - API wallet support
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # Open Broker
2
+
3
+ Hyperliquid trading CLI. Execute orders, manage positions, and run trading strategies on Hyperliquid DEX.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g openbroker
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # 1. Setup (generates wallet, creates config, approves builder fee)
15
+ openbroker setup
16
+
17
+ # 2. Fund your wallet with USDC on Arbitrum, then deposit at https://app.hyperliquid.xyz/
18
+
19
+ # 3. Start trading
20
+ openbroker account # View account info
21
+ openbroker buy --coin ETH --size 0.1 # Market buy
22
+ openbroker search --query GOLD # Find markets
23
+ ```
24
+
25
+ ## Commands
26
+
27
+ ### Setup
28
+ ```bash
29
+ openbroker setup # Interactive setup wizard
30
+ openbroker approve-builder # Approve builder fee (one-time)
31
+ ```
32
+
33
+ ### Account Info
34
+ ```bash
35
+ openbroker account # Balance, equity, margin
36
+ openbroker positions # Open positions with PnL
37
+ openbroker funding --top 20 # Funding rates
38
+ openbroker markets --coin ETH # Market data
39
+ openbroker all-markets # All markets (perps, HIP-3, spot)
40
+ openbroker search --query GOLD # Search across providers
41
+ openbroker spot --balances # Spot balances
42
+ ```
43
+
44
+ ### Trading
45
+ ```bash
46
+ # Market orders
47
+ openbroker buy --coin ETH --size 0.1
48
+ openbroker sell --coin BTC --size 0.01
49
+
50
+ # Limit orders
51
+ openbroker limit --coin ETH --side buy --size 1 --price 3000
52
+
53
+ # TP/SL on existing position
54
+ openbroker tpsl --coin HYPE --tp 40 --sl 30
55
+ openbroker tpsl --coin ETH --tp +10% --sl -5%
56
+
57
+ # Cancel orders
58
+ openbroker cancel --coin ETH # Cancel all ETH orders
59
+ openbroker cancel --all # Cancel all orders
60
+ ```
61
+
62
+ ### Advanced Execution
63
+ ```bash
64
+ # TWAP - split order over time
65
+ openbroker twap --coin ETH --side buy --size 1 --duration 3600
66
+
67
+ # Scale - grid of limit orders
68
+ openbroker scale --coin ETH --side buy --size 1 --levels 5 --range 2
69
+
70
+ # Bracket - entry with TP and SL
71
+ openbroker bracket --coin ETH --side buy --size 0.5 --tp 3 --sl 1.5
72
+
73
+ # Chase - follow price with ALO orders
74
+ openbroker chase --coin ETH --side buy --size 0.5 --timeout 300
75
+ ```
76
+
77
+ ### Strategies
78
+ ```bash
79
+ # Funding arbitrage
80
+ openbroker funding-arb --coin ETH --size 5000 --min-funding 25
81
+
82
+ # Grid trading
83
+ openbroker grid --coin ETH --lower 3000 --upper 4000 --grids 10 --size 0.1
84
+
85
+ # DCA
86
+ openbroker dca --coin ETH --amount 100 --interval 1h --count 24
87
+
88
+ # Market making
89
+ openbroker mm-maker --coin HYPE --size 1 --offset 1
90
+ ```
91
+
92
+ ## Options
93
+
94
+ | Option | Description |
95
+ |--------|-------------|
96
+ | `--coin` | Asset symbol (ETH, BTC, SOL, HYPE, etc.) |
97
+ | `--side` | Order direction: `buy` or `sell` |
98
+ | `--size` | Order size in base asset |
99
+ | `--price` | Limit price |
100
+ | `--dry` | Preview without executing |
101
+ | `--help` | Show command help |
102
+
103
+ ## Safety
104
+
105
+ **Always use `--dry` first** to preview any operation:
106
+
107
+ ```bash
108
+ openbroker buy --coin ETH --size 0.1 --dry
109
+ ```
110
+
111
+ **Use testnet** for testing:
112
+
113
+ ```bash
114
+ export HYPERLIQUID_NETWORK="testnet"
115
+ ```
116
+
117
+ ## Configuration
118
+
119
+ Create a `.env` file (or run `openbroker setup`):
120
+
121
+ ```bash
122
+ HYPERLIQUID_PRIVATE_KEY=0x... # Required: wallet private key
123
+ HYPERLIQUID_NETWORK=mainnet # Optional: mainnet (default) or testnet
124
+ HYPERLIQUID_ACCOUNT_ADDRESS=0x... # Optional: for API wallets
125
+ ```
126
+
127
+ ### API Wallet Setup
128
+
129
+ For automated trading, use an API wallet:
130
+
131
+ ```bash
132
+ HYPERLIQUID_PRIVATE_KEY="0x..." # API wallet private key
133
+ HYPERLIQUID_ACCOUNT_ADDRESS="0x..." # Main account address
134
+ ```
135
+
136
+ **Note:** Builder fee must be approved with the main wallet first.
137
+
138
+ ## Builder Fee
139
+
140
+ Open Broker charges **1 bps (0.01%)** per trade to fund development.
141
+
142
+ ```bash
143
+ openbroker approve-builder --check # Check status
144
+ openbroker approve-builder # Approve (free, no funds needed)
145
+ ```
146
+
147
+ ## Development
148
+
149
+ For local development without global install:
150
+
151
+ ```bash
152
+ git clone https://github.com/monemetrics/openbroker.git
153
+ cd openbroker
154
+ npm install
155
+ npx tsx scripts/info/account.ts
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT
package/SKILL.md ADDED
@@ -0,0 +1,296 @@
1
+ ---
2
+ name: openbroker
3
+ description: Hyperliquid trading CLI. Execute market orders, limit orders, manage positions, view funding rates, and run trading strategies. Use for any Hyperliquid perp trading task.
4
+ license: MIT
5
+ compatibility: Requires Node.js 22+, network access to api.hyperliquid.xyz
6
+ metadata:
7
+ author: monemetrics
8
+ version: "1.0.3"
9
+ allowed-tools: Bash(openbroker:*) Bash(npm:*) Read
10
+ ---
11
+
12
+ # Open Broker - Hyperliquid Trading CLI
13
+
14
+ Execute trading operations on Hyperliquid DEX with builder fee support.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install -g openbroker
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```bash
25
+ # 1. Setup (generates wallet, creates config, approves builder fee)
26
+ openbroker setup
27
+
28
+ # 2. Fund your wallet with USDC on Arbitrum, then deposit at https://app.hyperliquid.xyz/
29
+
30
+ # 3. Start trading
31
+ openbroker account
32
+ openbroker buy --coin ETH --size 0.1
33
+ ```
34
+
35
+ ## Command Reference
36
+
37
+ ### Setup Commands
38
+ ```bash
39
+ openbroker setup # Interactive setup wizard
40
+ openbroker approve-builder # Approve builder fee (one-time)
41
+ openbroker approve-builder --check # Check approval status
42
+ ```
43
+
44
+ ### Account Info
45
+ ```bash
46
+ openbroker account # Balance, equity, margin
47
+ openbroker account --orders # Include open orders
48
+ openbroker positions # Open positions with PnL
49
+ openbroker positions --coin ETH # Specific coin
50
+ ```
51
+
52
+ ### Funding Rates
53
+ ```bash
54
+ openbroker funding --top 20 # Top 20 by funding rate
55
+ openbroker funding --coin ETH # Specific coin
56
+ ```
57
+
58
+ ### Markets
59
+ ```bash
60
+ openbroker markets --top 30 # Top 30 main perps
61
+ openbroker markets --coin BTC # Specific coin
62
+ ```
63
+
64
+ ### All Markets (Perps + Spot + HIP-3)
65
+ ```bash
66
+ openbroker all-markets # Show all markets
67
+ openbroker all-markets --type perp # Main perps only
68
+ openbroker all-markets --type hip3 # HIP-3 perps only
69
+ openbroker all-markets --type spot # Spot markets only
70
+ openbroker all-markets --top 20 # Top 20 by volume
71
+ ```
72
+
73
+ ### Search Markets (Find assets across providers)
74
+ ```bash
75
+ openbroker search --query GOLD # Find all GOLD markets
76
+ openbroker search --query BTC # Find BTC across all providers
77
+ openbroker search --query ETH --type perp # ETH perps only
78
+ ```
79
+
80
+ ### Spot Markets
81
+ ```bash
82
+ openbroker spot # Show all spot markets
83
+ openbroker spot --coin PURR # Show PURR market info
84
+ openbroker spot --balances # Show your spot balances
85
+ openbroker spot --top 20 # Top 20 by volume
86
+ ```
87
+
88
+ ## Trading Commands
89
+
90
+ ### Market Orders (Quick)
91
+ ```bash
92
+ openbroker buy --coin ETH --size 0.1
93
+ openbroker sell --coin BTC --size 0.01
94
+ openbroker buy --coin SOL --size 5 --slippage 100 # Custom slippage (bps)
95
+ ```
96
+
97
+ ### Market Orders (Full)
98
+ ```bash
99
+ openbroker market --coin ETH --side buy --size 0.1
100
+ openbroker market --coin BTC --side sell --size 0.01 --slippage 100
101
+ ```
102
+
103
+ ### Limit Orders
104
+ ```bash
105
+ openbroker limit --coin ETH --side buy --size 1 --price 3000
106
+ openbroker limit --coin SOL --side sell --size 10 --price 200 --tif ALO
107
+ ```
108
+
109
+ ### Set TP/SL on Existing Position
110
+ ```bash
111
+ # Set take profit at $40, stop loss at $30
112
+ openbroker tpsl --coin HYPE --tp 40 --sl 30
113
+
114
+ # Set TP at +10% from entry, SL at entry (breakeven)
115
+ openbroker tpsl --coin HYPE --tp +10% --sl entry
116
+
117
+ # Set only stop loss at -5% from entry
118
+ openbroker tpsl --coin ETH --sl -5%
119
+
120
+ # Partial position TP/SL
121
+ openbroker tpsl --coin ETH --tp 4000 --sl 3500 --size 0.5
122
+ ```
123
+
124
+ ### Trigger Orders (Standalone TP/SL)
125
+ ```bash
126
+ # Take profit: sell when price rises to $40
127
+ openbroker trigger --coin HYPE --side sell --size 0.5 --trigger 40 --type tp
128
+
129
+ # Stop loss: sell when price drops to $30
130
+ openbroker trigger --coin HYPE --side sell --size 0.5 --trigger 30 --type sl
131
+ ```
132
+
133
+ ### Cancel Orders
134
+ ```bash
135
+ openbroker cancel --all # Cancel all orders
136
+ openbroker cancel --coin ETH # Cancel ETH orders only
137
+ openbroker cancel --oid 123456 # Cancel specific order
138
+ ```
139
+
140
+ ## Advanced Execution
141
+
142
+ ### TWAP (Time-Weighted Average Price)
143
+ ```bash
144
+ # Execute 1 ETH buy over 1 hour (auto-calculates slices)
145
+ openbroker twap --coin ETH --side buy --size 1 --duration 3600
146
+
147
+ # Custom intervals with randomization
148
+ openbroker twap --coin BTC --side sell --size 0.5 --duration 1800 --intervals 6 --randomize 20
149
+ ```
150
+
151
+ ### Scale In/Out (Grid Orders)
152
+ ```bash
153
+ # Place 5 buy orders ranging 2% below current price
154
+ openbroker scale --coin ETH --side buy --size 1 --levels 5 --range 2
155
+
156
+ # Scale out with exponential distribution
157
+ openbroker scale --coin BTC --side sell --size 0.5 --levels 4 --range 3 --distribution exponential --reduce
158
+ ```
159
+
160
+ ### Bracket Order (Entry + TP + SL)
161
+ ```bash
162
+ # Long ETH with 3% take profit and 1.5% stop loss
163
+ openbroker bracket --coin ETH --side buy --size 0.5 --tp 3 --sl 1.5
164
+
165
+ # Short with limit entry
166
+ openbroker bracket --coin BTC --side sell --size 0.1 --entry limit --price 100000 --tp 5 --sl 2
167
+ ```
168
+
169
+ ### Chase Order (Follow Price)
170
+ ```bash
171
+ # Chase buy with ALO orders until filled
172
+ openbroker chase --coin ETH --side buy --size 0.5 --timeout 300
173
+
174
+ # Aggressive chase with tight offset
175
+ openbroker chase --coin SOL --side buy --size 10 --offset 2 --timeout 60
176
+ ```
177
+
178
+ ## Trading Strategies
179
+
180
+ ### Funding Arbitrage
181
+ ```bash
182
+ # Collect funding on ETH if rate > 25% annualized
183
+ openbroker funding-arb --coin ETH --size 5000 --min-funding 25
184
+
185
+ # Run for 24 hours, check every 30 minutes
186
+ openbroker funding-arb --coin BTC --size 10000 --duration 24 --check 30 --dry
187
+ ```
188
+
189
+ ### Grid Trading
190
+ ```bash
191
+ # ETH grid from $3000-$4000 with 10 levels, 0.1 ETH per level
192
+ openbroker grid --coin ETH --lower 3000 --upper 4000 --grids 10 --size 0.1
193
+
194
+ # Accumulation grid (buys only)
195
+ openbroker grid --coin BTC --lower 90000 --upper 100000 --grids 5 --size 0.01 --mode long
196
+ ```
197
+
198
+ ### DCA (Dollar Cost Averaging)
199
+ ```bash
200
+ # Buy $100 of ETH every hour for 24 hours
201
+ openbroker dca --coin ETH --amount 100 --interval 1h --count 24
202
+
203
+ # Invest $5000 in BTC over 30 days with daily purchases
204
+ openbroker dca --coin BTC --total 5000 --interval 1d --count 30
205
+ ```
206
+
207
+ ### Market Making Spread
208
+ ```bash
209
+ # Market make ETH with 0.1 size, 10bps spread
210
+ openbroker mm-spread --coin ETH --size 0.1 --spread 10
211
+
212
+ # Tighter spread with position limit
213
+ openbroker mm-spread --coin BTC --size 0.01 --spread 5 --max-position 0.1
214
+ ```
215
+
216
+ ### Maker-Only MM (ALO orders)
217
+ ```bash
218
+ # Market make using ALO (post-only) orders - guarantees maker rebates
219
+ openbroker mm-maker --coin HYPE --size 1 --offset 1
220
+
221
+ # Wider offset for volatile assets
222
+ openbroker mm-maker --coin ETH --size 0.1 --offset 2 --max-position 0.5
223
+ ```
224
+
225
+ ## Order Types
226
+
227
+ ### Limit Orders vs Trigger Orders
228
+
229
+ **Limit Orders** (`openbroker limit`):
230
+ - Execute immediately if price is met
231
+ - Rest on the order book until filled or cancelled
232
+ - A limit sell BELOW current price fills immediately (taker)
233
+ - NOT suitable for stop losses
234
+
235
+ **Trigger Orders** (`openbroker trigger`, `openbroker tpsl`):
236
+ - Stay dormant until trigger price is reached
237
+ - Only activate when price hits the trigger level
238
+ - Proper way to set stop losses and take profits
239
+ - Won't fill prematurely
240
+
241
+ ### When to Use Each
242
+
243
+ | Scenario | Command |
244
+ |----------|---------|
245
+ | Buy at specific price below market | `openbroker limit` |
246
+ | Sell at specific price above market | `openbroker limit` |
247
+ | Stop loss (exit if price drops) | `openbroker trigger --type sl` |
248
+ | Take profit (exit at target) | `openbroker trigger --type tp` |
249
+ | Add TP/SL to existing position | `openbroker tpsl` |
250
+
251
+ ## Common Arguments
252
+
253
+ All commands support `--dry` for dry run (preview without executing).
254
+
255
+ | Argument | Description |
256
+ |----------|-------------|
257
+ | `--coin` | Asset symbol (ETH, BTC, SOL, HYPE, etc.) |
258
+ | `--side` | Order direction: `buy` or `sell` |
259
+ | `--size` | Order size in base asset |
260
+ | `--price` | Limit price |
261
+ | `--dry` | Preview without executing |
262
+ | `--help` | Show command help |
263
+
264
+ ### Order Arguments
265
+ | Argument | Description |
266
+ |----------|-------------|
267
+ | `--trigger` | Trigger price (for trigger orders) |
268
+ | `--type` | Trigger type: `tp` or `sl` |
269
+ | `--slippage` | Slippage tolerance in bps (for market orders) |
270
+ | `--tif` | Time in force: GTC, IOC, ALO |
271
+ | `--reduce` | Reduce-only order |
272
+
273
+ ### TP/SL Price Formats
274
+ | Format | Example | Description |
275
+ |--------|---------|-------------|
276
+ | Absolute | `--tp 40` | Price of $40 |
277
+ | Percentage up | `--tp +10%` | 10% above entry |
278
+ | Percentage down | `--sl -5%` | 5% below entry |
279
+ | Entry price | `--sl entry` | Breakeven stop |
280
+
281
+ ## Environment Variables
282
+
283
+ Create a `.env` file or set these environment variables:
284
+
285
+ | Variable | Required | Description |
286
+ |----------|----------|-------------|
287
+ | `HYPERLIQUID_PRIVATE_KEY` | Yes | Wallet private key (0x...) |
288
+ | `HYPERLIQUID_NETWORK` | No | `mainnet` (default) or `testnet` |
289
+ | `HYPERLIQUID_ACCOUNT_ADDRESS` | No | For API wallets |
290
+
291
+ ## Risk Warning
292
+
293
+ - Always use `--dry` first to preview orders
294
+ - Start with small sizes on testnet (`HYPERLIQUID_NETWORK=testnet`)
295
+ - Monitor positions and liquidation prices
296
+ - Use `--reduce` for closing positions only