# config.py - Configuration for Multi-Coin Data Collector
# Edit this file to customize the collector behavior

# ================================================================
# SYMBOLS CONFIGURATION
# ================================================================

# List of trading pairs to track
# Add or remove symbols as needed
SYMBOLS = [
    "BNBUSDT",
    "BTCUSDT",
    # "ETHUSDT",
    # "SOLUSDT",
    # "ADAUSDT",
    # "DOGEUSDT",
    # "XRPUSDT",
    # "AVAXUSDT",
    # "MATICUSDT",
    # "DOTUSDT",
]

# ================================================================
# COLLECTION SETTINGS
# ================================================================

# How often to collect data via REST API (seconds)
# Recommended: 2-5 seconds
# Lower = more data but higher load
REST_INTERVAL = 2

# WebSocket reconnection settings
WS_MAX_RETRIES = 5
WS_RETRY_DELAY = 5  # seconds

# ================================================================
# DATA STORAGE
# ================================================================

# Base directory for data storage
# Each symbol will have its own subdirectory
DATA_DIR_BASE = "/var/www/html/crypto"

# Data retention (for cleanup script)
KEEP_DAYS = 30

# ================================================================
# THRESHOLDS
# ================================================================

# Whale trade threshold (USD)
# Trades larger than this are considered "whale trades"
WHALE_THRESHOLD_USD = 50_000

# Large trade threshold (USD)
# Trades larger than this are counted in volume metrics
LARGE_TRADE_THRESHOLD_USD = 10_000

# ================================================================
# API SETTINGS
# ================================================================

# Binance REST API endpoints
BINANCE_API_BASE = "https://api.binance.com"
BINANCE_WS_BASE = "wss://stream.binance.com:9443"

# Request timeout (seconds)
API_TIMEOUT = 5

# ================================================================
# MEMPOOL SETTINGS (BTC only)
# ================================================================

# Mempool API endpoint
MEMPOOL_API_BASE = "https://mempool.space/api"

# Fetch mempool data only for these symbols
# (currently only BTCUSDT is supported)
MEMPOOL_SYMBOLS = ["BTCUSDT"]

# ================================================================
# LOGGING SETTINGS
# ================================================================

# Print summary every N records
SUMMARY_INTERVAL_RECORDS = 50

# Print file stats every N records
FILE_STATS_INTERVAL = 100

# Print daily summary every N seconds
DAILY_SUMMARY_INTERVAL = 600  # 10 minutes

# ================================================================
# PERFORMANCE TUNING
# ================================================================

# Window sizes (number of items to keep in memory)
PRICE_WINDOW_SIZE = 120      # 2 minutes at 1 sample/sec
PRICE_HISTORY_SIZE = 1800    # 30 minutes
VOLUME_WINDOW_SIZE = 300     # 5 minutes
TRADES_WINDOW_SIZE = 2000    # Recent trades
CVD_HISTORY_SIZE = 900       # 15 minutes
WHALE_HISTORY_SIZE = 300     # 5 minutes

# WebSocket trade buffer flush interval (seconds)
WS_BUFFER_FLUSH_INTERVAL = 2

# ================================================================
# ADVANCED SETTINGS
# ================================================================

# Enable/disable specific features
ENABLE_MEMPOOL = True         # Fetch mempool data
ENABLE_ORDERBOOK = True       # Fetch orderbook depth
ENABLE_KLINES = True          # Fetch historical candles
ENABLE_HTF_TREND = True       # Calculate long-term trend

# Number of historical candles for HTF trend
HTF_CANDLES_LIMIT = 96  # 24 hours of 15m candles

# Orderbook depth
ORDERBOOK_LIMIT = 100

# Aggregate trades limit
AGGTRADES_LIMIT = 1000

# ================================================================
# SAFETY LIMITS
# ================================================================

# Maximum symbols to prevent overload
MAX_SYMBOLS = 20

# Validate configuration on import
if len(SYMBOLS) > MAX_SYMBOLS:
    raise ValueError(f"Too many symbols ({len(SYMBOLS)}). Maximum is {MAX_SYMBOLS}")

# Ensure REST_INTERVAL is reasonable
if REST_INTERVAL < 1:
    raise ValueError("REST_INTERVAL must be at least 1 second")
if REST_INTERVAL > 60:
    print(f"Warning: REST_INTERVAL of {REST_INTERVAL} seconds is quite high")

# ================================================================
# EXPORT ALL SETTINGS
# ================================================================

__all__ = [
    'SYMBOLS',
    'REST_INTERVAL',
    'WS_MAX_RETRIES',
    'WS_RETRY_DELAY',
    'DATA_DIR_BASE',
    'KEEP_DAYS',
    'WHALE_THRESHOLD_USD',
    'LARGE_TRADE_THRESHOLD_USD',
    'BINANCE_API_BASE',
    'BINANCE_WS_BASE',
    'API_TIMEOUT',
    'MEMPOOL_API_BASE',
    'MEMPOOL_SYMBOLS',
    'SUMMARY_INTERVAL_RECORDS',
    'FILE_STATS_INTERVAL',
    'DAILY_SUMMARY_INTERVAL',
    'PRICE_WINDOW_SIZE',
    'PRICE_HISTORY_SIZE',
    'VOLUME_WINDOW_SIZE',
    'TRADES_WINDOW_SIZE',
    'CVD_HISTORY_SIZE',
    'WHALE_HISTORY_SIZE',
    'WS_BUFFER_FLUSH_INTERVAL',
    'ENABLE_MEMPOOL',
    'ENABLE_ORDERBOOK',
    'ENABLE_KLINES',
    'ENABLE_HTF_TREND',
    'HTF_CANDLES_LIMIT',
    'ORDERBOOK_LIMIT',
    'AGGTRADES_LIMIT',
]
