Spaces:
Sleeping
Sleeping
Starchild Agent
Starchild
S27 Stage E: settings re-segmented to 8 v8-only sections; purge 27 dead CFG keys + 28 schema fields (legacy weighted-filter stack, conviction blend, verdict-stability knobs) + orphan CONVICTION_ENABLED; 0 dead switches, save round-trip verified; preflight realigned. Refactor A-E complete
b21c07d Download preflight_check.py from abyXsmart/FVG-Delta-Crypto-Core: direct link, hf CLI and curl.
- Browser
- Download file 5.32 kB
-
https://huggingface.co/spaces/abyXsmart/FVG-Delta-Crypto-Core/resolve/main/preflight_check.py
- Command line
-
hf download hf://spaces/abyXsmart/FVG-Delta-Crypto-Core/preflight_check.py
-
curl -L -o preflight_check.py https://huggingface.co/spaces/abyXsmart/FVG-Delta-Crypto-Core/resolve/main/preflight_check.py
5.32 kB
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import importlib | |
| import os | |
| # v7.0: Telegram credentials are NO LONGER required at boot — they can be entered on the | |
| # Settings page (/settings) and are stored on the persistent disk. They remain optional | |
| # env/secrets for users who prefer Hugging Face secrets. | |
| REQUIRED_ENV: list = [] | |
| OPTIONAL_ENV = [ | |
| "TELEGRAM_BOT_TOKEN", | |
| "TELEGRAM_CHAT_ID", | |
| "TELEGRAM_API_BASE", | |
| "BROWSER_ALERT_SOUND", | |
| # core scanner | |
| "SCANNER_ENABLED", | |
| "SCAN_INTERVAL_SECONDS", | |
| "SYMBOL_REFRESH_MINUTES", | |
| "SCAN_SHARDS", | |
| "REQUEST_TIMEOUT_SECONDS", | |
| "REQUEST_RETRIES", | |
| "REQUEST_CONCURRENCY", | |
| "REQUEST_JITTER_MS", | |
| "MEXC_MAX_FUTURES_SYMBOLS", | |
| "MAX_BARS_PER_SYMBOL", | |
| "ATR_PERIOD", | |
| # detection | |
| "MIN_IMPULSE_BODY_MULT", | |
| "MIN_IMPULSE_RANGE_MULT", | |
| "MIN_VELOCITY_RANGE_MULT", | |
| "MIN_STAGE1_INDUCEMENTS", | |
| "ZONE_TOUCH_BUFFER_ATR", | |
| "ZONE_TTL_SECONDS", | |
| "MAX_ZONE_AGE_CANDLES", | |
| "RETRACEMENT_MIN_FVG_GAP_ATR", | |
| "SL_WICK_BUFFER_ATR", | |
| # risk / leverage | |
| "LEV_TARGET_SL_LOSS_PCT", | |
| "LEV_MIN", | |
| "LEV_MAX", | |
| "LEV_STEP", | |
| # universe | |
| "UNIVERSE_TOP_N", | |
| "UNIVERSE_MIN_TURNOVER", | |
| "UNIVERSE_EXCLUDE", | |
| "UNIVERSE_EXCLUDE_CONTAINS", | |
| # persistence (Hugging Face mounted disk) | |
| "PERSIST_DIR", | |
| # === Smart Engine v8 — the live decision system ========================= | |
| "PROMOTION_ENABLED", | |
| "CONVICTION_MIN_CONFLUENCE", | |
| "CONVICTION_CONFIRM_CYCLES", | |
| "STABILITY_MIN_CYCLES", | |
| "STABILITY_ADVERSE_ATR", | |
| # v8 entry-model recognition | |
| "ENTRY_MODEL_ENABLED", | |
| "EM_WICK_BODY_RATIO", | |
| "EM_DISPLACEMENT_ATR", | |
| "EM_REACTION_WINDOW", | |
| # v8 market regime + portfolio risk | |
| "MARKET_PERMISSION_ENABLED", | |
| "MARKET_PERMISSION_STRICT", | |
| "PORTFOLIO_RISK_ENABLED", | |
| "MAX_CONCURRENT_TRADES", | |
| "MAX_ALIGNED_DIRECTION", | |
| "COST_AWARE_ENABLED", | |
| "MIN_NET_RR", | |
| # v8 Stage-5 guardian + order flow | |
| "GUARDIAN_ENABLED", | |
| "GUARDIAN_LTF_INTERVAL", | |
| "GUARDIAN_LTF_BARS", | |
| "GUARDIAN_TERMINAL_CONFIRMS", | |
| "GUARDIAN_TERMINAL_MIN_CONF", | |
| "FOOTPRINT_STRONG_PCT", | |
| # alerts / display | |
| "ALERT_COOLDOWN_SECONDS", | |
| "DASHBOARD_REFRESH_SECONDS", | |
| "WEEKLY_ALERT_ENABLED", | |
| "WEEKLY_ALERT_WEEKDAY_UTC", | |
| "WEEKLY_ALERT_HOUR_UTC", | |
| "WEEKLY_ALERT_MINUTE_UTC", | |
| "WEEKLY_ALERT_CUSTOM_TEXT", | |
| ] | |
| REQUIRED_MODULES = ["fastapi", "uvicorn", "aiohttp", "numpy", "matplotlib"] | |
| # Smart-Engine v8 internal-consistency contract. These are the ONLY decision brains the | |
| # live engine uses (the legacy v7.5 fallback path has been retired). If any are missing the | |
| # build is broken; we fail loudly so a half-migrated upload is caught before it ships. | |
| V8_FUNCTIONS = ( | |
| "structural_read", # the single leading-structure read (Stage 4 + Stage 5) | |
| "evaluate_pre_entry_conviction", # Stage 4 promotion decision | |
| "classify_entry_model_sticky", # Stage 4 in-zone entry model | |
| "market_permission", # v8 regime gate | |
| "evaluate_trade_guardian", # Stage 5 live management | |
| "send_guardian_terminal_alert", # Stage 5 terminal alert | |
| "refresh_oi_funding", | |
| "refresh_btc_ltf_trend", | |
| ) | |
| V8_CFG_KEYS = ( | |
| "promotion_enabled", "scanner_enabled", | |
| "conviction_min_confluence", "conviction_confirm_cycles", | |
| "stability_min_cycles", "stability_adverse_atr", | |
| "market_permission_enabled", "portfolio_risk_enabled", | |
| "guardian_enabled", "guardian_terminal_confirms", | |
| ) | |
| def main() -> int: | |
| print("=== FVG-Delta Smart Engine v8 Preflight ===") | |
| bad = False | |
| for m in REQUIRED_MODULES: | |
| try: | |
| importlib.import_module(m) | |
| print(f"[OK] module: {m}") | |
| except Exception as e: | |
| print(f"[FAIL] module: {m} ({e})") | |
| bad = True | |
| for k in REQUIRED_ENV: | |
| if not os.getenv(k, "").strip(): | |
| print(f"[FAIL] required env missing: {k}") | |
| bad = True | |
| else: | |
| print(f"[OK] required env set: {k}") | |
| for k in OPTIONAL_ENV: | |
| if os.getenv(k) is None: | |
| print(f"[WARN] optional env not set: {k} (default will be used)") | |
| else: | |
| print(f"[OK] optional env set: {k}") | |
| try: | |
| import app # noqa: F401 | |
| print("[OK] app import successful") | |
| except Exception as e: | |
| print(f"[FAIL] app import failed: {e}") | |
| bad = True | |
| # Smart Engine v8 smoke check: confirm the v8 decision brains + config keys are present | |
| # (no network — just verifies the build is internally consistent so Stage 4/5 can run). | |
| try: | |
| import app as _app | |
| for fn in V8_FUNCTIONS: | |
| if not hasattr(_app, fn): | |
| print(f"[FAIL] v8 function missing: {fn}") | |
| bad = True | |
| for key in V8_CFG_KEYS: | |
| if key not in _app.CFG: | |
| print(f"[FAIL] v8 config key missing: {key}") | |
| bad = True | |
| if not bad: | |
| print("[OK] Smart Engine v8 present (decision brains + config keys)") | |
| except Exception as e: | |
| print(f"[WARN] v8 smoke check skipped: {e}") | |
| if bad: | |
| print("\nPreflight result: FAILED") | |
| return 1 | |
| print("\nPreflight result: PASSED") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |