File size: 6,061 Bytes
c6262df | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ---
license: mit
title: Confluence Reversal Crypto Engine v1.0
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
emoji: π
colorFrom: green
colorTo: indigo
pinned: true
short_description: CRE Signals Bot
---
<!--
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β οΈ DO NOT EDIT THE YAML METADATA BLOCK ABOVE THIS LINE.
Hugging Face Spaces parses that front-matter to configure the Space
(SDK, version, entrypoint, card). Changing a key or breaking the YAML
will cause the Space to fail to build or mis-render its card.
Edit the human-readable documentation BELOW this comment only.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-->
# π Confluence Reversal Crypto Engine (CRE) v1.0
A crypto-futures **reversal signal** engine. CRE scans the **whole USDT-perp market**
(filtered down to the liquid, tradeable names), and scores high-probability
mean-reversion setups by combining **four independent, confluent data layers** into a
single score. Strong setups are pushed to Telegram and shown on a live dashboard.
> **This is a measurement instrument first, a signal bot second.** Its honest purpose for
> the first 1β2 months is to *log and prove* whether the edge exists β not to promise profit.
> Signals are **not financial advice**.
---
## What It Does
| Layer | Source (OKX) | Detects |
|-------|--------------|---------|
| **L1 β Liquidation Flush** | `liquidation-orders` WebSocket | Exhausted momentum via liquidation clusters |
| **L2 β Funding / OI Divergence** | Funding rate + open interest | Smart money exiting (extreme funding + OI drop) |
| **L3 β Order-Flow Imbalance** | Taker buy/sell volume | Aggressive buy/sell exhaustion |
| **L4 β Structural Context** | 15m / 1h klines | Fair Value Gaps, swing levels, breaker / BoS |
Weighted score β tier **WATCH / SETUP / SNIPER**. SETUP and SNIPER fire alerts; WATCH is
logged silently. Full strategy logic, formulas, and risk rules live in `SKILL.md`.
**Data source:** OKX public API (no key) β the one free, geo-reachable exchange that
exposes all four layers (Binance/Bybit are geo-blocked on most free hosts). Each signal
is about the *coin*, not the venue β so you can act on it on Bybit, Binance, or anywhere.
**Universe:** dynamic. CRE rebuilds its watchlist hourly from all OKX USDT perps, keeping
the liquid ones (24h turnover filter) and dropping stablecoins/junk. One liquidation stream
watches the entire market; only coins that actually flush get the heavy per-coin scoring β
so a wide universe stays cheap. Set `WATCHLIST` to pin a fixed list instead.
Each signal carries a **TV** link (TradingView, on your chosen exchange) and a **Chart**
(an annotated screenshot marking FVG, swings, BoS, and the entry/stop/target levels).
---
## Configuration (Space Secrets & Variables)
| Name | Type | Required | Purpose |
|------|------|----------|---------|
| `TELEGRAM_BOT_TOKEN` | **secret** | for alerts | Telegram bot token from @BotFather |
| `TELEGRAM_CHAT_ID` | **secret** | for alerts | Destination chat/channel id |
| `COINGLASS_API_KEY` | **secret** | no | Optional cross-exchange enrichment |
| `TV_EXCHANGE` | variable | no (default `BYBIT`) | Where TV links point: `BYBIT` / `BINANCE` / `MEXC` / `OKX` |
| `DB_PATH` | variable | no | SQLite path. Default `./cre.db`. Set `/data/cre.db` with persistent storage |
| `UNIVERSE_MAX` | variable | no (default `80`) | Max coins kept after the liquidity funnel |
| `UNIVERSE_MIN_TURNOVER_USD` | variable | no (default `20000000`) | Min 24h USD turnover to qualify |
| `WATCHLIST` | variable | no | Comma-separated symbols to pin a fixed universe (disables the scan) |
| `POLL_INTERVAL_SEC` | variable | no (default `60`) | Market poll cadence |
> **Telegram token + chat id are SECRETS** (encrypted, not publicly visible). The
> *Variables* tab is the one visible to anyone who can see the Space β never put the token there.
### Persistence β HF Storage Bucket (recommended)
CRE persists its database to an **HF Storage Bucket** so state survives restarts and sleep:
on boot it **restores** the DB from the bucket, then **syncs it back** periodically and on
shutdown. After a reboot the dashboard reloads the last state and continues β open trades and
full signal history are recalled.
- **How:** SQLite runs on the Space's fast local disk (reliable file locking); a background
sync worker mirrors it to the bucket. We deliberately do **not** run SQLite directly on a
mounted bucket β object storage doesn't support SQLite's locking safely. Snapshot/restore is
the robust pattern (the same approach HF's own tools use).
- **Setup:** create a bucket, add secret `HF_TOKEN` (write scope) + variable `CRE_BUCKET`
(`owner/bucket-name`). See `HF_SETUP.md`. The DB is only megabytes, so storage cost is minimal.
- **Without a bucket:** CRE still runs fully (ephemeral `DB_PATH=./cre.db`), but history resets
on restart β fine for evaluation, not for a long-running track record.
- **Sleep behavior:** free Spaces sleep after ~48h with no UI traffic; a sleeping Space cannot poll
or alert. CRE handles sleep/wake gracefully β gap-marked liquidation buckets are excluded from baselines.
---
## Disclaimer
CRE is an experimental research tool. Mean-reversion strategies lose in strong trends; expect
losing streaks. Judge the system on 100+ logged signals, not on 10. The log records *alerted*
levels, not your actual fills. Nothing here is financial advice. Trade at your own risk.
---
*Built from the Confluence Reversal Engine v1.0 specification, optimized against live data.
Strategy thresholds are version-controlled config β change them deliberately, never silently.*
|