Agentic AI: An Overview

Ravi Tiwari
6 min readDec 26, 2024

--

Agentic AI

Agentic AI refers to intelligent systems that can not only perceive and analyze information but also act autonomously to achieve a specified goal. Unlike traditional machine learning models, which only provide predictions or classifications, Agentic AI systems iterate through sense-making, decision-making, and taking actions in an environment.

These systems can be thought of as “agents” that:

  1. Gather Information (e.g., reading the latest news).
  2. Analyze and Reason (e.g., perform sentiment analysis, price forecasts, or risk assessments).
  3. Act (e.g., propose or execute an action such as buying, selling, or holding a cryptocurrency).

In the world of finance and trading, an Agentic AI system could read market news, social media sentiment, and on-chain metrics to predict short-term price movements, then automatically place trades or provide alerts to the user.

Example: Reading ADA News & Pricing, Making a Buy/Sell/Hold Decision

Suppose we want a minimal AI agent that:

  1. Fetches the Latest ADA News: We’ll collect headlines or articles mentioning Cardano (ADA).
  2. Checks ADA Pricing: We’ll fetch the current ADA price from a cryptocurrency price API.
  3. Analyzes Sentiment: Using a sentiment analysis model, we’ll estimate whether the news is generally positive (bullish), negative (bearish), or neutral.
  4. Makes a Decision: Based on the sentiment score and the price trend (or thresholds), the agent will recommend either a Buy, Sell, or Hold.

Disclaimer: The code and approach below are purely for demonstration. This is not financial advice. Trading cryptocurrencies poses significant risk, and you should do your own research and consider your financial situation carefully before making any trades.

Step-by-Step Outline

Installation and Setup

  • We’ll use Python, requests or yfinance (or any other crypto data library) for fetching crypto prices.
  • For sentiment analysis, we’ll demonstrate a simple example using a Hugging Face model (like distilbert-base-uncased-finetuned-sst-2-english) or TextBlob as a quick alternative.

Fetch Current ADA Price

  • We can use an API endpoint that provides the current market price of Cardano (ADA).
  • Alternatively, we could use a library like requests to call a public crypto API (e.g., CoinGecko, Binance, or any aggregator).

Fetch News Headlines

  • We can manually define some sample headlines in code (for demonstration).
  • For a production system, you might parse RSS feeds, aggregator APIs, or web-scraped articles.

Perform Sentiment Analysis

  • Convert each headline/article text into a sentiment score.
  • Aggregate the scores or measure the general sentiment for the day’s news.

Decision Logic

  • For demonstration, define a simple rule-based logic. For instance:
  • If the average sentiment is highly positive, the agent leans Buy.
  • If the average sentiment is highly negative, the agent leans Sell.
  • Otherwise, Hold.

Output Recommendation

  • Print or return a final recommendation: Buy, Sell, or Hold.

Example Python Implementation

Below is a minimal, end-to-end example:

import requests
import json
import numpy as np

# For sentiment analysis:
# Option 1: Use Hugging Face Transformers pipeline
from transformers import pipeline

# OR
# Option 2: Use TextBlob (a simpler approach)
# from textblob import TextBlob

def fetch_ada_price():
"""
Fetch current Cardano (ADA) price from a public API such as CoinGecko.
Returns the current price in USD (float).
"""
try:
# CoinGecko example endpoint
url = "https://api.coingecko.com/api/v3/simple/price"
params = {
"ids": "cardano",
"vs_currencies": "usd"
}
response = requests.get(url, params=params)
data = response.json()

# Extract the price from the JSON
current_price = data["cardano"]["usd"]
return current_price
except Exception as e:
print(f"Error fetching ADA price: {e}")
return None

def fetch_news_headlines():
"""
Returns a list of sample headlines about ADA or Cardano.
In a real agent, this would call a news API or parse an RSS feed.
"""
# For demonstration, we will define some static headlines.
# You can replace this with actual API calls or web scrapers.
headlines = [
"Cardano Surges After Positive Development Updates",
"Experts Warn Of Possible Correction in Cardano",
"Major Financial Institution to Begin Holding ADA Reserves",
"Bearish Signals Emerge Despite Cardano's Strong Performance",
"Investors Show Growing Interest in Cardano's Future"
]
return headlines

def analyze_sentiment(headlines):
"""
Uses a Hugging Face sentiment pipeline to analyze each headline.
Returns the average sentiment score (range roughly from -1.0 to +1.0).
"""
# Initialize sentiment pipeline (using a default pretrained model)
sentiment_pipeline = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

scores = []
for headline in headlines:
result = sentiment_pipeline(headline)[0] # returns [{'label': 'POSITIVE'/'NEGATIVE', 'score': float}]
label = result['label']
score = result['score']

# Convert the model's "label" into a numeric scale:
# POSITIVE = +1, NEGATIVE = -1
if label == "POSITIVE":
numeric_score = score # e.g., 0.95 -> strongly positive
else: # "NEGATIVE"
numeric_score = -score # e.g., -0.90 -> strongly negative

scores.append(numeric_score)

# Calculate the average sentiment
avg_sentiment = np.mean(scores)
return avg_sentiment

def make_decision(avg_sentiment, current_price):
"""
Given the average sentiment and the current ADA price,
decide whether to 'Buy', 'Sell', or 'Hold'.

A simple rule-based approach:
- If sentiment > 0.3, recommend 'Buy'
- If sentiment < -0.3, recommend 'Sell'
- Otherwise, 'Hold'

In a real system, you might incorporate price movements,
technical indicators, or more sophisticated logic.
"""
if avg_sentiment > 0.3:
decision = "BUY"
elif avg_sentiment < -0.3:
decision = "SELL"
else:
decision = "HOLD"
return decision

def run_agentic_ai():
"""
Main function to run our minimal agentic AI for ADA.
"""
print("=== Fetching ADA Price ===")
price = fetch_ada_price()
if price is None:
print("Could not fetch price. Exiting.")
return

print(f"Current ADA Price (USD): {price}")

print("\n=== Fetching News Headlines ===")
headlines = fetch_news_headlines()
for hl in headlines:
print(" -", hl)

print("\n=== Analyzing Sentiment ===")
avg_sentiment = analyze_sentiment(headlines)
print(f"Average sentiment score: {avg_sentiment:.4f}")

print("\n=== Making Decision ===")
decision = make_decision(avg_sentiment, price)
print(f"Final Recommendation: {decision}\n")

if __name__ == "__main__":
run_agentic_ai()

Output

ADA Final recommendation

How This Code Works

fetch_ada_price():

  • Makes a GET request to CoinGecko’s simple price API.
  • Parses the JSON response for ADA (Cardano) in USD.
  • Returns the current price or None if there was an error.

fetch_news_headlines():

  • Currently returns a static list of headlines. (In production, you would replace this with a real news data source.)

analyze_sentiment(headlines):

  • Uses a Hugging Face sentiment analysis pipeline with the pretrained distilbert-base-uncased-finetuned-sst-2-english model.
  • Each headline is processed, returning a label (“POSITIVE” or “NEGATIVE”) and a score.
  • We convert the label into a numeric scale (positive sentiment -> +score, negative sentiment -> -score).
  • We average the resulting sentiment scores to determine an overall measure of positivity or negativity.

make_decision(avg_sentiment, current_price):

  • Applies a trivial rule-based system.
  • If the average sentiment is clearly above 0.3, we assume bullishness and recommend Buy.
  • If it’s clearly below -0.3, we assume bearishness and recommend Sell.
  • Otherwise, we remain neutral with Hold.

run_agentic_ai():

  • Ties all the steps together: fetch the price, fetch the news, analyze sentiment, and finally make a trading recommendation.

Source Code: https://github.com/code-examples-umeey/AgenticAIExample

Conclusion

This example demonstrates how an Agentic AI can autonomously gather market-related information (ADA news and pricing), perform sentiment analysis to gauge the market’s temperature, and then act on it (in this case, deciding a buy, sell, or hold). In practice, financial markets are more complex, and you’d need deeper validation, more robust data sources, and advanced risk management.

However, this toy example serves as an introduction to building an agentic AI for cryptocurrency trading, showcasing the fundamental steps involved in creating an end-to-end system that senses, decides, and can act.

Final Reminder: This is for demonstration only and not financial advice. Always do your own due diligence.

Happy coding, and trade responsibly!

--

--

Ravi Tiwari
Ravi Tiwari

Written by Ravi Tiwari

Experienced hands-on CTO with 20+ years of cloud native microservices expertise, driving solutions for large-scale enterprises.

No responses yet