The News Agent retrieves crypto news headlines from NewsData.io and scores each one against lists of bullish and bearish keywords. It aggregates the per-headline scores into an overall market sentiment verdict alongside per-sentiment counts and the full classified headline list. Stage 4/6 of the Elyra pipeline calls this agent automatically; you can also invoke it directly.Documentation Index
Fetch the complete documentation index at: https://docs.getelyra.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
You need a NewsData.io API key. Get one at newsdata.io and set it in your environment:api_key parameter. If the key is absent, the underlying collector will fail and the agent will raise an exception — unless the full pipeline is running, which catches the error and substitutes neutral defaults automatically.
CLI usage
NEWSDATA_API_KEY from the environment and prints the full sentiment result as JSON.
Python usage
get_news_sentiment()
Fetches up to limit headlines matching query from NewsData.io, classifies each headline as "bullish", "bearish", or "neutral", and returns an aggregate sentiment result.
Signature
Parameters
Maximum number of headlines to fetch from NewsData.io.
Search query passed to the NewsData.io API. Change this to focus on a specific asset or topic (e.g.
"bitcoin", "solana ETF").NewsData.io API key. If omitted, the function reads
NEWSDATA_API_KEY from the environment.Sentiment classification
Each headline’s title and description are combined, lowercased, and matched against two keyword lists:- Bullish keywords include:
surge,rally,gain,bullish,breakout,all-time high,ath,adoption,etf,approval,record high, and others. - Bearish keywords include:
crash,plunge,drop,bearish,collapse,ban,crackdown,hack,exploit,liquidation, and others.
"bullish" if its bullish keyword count exceeds its bearish count, "bearish" if the reverse is true, and "neutral" if they are equal.
The overall sentiment field is set to whichever per-headline class has a strict majority. If no class has a strict majority, the overall sentiment is "neutral".
Return value
Returnsdict[str, Any].
Aggregate market sentiment across all fetched headlines. One of
"bullish", "bearish", or "neutral".Number of headlines classified as bullish.
Number of headlines classified as bearish.
Number of headlines classified as neutral.
List of classified headline objects, one per fetched article.
Example response
Graceful degradation
IfNEWSDATA_API_KEY is not set and no api_key argument is provided, the full pipeline (main.py) catches the resulting error and substitutes these neutral defaults:
Sentiment classification uses predefined keyword lists for bullish and bearish signals. The bullish list includes terms like
surge, rally, ath, etf, and adoption. The bearish list includes terms like crash, hack, exploit, ban, and liquidation.