Download links.py from abyXsmart/Confluence_Reversal_Engine: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/abyXsmart/Confluence_Reversal_Engine/resolve/main/links.py
- Command line
-
hf download hf://spaces/abyXsmart/Confluence_Reversal_Engine/links.py
-
curl -L -o links.py https://huggingface.co/spaces/abyXsmart/Confluence_Reversal_Engine/resolve/main/links.py
1.6 kB
| """ | |
| Per-pair link + symbol helpers (decision D7). | |
| • display_name('BTC-USDT-SWAP') -> 'BTC' | |
| • pair_label('BTC-USDT-SWAP') -> 'BTC/USDT' | |
| • tv_link(symbol) -> TradingView chart URL on the configured | |
| exchange (TV_EXCHANGE var: BYBIT|BINANCE|MEXC|OKX) | |
| The "Chart" annotated-screenshot link is produced in the UI layer (Step 4) using | |
| chart.py; this module only builds the lightweight text/URL bits. | |
| """ | |
| from __future__ import annotations | |
| import config | |
| # TradingView symbol suffix per exchange. Perps use the '.P' suffix on TV. | |
| _TV_PERP_SUFFIX = { | |
| "BYBIT": ".P", | |
| "BINANCE": ".P", | |
| "MEXC": ".P", | |
| "OKX": ".P", | |
| } | |
| def parts(symbol: str) -> tuple[str, str]: | |
| """'BTC-USDT-SWAP' -> ('BTC', 'USDT'). Tolerant of plain 'BTCUSDT'.""" | |
| if "-" in symbol: | |
| bits = symbol.split("-") | |
| return bits[0], (bits[1] if len(bits) > 1 else "USDT") | |
| if symbol.upper().endswith("USDT"): | |
| return symbol[:-4].upper(), "USDT" | |
| return symbol.upper(), "USDT" | |
| def display_name(symbol: str) -> str: | |
| return parts(symbol)[0] | |
| def pair_label(symbol: str) -> str: | |
| base, quote = parts(symbol) | |
| return f"{base}/{quote}" | |
| def tv_link(symbol: str, tv_exchange: str | None = None) -> str: | |
| """Build a TradingView URL pointing at the user's chosen exchange.""" | |
| ex = (tv_exchange or config.TV_EXCHANGE).upper() | |
| base, quote = parts(symbol) | |
| suffix = _TV_PERP_SUFFIX.get(ex, ".P") | |
| tv_symbol = f"{ex}:{base}{quote}{suffix}" | |
| return f"https://www.tradingview.com/chart/?symbol={tv_symbol}" | |