You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add matched-size arb execution rules to skill docs
Both legs of a funding arb MUST have identical size to maintain
delta-neutral. Added step-by-step: check orderbook depth on both
sides, compute min fillable size, execute with same ORDER_SIZE,
verify match after fill. Covers chunked orders and mismatch recovery.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
perp --json arb scan --min 5 # are current rates still favorable?
141
141
```
142
142
143
-
### Order Execution: Sequential Leg Management
143
+
### Order Execution: Matched Size, Sequential Legs
144
144
145
-
**NEVER close or open both legs of an arb at once with market orders.**You must manage execution carefully.
145
+
**The #1 rule of arb execution: BOTH LEGS MUST HAVE THE EXACT SAME SIZE.**A size mismatch means you have net directional exposure — the whole point of arb is to be delta-neutral.
146
146
147
-
#### Why This Matters
148
-
Orderbooks have limited depth at each price level. A large market order will eat through multiple ticks and suffer heavy slippage. Worse, if you close one leg but fail to close the other (exchange error, rate limit, network issue), you are left with naked directional exposure.
147
+
#### Step 1: Determine Matched Order Size
149
148
150
-
#### Pre-Execution: Check Orderbook Depth
151
-
Before executing, verify that the orderbook can absorb your size at acceptable prices on BOTH sides:
149
+
Before placing ANY order, compute a single `ORDER_SIZE` that BOTH exchanges can fill:
**CRITICAL: Each exchange has its own minimum order size and step size.**
175
+
```bash
176
+
perp --json -e <EX> market info <SYM># check minOrderSize, stepSize
177
+
```
178
+
Round `ORDER_SIZE` to the coarser step size of the two exchanges. If the matched size falls below either exchange's minimum, the arb is NOT executable at this size — reduce target or skip.
179
+
180
+
#### Step 2: Execute Legs Sequentially with Same Size
181
+
182
+
Once you have a single `ORDER_SIZE`, execute both legs using THAT EXACT SIZE:
perp --json -e <EX_A> market book <SYM># check bids/asks depth
154
-
perp --json -e <EX_B> market book <SYM># check bids/asks depth
155
-
```
156
-
157
-
Look at the size available at the best tick. If your order size exceeds what's available at the best 2-3 ticks, you MUST split the order.
158
-
159
-
#### Execution Strategy
160
-
1.**Determine executable chunk size** — the largest size both orderbooks can absorb at the best tick without excessive slippage
161
-
2.**Execute in sequential chunks:**
162
-
```
163
-
Chunk 1: close X on Exchange A → immediately open X on Exchange B
164
-
Chunk 2: close X on Exchange A → immediately open X on Exchange B
165
-
... repeat until full size is executed
166
-
```
167
-
3.**Verify each chunk** before proceeding to the next:
168
-
```bash
169
-
perp --json -e <EX_A> account positions # confirm partial close
170
-
perp --json -e <EX_B> account positions # confirm partial open
171
-
```
172
-
4.**Re-check the orderbook** between chunks — liquidity may have changed
173
-
174
-
#### Paired Execution Rule
175
-
Each chunk must be a **matched pair**: close on one side, open on the other. Never execute multiple closes without the corresponding opens. If one leg fails:
176
-
- STOP immediately
177
-
- Assess your current exposure
178
-
- Decide whether to retry the failed leg or unwind the completed leg
179
-
- Do NOT continue with remaining chunks
200
+
perp --json -e <LONG_EX> account positions # size = X
201
+
perp --json -e <SHORT_EX> account positions # size must = X
202
+
```
203
+
If sizes differ (partial fill, rounding), immediately adjust the larger position to match the smaller one.
204
+
205
+
#### Step 3: Split Large Orders into Matched Chunks
206
+
207
+
If your desired size exceeds what the orderbooks can absorb at best ticks, split into chunks — but **every chunk must be a matched pair with identical size on both sides**:
208
+
209
+
```
210
+
Chunk 1: buy 0.3 on Exchange A → sell 0.3 on Exchange B → verify both
211
+
Chunk 2: buy 0.3 on Exchange A → sell 0.3 on Exchange B → verify both
212
+
... repeat until full size is executed
213
+
```
214
+
215
+
**Rules:**
216
+
1. Re-check orderbook depth between chunks — liquidity changes
217
+
2. Each chunk: same size on both sides, no exceptions
218
+
3. If one leg fails → STOP immediately, do NOT continue
219
+
4. Assess exposure: retry the failed leg, or unwind the completed leg
220
+
5. NEVER execute multiple orders on one side without matching the other
180
221
181
222
#### Using Limit Orders for Better Execution
182
-
For non-urgent transitions, consider limit orders at the best bid/ask instead of market orders:
223
+
For non-urgent entries, use limit orders at best bid/ask instead of market:
This avoids crossing the spread but risks not getting filled. Set a timeout and fall back to market if unfilled. **Both legs must still use the same `ORDER_SIZE`.**
0 commit comments