Skip to content

piraterobot0/Tracking-Tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Derive Options Market Watcher

A standalone market monitoring and analysis system for Derive protocol ETH options markets.

Overview

This system continuously monitors Derive options markets to identify trading opportunities based on spreads, volumes, and market dynamics. It provides real-time market scanning, historical trend analysis, and opportunity scoring.

Components

1. watcher.exs - Market Scanner

The main scanning engine that:

  • Fetches all active ETH options from Derive
  • Collects orderbook depths and ticker data
  • Calculates spreads, volumes, and Greeks
  • Scores opportunities based on configurable criteria
  • Saves timestamped snapshots to JSON files

2. analyzer.exs - Market Analyzer

Analysis tool for market data that provides:

  • Latest snapshot analysis
  • Historical comparison between snapshots
  • Trend analysis across multiple snapshots
  • Opportunity identification by strategy type
  • Spread and volume analytics

3. config.json.template - Configuration Template

Template configuration file with:

  • API credentials placeholders
  • Scanning parameters
  • Output settings
  • Opportunity scoring weights
  • Strategy definitions

Setup

  1. Install Elixir Dependencies The scripts will auto-install required dependencies on first run.

  2. Configure API Access

    • Copy config.json.template to config.json
    • Add your Derive API credentials
    • Adjust scanning parameters as needed
  3. Set Environment Variables (Optional)

    export DERIVE_API_KEY="your_api_key"
    export DERIVE_API_SECRET="your_api_secret"
    export DERIVE_SUBACCOUNT_ID="your_subaccount_id"
    export DERIVE_RPC_URL="https://api.derive.xyz"
    export MARKET_DATA_DIR="market_data"

Usage

Running the Market Watcher

# Run with default settings (uses environment variables or defaults)
elixir watcher.exs

# Run with custom output directory
elixir watcher.exs /path/to/output/dir

# Run continuously (with cron or loop)
while true; do
  elixir watcher.exs
  sleep 600  # Wait 10 minutes
done

Analyzing Market Data

# Analyze the latest snapshot
elixir analyzer.exs latest

# Compare two snapshots
elixir analyzer.exs compare market_data/market_1234.json market_data/market_5678.json

# Analyze trends across all snapshots
elixir analyzer.exs trends market_data

# Find top opportunities in latest snapshot
elixir analyzer.exs opportunities

# Find opportunities in specific file
elixir analyzer.exs opportunities market_data/market_1234.json

Output Format

Market snapshots are saved as JSON files with the following structure:

{
  "timestamp": "2025-01-31T12:00:00Z",
  "markets_scanned": 150,
  "data": [
    {
      "instrument_name": "ETH-31JAN25-3800-C",
      "strike": 3800,
      "type": "CALL",
      "expiry": "31JAN25",
      "days_to_expiry": 3.5,
      "best_bid": 120.50,
      "best_ask": 126.50,
      "spread_dollars": 6.00,
      "spread_percent": 4.74,
      "volume_24h": 45.2,
      "open_interest": 123.5,
      "greeks": {
        "delta": 0.55,
        "gamma": 0.0012,
        "theta": -15.2,
        "vega": 8.3,
        "iv": 0.65
      },
      "opportunity_scores": {
        "total_score": 75,
        "spread_score": 100,
        "volume_score": 70,
        "oi_score": 80,
        "competition_score": 70
      }
    }
  ]
}

Opportunity Scoring

Markets are scored from 0-100 based on:

  • Spread Score (40% weight)

    • Optimal: $3-10 (score: 100)
    • Too tight (<$1): Heavy competition (score: 20)
    • Too wide (>$20): Likely illiquid (score: 40)
  • Volume Score (30% weight)

    • Based on 24-hour trading volume
    • Higher volume = higher score
  • Open Interest Score (20% weight)

    • Indicates market liquidity
    • More OI = higher score
  • Competition Score (10% weight)

    • Based on spread tightness
    • Wider spreads = less competition = higher score

Strategy Types

The analyzer identifies opportunities for different strategies:

  1. Short-term High Theta (≤7 days, spread ≥$5)

    • Capture high time decay on near-expiry options
    • Higher risk but potentially higher returns
  2. Medium-term Balanced (7-21 days, good volume)

    • Balance between theta decay and time value
    • More stable spreads
  3. High Volume Markets (≥100 contracts/day)

    • Focus on liquid markets
    • Easier to enter/exit positions
  4. Wide Spread Opportunities (≥$20 spread)

    • Less competitive markets
    • Potential for larger profit margins

Automation

Using Cron

# Add to crontab for automatic scanning every 10 minutes
*/10 * * * * /usr/bin/elixir /path/to/watcher.exs >> /var/log/derive_watcher.log 2>&1

Using systemd

Create a service file /etc/systemd/system/derive-watcher.service:

[Unit]
Description=Derive Options Market Watcher
After=network.target

[Service]
Type=simple
User=youruser
WorkingDirectory=/path/to/watcher
ExecStart=/usr/bin/elixir watcher.exs
Restart=always
RestartSec=600

[Install]
WantedBy=multi-user.target

Data Management

To prevent disk space issues:

  • Set max_files_to_keep in config
  • Implement log rotation
  • Archive old data periodically

Example cleanup script:

# Keep only last 7 days of data
find market_data -name "market_*.json" -mtime +7 -delete

Troubleshooting

  1. API Connection Issues

    • Verify API credentials
    • Check network connectivity
    • Ensure RPC URL is correct
  2. No Data Returned

    • Check if markets are active
    • Verify strike range and expiry parameters
    • Ensure ETH price fetch is working
  3. High Memory Usage

    • Reduce days_ahead parameter
    • Limit strike_range_percent
    • Process fewer instruments at once

License

This software is provided as-is for educational and research purposes. Use at your own risk when trading real assets.

Contributing

Contributions welcome! Please ensure:

  • Code is well-documented
  • No hardcoded credentials
  • Tests for new features
  • Clear commit messages

About

Various tools for tracking various on-chain protocols.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors