Automating Financial News Summaries with AI Agents

✨ How I Built an AI-Powered Bot That Creates Financial News Tweets

Staying on top of financial news can be overwhelming—especially when every headline could move markets. As someone who shares timely market updates, I wanted to automate the most time-consuming part: summarizing news and creating engaging tweets.

So, I built an AI agent-powered content bot that fetches the latest financial news, summarizes each article, and crafts a tweet ready for posting. Here's a breakdown of how I built it and how you can too.

🚀 What This Bot Does

  1. Fetches financial news headlines from the last few hours.

  2. Summarizes each article using a GPT-powered agent.

  3. Generates a tweet that captures the most important highlights.

You can run this bot every few hours to stay current and maintain an active, insightful presence on X (Twitter).

🔍 Step 1: Collecting Recent Financial News

To start, I used Financial Modeling Prep as the source of truth for the latest headlines. The bot pulls in articles from the last 3 hours:

async def get_news_urls(client: httpx.AsyncClient, hours_ago: int = 3) -> list:
    ...  # fetches URLs of articles published within the last `hours_ago`

The loop fetches pages of news until it hits an article older than our cutoff time.

🧱 Step 2: Summarizing the Articles

Each article URL is passed to an AI agent named news_summarizer, which uses GPT-4o to summarize the content concisely:

article_summary_agent = Agent(
    name="news_summarizer",
    model="gpt-4o",
    instructions="...",
    output_type=NewsSummaries,
)

This abstracts away the need to manually skim and summarize articles—a huge time-saver.

📱 Step 3: Creating the Tweet

Once we have all summaries, the tweet_generator agent composes a tweet from the distilled content:

tweet_agent = Agent(
    name="tweet_generator",
    model="gpt-4o",
    instructions="...",
    output_type=TweetSummary,
)

It keeps it within the character limit and adds relevant hashtags to boost visibility.

⏳ Running the Bot

Here’s how it all ties together in the main script:

urls = await get_news_urls(client, hours_ago=3)
summaries = await Runner.run(article_summary_agent, ...)
tweet = await Runner.run(tweet_agent, ...)
print(tweet.final_output.tweet)

This script is designed to be run as a scheduled job (e.g. via cron or a serverless function) every few hours.

🚧 Tools Used

  • Python for scripting

  • httpx for async HTTP requests

  • OpenAI for GPT-4o agent models

  • Pydantic for output validation

  • dotenv for environment variables

  • Financial Modeling Prep API for news

📊 Future Improvements

  • Add sentiment analysis to each news item

  • Schedule auto-posting via the X (Twitter) API

  • Include stock ticker mentions with $TSLA, $AAPL, etc.

  • Create a web dashboard to view & approve tweets

🌎 Try It Yourself!

If you're interested in building your own version of this bot or want to learn more about using AI Agents for content creation, feel free to connect with me on X @ManderAmandeep.