Download config.py from abyXsmart/Confluence_Reversal_Engine: direct link, hf CLI and curl.
- Browser
- Download file 7.07 kB
-
https://huggingface.co/spaces/abyXsmart/Confluence_Reversal_Engine/resolve/main/config.py
- Command line
-
hf download hf://spaces/abyXsmart/Confluence_Reversal_Engine/config.py
-
curl -L -o config.py https://huggingface.co/spaces/abyXsmart/Confluence_Reversal_Engine/resolve/main/config.py
7.07 kB
| """ | |
| CRE v1.0 β Central configuration. | |
| Single source of truth for runtime settings AND version-controlled strategy | |
| thresholds (spec Β§7). Engine code reads from here; never hard-codes a number. | |
| THRESHOLDS is snapshotted into config_versions at boot so every signal is | |
| traceable to the exact parameter set that produced it. | |
| Infra settings come from environment variables (HF Space Secrets/Variables); | |
| strategy thresholds are code-defined and version-bumped deliberately. | |
| """ | |
| from __future__ import annotations | |
| import os | |
| # ββ Version ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| APP_VERSION = "1.0" | |
| CONFIG_VERSION = 3 # bumped: engine thresholds + conviction ranking (no active cap) | |
| # ββ Exchange / data source (spec Β§2, Β§12 geo-fallback) βββββββββββββββββββββββ | |
| # OKX is the data source: the only free, geo-reachable exchange that preserves ALL | |
| # four layers β funding, OI, klines, liquidations (L1) and the taker buy/sell split | |
| # (L3). Binance/Bybit are geo-blocked on free hosts (451/403) and were removed in v1.0. | |
| EXCHANGE = os.getenv("EXCHANGE", "okx").lower().strip() # okx (only supported source) | |
| # ββ Universe: dynamic whole-market scan with a quality funnel (D5) ββββββββββββ | |
| # Mode "dynamic" = scan all USDT perps, keep the liquid ones. Mode "fixed" = | |
| # only the symbols in WATCHLIST. Setting WATCHLIST forces fixed mode. | |
| _WATCHLIST_ENV = os.getenv("WATCHLIST", "").strip() | |
| UNIVERSE_MODE = "fixed" if _WATCHLIST_ENV else os.getenv("UNIVERSE_MODE", "dynamic").lower() | |
| WATCHLIST = [s.strip().upper() for s in _WATCHLIST_ENV.split(",") if s.strip()] | |
| # Funnel parameters (the "remove the junk" filter). Tunable via env. | |
| UNIVERSE_MAX = int(os.getenv("UNIVERSE_MAX", "80")) # cap on coins scanned | |
| UNIVERSE_MIN_TURNOVER_USD = float(os.getenv("UNIVERSE_MIN_TURNOVER_USD", "20000000")) # min 24h USD turnover | |
| UNIVERSE_REFRESH_SEC = int(os.getenv("UNIVERSE_REFRESH_SEC", "3600")) # rebuild hourly | |
| # Bases excluded outright (stables / wrapped / non-tradeable noise). | |
| UNIVERSE_EXCLUDE_BASES = { | |
| "USDC", "USDT", "DAI", "TUSD", "FDUSD", "USDD", "USDE", "PYUSD", | |
| "EUR", "GUSD", "USTC", | |
| } | |
| # ββ Per-pair links (D7) ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Where the "TV" link points. You trade on Bybit β default BYBIT. Switch freely. | |
| TV_EXCHANGE = os.getenv("TV_EXCHANGE", "BYBIT").upper().strip() # BYBIT|BINANCE|MEXC|OKX | |
| CHART_ENABLED = os.getenv("CHART_ENABLED", "1") == "1" # annotated screenshot on/off | |
| # ββ Storage (spec Β§12 ephemeral-storage warning) βββββββββββββββββββββββββββββ | |
| DB_PATH = os.getenv("DB_PATH", "./cre.db") # HF persistent storage β /data/cre.db | |
| # ββ Polling cadence ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| POLL_INTERVAL_SEC = int(os.getenv("POLL_INTERVAL_SEC", "60")) | |
| HTTP_TIMEOUT_SEC = float(os.getenv("HTTP_TIMEOUT_SEC", "15")) | |
| WS_BACKOFF_START = 1.0 | |
| WS_BACKOFF_CAP = 60.0 | |
| # ββ Telegram alerts (spec Β§10) β SECRETS, never hard-code (D8) ββββββββββββββββ | |
| TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN", "").strip() | |
| TELEGRAM_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID", "").strip() | |
| ALERTS_ENABLED = bool(TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID) | |
| # ββ Optional Coinglass enrichment (spec Β§2.2) ββββββββββββββββββββββββββββββββ | |
| COINGLASS_API_KEY = os.getenv("COINGLASS_API_KEY", "").strip() | |
| COINGLASS_ENABLED = bool(COINGLASS_API_KEY) | |
| # ββ Liquidation baseline (spec Β§2.1, Β§15.3) ββββββββββββββββββββββββββββββββββ | |
| LIQ_BASELINE_DAYS_REQUIRED = 7 # cold-start: WATCH-only until this many days collected | |
| # ββ Strategy thresholds (version-controlled, spec Β§3βΒ§6) βββββββββββββββββββββ | |
| # Layer/scoring/risk thresholds (Β§3βΒ§6) are appended in Step 2 alongside the | |
| # engine code that consumes them; CONFIG_VERSION bumps then. | |
| THRESHOLDS: dict = { | |
| "funding_history_limit": 100, # OKX caps funding history at 100/call | |
| "oi_history_period": "1H", # OKX rubik period format | |
| "oi_history_limit": 200, | |
| "kline_intervals": ["1m", "15m", "1H"], | |
| "kline_limit": 300, | |
| "taker_period": "1H", | |
| "poll_interval_sec": POLL_INTERVAL_SEC, | |
| "liq_baseline_days_required": LIQ_BASELINE_DAYS_REQUIRED, | |
| "universe_max": UNIVERSE_MAX, | |
| "universe_min_turnover_usd": UNIVERSE_MIN_TURNOVER_USD, | |
| # ββ Engine: layer weights (sum=1.0) β confluence score (spec Β§3/Β§4) ββββββ | |
| "layer_weights": {"L1": 0.30, "L2": 0.25, "L3": 0.25, "L4": 0.20}, | |
| "liq_flush_cap_mult": 5.0, # flush / rolling baseline; cap_multΓ => full L1 | |
| "funding_z_ref": 2.0, # |funding_z| saturating the funding sub-score | |
| "oi_drop_ref_pct": 5.0, # % OI drop giving full OI sub-score | |
| "funding_sub_w": 0.6, "oi_sub_w": 0.4, | |
| "taker_delta_z_ref": 2.0, # |taker delta z| saturating L3 | |
| "struct_w": {"fvg": 0.40, "swing": 0.35, "bos": 0.25}, | |
| "swing_lookback": 3, | |
| "atr_period": 14, | |
| # ββ Levels (spec Β§4) βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| "stop_atr_mult": 1.5, | |
| "target_r_multiples": [1.0, 2.0], | |
| "entry_buffer_atr": 0.10, | |
| # ββ Tiers (confluence 0..100) ββββββββββββββββββββββββββββββββββββββββββββ | |
| "tiers": {"sniper": 75, "setup": 55, "watch": 35}, | |
| # ββ Conviction (0..100): ranks ALL qualifying setups (no active cap) ββββββ | |
| "conviction_w": { | |
| "confluence": 0.45, "liquidity": 0.15, "reversal": 0.20, | |
| "trend": 0.10, "baseline": 0.10, | |
| }, | |
| "conviction_tags": {"elite": 85, "strong": 70, "moderate": 55}, | |
| "liq_turnover_floor_usd": 2.0e7, | |
| "liq_turnover_ref_usd": 2.0e9, | |
| "btc_trend_atr_ref": 2.0, | |
| # ββ Risk (spec Β§6): cooldown kept; hard active/direction caps REMOVED βββββ | |
| "cooldown_hours": 4, | |
| "size_by_tag": {"elite": 1.0, "strong": 0.7, "moderate": 0.4, "watch": 0.0}, | |
| } | |
| def snapshot() -> dict: | |
| """Full config snapshot persisted to config_versions at boot (spec Β§7).""" | |
| return { | |
| "config_version": CONFIG_VERSION, | |
| "exchange": EXCHANGE, | |
| "universe_mode": UNIVERSE_MODE, | |
| "watchlist": WATCHLIST, | |
| "tv_exchange": TV_EXCHANGE, | |
| "thresholds": THRESHOLDS, | |
| } | |