Remove synthetic data fallback; fix concurrent API credit exhaustion
data_provider: - Remove _generate_synthetic_data entirely — no more fake prices - Raise DataUnavailableError instead of falling back to synthetic data (no API key, daily limit hit, API returns no values, fetch failure) - Move rate limiter to module-level globals (_rate_lock, _rate_request_times, _rate_daily_credits) so all ForexDataProvider instances running in parallel threads share the same 8-credit/min and 800-credit/day accounting - _throttle now raises DataUnavailableError on daily limit (was silent return False) - Remove _no_api_data tracking, numpy/hashlib imports telegram_bot: - Detect F-grade reports caused by data unavailability and show clean "Data unavailable" line per TF instead of a garbled zero-price card Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,19 @@ def _build_combined_signal(
|
||||
continue
|
||||
r = reports[0]
|
||||
|
||||
# If primary TF data was unavailable the engine returns grade F with a warning.
|
||||
# Show a clean "data unavailable" line instead of a garbled card.
|
||||
if r.signal_quality == "F" and any(
|
||||
"unavailable" in w.lower() or "api" in w.lower() or "credits" in w.lower()
|
||||
for w in r.warnings
|
||||
):
|
||||
lines.append("")
|
||||
lines.append("────────────────────────")
|
||||
lines.append(f"<b>{tf}</b> — ❌ Data unavailable")
|
||||
if r.warnings:
|
||||
lines.append(f"<i>{_h(r.warnings[0])}</i>")
|
||||
continue
|
||||
|
||||
dot = _grade_dot(r.signal_quality)
|
||||
action = _signal_action(r.final_signal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user