--- title: Forex + Crypto Trading Prediction emoji: 📈 colorFrom: blue colorTo: green sdk: gradio sdk_version: 4.44.1 app_file: app.py pinned: false --- # Forex + Crypto Trading Prediction App Single-file, self-contained prediction & backtesting app for Forex and Crypto markets, built with **Gradio + CatBoost**. Prediction/backtesting only — **no live trade execution**. ## Features - **Data ingestion** — live via `yfinance` → Twelve Data (optional API key) → CSV upload/cache fallback, with flexible column mapping and canonicalization. - **Timezone & calendar handling** — fixed operational timezone (Asia/Kolkata), gap classification (weekend/holiday/outage), holiday calendar versioning. - **Feature engineering** — core technical indicator set (EMA, MACD, RSI, Stochastic, ADX, Bollinger Bands, ATR, VWAP, OBV, Donchian, etc.), fractional differencing, leak-safe rolling windows. - **Labeling** — triple-barrier labeling (with fixed-threshold fallback). - **Model training** — CatBoost with HistGB fallback, walk-forward cross-validation, hyperparameter search, fold-stability rejection rule, deterministic seeding (SEED=42). - **Calibration & confidence** — bootstrap-averaged isotonic / Platt calibration plus a time-weighted split-conformal layer for confidence bands. - **Drift & auto-retrain** — PSI/F1/confidence drift monitors, scheduled and volume-triggered retraining with acceptance gating and rollback. - **Backtesting & forward test** — out-of-sample backtest with commissions, slippage, spread, and a strictly separate paper-trading forward test. - **Observability** — sequential operational event log and an append-only JSONL audit trail. - **Developer self-test** — `--selftest` runs an end-to-end acceptance check on synthetic Forex & Crypto fixtures (fast HPO). ## Run locally ```bash pip install -r requirements.txt python app.py ``` The Gradio UI launches on `http://localhost:7860`. ## Developer acceptance check ```bash python app.py --selftest ``` ## Deploy on Hugging Face Spaces 1. Create a new Space with SDK = **Gradio**. 2. Upload `app.py`, `requirements.txt`, and this `README.md`. 3. The Space will build and launch automatically (`app_file: app.py`). ## Notes - All timestamps are shown in IST (UTC+5:30). - Historical backtests are never evidence of future performance. - A Twelve Data API key is optional and, if provided, is kept for the session only — never logged or persisted to source. - Target runtime: Python 3.10+, 2 CPU / 16 GB RAM (Docker-based Spaces).