Principle:24mlight A Share investment Agent News Search Pipeline
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, Web_Scraping, Finance |
| Last Updated | 2026-10-10 14:00 GMT |
Overview
A multi-layer news fetching pipeline that combines SQLite caching, agent-specific query construction, Tavily API search with key rotation, deduplication, and LLM sentiment scoring into a single end-to-end news intelligence system.
Description
The news search pipeline follows a prioritized multi-stage approach:
- Cache Lookup: Checks SQLite cache (
stock_news_daily_cachetable) for existing news matching the symbol and date. If sufficient cached news exists (>= max_news), returns immediately without API calls.
- Query Construction: Builds an optimized search query based on the agent type (sentiment, macro, market snapshot). Supports rule-based queries (Chinese, Tavily-compatible) and optional LLM-generated queries.
- Tavily API Search: Uses the Tavily News Search API with automatic API key rotation. Builds a payload with topic="news", date range, and max results capped at 10. Parses raw API responses into structured
NewsSearchResultobjects.
- Deduplication and Cache Write: Merges new results with cached news, deduplicates by title, sorts by time, and writes the combined list back to SQLite cache.
- LLM Sentiment Analysis: Sends formatted news content to an LLM with sentiment analysis prompts, parses the JSON response for score/signal/confidence/reasoning.
Usage
Use this principle when:
- Building news intelligence pipelines with caching to minimize API costs
- Requiring agent-specific query optimization (different search terms for different analysis types)
- Implementing search provider abstraction with fallback and key rotation
Theoretical Basis
# Abstract pipeline (not real implementation)
def get_stock_news(symbol, max_news, date, agent_name):
# 1. Check cache
cached = cache.fetch(symbol, date)
if len(cached) >= max_news:
return cached[:max_news]
# 2. Build query (agent-specific)
query = build_news_query(symbol, agent_name=agent_name)
# 3. Search via Tavily
results = tavily_search.search(SearchQuery(query=query, max_results=10))
# 4. Deduplicate and merge
combined = deduplicate(cached + convert_to_news_format(results, symbol))
# 5. Cache write
cache.upsert(symbol, date, combined)
return combined[:max_news]
Cache key: (symbol, cache_date) — daily granularity
Tavily payload constraints:
topic: always "news"max_results: capped at 10 per API callsearch_depth: "basic"- Date filtering via
start_date/end_dateordaysparameter
Related Pages
Implemented By
- Implementation:24mlight_A_Share_investment_Agent_get_stock_news
- Implementation:24mlight_A_Share_investment_Agent_build_news_query
- Implementation:24mlight_A_Share_investment_Agent_TavilyNewsSearch_search
- Implementation:24mlight_A_Share_investment_Agent_AkshareSQLiteCache
Uses Heuristics
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment