From c4e1ba55893d7b14bbe8ac23d234517c1036b565 Mon Sep 17 00:00:00 2001 From: Harwinder Date: Mon, 4 May 2026 17:42:56 -0400 Subject: [PATCH] Add CLAUDE.md with two known bugs Bug 1: concurrent TF scans exhaust free-tier API credits (8/min limit) Bug 2: XAUUSD synthetic fallback uses wrong base price (~1.0 vs ~3300) Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..432f714 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,64 @@ +# ForexBot2 — Known Bugs & Dev Notes + +## Bug 1 — Concurrent TF scans exhaust API credits instantly + +**Symptom:** +``` +Batch prefetch failed for 1wk: You have run out of API credits for the current minute. +9 API credits were used, with the current limit at https://twelvedata.com/pricing +``` +Warnings appear for every timeframe (1h, 4h, 1d, 1wk) in rapid succession. + +**Root cause:** +`telegram_bot.py` runs all 4 `SCAN_TIMEFRAMES` concurrently via `ThreadPoolExecutor`. +Each `SignalAggregator` fires its own batch prefetch simultaneously. +Free tier limit is **8 credits/minute** — 4 parallel scans hit this in under a second. + +**Impact:** +Confirmation timeframes fail and fall back to synthetic data. +Primary TF still has real data (first request wins the credits). + +**Fix (not yet implemented):** +Run timeframes sequentially with a 60-second wait between each, or reduce +`SCAN_TIMEFRAMES` to a single primary TF and use the engine's built-in +multi-timeframe confirmation (which already batches efficiently in 3 calls). + +--- + +## Bug 2 — XAUUSD (Gold) shows wrong price (~1.01 instead of ~3300) + +**Symptom:** +``` +Entry: 1.01037 +Take Profit: 1.00767 (+0.3 pips) +Stop Loss: 1.01172 (-0.1 pips) +``` + +**Root cause:** +Two compounding issues: + +1. XAUUSD is not available on the Twelve Data **free tier** — API returns no data. +2. `data_provider._generate_synthetic_data()` uses a `pair_params` dict for base + prices. XAUUSD either falls through to a wrong default (~1.0) instead of the + correct ~3300 baseline. + +Check `data_provider.py` → `_generate_synthetic_data()` → `pair_params` dict. +Verify `"XAUUSD=X"` has a correct `"price"` entry around `3300.0`. + +**Impact:** +All indicator values, entry, TP, and SL for XAUUSD are meaningless when +running on the free tier (synthetic data with wrong base price). + +**Fix (not yet implemented):** +- Correct the base price in `pair_params` for `XAUUSD=X`. +- Add a bot-level guard: if `report.current_price < 100` for XAUUSD, + suppress the trade setup and show a "data unavailable" message instead. + +--- + +## Notes + +- Free tier: 8 credits/min, 800 credits/day. Each full scan = ~21 credits. +- Supported pairs (live data on free tier): EURUSD, GBPUSD, USDJPY, USDCHF, + AUDUSD, USDCAD, NZDUSD, EURGBP, EURJPY, GBPJPY, AUDJPY, EURCHF, CADJPY. +- All other symbols (XAU, XAG, commodities, indices) fall back to synthetic GBM data.