Add 4-pair candle-boundary auto-scanner (free tier safe)

Expand from 2 to 4 pairs (EUR/USD, USD/JPY, GBP/USD, XAU/USD) with
automatic scanning at M15 and H1 candle close boundaries. Scheduler
staggers H1 by 60s to stay within 8 credits/min; daily budget is
480 of 800 allowed. Cache TTL is now candle-duration-aware so cross-TF
confirmation data is reused without extra API calls. Spread estimate
uses primary-TF data instead of fetching M5 separately.
This commit is contained in:
harwinder
2026-05-11 15:30:11 -04:00
parent a708609f8b
commit 873cf5487e
4 changed files with 315 additions and 51 deletions
Regular → Executable
+8 -1
View File
@@ -43,6 +43,12 @@ class ForexDataProvider:
Timeframe.D1: 1, Timeframe.W1: 0.143,
}
CANDLE_SECONDS = {
Timeframe.M1: 60, Timeframe.M5: 300, Timeframe.M15: 900,
Timeframe.M30: 1800, Timeframe.H1: 3600, Timeframe.H4: 14400,
Timeframe.D1: 86400, Timeframe.W1: 604800,
}
RATE_LIMIT = 8
RATE_WINDOW = 60.0
@@ -79,9 +85,10 @@ class ForexDataProvider:
cache_key = f"{symbol}_{timeframe.value}"
now = time.time()
cache_ttl = self.CANDLE_SECONDS.get(timeframe, self.config.refresh_interval)
if (
cache_key in self._cache_timestamps
and (now - self._cache_timestamps[cache_key]) < self.config.refresh_interval
and (now - self._cache_timestamps[cache_key]) < cache_ttl
and cache_key in self._cache
):
cached = self._cache.get(cache_key)