fix(news): strip GNews operator dashes and stop phantom query-budget counting #12

Merged
chemavx merged 1 commits from fix/gnews-minor into main 2026-06-26 08:09:05 +00:00
Owner

Two minor faults found during the GNews capture/prioritisation diagnostic.

1. HTTP 400 on hyphenated queries

- is GNews's exclusion operator, so a token like "El-Sayed" returned HTTP 400 and wasted a query. _PUNCT_RE now strips -, en dash and em dash to spaces.

2. Phantom gnews_queries_used counter

The per-cycle budget counter incremented in evaluate() before get_sentiment() checked the API key, so with no key the [CYCLE SUMMARY] reported a phantom gnews_queries_used: 5/5 with zero real requests. Added NewsClient.enabled and gated the GNews block on it — with no key the counter stays 0/5 and no spurious SKIP_GNEWS_PRIORITY is logged. No behaviour change when a key is present.

Prioritisation itself was confirmed correct and left untouched: politics markets are sorted by gnews_priority DESC and prior-extreme markets return before the budget is consumed, so no query is ever spent on a market that cannot trade.

Tests: tests/test_news_query.py (4 new); full suite 66 passed.

🤖 Generated with Claude Code

Two minor faults found during the GNews capture/prioritisation diagnostic. ## 1. HTTP 400 on hyphenated queries `-` is GNews's exclusion operator, so a token like "El-Sayed" returned HTTP 400 and wasted a query. `_PUNCT_RE` now strips `-`, en dash and em dash to spaces. ## 2. Phantom `gnews_queries_used` counter The per-cycle budget counter incremented in `evaluate()` before `get_sentiment()` checked the API key, so with no key the `[CYCLE SUMMARY]` reported a phantom `gnews_queries_used: 5/5` with zero real requests. Added `NewsClient.enabled` and gated the GNews block on it — with no key the counter stays `0/5` and no spurious `SKIP_GNEWS_PRIORITY` is logged. No behaviour change when a key is present. Prioritisation itself was confirmed correct and left untouched: politics markets are sorted by `gnews_priority` DESC and prior-extreme markets return before the budget is consumed, so no query is ever spent on a market that cannot trade. **Tests:** `tests/test_news_query.py` (4 new); full suite 66 passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chemavx added 1 commit 2026-06-26 08:08:27 +00:00
Two minor faults found during the GNews capture/prioritisation diagnostic:

1. Hyphens/dashes reached the GNews query verbatim. '-' is GNews's exclusion
   operator, so a token like "El-Sayed" returned HTTP 400 and wasted a query.
   _PUNCT_RE now strips '-', en dash and em dash to spaces.

2. The per-cycle GNews budget counter incremented in evaluate() before
   get_sentiment() checked the API key, so with no key configured the
   [CYCLE SUMMARY] reported a phantom "gnews_queries_used: 5/5" with zero real
   requests. Added NewsClient.enabled and gated the GNews block on it; with no
   key the counter stays 0/5 and no spurious SKIP_GNEWS_PRIORITY is logged.
   No behaviour change when a key is present.

Prioritisation itself was confirmed correct and is left untouched: politics
markets are sorted by gnews_priority DESC and prior-extreme markets return
before the budget is consumed, so no query is ever spent on a market that
cannot trade.

Tests: tests/test_news_query.py (4 new); full suite 66 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
chemavx merged commit af0d1fbc59 into main 2026-06-26 08:09:05 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: chemavx/polymarket-bot#12