@intentsolutionsio/crypto-derivatives-tracker 1.0.0

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.
Files changed (29) hide show
  1. package/.claude-plugin/plugin.json +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +173 -0
  4. package/agents/derivatives-agent.md +408 -0
  5. package/package.json +43 -0
  6. package/skills/skill-adapter/assets/README.md +6 -0
  7. package/skills/skill-adapter/assets/config-template.json +32 -0
  8. package/skills/skill-adapter/assets/skill-schema.json +28 -0
  9. package/skills/skill-adapter/assets/test-data.json +27 -0
  10. package/skills/skill-adapter/references/README.md +4 -0
  11. package/skills/skill-adapter/references/best-practices.md +69 -0
  12. package/skills/skill-adapter/references/examples.md +73 -0
  13. package/skills/skill-adapter/scripts/README.md +8 -0
  14. package/skills/skill-adapter/scripts/helper-template.sh +42 -0
  15. package/skills/skill-adapter/scripts/validation.sh +32 -0
  16. package/skills/tracking-crypto-derivatives/ARD.md +376 -0
  17. package/skills/tracking-crypto-derivatives/PRD.md +258 -0
  18. package/skills/tracking-crypto-derivatives/SKILL.md +127 -0
  19. package/skills/tracking-crypto-derivatives/config/settings.yaml +152 -0
  20. package/skills/tracking-crypto-derivatives/references/errors.md +224 -0
  21. package/skills/tracking-crypto-derivatives/references/examples.md +460 -0
  22. package/skills/tracking-crypto-derivatives/references/implementation.md +113 -0
  23. package/skills/tracking-crypto-derivatives/scripts/basis_calculator.py +377 -0
  24. package/skills/tracking-crypto-derivatives/scripts/derivatives_tracker.py +579 -0
  25. package/skills/tracking-crypto-derivatives/scripts/formatters.py +459 -0
  26. package/skills/tracking-crypto-derivatives/scripts/funding_tracker.py +308 -0
  27. package/skills/tracking-crypto-derivatives/scripts/liquidation_monitor.py +356 -0
  28. package/skills/tracking-crypto-derivatives/scripts/oi_analyzer.py +338 -0
  29. package/skills/tracking-crypto-derivatives/scripts/options_analyzer.py +373 -0
@@ -0,0 +1,258 @@
1
+ # PRD: Crypto Derivatives Tracker
2
+
3
+ ## Summary
4
+
5
+ **One-liner**: Track cryptocurrency futures, options, and perpetual swaps with comprehensive market analysis
6
+ **Domain**: Cryptocurrency / Derivatives Trading
7
+ **Users**: Derivatives Traders, Arbitrage Specialists, Risk Managers
8
+
9
+ ---
10
+
11
+ ## Problem Statement
12
+
13
+ Crypto derivatives markets generate massive amounts of data across multiple exchanges - funding rates, open interest, liquidations, options flow, and basis spreads. Traders need to:
14
+
15
+ 1. Monitor funding rates across 5+ exchanges simultaneously
16
+ 2. Track open interest changes to gauge market positioning
17
+ 3. Identify liquidation clusters and cascade risks
18
+ 4. Analyze options flow for smart money signals
19
+ 5. Find basis trading and funding arbitrage opportunities
20
+
21
+ Manual monitoring is impractical given the 24/7 nature of crypto markets and the speed at which conditions change. A unified tool that aggregates derivatives data and generates actionable insights is essential.
22
+
23
+ ---
24
+
25
+ ## Target Users
26
+
27
+ ### Persona 1: Derivatives Day Trader
28
+ - **Background**: Full-time crypto trader focusing on perpetual swaps
29
+ - **Goals**: Profit from funding rate extremes, OI divergences, and liquidation cascades
30
+ - **Pain Points**: Data fragmented across exchanges, misses funding changes
31
+ - **Success Criteria**: Consistent funding capture, early entry before liquidation cascades
32
+
33
+ ### Persona 2: Basis Arbitrageur
34
+ - **Background**: Market-neutral trader running cash-and-carry strategies
35
+ - **Goals**: Lock in risk-free returns via spot-futures basis trades
36
+ - **Pain Points**: Manual basis calculations, timing entry/exit around funding
37
+ - **Success Criteria**: Captures basis premium with minimal directional risk
38
+
39
+ ### Persona 3: Options Flow Analyst
40
+ - **Background**: Institutional researcher tracking smart money via options
41
+ - **Goals**: Identify unusual options activity and positioning before moves
42
+ - **Pain Points**: Options data scattered, hard to interpret Greeks at scale
43
+ - **Success Criteria**: Detects smart money positioning ahead of price moves
44
+
45
+ ---
46
+
47
+ ## User Stories
48
+
49
+ ### US-1: Funding Rate Monitoring (Critical)
50
+ **As a** derivatives trader
51
+ **I want to** see funding rates across all major exchanges in one view
52
+ **So that** I can identify arbitrage opportunities and sentiment extremes
53
+
54
+ **Acceptance Criteria**:
55
+ - Display funding rates for BTC, ETH, SOL across Binance, Bybit, OKX, Deribit
56
+ - Show current, 24h average, and 7d average rates
57
+ - Calculate annualized funding yield
58
+ - Alert when funding exceeds configurable threshold (default: 0.1%)
59
+
60
+ ### US-2: Open Interest Analysis (Critical)
61
+ **As a** derivatives trader
62
+ **I want to** track open interest changes by exchange and contract type
63
+ **So that** I can gauge market positioning and trend strength
64
+
65
+ **Acceptance Criteria**:
66
+ - Show total OI in USD and BTC/ETH equivalent
67
+ - Display 24h, 7d, 30d OI changes
68
+ - Compare OI across exchanges (market share)
69
+ - Analyze OI vs price divergences
70
+
71
+ ### US-3: Liquidation Monitoring (Critical)
72
+ **As a** derivatives trader
73
+ **I want to** see liquidation levels and recent liquidation events
74
+ **So that** I can avoid cascade zones and position for liquidation-driven moves
75
+
76
+ **Acceptance Criteria**:
77
+ - Display liquidation heatmap with price levels
78
+ - Show recent large liquidations (>$100K)
79
+ - Calculate long/short liquidation zones
80
+ - Estimate cascade risk at key levels
81
+
82
+ ### US-4: Basis Tracking (High)
83
+ **As a** basis arbitrageur
84
+ **I want to** see spot-futures basis across all expiries
85
+ **So that** I can identify cash-and-carry opportunities
86
+
87
+ **Acceptance Criteria**:
88
+ - Calculate perpetual-spot basis (real-time)
89
+ - Calculate quarterly-spot basis with annualized yield
90
+ - Compare basis across exchanges
91
+ - Signal when basis exceeds profitability threshold
92
+
93
+ ### US-5: Options Flow Analysis (High)
94
+ **As an** options analyst
95
+ **I want to** track unusual options activity and positioning
96
+ **So that** I can identify smart money moves
97
+
98
+ **Acceptance Criteria**:
99
+ - Show large options trades (premium > $100K)
100
+ - Display put/call ratio by volume and OI
101
+ - Calculate max pain for upcoming expiries
102
+ - Analyze implied volatility levels and skew
103
+
104
+ ### US-6: Multi-Asset Dashboard (Medium)
105
+ **As a** portfolio manager
106
+ **I want to** see derivatives metrics for multiple assets
107
+ **So that** I can monitor my entire derivatives exposure
108
+
109
+ **Acceptance Criteria**:
110
+ - Support BTC, ETH, SOL, and major altcoins
111
+ - Display comparative funding rates
112
+ - Show aggregate OI across assets
113
+ - Highlight assets with extreme metrics
114
+
115
+ ---
116
+
117
+ ## Functional Requirements
118
+
119
+ ### REQ-1: Multi-Exchange Data Aggregation
120
+ - Fetch funding rates from Binance, Bybit, OKX, Deribit, BitMEX
121
+ - Aggregate open interest across exchanges
122
+ - Support both USDT-margined and coin-margined contracts
123
+
124
+ ### REQ-2: Funding Rate Analysis
125
+ - Current funding rate with countdown to next payment
126
+ - Historical funding (24h, 7d, 30d averages)
127
+ - Funding arbitrage opportunities between exchanges
128
+ - Annualized funding yield calculation
129
+
130
+ ### REQ-3: Open Interest Analytics
131
+ - Total OI by asset and exchange
132
+ - OI change tracking (1h, 24h, 7d)
133
+ - Long/short ratio by exchange
134
+ - OI vs price divergence detection
135
+
136
+ ### REQ-4: Liquidation Intelligence
137
+ - Real-time liquidation tracking
138
+ - Liquidation heatmap generation
139
+ - Cascade risk estimation
140
+ - Historical liquidation analysis
141
+
142
+ ### REQ-5: Options Market Data
143
+ - Implied volatility by strike and expiry
144
+ - Put/call ratio tracking
145
+ - Max pain calculation
146
+ - Options flow for large trades
147
+
148
+ ### REQ-6: Basis Calculations
149
+ - Perpetual basis (funding-implied)
150
+ - Quarterly futures basis
151
+ - Annualized yield calculation
152
+ - Basis convergence alerts
153
+
154
+ ---
155
+
156
+ ## API Integrations
157
+
158
+ | Source | Data Provided | Rate Limits |
159
+ |--------|---------------|-------------|
160
+ | Binance Futures | Funding, OI, liquidations | 1200/min |
161
+ | Bybit | Funding, OI, positions | 120/min |
162
+ | OKX | Funding, OI, options | 60/min |
163
+ | Deribit | Options, funding, OI | 10K/day |
164
+ | Coinglass | Aggregated derivatives | API key required |
165
+
166
+ ---
167
+
168
+ ## Success Metrics
169
+
170
+ 1. **Data Freshness**: All metrics updated within 5 seconds
171
+ 2. **Exchange Coverage**: 5+ CEX, 3+ DEX protocols supported
172
+ 3. **Alert Accuracy**: 90%+ of funding extremes detected
173
+ 4. **User Satisfaction**: Clear, actionable output format
174
+
175
+ ---
176
+
177
+ ## Non-Goals
178
+
179
+ - **Not** executing trades or managing positions
180
+ - **Not** providing financial advice or guaranteed signals
181
+ - **Not** real-time order book depth analysis
182
+ - **Not** custom strategy backtesting
183
+ - **Not** portfolio accounting or tax reporting
184
+
185
+ ---
186
+
187
+ ## Risk Considerations
188
+
189
+ ### Market Risks
190
+ - Funding rates can flip rapidly during volatility
191
+ - Liquidation cascades can gap through levels
192
+ - Options pricing models have limitations
193
+
194
+ ### Data Risks
195
+ - Exchange API outages or rate limits
196
+ - Delayed or stale data during high volatility
197
+ - Inconsistent data formats between exchanges
198
+
199
+ ### User Risks
200
+ - Over-reliance on signals without risk management
201
+ - Misinterpretation of complex derivatives metrics
202
+ - Leverage amplifies both gains and losses
203
+
204
+ ---
205
+
206
+ ## Examples
207
+
208
+ ### Example 1: Funding Rate Alert
209
+ ```
210
+ User: "What's the funding rate for BTC?"
211
+
212
+ Output:
213
+ BTC PERPETUAL FUNDING RATES
214
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
215
+ Exchange Current 24h Avg 7d Avg Next Payment
216
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
217
+ Binance +0.0150% +0.0120% +0.0080% 2h 15m
218
+ Bybit +0.0180% +0.0140% +0.0100% 2h 15m
219
+ OKX +0.0130% +0.0110% +0.0090% 2h 15m
220
+ Deribit +0.0200% +0.0150% +0.0120% 2h 15m
221
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
222
+ Annualized: +15.77% (based on current rates)
223
+ Sentiment: Moderately Bullish
224
+ Arbitrage: None (rates aligned)
225
+ ```
226
+
227
+ ### Example 2: Liquidation Analysis
228
+ ```
229
+ User: "Where are the BTC liquidation levels?"
230
+
231
+ Output:
232
+ BTC LIQUIDATION HEATMAP
233
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
234
+ Current Price: $67,500
235
+
236
+ LONG LIQUIDATIONS (below current):
237
+ $65,000: $125M at risk (HIGH DENSITY)
238
+ $62,500: $85M at risk
239
+ $60,000: $210M at risk (CRITICAL CLUSTER)
240
+
241
+ SHORT LIQUIDATIONS (above current):
242
+ $70,000: $95M at risk
243
+ $72,500: $145M at risk (HIGH DENSITY)
244
+ $75,000: $180M at risk
245
+
246
+ Last 24h Liquidations:
247
+ Longs: $45.2M | Shorts: $32.8M
248
+ Largest: $5.2M long at $66,800
249
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Version History
255
+
256
+ | Version | Date | Author | Changes |
257
+ |---------|------|--------|---------|
258
+ | 1.0.0 | 2025-01-15 | Jeremy Longshore | Initial PRD |
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: tracking-crypto-derivatives
3
+ description: |
4
+ Track cryptocurrency futures, options, and perpetual swaps with funding rates, open interest, liquidations, and comprehensive derivatives market analysis.
5
+ Use when monitoring derivatives markets, analyzing funding rates, tracking open interest, finding liquidation levels, or researching options flow.
6
+ Trigger with phrases like "funding rate", "open interest", "perpetual swap", "futures basis", "liquidation levels", "options flow", "put call ratio", "derivatives analysis", or "BTC perps".
7
+ allowed-tools: Read, Write, Edit, Grep, Glob, Bash(crypto:derivatives-*)
8
+ version: 1.0.0
9
+ author: Jeremy Longshore <jeremy@intentsolutions.io>
10
+ license: MIT
11
+ compatible-with: claude-code, codex, openclaw
12
+ tags: [crypto, monitoring, tracking-crypto]
13
+ ---
14
+ # Tracking Crypto Derivatives
15
+
16
+ ## Overview
17
+
18
+ Aggregate funding rates, open interest, liquidations, and options data across CEX and DEX derivatives exchanges to produce actionable trading insights.
19
+
20
+ **Supported Markets**: Perpetual Swaps (Binance, Bybit, OKX, Deribit, BitMEX), Quarterly Futures, Options (Deribit, OKX, Bybit), DEX Perpetuals (dYdX, GMX, Drift Protocol).
21
+
22
+ ## Prerequisites
23
+
24
+ - Python 3.8+ installed
25
+ - Network access to exchange APIs
26
+ - Optional: API keys for higher rate limits
27
+ - Understanding of derivatives concepts (funding, OI, basis)
28
+
29
+ ## Instructions
30
+
31
+ 1. **Check funding rates** across exchanges to identify sentiment and arbitrage opportunities:
32
+ ```bash
33
+ python derivatives_tracker.py funding BTC
34
+ python derivatives_tracker.py funding BTC ETH SOL
35
+ python derivatives_tracker.py funding BTC --history 7d
36
+ ```
37
+ - Positive funding (>0.01%): Longs pay shorts, bullish sentiment
38
+ - Negative funding (<-0.01%): Shorts pay longs, bearish sentiment
39
+ - Extreme funding (>0.1%): Potential contrarian opportunity
40
+
41
+ 2. **Analyze open interest** to gauge market positioning and trend strength:
42
+ ```bash
43
+ python derivatives_tracker.py oi BTC
44
+ python derivatives_tracker.py oi BTC --changes
45
+ python derivatives_tracker.py oi BTC --divergence
46
+ ```
47
+ - Rising OI + Rising Price = strong bullish trend
48
+ - Rising OI + Falling Price = strong bearish trend
49
+ - Falling OI + Rising Price = short covering rally
50
+ - Falling OI + Falling Price = long liquidations
51
+
52
+ 3. **Monitor liquidations** to find support/resistance clusters:
53
+ ```bash
54
+ python derivatives_tracker.py liquidations BTC
55
+ python derivatives_tracker.py liquidations BTC --recent
56
+ python derivatives_tracker.py liquidations BTC --min-size 100000 # 100000 = minimum USD liquidation size filter
57
+ ```
58
+
59
+ 4. **Analyze options market** for IV, put/call ratio, and max pain:
60
+ ```bash
61
+ python derivatives_tracker.py options BTC
62
+ python derivatives_tracker.py options BTC --pcr
63
+ python derivatives_tracker.py options BTC --expiry 2025-01-31 # 2025 = target expiry year
64
+ ```
65
+
66
+ 5. **Calculate basis** for spot-futures arbitrage opportunities:
67
+ ```bash
68
+ python derivatives_tracker.py basis BTC
69
+ python derivatives_tracker.py basis BTC --quarterly
70
+ python derivatives_tracker.py basis --all
71
+ ```
72
+
73
+ 6. **Run full dashboard** for comprehensive derivatives overview:
74
+ ```bash
75
+ python derivatives_tracker.py dashboard BTC
76
+ python derivatives_tracker.py dashboard BTC ETH SOL
77
+ python derivatives_tracker.py dashboard BTC --output json
78
+ ```
79
+
80
+ ## Output
81
+
82
+ The skill produces structured reports per market type:
83
+
84
+ - **Funding Rate Report**: Current, 24h avg, 7d avg rates per exchange with annualized yield and sentiment
85
+ - **Open Interest Report**: OI per exchange with 24h/7d changes, share %, and long/short ratio
86
+ - **Liquidation Heatmap**: Long/short liquidation clusters by price level with USD density
87
+ - **Options Overview**: Put/call ratio, IV rank, max pain, and large flow alerts
88
+ - **Basis Report**: Spot-perp and quarterly basis with annualized carry rates
89
+
90
+ See `${CLAUDE_SKILL_DIR}/references/implementation.md` for detailed output format examples.
91
+
92
+ ## Error Handling
93
+
94
+ | Error | Cause | Fix |
95
+ |-------|-------|-----|
96
+ | `ERR_RATE_LIMIT` | Too many API requests | Reduce frequency or add API key |
97
+ | `ERR_EXCHANGE_DOWN` | Exchange API unavailable | Try alternative exchange |
98
+ | `ERR_SYMBOL_INVALID` | Wrong symbol format | Use BTC, ETH (not BTCUSDT) |
99
+
100
+ ## Examples
101
+
102
+ **Morning derivatives check** - Scan funding, OI, and liquidations for top assets:
103
+ ```bash
104
+ python derivatives_tracker.py dashboard BTC ETH SOL
105
+ ```
106
+
107
+ **Funding rate arbitrage** - Alert when funding exceeds threshold for cash-and-carry:
108
+ ```bash
109
+ python derivatives_tracker.py funding BTC --alert-threshold 0.08
110
+ ```
111
+
112
+ **Pre-expiry options analysis** - Check max pain and IV before Friday expiry:
113
+ ```bash
114
+ python derivatives_tracker.py options BTC --expiry friday
115
+ ```
116
+
117
+ **Basis trading scan** - Find all pairs with annualized yield above 5%:
118
+ ```bash
119
+ python derivatives_tracker.py basis --all --min-yield 5 # 5 = minimum annualized yield %
120
+ ```
121
+
122
+ ## Resources
123
+
124
+ - **Coinglass**: Aggregated derivatives data
125
+ - **Exchange APIs**: Binance, Bybit, OKX, Deribit
126
+ - **The Graph**: DEX perpetuals data
127
+ - `${CLAUDE_SKILL_DIR}/references/implementation.md` - Detailed output formats, options/basis guides, key concepts
@@ -0,0 +1,152 @@
1
+ # Crypto Derivatives Tracker Configuration
2
+ # ==========================================
3
+
4
+ # General settings
5
+ general:
6
+ # Default output format: console or json
7
+ default_format: console
8
+
9
+ # Default symbols to track
10
+ default_symbols:
11
+ - BTC
12
+ - ETH
13
+
14
+ # Cache TTL in seconds
15
+ cache_ttl: 300
16
+
17
+ # Request timeout in seconds
18
+ request_timeout: 30
19
+
20
+ # Exchange configuration
21
+ exchanges:
22
+ # Enabled exchanges for data collection
23
+ enabled:
24
+ - binance
25
+ - bybit
26
+ - okx
27
+ - deribit
28
+ - bitmex
29
+
30
+ # Primary exchange for each data type
31
+ primary:
32
+ funding: binance
33
+ open_interest: binance
34
+ liquidations: binance
35
+ options: deribit
36
+ basis: binance
37
+
38
+ # Rate limits (requests per minute)
39
+ rate_limits:
40
+ binance: 1200
41
+ bybit: 120
42
+ okx: 60
43
+ deribit: 100
44
+ bitmex: 30
45
+
46
+ # Funding rate settings
47
+ funding:
48
+ # Interpretation thresholds (8-hour rate as percentage)
49
+ thresholds:
50
+ extreme: 0.08 # Above this is extreme
51
+ strong: 0.03 # Above this is strong
52
+ neutral: 0.005 # Below this is neutral
53
+
54
+ # Minimum spread for arbitrage alerts (percentage)
55
+ min_arb_spread: 0.02
56
+
57
+ # Alert on extreme funding
58
+ alert_extreme: true
59
+
60
+ # Open interest settings
61
+ open_interest:
62
+ # Trend detection thresholds (24h change percentage)
63
+ thresholds:
64
+ strong_change: 10.0 # >10% is strong move
65
+ moderate_change: 5.0 # >5% is moderate
66
+
67
+ # Divergence detection minimum change
68
+ divergence_min_change: 2.0
69
+
70
+ # Liquidation settings
71
+ liquidations:
72
+ # Cascade risk thresholds (USD within 5% of price)
73
+ cascade_thresholds:
74
+ critical: 500000000 # $500M
75
+ high: 200000000 # $200M
76
+ medium: 100000000 # $100M
77
+
78
+ # Minimum liquidation size to track (USD)
79
+ min_liquidation_size: 100000
80
+
81
+ # Large liquidation threshold (USD)
82
+ large_liquidation_threshold: 1000000
83
+
84
+ # Options settings
85
+ options:
86
+ # IV interpretation thresholds (percentage)
87
+ iv_thresholds:
88
+ high: 70.0
89
+ low: 40.0
90
+
91
+ # Put/call ratio interpretation
92
+ pcr_thresholds:
93
+ bearish: 1.2 # Above this is bearish
94
+ bullish: 0.7 # Below this is bullish
95
+
96
+ # Days until expiry for pressure levels
97
+ expiry_pressure:
98
+ high: 2 # <= 2 days
99
+ medium: 7 # <= 7 days
100
+
101
+ # Basis settings
102
+ basis:
103
+ # Structure interpretation thresholds (annualized percentage)
104
+ structure_thresholds:
105
+ strong: 5.0 # >5% annualized is strong
106
+ moderate: 2.0 # >2% is moderate
107
+
108
+ # Minimum yield for carry trade alerts
109
+ min_carry_yield: 5.0
110
+
111
+ # Output formatting
112
+ formatting:
113
+ # Console width
114
+ console_width: 70
115
+
116
+ # Number of decimal places
117
+ decimals:
118
+ rate: 4
119
+ percentage: 2
120
+ currency: 0
121
+
122
+ # Currency formatting
123
+ currency:
124
+ symbol: "$"
125
+ thousands_separator: ","
126
+ decimal_separator: "."
127
+
128
+ # Alerts and notifications
129
+ alerts:
130
+ # Enable alerts
131
+ enabled: false
132
+
133
+ # Alert conditions
134
+ conditions:
135
+ extreme_funding: true
136
+ high_cascade_risk: true
137
+ large_liquidation: true
138
+ oi_divergence: true
139
+
140
+ # Webhook URL for alerts (optional)
141
+ webhook_url: ""
142
+
143
+ # Logging
144
+ logging:
145
+ # Log level: DEBUG, INFO, WARNING, ERROR
146
+ level: INFO
147
+
148
+ # Log file path (optional)
149
+ file: ""
150
+
151
+ # Log format
152
+ format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"