@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,224 @@
1
+ # Error Handling Reference
2
+
3
+ ## Exchange API Errors
4
+
5
+ ### Authentication Failures
6
+
7
+ **API Key Invalid**
8
+ - Error: `Invalid API key` or `Signature mismatch`
9
+ - Causes: Expired key, wrong permissions, clock drift
10
+ - Solution:
11
+ 1. Regenerate API keys on exchange
12
+ 2. Ensure read-only permissions enabled
13
+ 3. Sync system clock: `sudo ntpdate pool.ntp.org`
14
+ 4. Check key has futures/derivatives permissions
15
+
16
+ **IP Whitelist Rejected**
17
+ - Error: `IP not in whitelist`
18
+ - Solution: Add current IP to exchange API settings or remove whitelist restriction
19
+
20
+ ### Rate Limiting
21
+
22
+ **Too Many Requests**
23
+ - Error: `429 Too Many Requests` or `Rate limit exceeded`
24
+ - Threshold varies by exchange:
25
+ - Binance: 1200 requests/minute (weighted)
26
+ - Bybit: 120 requests/minute
27
+ - OKX: 60 requests/2 seconds
28
+ - Deribit: 100 requests/second
29
+ - Solution:
30
+ 1. Implement exponential backoff
31
+ 2. Use WebSocket for real-time data
32
+ 3. Cache static data (max pain, OI levels)
33
+ 4. Batch requests where possible
34
+
35
+ **Weight Exceeded**
36
+ - Error: `Request weight exceeded`
37
+ - Solution: Some endpoints cost more weight; use lightweight endpoints or wait
38
+
39
+ ## Data Quality Errors
40
+
41
+ ### Missing or Stale Data
42
+
43
+ **No Data Available**
44
+ - Error: `No funding data available for {symbol}`
45
+ - Causes: Symbol not listed, exchange down, maintenance
46
+ - Solution:
47
+ 1. Verify symbol exists on exchange
48
+ 2. Check exchange status page
49
+ 3. Fall back to alternative exchange
50
+ 4. Use mock data for testing
51
+
52
+ **Stale Timestamp**
53
+ - Error: Data timestamp older than expected
54
+ - Solution:
55
+ 1. Check WebSocket connection alive
56
+ 2. Verify exchange API operational
57
+ 3. Increase polling frequency
58
+ 4. Implement freshness checks
59
+
60
+ ### Invalid Values
61
+
62
+ **Negative Funding Rate**
63
+ - Not an error - negative funding is valid (shorts pay longs)
64
+ - Just ensure your calculations handle negative correctly
65
+
66
+ **Zero Open Interest**
67
+ - May indicate:
68
+ - New symbol with no positions
69
+ - Data not yet populated
70
+ - Exchange maintenance
71
+ - Solution: Filter out or flag as incomplete
72
+
73
+ **Implausible Values**
74
+ - Funding rate > 10% per 8h → likely data error
75
+ - IV > 500% → verify or exclude
76
+ - Solution: Implement sanity checks and outlier filtering
77
+
78
+ ## Calculation Errors
79
+
80
+ ### Division by Zero
81
+
82
+ **Empty Exchange List**
83
+ - Error: `Division by zero` in weighted average
84
+ - Cause: No exchanges returned data
85
+ - Solution:
86
+ ```python
87
+ if not exchanges:
88
+ raise ValueError("No exchange data available")
89
+ total = sum(oi.value for oi in exchanges)
90
+ if total == 0:
91
+ raise ValueError("Total OI is zero")
92
+ ```
93
+
94
+ ### Decimal Precision
95
+
96
+ **Precision Loss**
97
+ - Error: Incorrect basis calculations due to floating point
98
+ - Solution: Use `Decimal` for all price/rate calculations
99
+ ```python
100
+ from decimal import Decimal, ROUND_HALF_UP
101
+ basis = (futures - spot) / spot
102
+ basis_pct = float(basis.quantize(Decimal('0.0001')))
103
+ ```
104
+
105
+ ### Date Handling
106
+
107
+ **Invalid Expiry Format**
108
+ - Error: `strptime` fails on expiry string
109
+ - Cause: Different exchange formats (YYYYMMDD vs YYYY-MM-DD)
110
+ - Solution:
111
+ ```python
112
+ formats = ['%Y-%m-%d', '%Y%m%d', '%d%b%y']
113
+ for fmt in formats:
114
+ try:
115
+ return datetime.strptime(expiry, fmt)
116
+ except ValueError:
117
+ continue
118
+ raise ValueError(f"Unknown expiry format: {expiry}")
119
+ ```
120
+
121
+ **Expiry Already Passed**
122
+ - Warning: Analyzing expired contract
123
+ - Solution: Filter to active expiries only
124
+
125
+ ## Network Errors
126
+
127
+ ### Connection Failures
128
+
129
+ **Connection Timeout**
130
+ - Error: `Connection timed out`
131
+ - Solution:
132
+ 1. Increase timeout: `timeout=30`
133
+ 2. Use retry with backoff
134
+ 3. Switch to backup endpoint
135
+ 4. Check network connectivity
136
+
137
+ **SSL Certificate Error**
138
+ - Error: `SSL: CERTIFICATE_VERIFY_FAILED`
139
+ - Solution:
140
+ 1. Update CA certificates
141
+ 2. For testing only: `verify=False` (not recommended for production)
142
+
143
+ ### WebSocket Issues
144
+
145
+ **Disconnected**
146
+ - Error: WebSocket connection closed unexpectedly
147
+ - Solution:
148
+ 1. Implement reconnection logic
149
+ 2. Use heartbeat/ping-pong
150
+ 3. Handle partial messages
151
+
152
+ ## Recovery Strategies
153
+
154
+ ### Graceful Degradation
155
+
156
+ 1. **Exchange Fallback**: If primary exchange fails, try alternatives
157
+ 2. **Cached Data**: Use last known good value with timestamp warning
158
+ 3. **Partial Results**: Return available data, flag missing exchanges
159
+
160
+ ### Retry Logic
161
+
162
+ ```python
163
+ import time
164
+
165
+ def fetch_with_retry(func, max_retries=3, base_delay=1):
166
+ for attempt in range(max_retries):
167
+ try:
168
+ return func()
169
+ except RateLimitError:
170
+ delay = base_delay * (2 ** attempt)
171
+ time.sleep(delay)
172
+ except ConnectionError:
173
+ if attempt < max_retries - 1:
174
+ time.sleep(base_delay)
175
+ else:
176
+ raise
177
+ raise RetryExhaustedError()
178
+ ```
179
+
180
+ ### Circuit Breaker
181
+
182
+ Track failures per exchange and temporarily disable problematic sources:
183
+
184
+ ```python
185
+ failures = defaultdict(int)
186
+ disabled_until = {}
187
+
188
+ def check_exchange_health(exchange):
189
+ if exchange in disabled_until:
190
+ if datetime.now() < disabled_until[exchange]:
191
+ return False
192
+ del disabled_until[exchange]
193
+ return True
194
+
195
+ def record_failure(exchange):
196
+ failures[exchange] += 1
197
+ if failures[exchange] >= 3:
198
+ disabled_until[exchange] = datetime.now() + timedelta(minutes=5)
199
+ ```
200
+
201
+ ## Common Issues by Exchange
202
+
203
+ ### Binance
204
+ - Issue: Weight limits are complex (different endpoints cost different)
205
+ - Solution: Track weight counter from response headers
206
+
207
+ ### Bybit
208
+ - Issue: V5 API has different structure than V3
209
+ - Solution: Use unified V5 endpoints consistently
210
+
211
+ ### OKX
212
+ - Issue: Requires specific headers for authentication
213
+ - Solution: Include `OK-ACCESS-*` headers correctly
214
+
215
+ ### Deribit
216
+ - Issue: Options data requires authentication
217
+ - Solution: Use API key even for read-only data
218
+
219
+ ### BitMEX
220
+ - Issue: Rate limits are very strict
221
+ - Solution: Aggressive caching, minimal polling
222
+
223
+ ---
224
+ *[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
@@ -0,0 +1,460 @@
1
+ # Usage Examples
2
+
3
+ ## CLI Examples
4
+
5
+ ### Funding Rate Analysis
6
+
7
+ **Basic funding rate check:**
8
+ ```bash
9
+ python derivatives_tracker.py funding BTC
10
+ ```
11
+
12
+ Output:
13
+ ```
14
+ ======================================================================
15
+ BTC FUNDING RATE ANALYSIS
16
+ ======================================================================
17
+
18
+ Exchange Current Annualized Next Payment
19
+ --------------------------------------------------
20
+ Binance +0.0100% +10.95% 4h 23m
21
+ Bybit +0.0095% +10.40% 4h 23m
22
+ OKX +0.0088% +9.64% 4h 23m
23
+ Deribit +0.0082% +8.98% 4h 23m
24
+ BitMEX +0.0078% +8.54% 4h 23m
25
+ --------------------------------------------------
26
+
27
+ Weighted Average: +0.0089%
28
+ Annualized: +9.70%
29
+ Spread (max-min): 0.0022%
30
+
31
+ Sentiment: 🟢 Moderate Bullish
32
+ ```
33
+
34
+ **JSON export:**
35
+ ```bash
36
+ python derivatives_tracker.py funding BTC --format json
37
+ ```
38
+
39
+ ### Open Interest Analysis
40
+
41
+ **Basic OI check:**
42
+ ```bash
43
+ python derivatives_tracker.py oi BTC
44
+ ```
45
+
46
+ Output:
47
+ ```
48
+ ======================================================================
49
+ BTC OPEN INTEREST ANALYSIS
50
+ ======================================================================
51
+
52
+ Exchange OI (USD) 24h Chg 7d Chg Share
53
+ ------------------------------------------------------------
54
+ Binance $6.20B +3.2% +8.5% 41.3%
55
+ Bybit $3.85B +2.8% +6.2% 25.7%
56
+ OKX $2.40B +1.5% +4.8% 16.0%
57
+ Deribit $1.50B +4.2% +12.1% 10.0%
58
+ BitMEX $1.05B +0.8% +2.4% 7.0%
59
+ ------------------------------------------------------------
60
+
61
+ Total OI: $15.00B
62
+ 24h Change: +2.9%
63
+ 7d Change: +7.8%
64
+
65
+ Long/Short Ratio: 1.05 (51.2% long)
66
+ Trend: Moderate Increasing
67
+ Dominant Exchange: Binance (41.3%)
68
+ ```
69
+
70
+ **With divergence analysis:**
71
+ ```bash
72
+ python derivatives_tracker.py oi BTC --price-change 3.5
73
+ ```
74
+
75
+ Output includes:
76
+ ```
77
+ ────────────────────────────────────────────────────────────────────────
78
+ DIVERGENCE ANALYSIS
79
+ ────────────────────────────────────────────────────────────────────────
80
+
81
+ 🔍 Divergence Detected!
82
+ OI: up (+2.9%)
83
+ Price: up (+3.5%)
84
+ Signal: BULLISH
85
+ Rising OI confirms bullish trend - new longs entering
86
+ Confidence: medium
87
+ ```
88
+
89
+ ### Liquidation Monitoring
90
+
91
+ **Basic liquidation summary:**
92
+ ```bash
93
+ python derivatives_tracker.py liquidations BTC
94
+ ```
95
+
96
+ Output:
97
+ ```
98
+ ======================================================================
99
+ BTC LIQUIDATION MONITOR
100
+ ======================================================================
101
+
102
+ Current Price: $67,500
103
+ ------------------------------------------------------------
104
+
105
+ 24h Liquidations:
106
+ Total: $125.5M
107
+ Longs: $75.3M
108
+ Shorts: $50.2M
109
+
110
+ Cascade Risk: 🟡 MEDIUM
111
+
112
+ ────────────────────────────────────────────────────────────────────────
113
+ LIQUIDATION HEATMAP
114
+ ────────────────────────────────────────────────────────────────────────
115
+
116
+ LONG LIQUIDATIONS (below $67,500):
117
+ $ 65,000 ████████████ $120M ⚠️ HIGH
118
+ $ 63,000 ████████ $80M MEDIUM
119
+ $ 60,000 ██████ $60M MEDIUM
120
+ $ 58,000 ██ $20M LOW
121
+
122
+ SHORT LIQUIDATIONS (above $67,500):
123
+ $ 70,000 ██████████ $100M HIGH
124
+ $ 72,000 ████████ $80M MEDIUM
125
+ $ 75,000 ██████ $60M MEDIUM
126
+ $ 78,000 ██ $20M LOW
127
+ ```
128
+
129
+ **With large liquidation history:**
130
+ ```bash
131
+ python derivatives_tracker.py liquidations BTC --large
132
+ ```
133
+
134
+ Adds:
135
+ ```
136
+ ────────────────────────────────────────────────────────────────────────
137
+ RECENT LARGE LIQUIDATIONS (>$1M)
138
+ ────────────────────────────────────────────────────────────────────────
139
+
140
+ Exchange Side Price Value When
141
+ ------------------------------------------------------------
142
+ Binance long $67,200 $5.2M 23m ago
143
+ Bybit long $66,850 $3.8M 1h ago
144
+ OKX short $68,100 $2.9M 2h ago
145
+ ```
146
+
147
+ ### Options Analysis
148
+
149
+ **Basic options summary:**
150
+ ```bash
151
+ python derivatives_tracker.py options BTC
152
+ ```
153
+
154
+ Output:
155
+ ```
156
+ ======================================================================
157
+ BTC OPTIONS ANALYSIS
158
+ ======================================================================
159
+
160
+ Expiry: 2025-01-31
161
+ Exchange: Deribit
162
+
163
+ Implied Volatility:
164
+ ATM IV: 55.5%
165
+ Interpretation: NORMAL
166
+ IV Rank: 52nd percentile
167
+
168
+ Put/Call Analysis:
169
+ PCR (Volume): 0.85
170
+ PCR (OI): 0.92
171
+ Sentiment: 🟢 BULLISH
172
+
173
+ Max Pain:
174
+ Price: $66,000
175
+ Distance: -2.2% from current
176
+
177
+ Open Interest:
178
+ Calls: $2.80B
179
+ Puts: $2.58B
180
+
181
+ Overall Sentiment: 🟢 BULLISH
182
+ Expiry Pressure: LOW
183
+ ```
184
+
185
+ **With max pain levels and options flow:**
186
+ ```bash
187
+ python derivatives_tracker.py options BTC --max-pain --flow
188
+ ```
189
+
190
+ ### Basis Analysis
191
+
192
+ **Basic basis/spread check:**
193
+ ```bash
194
+ python derivatives_tracker.py basis BTC
195
+ ```
196
+
197
+ Output:
198
+ ```
199
+ ======================================================================
200
+ BTC BASIS ANALYSIS
201
+ ======================================================================
202
+
203
+ Spot Price: $67,500
204
+ ------------------------------------------------------------
205
+
206
+ Expiry Futures Basis Annual Days
207
+ ------------------------------------------------------------
208
+ 2025-01-31 $68,175 +1.00% +13.0% 28
209
+ 2025-02-28 $68,850 +2.00% +13.1% 56
210
+ 2025-03-28 $69,863 +3.50% +15.2% 84
211
+ 2025-06-27 $71,550 +6.00% +13.1% 168
212
+ ------------------------------------------------------------
213
+
214
+ Market Structure: Moderate Contango
215
+ Average Basis: +3.13%
216
+ Average Annualized: +13.6%
217
+ Best Carry: 2025-03-28 (+15.2% annualized)
218
+
219
+ ────────────────────────────────────────────────────────────────────────
220
+ TERM STRUCTURE
221
+ ────────────────────────────────────────────────────────────────────────
222
+ 2025-01-31 ▲ ++++++ +13.0%
223
+ 2025-02-28 ▲ ++++++ +13.1%
224
+ 2025-03-28 ▲ +++++++ +15.2%
225
+ 2025-06-27 ▲ ++++++ +13.1%
226
+ ```
227
+
228
+ **With carry trade scanner:**
229
+ ```bash
230
+ python derivatives_tracker.py basis BTC --carry
231
+ ```
232
+
233
+ ### Multi-Asset Dashboard
234
+
235
+ **Quick market overview:**
236
+ ```bash
237
+ python derivatives_tracker.py dashboard BTC ETH SOL
238
+ ```
239
+
240
+ Output:
241
+ ```
242
+ ======================================================================
243
+ CRYPTO DERIVATIVES DASHBOARD
244
+ ======================================================================
245
+
246
+ ======================================================================
247
+ BTC
248
+ ======================================================================
249
+
250
+ 📊 FUNDING
251
+ Rate: +0.0089% (+9.70% annual)
252
+ Sentiment: 🟢 Bullish
253
+
254
+ 📈 OPEN INTEREST
255
+ Total: $15.0B (+2.9% 24h)
256
+ Long/Short: 1.05 (51% long)
257
+ Trend: Moderate Increasing
258
+
259
+ 💥 LIQUIDATIONS (24h)
260
+ Total: $125.5M
261
+ Longs: $75.3M | Shorts: $50.2M
262
+ Cascade Risk: 🟡 MEDIUM
263
+
264
+ ======================================================================
265
+ ETH
266
+ ======================================================================
267
+
268
+ 📊 FUNDING
269
+ Rate: +0.0072% (+7.88% annual)
270
+ Sentiment: 🟢 Bullish
271
+
272
+ 📈 OPEN INTEREST
273
+ Total: $8.2B (+1.8% 24h)
274
+ Long/Short: 1.02 (50.5% long)
275
+ Trend: Weak Increasing
276
+
277
+ 💥 LIQUIDATIONS (24h)
278
+ Total: $45.2M
279
+ Longs: $28.1M | Shorts: $17.1M
280
+ Cascade Risk: 🟢 LOW
281
+
282
+ ======================================================================
283
+ SOL
284
+ ======================================================================
285
+
286
+ 📊 FUNDING
287
+ Rate: +0.0156% (+17.08% annual)
288
+ Sentiment: 🟢 Strong Bullish
289
+
290
+ 📈 OPEN INTEREST
291
+ Total: $2.1B (+5.2% 24h)
292
+ Long/Short: 1.15 (53.5% long)
293
+ Trend: Strong Increasing
294
+
295
+ 💥 LIQUIDATIONS (24h)
296
+ Total: $32.8M
297
+ Longs: $8.2M | Shorts: $24.6M
298
+ Cascade Risk: 🟢 LOW
299
+ ```
300
+
301
+ ## Programmatic Usage
302
+
303
+ ### Funding Rate Arbitrage Detection
304
+
305
+ ```python
306
+ from funding_tracker import FundingTracker
307
+
308
+ tracker = FundingTracker()
309
+
310
+ # Find arbitrage opportunities
311
+ opportunities = tracker.get_arbitrage_opportunities(
312
+ symbols=["BTC", "ETH", "SOL"],
313
+ min_spread=0.02
314
+ )
315
+
316
+ for opp in opportunities:
317
+ print(f"{opp['symbol']}: Long {opp['long_exchange']} "
318
+ f"({opp['long_rate']:+.4%}), "
319
+ f"Short {opp['short_exchange']} "
320
+ f"({opp['short_rate']:+.4%})")
321
+ print(f" Spread: {opp['spread']:.4%} per 8h")
322
+ print(f" Annualized: {opp['profit_annual_pct']:.1f}%")
323
+ ```
324
+
325
+ ### OI Divergence Trading Signals
326
+
327
+ ```python
328
+ from oi_analyzer import OIAnalyzer
329
+
330
+ analyzer = OIAnalyzer()
331
+
332
+ # Check for OI/price divergence
333
+ price_change_24h = 3.5 # From your data source
334
+
335
+ divergence = analyzer.detect_divergence("BTC", price_change_24h)
336
+
337
+ if divergence:
338
+ if divergence.signal == "bullish":
339
+ print("Strong bullish trend confirmed by OI")
340
+ elif divergence.signal == "short_squeeze":
341
+ print("Rally may be weak - shorts covering")
342
+ elif divergence.signal == "long_liquidation":
343
+ print("Selloff may find support - longs washing out")
344
+ ```
345
+
346
+ ### Liquidation Level Alerts
347
+
348
+ ```python
349
+ from liquidation_monitor import LiquidationMonitor
350
+
351
+ monitor = LiquidationMonitor()
352
+ current_price = Decimal("67500")
353
+
354
+ summary = monitor.get_summary("BTC", current_price)
355
+
356
+ # Alert on high cascade risk
357
+ if summary.cascade_risk in ["high", "critical"]:
358
+ print(f"⚠️ High liquidation risk!")
359
+ print(f" ${float(summary.total_24h_usd)/1e6:.0f}M liquidated in 24h")
360
+
361
+ # Find nearest levels
362
+ if summary.nearest_long_level:
363
+ lvl = summary.nearest_long_level
364
+ distance = (float(current_price) - float(lvl.price)) / float(current_price) * 100
365
+ print(f"Nearest long liquidations: ${lvl.price:,.0f} ({distance:.1f}% below)")
366
+ ```
367
+
368
+ ### Options IV Percentile Tracking
369
+
370
+ ```python
371
+ from options_analyzer import OptionsAnalyzer
372
+
373
+ analyzer = OptionsAnalyzer()
374
+
375
+ analysis = analyzer.analyze("BTC", current_price=Decimal("67500"))
376
+
377
+ if analysis.iv_interpretation == "high":
378
+ print(f"IV elevated at {analysis.snapshot.atm_iv:.1f}%")
379
+ print("Consider premium selling strategies")
380
+ elif analysis.iv_interpretation == "low":
381
+ print(f"IV compressed at {analysis.snapshot.atm_iv:.1f}%")
382
+ print("Consider premium buying strategies")
383
+
384
+ # Check put/call sentiment
385
+ if analysis.overall_sentiment == "bullish":
386
+ print("Options flow indicates bullish positioning")
387
+ ```
388
+
389
+ ### Basis Carry Trade Scanner
390
+
391
+ ```python
392
+ from basis_calculator import BasisCalculator
393
+
394
+ calc = BasisCalculator()
395
+
396
+ # Find carry opportunities across assets
397
+ opportunities = calc.find_carry_opportunities(
398
+ symbols=["BTC", "ETH"],
399
+ min_yield=5.0 # Minimum 5% annualized
400
+ )
401
+
402
+ for opp in opportunities:
403
+ print(f"\n{opp.symbol} {opp.expiry}")
404
+ print(f" Strategy: {opp.strategy}")
405
+ print(f" Yield: {opp.annualized_yield:.1f}% annualized")
406
+ print(f" Risk: {opp.risk_notes}")
407
+ ```
408
+
409
+ ## Integration Patterns
410
+
411
+ ### Combine with Price Alerts
412
+
413
+ ```python
414
+ # Pseudo-code for alert system integration
415
+ def check_derivatives_alerts(symbol, price, price_change_24h):
416
+ alerts = []
417
+
418
+ # Funding
419
+ funding = FundingTracker().analyze(symbol)
420
+ if funding.is_extreme:
421
+ alerts.append(f"Extreme funding: {funding.weighted_avg:+.4%}")
422
+
423
+ # OI divergence
424
+ oi = OIAnalyzer()
425
+ div = oi.detect_divergence(symbol, price_change_24h)
426
+ if div and div.confidence == "high":
427
+ alerts.append(f"OI divergence: {div.signal}")
428
+
429
+ # Liquidations
430
+ liq = LiquidationMonitor().get_summary(symbol, Decimal(str(price)))
431
+ if liq.cascade_risk == "critical":
432
+ alerts.append(f"Critical liquidation risk!")
433
+
434
+ return alerts
435
+ ```
436
+
437
+ ### JSON Export for Dashboards
438
+
439
+ ```python
440
+ from formatters import JSONFormatter
441
+
442
+ json_fmt = JSONFormatter()
443
+
444
+ # Export complete dashboard data
445
+ dashboard = json_fmt.derivatives_dashboard(
446
+ symbol="BTC",
447
+ funding=funding_data,
448
+ oi=oi_data,
449
+ liquidations=liq_data,
450
+ options=options_data,
451
+ basis=basis_data
452
+ )
453
+
454
+ # Write to file or send to API
455
+ with open("derivatives_dashboard.json", "w") as f:
456
+ f.write(dashboard)
457
+ ```
458
+
459
+ ---
460
+ *[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*