Skip to content

Commit feccd35

Browse files
committed
Switch to Twelve Data priority scan (multi-key support) with FMP fallback
1 parent f72463c commit feccd35

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/daily_scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ concurrency:
2222
jobs:
2323
scan:
2424
runs-on: ubuntu-latest
25-
timeout-minutes: 15
25+
timeout-minutes: 30
2626

2727
# ── All secrets & config as env vars (job level) ──────────
2828
env:
@@ -96,7 +96,7 @@ jobs:
9696

9797
# ── 6. Run the bot ──────────────────────────────────────
9898
- name: Run Tech Losers Scan
99-
run: python main.py --no-wait --scan-source fmp-quotes
99+
run: python main.py --no-wait --scan-source td
100100

101101
# ── 7. Upload report artifacts (optional, for debugging) ─
102102
- name: Upload reports

src/provider_router.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,20 @@ def get_tech_losers(self) -> List[FilteredStock]:
122122
self.scan_source = "fmp-quotes"
123123
return self.get_tech_losers() # Recursively call with new mode
124124
else:
125-
losers = self.fmp.scan_tech_universe(limit=self.sample_size)
126-
from .tech_universe import get_universe_size
127-
self._stats["total_scanned"] = get_universe_size(limit=self.sample_size)
125+
# Default: Twelve Data (Primary) with FMP Fallback
126+
# User Preference: "Multiple 12 data API keys to scan 545 stocks... FMP as fallback"
127+
print("[Source] Using Twelve Data (Primary) - Multi-Key Scan")
128+
try:
129+
# This automatically uses multiple keys if configured in env/secrets
130+
losers = self.fmp.scan_tech_universe(limit=self.sample_size)
131+
from .tech_universe import get_universe_size
132+
self._stats["total_scanned"] = get_universe_size(limit=self.sample_size)
133+
except Exception as e:
134+
print(f"\n[Error] Twelve Data scan failed: {e}")
135+
print("[Fallback] Switching to FMP Biggest Losers Feed (Safe Mode)...")
136+
# Fallback to the single-request FMP feed (always safe)
137+
losers = self.fmp.get_biggest_losers_fmp()
138+
self._stats["total_scanned"] = len(losers)
128139
self._stats["total_losers"] = len(losers)
129140

130141
if not losers:

0 commit comments

Comments
 (0)