DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 26.7h Behind: Catching Investing Sentiment Leads with Pulsebit

Your Pipeline Is 26.7h Behind: Catching Investing Sentiment Leads with Pulsebit

We’ve recently uncovered a striking anomaly: a 24h momentum spike of +0.302. This specific spike signals a notable uptick in sentiment around investing, particularly in the context of U.S. Steel's major investment in Fairfield operations. The data points to three articles clustering around this theme, providing a rich narrative to dive into. It’s an exciting moment for anyone tracking shifts in sentiment in the investing landscape.

However, if your model isn’t designed to handle multilingual origins or entity dominance, you’re going to miss out on opportunities like this. In this case, your pipeline was lagging by 26.7 hours, with the leading language being English. Imagine missing out on a significant investing sentiment shift simply because your data pipeline wasn’t set up to capture it in real-time. You could have been ahead of the game, but instead, you’re left playing catch-up.

English coverage led by 26.7 hours. Ca at T+26.7h. Confidenc
English coverage led by 26.7 hours. Ca at T+26.7h. Confidence scores: English 0.75, Spanish 0.75, French 0.75 Source: Pulsebit /sentiment_by_lang.

Here’s how we can catch these sentiments using Python and our API. First, let’s filter for English-language content related to investing. We’ll use a query that specifies the language, ensuring our results are aligned with the dominant narrative:

import requests

# Define the API endpoint and parameters
url = "https://api.pulsebit.com/v1/sentiment"
params = {
    "topic": "investing",
    "lang": "en",
    "momentum": +0.302
}

# Make the API call
response = requests.get(url, params=params)

![Left: Python GET /news_semantic call for 'investing'. Right:](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_code_output_split_1782427555313.png)
*Left: Python GET /news_semantic call for 'investing'. Right: returned JSON response structure (clusters: 3). Source: Pulsebit /news_semantic.*


# Check the results
data = response.json()
print(data)
Enter fullscreen mode Exit fullscreen mode

Next, we’ll run the cluster reason string back through our sentiment endpoint to score the narrative framing itself. This will help us understand how the clustered themes are influencing sentiment. Here’s the code for that:

# Define the cluster reason string
cluster_reason = "Clustered by shared themes: investinglive, americas, market, news, wrap:."

# Make the sentiment API call for the cluster reason
sentiment_response = requests.post(url, json={"text": cluster_reason})
sentiment_data = sentiment_response.json()

# Output the sentiment score
print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

Now that we have the sentiment scores, we can build actionable insights. Here are three specific signals we can develop from this data:

  1. Geo-Filtered Signal: Create a signal that captures sentiment specifically within the U.S. regarding investing in steel. Set a threshold score of +0.5 for sentiment and use the geographic filter for "en" to ensure you’re only pulling English-language articles.

![DATA UNAVAILABLE: countries — verify /news_recent is return
[DATA UNAVAILABLE: countries — verify /news_recent is returning country/region values for topic: investing]

  1. Meta-Sentiment Loop: Develop a meta-sentiment analysis function that leverages the cluster reason. Score the narrative and set a threshold of +0.4. This way, you can identify which narratives are gaining traction and how they relate to the broader market themes, focusing on those like "investinglive" and "news."

  2. Forming Theme Tracker: Create a monitoring tool that captures the forming themes related to investing, particularly those showing +0.00 momentum. By tracking signals such as "google," "investing," and "news," versus mainstream themes, you can identify emerging trends before they hit the radar.

These builds not only enhance your understanding of sentiment dynamics but also position you ahead of your peers in capturing actionable insights from the data.

To get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the above code and run it in under 10 minutes. Start leveraging the power of sentiment analysis to drive your investing strategies.

Top comments (0)