@intentsolutionsio/crypto-derivatives-tracker 1.0.0 → 1.0.3
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/README.md +16 -1
- package/agents/derivatives-agent.md +29 -0
- package/package.json +1 -1
- package/skills/skill-adapter/references/README.md +0 -1
- package/skills/skill-adapter/references/examples.md +6 -0
- package/skills/tracking-crypto-derivatives/ARD.md +22 -0
- package/skills/tracking-crypto-derivatives/PRD.md +26 -0
- package/skills/tracking-crypto-derivatives/SKILL.md +28 -6
- package/skills/tracking-crypto-derivatives/references/errors.md +24 -0
- package/skills/tracking-crypto-derivatives/references/examples.md +19 -0
- package/skills/tracking-crypto-derivatives/references/implementation.md +8 -0
- package/skills/tracking-crypto-derivatives/scripts/basis_calculator.py +23 -24
- package/skills/tracking-crypto-derivatives/scripts/derivatives_tracker.py +176 -175
- package/skills/tracking-crypto-derivatives/scripts/formatters.py +13 -18
- package/skills/tracking-crypto-derivatives/scripts/funding_tracker.py +34 -34
- package/skills/tracking-crypto-derivatives/scripts/liquidation_monitor.py +31 -35
- package/skills/tracking-crypto-derivatives/scripts/oi_analyzer.py +23 -27
- package/skills/tracking-crypto-derivatives/scripts/options_analyzer.py +42 -41
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Track cryptocurrency futures, options, and perpetual swaps with funding rates, o
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
22
|
The derivatives agent automatically activates when you discuss:
|
|
23
|
+
|
|
23
24
|
- Futures, options, or perpetual swaps
|
|
24
25
|
- Funding rates and open interest
|
|
25
26
|
- Derivatives trading strategies
|
|
@@ -45,6 +46,7 @@ Compare funding rates across Binance, Bybit, and OKX
|
|
|
45
46
|
## Supported Markets
|
|
46
47
|
|
|
47
48
|
### Centralized Exchanges
|
|
49
|
+
|
|
48
50
|
- **Binance Futures** - Largest volume, USDT and coin-margined
|
|
49
51
|
- **Bybit** - Popular perpetuals, good liquidity
|
|
50
52
|
- **OKX** - Comprehensive derivatives suite
|
|
@@ -53,6 +55,7 @@ Compare funding rates across Binance, Bybit, and OKX
|
|
|
53
55
|
- **BitMEX** - Crypto perpetuals pioneer
|
|
54
56
|
|
|
55
57
|
### Decentralized Protocols
|
|
58
|
+
|
|
56
59
|
- **dYdX** - Perpetuals on Ethereum/StarkEx
|
|
57
60
|
- **GMX** - Perpetuals on Arbitrum/Avalanche
|
|
58
61
|
- **Synthetix** - Synthetic assets and perps
|
|
@@ -83,22 +86,26 @@ Create a `.derivatives-config.json` file:
|
|
|
83
86
|
## Key Metrics Explained
|
|
84
87
|
|
|
85
88
|
### Funding Rates
|
|
89
|
+
|
|
86
90
|
- **Positive funding**: Longs pay shorts (bullish sentiment)
|
|
87
91
|
- **Negative funding**: Shorts pay longs (bearish sentiment)
|
|
88
92
|
- **Extreme rates** (>0.1% 8-hour): Contrarian opportunity
|
|
89
93
|
|
|
90
94
|
### Open Interest (OI)
|
|
95
|
+
|
|
91
96
|
- **Rising OI + Rising Price**: Strong bullish trend
|
|
92
97
|
- **Rising OI + Falling Price**: Strong bearish trend
|
|
93
98
|
- **Falling OI + Rising Price**: Short covering
|
|
94
99
|
- **Falling OI + Falling Price**: Long liquidations
|
|
95
100
|
|
|
96
101
|
### Futures Basis
|
|
102
|
+
|
|
97
103
|
- **Contango** (positive): Futures > spot (normal)
|
|
98
104
|
- **Backwardation** (negative): Futures < spot (high demand)
|
|
99
105
|
- **Cash-and-carry**: Buy spot + sell futures
|
|
100
106
|
|
|
101
107
|
### Options Greeks
|
|
108
|
+
|
|
102
109
|
- **Delta**: Price sensitivity
|
|
103
110
|
- **Gamma**: Rate of delta change
|
|
104
111
|
- **Vega**: Volatility sensitivity
|
|
@@ -107,18 +114,23 @@ Create a `.derivatives-config.json` file:
|
|
|
107
114
|
## Trading Strategies
|
|
108
115
|
|
|
109
116
|
### 1. Funding Rate Arbitrage
|
|
117
|
+
|
|
110
118
|
Long spot + Short perpetual when funding > 0.1%
|
|
111
119
|
|
|
112
120
|
### 2. Basis Trading
|
|
121
|
+
|
|
113
122
|
Buy spot + Sell quarterly futures when basis > 5% annualized
|
|
114
123
|
|
|
115
124
|
### 3. Liquidation Hunting
|
|
125
|
+
|
|
116
126
|
Target clusters of liquidations for potential cascades
|
|
117
127
|
|
|
118
128
|
### 4. Options Volatility Trading
|
|
129
|
+
|
|
119
130
|
Buy straddles when IV low, sell spreads when IV high
|
|
120
131
|
|
|
121
132
|
### 5. Options Flow Following
|
|
133
|
+
|
|
122
134
|
Track smart money positioning via unusual options activity
|
|
123
135
|
|
|
124
136
|
## Data Sources
|
|
@@ -132,6 +144,7 @@ Track smart money positioning via unusual options activity
|
|
|
132
144
|
## Risk Management
|
|
133
145
|
|
|
134
146
|
️ **Critical Considerations**:
|
|
147
|
+
|
|
135
148
|
- Derivatives use leverage - high risk of liquidation
|
|
136
149
|
- Funding costs accumulate in perpetuals
|
|
137
150
|
- Options can expire worthless (theta decay)
|
|
@@ -139,6 +152,7 @@ Track smart money positioning via unusual options activity
|
|
|
139
152
|
- Volatile markets can gap through stop losses
|
|
140
153
|
|
|
141
154
|
### Best Practices
|
|
155
|
+
|
|
142
156
|
1. Use appropriate position sizing
|
|
143
157
|
2. Monitor liquidation prices continuously
|
|
144
158
|
3. Account for funding costs
|
|
@@ -150,6 +164,7 @@ Track smart money positioning via unusual options activity
|
|
|
150
164
|
️ **Crypto derivatives are extremely risky instruments.**
|
|
151
165
|
|
|
152
166
|
Users should:
|
|
167
|
+
|
|
153
168
|
- Fully understand leverage and liquidation mechanics
|
|
154
169
|
- Only trade with funds they can afford to lose
|
|
155
170
|
- Use proper position sizing and risk management
|
|
@@ -166,7 +181,7 @@ MIT License - See LICENSE file for details
|
|
|
166
181
|
## Support
|
|
167
182
|
|
|
168
183
|
- GitHub Issues: [Report bugs](https://github.com/jeremylongshore/claude-code-plugins/issues)
|
|
169
|
-
- Documentation:
|
|
184
|
+
- Documentation: Full docs
|
|
170
185
|
|
|
171
186
|
---
|
|
172
187
|
|
|
@@ -11,6 +11,7 @@ You are a specialized agent for tracking and analyzing cryptocurrency derivative
|
|
|
11
11
|
## Your Capabilities
|
|
12
12
|
|
|
13
13
|
### Perpetual Swaps Analysis
|
|
14
|
+
|
|
14
15
|
- **Funding rates** across all major exchanges (Binance, Bybit, OKX, Deribit, FTX)
|
|
15
16
|
- **Predicted funding** for next payment period
|
|
16
17
|
- **Funding arbitrage** opportunities between exchanges
|
|
@@ -19,6 +20,7 @@ You are a specialized agent for tracking and analyzing cryptocurrency derivative
|
|
|
19
20
|
- **Long/short ratio** by exchange and timeframe
|
|
20
21
|
|
|
21
22
|
### Futures Market Analysis
|
|
23
|
+
|
|
22
24
|
- **Open interest** tracking across all expiries
|
|
23
25
|
- **Futures basis** (premium/discount to spot)
|
|
24
26
|
- **Roll yields** and calendar spread opportunities
|
|
@@ -27,6 +29,7 @@ You are a specialized agent for tracking and analyzing cryptocurrency derivative
|
|
|
27
29
|
- **Contango/backwardation** analysis
|
|
28
30
|
|
|
29
31
|
### Options Market Intelligence
|
|
32
|
+
|
|
30
33
|
- **Implied volatility (IV)** across strikes and expiries
|
|
31
34
|
- **Options flow**: Large trades and unusual activity
|
|
32
35
|
- **Put/call ratio** and skew analysis
|
|
@@ -36,6 +39,7 @@ You are a specialized agent for tracking and analyzing cryptocurrency derivative
|
|
|
36
39
|
- **Open interest by strike** for support/resistance
|
|
37
40
|
|
|
38
41
|
### Derivatives Market Metrics
|
|
42
|
+
|
|
39
43
|
- **Total open interest** across all derivatives
|
|
40
44
|
- **Volume analysis** by product type
|
|
41
45
|
- **Exchange market share** for derivatives
|
|
@@ -44,6 +48,7 @@ You are a specialized agent for tracking and analyzing cryptocurrency derivative
|
|
|
44
48
|
- **Basis trading opportunities**
|
|
45
49
|
|
|
46
50
|
### Trading Signal Generation
|
|
51
|
+
|
|
47
52
|
- **Funding rate extremes**: Contrarian signals
|
|
48
53
|
- **Open interest divergence**: Trend strength indicators
|
|
49
54
|
- **Options positioning**: Smart money tracking
|
|
@@ -54,6 +59,7 @@ You are a specialized agent for tracking and analyzing cryptocurrency derivative
|
|
|
54
59
|
## When to Activate
|
|
55
60
|
|
|
56
61
|
Activate this agent when users need to:
|
|
62
|
+
|
|
57
63
|
- Analyze derivatives market positioning
|
|
58
64
|
- Track funding rates for perpetual swaps
|
|
59
65
|
- Monitor open interest and liquidations
|
|
@@ -67,6 +73,7 @@ Activate this agent when users need to:
|
|
|
67
73
|
## Approach
|
|
68
74
|
|
|
69
75
|
### Analysis Methodology
|
|
76
|
+
|
|
70
77
|
1. **Data Collection**: Aggregate data from multiple exchanges and data providers
|
|
71
78
|
2. **Market Structure**: Analyze current positioning (long/short, OI, funding)
|
|
72
79
|
3. **Historical Context**: Compare to historical levels and patterns
|
|
@@ -76,7 +83,9 @@ Activate this agent when users need to:
|
|
|
76
83
|
7. **Signal Generation**: Produce actionable insights with risk parameters
|
|
77
84
|
|
|
78
85
|
### Output Format
|
|
86
|
+
|
|
79
87
|
Present analysis in structured format:
|
|
88
|
+
|
|
80
89
|
```
|
|
81
90
|
CRYPTO DERIVATIVES MARKET ANALYSIS
|
|
82
91
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
@@ -230,6 +239,7 @@ Strategy Recommendations:
|
|
|
230
239
|
## Supported Exchanges
|
|
231
240
|
|
|
232
241
|
### Centralized Exchanges
|
|
242
|
+
|
|
233
243
|
- **Binance Futures**: Largest volume, USDT and coin-margined
|
|
234
244
|
- **Bybit**: Popular for perpetuals, good liquidity
|
|
235
245
|
- **OKX**: Comprehensive derivatives suite
|
|
@@ -240,6 +250,7 @@ Strategy Recommendations:
|
|
|
240
250
|
- **Gate.io**: Wide range of altcoin derivatives
|
|
241
251
|
|
|
242
252
|
### Decentralized Protocols
|
|
253
|
+
|
|
243
254
|
- **dYdX**: Perpetuals on Ethereum/StarkEx
|
|
244
255
|
- **GMX**: Perpetuals on Arbitrum/Avalanche
|
|
245
256
|
- **Synthetix**: Synthetic assets and perps
|
|
@@ -250,24 +261,28 @@ Strategy Recommendations:
|
|
|
250
261
|
## Key Derivatives Concepts
|
|
251
262
|
|
|
252
263
|
### Funding Rates
|
|
264
|
+
|
|
253
265
|
- **Positive funding**: Longs pay shorts (bullish sentiment)
|
|
254
266
|
- **Negative funding**: Shorts pay longs (bearish sentiment)
|
|
255
267
|
- **Extreme rates**: Contrarian opportunity (often >0.1% 8-hour)
|
|
256
268
|
- **Funding arbitrage**: Long spot + short perp when funding is high
|
|
257
269
|
|
|
258
270
|
### Open Interest
|
|
271
|
+
|
|
259
272
|
- **Rising OI + rising price**: Strong bullish trend
|
|
260
273
|
- **Rising OI + falling price**: Strong bearish trend
|
|
261
274
|
- **Falling OI + rising price**: Short covering
|
|
262
275
|
- **Falling OI + falling price**: Long liquidations
|
|
263
276
|
|
|
264
277
|
### Futures Basis
|
|
278
|
+
|
|
265
279
|
- **Contango (positive basis)**: Futures > spot (normal market)
|
|
266
280
|
- **Backwardation (negative basis)**: Futures < spot (high demand for spot)
|
|
267
281
|
- **Cash-and-carry**: Buy spot + sell futures (earn basis)
|
|
268
282
|
- **Reverse cash-and-carry**: Sell spot + buy futures
|
|
269
283
|
|
|
270
284
|
### Options Greeks
|
|
285
|
+
|
|
271
286
|
- **Delta**: Price sensitivity to underlying
|
|
272
287
|
- **Gamma**: Rate of delta change
|
|
273
288
|
- **Vega**: Sensitivity to volatility changes
|
|
@@ -275,6 +290,7 @@ Strategy Recommendations:
|
|
|
275
290
|
- **Rho**: Interest rate sensitivity (less relevant in crypto)
|
|
276
291
|
|
|
277
292
|
### Implied Volatility
|
|
293
|
+
|
|
278
294
|
- **High IV**: Options expensive, expect big moves
|
|
279
295
|
- **Low IV**: Options cheap, complacency
|
|
280
296
|
- **IV Rank**: Percentile of IV over past year
|
|
@@ -283,6 +299,7 @@ Strategy Recommendations:
|
|
|
283
299
|
## Trading Strategies
|
|
284
300
|
|
|
285
301
|
### 1. Funding Rate Arbitrage
|
|
302
|
+
|
|
286
303
|
```
|
|
287
304
|
When: Funding > 0.1% (8-hour) or < -0.05%
|
|
288
305
|
Strategy:
|
|
@@ -292,6 +309,7 @@ Risk: Basis risk, exchange risk
|
|
|
292
309
|
```
|
|
293
310
|
|
|
294
311
|
### 2. Basis Trading (Cash-and-Carry)
|
|
312
|
+
|
|
295
313
|
```
|
|
296
314
|
When: Quarterly basis > 5% annualized
|
|
297
315
|
Strategy: Buy spot + Sell quarterly futures
|
|
@@ -300,6 +318,7 @@ Risk: Margin requirements, early liquidation
|
|
|
300
318
|
```
|
|
301
319
|
|
|
302
320
|
### 3. Liquidation Hunting
|
|
321
|
+
|
|
303
322
|
```
|
|
304
323
|
When: Large liquidation clusters identified
|
|
305
324
|
Strategy: Enter positions targeting liquidation cascades
|
|
@@ -307,6 +326,7 @@ Risk: False breakouts, slippage
|
|
|
307
326
|
```
|
|
308
327
|
|
|
309
328
|
### 4. Options Volatility Trading
|
|
329
|
+
|
|
310
330
|
```
|
|
311
331
|
When: IV rank < 20 (cheap vol) or > 80 (expensive vol)
|
|
312
332
|
Strategy:
|
|
@@ -316,6 +336,7 @@ Risk: Gamma risk, large moves
|
|
|
316
336
|
```
|
|
317
337
|
|
|
318
338
|
### 5. Put/Call Dispersion
|
|
339
|
+
|
|
319
340
|
```
|
|
320
341
|
When: Unusual options flow detected
|
|
321
342
|
Strategy: Follow smart money positioning
|
|
@@ -325,18 +346,21 @@ Risk: Misinterpretation, manipulation
|
|
|
325
346
|
## Risk Management
|
|
326
347
|
|
|
327
348
|
### Position Sizing
|
|
349
|
+
|
|
328
350
|
- Derivatives are leveraged - use smaller positions
|
|
329
351
|
- Account for funding costs in perps
|
|
330
352
|
- Consider theta decay in options
|
|
331
353
|
- Monitor liquidation prices continuously
|
|
332
354
|
|
|
333
355
|
### Exchange Risk
|
|
356
|
+
|
|
334
357
|
- Counterparty risk on CEXes
|
|
335
358
|
- Smart contract risk on DEXes
|
|
336
359
|
- Spread positions across exchanges
|
|
337
360
|
- Keep most funds in cold storage
|
|
338
361
|
|
|
339
362
|
### Market Risk
|
|
363
|
+
|
|
340
364
|
- Volatile funding can erode profits
|
|
341
365
|
- Basis can widen before converging
|
|
342
366
|
- Liquidation cascades can gap prices
|
|
@@ -345,12 +369,14 @@ Risk: Misinterpretation, manipulation
|
|
|
345
369
|
## Data Sources
|
|
346
370
|
|
|
347
371
|
### Exchange APIs
|
|
372
|
+
|
|
348
373
|
- Binance API: Futures, perpetuals, funding
|
|
349
374
|
- Deribit API: Options data, IV surface
|
|
350
375
|
- Bybit API: Perpetuals, funding, liquidations
|
|
351
376
|
- OKX API: Comprehensive derivatives data
|
|
352
377
|
|
|
353
378
|
### Aggregators
|
|
379
|
+
|
|
354
380
|
- **Coinglass**: OI, funding, liquidations across exchanges
|
|
355
381
|
- **Glassnode**: On-chain + derivatives metrics
|
|
356
382
|
- **Skew**: Derivatives dashboards (deprecated, use alternatives)
|
|
@@ -358,6 +384,7 @@ Risk: Misinterpretation, manipulation
|
|
|
358
384
|
- **Amberdata**: Institutional derivatives data
|
|
359
385
|
|
|
360
386
|
### On-Chain Data (for DEXes)
|
|
387
|
+
|
|
361
388
|
- **The Graph**: dYdX, GMX subgraphs
|
|
362
389
|
- **Dune Analytics**: Perpetual Protocol, Synthetix
|
|
363
390
|
- **DefiLlama**: TVL and volume for DeFi perps
|
|
@@ -365,6 +392,7 @@ Risk: Misinterpretation, manipulation
|
|
|
365
392
|
## Example Queries
|
|
366
393
|
|
|
367
394
|
You can answer questions like:
|
|
395
|
+
|
|
368
396
|
- "What's the current funding rate for BTC perpetuals?"
|
|
369
397
|
- "Show me open interest across all BTC futures"
|
|
370
398
|
- "Analyze options flow for ETH expiring Friday"
|
|
@@ -397,6 +425,7 @@ You can answer questions like:
|
|
|
397
425
|
## Risk Disclaimer
|
|
398
426
|
|
|
399
427
|
Crypto derivatives are **extremely risky** instruments. Users should:
|
|
428
|
+
|
|
400
429
|
- Fully understand leverage and liquidation mechanics
|
|
401
430
|
- Only trade with funds they can afford to lose completely
|
|
402
431
|
- Use appropriate position sizing and risk management
|
package/package.json
CHANGED
|
@@ -7,11 +7,13 @@ This document provides practical examples of how to use this skill effectively.
|
|
|
7
7
|
### Example 1: Simple Activation
|
|
8
8
|
|
|
9
9
|
**User Request:**
|
|
10
|
+
|
|
10
11
|
```
|
|
11
12
|
[Describe trigger phrase here]
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
**Skill Response:**
|
|
16
|
+
|
|
15
17
|
1. Analyzes the request
|
|
16
18
|
2. Performs the required action
|
|
17
19
|
3. Returns results
|
|
@@ -19,11 +21,13 @@ This document provides practical examples of how to use this skill effectively.
|
|
|
19
21
|
### Example 2: Complex Workflow
|
|
20
22
|
|
|
21
23
|
**User Request:**
|
|
24
|
+
|
|
22
25
|
```
|
|
23
26
|
[Describe complex scenario]
|
|
24
27
|
```
|
|
25
28
|
|
|
26
29
|
**Workflow:**
|
|
30
|
+
|
|
27
31
|
1. Step 1: Initial analysis
|
|
28
32
|
2. Step 2: Data processing
|
|
29
33
|
3. Step 3: Result generation
|
|
@@ -34,6 +38,7 @@ This document provides practical examples of how to use this skill effectively.
|
|
|
34
38
|
### Pattern 1: Chaining Operations
|
|
35
39
|
|
|
36
40
|
Combine this skill with other tools:
|
|
41
|
+
|
|
37
42
|
```
|
|
38
43
|
Step 1: Use this skill for [purpose]
|
|
39
44
|
Step 2: Chain with [other tool]
|
|
@@ -43,6 +48,7 @@ Step 3: Finalize with [action]
|
|
|
43
48
|
### Pattern 2: Error Handling
|
|
44
49
|
|
|
45
50
|
If issues occur:
|
|
51
|
+
|
|
46
52
|
- Check trigger phrase matches
|
|
47
53
|
- Verify context is available
|
|
48
54
|
- Review allowed-tools permissions
|
|
@@ -47,27 +47,34 @@ This skill aggregates derivatives data from multiple exchanges, normalizes forma
|
|
|
47
47
|
## Workflow
|
|
48
48
|
|
|
49
49
|
### Step 1: Exchange Client Initialization
|
|
50
|
+
|
|
50
51
|
Configure API connections for each supported exchange with rate limiting.
|
|
51
52
|
|
|
52
53
|
### Step 2: Data Fetching
|
|
54
|
+
|
|
53
55
|
Parallel fetch from all exchanges for:
|
|
56
|
+
|
|
54
57
|
- Funding rates (perpetuals)
|
|
55
58
|
- Open interest (futures + perps)
|
|
56
59
|
- Recent liquidations
|
|
57
60
|
- Options data (Deribit primarily)
|
|
58
61
|
|
|
59
62
|
### Step 3: Data Normalization
|
|
63
|
+
|
|
60
64
|
Standardize formats across exchanges:
|
|
65
|
+
|
|
61
66
|
- Convert funding to 8-hour basis
|
|
62
67
|
- Normalize OI to USD equivalent
|
|
63
68
|
- Unify liquidation formats
|
|
64
69
|
|
|
65
70
|
### Step 4: Analysis & Aggregation
|
|
71
|
+
|
|
66
72
|
- Calculate weighted averages
|
|
67
73
|
- Detect divergences
|
|
68
74
|
- Generate signals
|
|
69
75
|
|
|
70
76
|
### Step 5: Output
|
|
77
|
+
|
|
71
78
|
Present in requested format (console/JSON).
|
|
72
79
|
|
|
73
80
|
---
|
|
@@ -97,13 +104,17 @@ Exchange APIs Normalization Analysis Output
|
|
|
97
104
|
## Progressive Disclosure Strategy
|
|
98
105
|
|
|
99
106
|
### Level 1: Quick Summary
|
|
107
|
+
|
|
100
108
|
Single-line current funding rate or OI.
|
|
109
|
+
|
|
101
110
|
```
|
|
102
111
|
BTC Funding: +0.015% (Binance) | OI: $18.5B (+2.3% 24h)
|
|
103
112
|
```
|
|
104
113
|
|
|
105
114
|
### Level 2: Standard Report
|
|
115
|
+
|
|
106
116
|
Tabular view across exchanges with key metrics.
|
|
117
|
+
|
|
107
118
|
```
|
|
108
119
|
BTC FUNDING RATES
|
|
109
120
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
@@ -115,6 +126,7 @@ Bybit +0.0180% +0.0140% +19.71%
|
|
|
115
126
|
```
|
|
116
127
|
|
|
117
128
|
### Level 3: Deep Analysis
|
|
129
|
+
|
|
118
130
|
Full derivatives dashboard with all metrics, signals, and risk assessment.
|
|
119
131
|
|
|
120
132
|
---
|
|
@@ -204,6 +216,7 @@ RATE_LIMITS = {
|
|
|
204
216
|
## Data Models
|
|
205
217
|
|
|
206
218
|
### FundingRate
|
|
219
|
+
|
|
207
220
|
```python
|
|
208
221
|
@dataclass
|
|
209
222
|
class FundingRate:
|
|
@@ -216,6 +229,7 @@ class FundingRate:
|
|
|
216
229
|
```
|
|
217
230
|
|
|
218
231
|
### OpenInterest
|
|
232
|
+
|
|
219
233
|
```python
|
|
220
234
|
@dataclass
|
|
221
235
|
class OpenInterest:
|
|
@@ -229,6 +243,7 @@ class OpenInterest:
|
|
|
229
243
|
```
|
|
230
244
|
|
|
231
245
|
### Liquidation
|
|
246
|
+
|
|
232
247
|
```python
|
|
233
248
|
@dataclass
|
|
234
249
|
class Liquidation:
|
|
@@ -242,6 +257,7 @@ class Liquidation:
|
|
|
242
257
|
```
|
|
243
258
|
|
|
244
259
|
### OptionsSnapshot
|
|
260
|
+
|
|
245
261
|
```python
|
|
246
262
|
@dataclass
|
|
247
263
|
class OptionsSnapshot:
|
|
@@ -327,17 +343,20 @@ async def fetch_all_funding(symbols: List[str]) -> Dict[str, FundingRate]:
|
|
|
327
343
|
## Testing Strategy
|
|
328
344
|
|
|
329
345
|
### Unit Tests
|
|
346
|
+
|
|
330
347
|
- Funding rate calculations
|
|
331
348
|
- OI normalization
|
|
332
349
|
- Liquidation aggregation
|
|
333
350
|
- Basis calculations
|
|
334
351
|
|
|
335
352
|
### Integration Tests
|
|
353
|
+
|
|
336
354
|
- Exchange API connectivity
|
|
337
355
|
- Rate limit handling
|
|
338
356
|
- Error recovery
|
|
339
357
|
|
|
340
358
|
### Mock Data
|
|
359
|
+
|
|
341
360
|
- Simulated exchange responses
|
|
342
361
|
- Historical liquidation data
|
|
343
362
|
- Options chain snapshots
|
|
@@ -347,11 +366,13 @@ async def fetch_all_funding(symbols: List[str]) -> Dict[str, FundingRate]:
|
|
|
347
366
|
## Security & Compliance
|
|
348
367
|
|
|
349
368
|
### API Key Handling
|
|
369
|
+
|
|
350
370
|
- Keys stored in environment variables or config
|
|
351
371
|
- Read-only permissions only (no trading)
|
|
352
372
|
- No key logging in outputs
|
|
353
373
|
|
|
354
374
|
### Data Privacy
|
|
375
|
+
|
|
355
376
|
- No personal data collected
|
|
356
377
|
- No trading history stored
|
|
357
378
|
- Analysis only, no execution
|
|
@@ -371,6 +392,7 @@ alerts:
|
|
|
371
392
|
```
|
|
372
393
|
|
|
373
394
|
### Alert Outputs
|
|
395
|
+
|
|
374
396
|
- Console warnings with emoji indicators
|
|
375
397
|
- JSON alerts for webhook integration
|
|
376
398
|
- Summary at end of report
|
|
@@ -25,18 +25,21 @@ Manual monitoring is impractical given the 24/7 nature of crypto markets and the
|
|
|
25
25
|
## Target Users
|
|
26
26
|
|
|
27
27
|
### Persona 1: Derivatives Day Trader
|
|
28
|
+
|
|
28
29
|
- **Background**: Full-time crypto trader focusing on perpetual swaps
|
|
29
30
|
- **Goals**: Profit from funding rate extremes, OI divergences, and liquidation cascades
|
|
30
31
|
- **Pain Points**: Data fragmented across exchanges, misses funding changes
|
|
31
32
|
- **Success Criteria**: Consistent funding capture, early entry before liquidation cascades
|
|
32
33
|
|
|
33
34
|
### Persona 2: Basis Arbitrageur
|
|
35
|
+
|
|
34
36
|
- **Background**: Market-neutral trader running cash-and-carry strategies
|
|
35
37
|
- **Goals**: Lock in risk-free returns via spot-futures basis trades
|
|
36
38
|
- **Pain Points**: Manual basis calculations, timing entry/exit around funding
|
|
37
39
|
- **Success Criteria**: Captures basis premium with minimal directional risk
|
|
38
40
|
|
|
39
41
|
### Persona 3: Options Flow Analyst
|
|
42
|
+
|
|
40
43
|
- **Background**: Institutional researcher tracking smart money via options
|
|
41
44
|
- **Goals**: Identify unusual options activity and positioning before moves
|
|
42
45
|
- **Pain Points**: Options data scattered, hard to interpret Greeks at scale
|
|
@@ -47,66 +50,78 @@ Manual monitoring is impractical given the 24/7 nature of crypto markets and the
|
|
|
47
50
|
## User Stories
|
|
48
51
|
|
|
49
52
|
### US-1: Funding Rate Monitoring (Critical)
|
|
53
|
+
|
|
50
54
|
**As a** derivatives trader
|
|
51
55
|
**I want to** see funding rates across all major exchanges in one view
|
|
52
56
|
**So that** I can identify arbitrage opportunities and sentiment extremes
|
|
53
57
|
|
|
54
58
|
**Acceptance Criteria**:
|
|
59
|
+
|
|
55
60
|
- Display funding rates for BTC, ETH, SOL across Binance, Bybit, OKX, Deribit
|
|
56
61
|
- Show current, 24h average, and 7d average rates
|
|
57
62
|
- Calculate annualized funding yield
|
|
58
63
|
- Alert when funding exceeds configurable threshold (default: 0.1%)
|
|
59
64
|
|
|
60
65
|
### US-2: Open Interest Analysis (Critical)
|
|
66
|
+
|
|
61
67
|
**As a** derivatives trader
|
|
62
68
|
**I want to** track open interest changes by exchange and contract type
|
|
63
69
|
**So that** I can gauge market positioning and trend strength
|
|
64
70
|
|
|
65
71
|
**Acceptance Criteria**:
|
|
72
|
+
|
|
66
73
|
- Show total OI in USD and BTC/ETH equivalent
|
|
67
74
|
- Display 24h, 7d, 30d OI changes
|
|
68
75
|
- Compare OI across exchanges (market share)
|
|
69
76
|
- Analyze OI vs price divergences
|
|
70
77
|
|
|
71
78
|
### US-3: Liquidation Monitoring (Critical)
|
|
79
|
+
|
|
72
80
|
**As a** derivatives trader
|
|
73
81
|
**I want to** see liquidation levels and recent liquidation events
|
|
74
82
|
**So that** I can avoid cascade zones and position for liquidation-driven moves
|
|
75
83
|
|
|
76
84
|
**Acceptance Criteria**:
|
|
85
|
+
|
|
77
86
|
- Display liquidation heatmap with price levels
|
|
78
87
|
- Show recent large liquidations (>$100K)
|
|
79
88
|
- Calculate long/short liquidation zones
|
|
80
89
|
- Estimate cascade risk at key levels
|
|
81
90
|
|
|
82
91
|
### US-4: Basis Tracking (High)
|
|
92
|
+
|
|
83
93
|
**As a** basis arbitrageur
|
|
84
94
|
**I want to** see spot-futures basis across all expiries
|
|
85
95
|
**So that** I can identify cash-and-carry opportunities
|
|
86
96
|
|
|
87
97
|
**Acceptance Criteria**:
|
|
98
|
+
|
|
88
99
|
- Calculate perpetual-spot basis (real-time)
|
|
89
100
|
- Calculate quarterly-spot basis with annualized yield
|
|
90
101
|
- Compare basis across exchanges
|
|
91
102
|
- Signal when basis exceeds profitability threshold
|
|
92
103
|
|
|
93
104
|
### US-5: Options Flow Analysis (High)
|
|
105
|
+
|
|
94
106
|
**As an** options analyst
|
|
95
107
|
**I want to** track unusual options activity and positioning
|
|
96
108
|
**So that** I can identify smart money moves
|
|
97
109
|
|
|
98
110
|
**Acceptance Criteria**:
|
|
111
|
+
|
|
99
112
|
- Show large options trades (premium > $100K)
|
|
100
113
|
- Display put/call ratio by volume and OI
|
|
101
114
|
- Calculate max pain for upcoming expiries
|
|
102
115
|
- Analyze implied volatility levels and skew
|
|
103
116
|
|
|
104
117
|
### US-6: Multi-Asset Dashboard (Medium)
|
|
118
|
+
|
|
105
119
|
**As a** portfolio manager
|
|
106
120
|
**I want to** see derivatives metrics for multiple assets
|
|
107
121
|
**So that** I can monitor my entire derivatives exposure
|
|
108
122
|
|
|
109
123
|
**Acceptance Criteria**:
|
|
124
|
+
|
|
110
125
|
- Support BTC, ETH, SOL, and major altcoins
|
|
111
126
|
- Display comparative funding rates
|
|
112
127
|
- Show aggregate OI across assets
|
|
@@ -117,35 +132,41 @@ Manual monitoring is impractical given the 24/7 nature of crypto markets and the
|
|
|
117
132
|
## Functional Requirements
|
|
118
133
|
|
|
119
134
|
### REQ-1: Multi-Exchange Data Aggregation
|
|
135
|
+
|
|
120
136
|
- Fetch funding rates from Binance, Bybit, OKX, Deribit, BitMEX
|
|
121
137
|
- Aggregate open interest across exchanges
|
|
122
138
|
- Support both USDT-margined and coin-margined contracts
|
|
123
139
|
|
|
124
140
|
### REQ-2: Funding Rate Analysis
|
|
141
|
+
|
|
125
142
|
- Current funding rate with countdown to next payment
|
|
126
143
|
- Historical funding (24h, 7d, 30d averages)
|
|
127
144
|
- Funding arbitrage opportunities between exchanges
|
|
128
145
|
- Annualized funding yield calculation
|
|
129
146
|
|
|
130
147
|
### REQ-3: Open Interest Analytics
|
|
148
|
+
|
|
131
149
|
- Total OI by asset and exchange
|
|
132
150
|
- OI change tracking (1h, 24h, 7d)
|
|
133
151
|
- Long/short ratio by exchange
|
|
134
152
|
- OI vs price divergence detection
|
|
135
153
|
|
|
136
154
|
### REQ-4: Liquidation Intelligence
|
|
155
|
+
|
|
137
156
|
- Real-time liquidation tracking
|
|
138
157
|
- Liquidation heatmap generation
|
|
139
158
|
- Cascade risk estimation
|
|
140
159
|
- Historical liquidation analysis
|
|
141
160
|
|
|
142
161
|
### REQ-5: Options Market Data
|
|
162
|
+
|
|
143
163
|
- Implied volatility by strike and expiry
|
|
144
164
|
- Put/call ratio tracking
|
|
145
165
|
- Max pain calculation
|
|
146
166
|
- Options flow for large trades
|
|
147
167
|
|
|
148
168
|
### REQ-6: Basis Calculations
|
|
169
|
+
|
|
149
170
|
- Perpetual basis (funding-implied)
|
|
150
171
|
- Quarterly futures basis
|
|
151
172
|
- Annualized yield calculation
|
|
@@ -187,16 +208,19 @@ Manual monitoring is impractical given the 24/7 nature of crypto markets and the
|
|
|
187
208
|
## Risk Considerations
|
|
188
209
|
|
|
189
210
|
### Market Risks
|
|
211
|
+
|
|
190
212
|
- Funding rates can flip rapidly during volatility
|
|
191
213
|
- Liquidation cascades can gap through levels
|
|
192
214
|
- Options pricing models have limitations
|
|
193
215
|
|
|
194
216
|
### Data Risks
|
|
217
|
+
|
|
195
218
|
- Exchange API outages or rate limits
|
|
196
219
|
- Delayed or stale data during high volatility
|
|
197
220
|
- Inconsistent data formats between exchanges
|
|
198
221
|
|
|
199
222
|
### User Risks
|
|
223
|
+
|
|
200
224
|
- Over-reliance on signals without risk management
|
|
201
225
|
- Misinterpretation of complex derivatives metrics
|
|
202
226
|
- Leverage amplifies both gains and losses
|
|
@@ -206,6 +230,7 @@ Manual monitoring is impractical given the 24/7 nature of crypto markets and the
|
|
|
206
230
|
## Examples
|
|
207
231
|
|
|
208
232
|
### Example 1: Funding Rate Alert
|
|
233
|
+
|
|
209
234
|
```
|
|
210
235
|
User: "What's the funding rate for BTC?"
|
|
211
236
|
|
|
@@ -225,6 +250,7 @@ Arbitrage: None (rates aligned)
|
|
|
225
250
|
```
|
|
226
251
|
|
|
227
252
|
### Example 2: Liquidation Analysis
|
|
253
|
+
|
|
228
254
|
```
|
|
229
255
|
User: "Where are the BTC liquidation levels?"
|
|
230
256
|
|