vantage / scripts /refresh_signals.py
sourabh gupta
feat(signals): implement external trends signals with cache-aside TTL
26d7a99
Raw
History Blame Contribute Delete
1.02 kB
# File Objective : CLI to refresh keyword signals and print the ranked momentum table.
# Scope : Dev script β€” verify signals.json is written and cache-aside works.
# What it does : Calls fetch_signals() then prints all keywords sorted by momentum.
# What it does not: Compute coverage or GapScore β€” that is the gap module's job.
from __future__ import annotations
import sys
from vantage_core.adapters.signals_pytrends import fetch_signals
def main() -> None:
records = fetch_signals()
if not records:
print("No signals returned β€” check internet or pytrends rate limit.")
sys.exit(1)
print(f"\n── Signals ({len(records)} keywords) ────────────────────────────────────")
for rec in sorted(records, key=lambda r: r.momentum_percentile, reverse=True):
print(f" {rec.momentum_percentile:.4f} {rec.z_score:+.3f} {rec.keyword}")
print()
if __name__ == "__main__":
main()