Add Telegram bot and fix excessive API calls
- Add telegram_bot.py: full bot interface with /scan, /signals, /pair, /all, /tf, /watch, /unwatch, /status, /help commands; per-chat state; background thread pool for analysis; auto message splitting - Fix data_provider: warn once per symbol with no API data and cache synthetic fallback to prevent redundant individual API calls - Fix signal_aggregator: derive spread estimate from already-fetched primary DataFrame instead of making a separate M5 API call per pair - Add python-telegram-bot[job-queue]>=20.0 to requirements.txt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-1
@@ -73,6 +73,7 @@ class ForexDataProvider:
|
||||
self._cache: Dict[str, pd.DataFrame] = {}
|
||||
self._cache_timestamps: Dict[str, float] = {}
|
||||
self._request_times: deque = deque() # timestamps of recent API credits used
|
||||
self._no_api_data: set = set() # td_symbols with no values from API (use synthetic)
|
||||
self._session = requests.Session()
|
||||
self._session.headers.update({
|
||||
"User-Agent": "Mozilla/5.0 (compatible; ForexIntel/1.0)"
|
||||
@@ -281,7 +282,20 @@ class ForexDataProvider:
|
||||
|
||||
values = sym_data.get("values")
|
||||
if not values:
|
||||
logger.warning(f"No values in batch response for {td_sym}")
|
||||
if td_sym not in self._no_api_data:
|
||||
logger.warning(
|
||||
f"No API data for {td_sym} — using synthetic data"
|
||||
)
|
||||
self._no_api_data.add(td_sym)
|
||||
# Cache synthetic so fetch_ohlcv won't make a redundant API call
|
||||
try:
|
||||
syn = self._generate_synthetic_data(symbol, timeframe, lookback_days)
|
||||
syn = self._validate_and_clean(syn, symbol, timeframe)
|
||||
cache_key = f"{symbol}_{timeframe.value}"
|
||||
self._cache[cache_key] = syn
|
||||
self._cache_timestamps[cache_key] = now
|
||||
except Exception:
|
||||
pass
|
||||
continue
|
||||
|
||||
records = [
|
||||
|
||||
Reference in New Issue
Block a user