Advanced AI Agents with LangGraph and Llama 3.1 | Analyze Bitcoin, Ethereum and Solana Markets
Based on Venelin Valkov's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
The system caches OpenBB historical prices, OpenBB money-supply series (M1/M2), and Go Search news into SQLite to avoid repeated API calls during experimentation.
Briefing
An AI agent workflow built with LangGraph can generate cryptocurrency market reports by combining three streams of evidence: cached historical price data (augmented with technical indicators), fresh news, and macro context from money-supply series. The system then runs specialized agents in parallel—one focused on price/indicators and another on news sentiment—before a final “financial reporter” agent merges both outputs into a structured recommendation, sentiment score, trend label, and multi-week price outlook. The practical value is speed and repeatability: once the data is stored locally, the graph can answer new user questions (e.g., “analyze Ethereum”) without repeatedly calling external APIs.
The pipeline starts by downloading daily historical prices for Bitcoin, Ethereum, and Solana (BTC USD, ethereum USD, Sana USD) plus macro money-supply measures (M1 and M2) from OpenBB, beginning around 2010-01-01 for the money supply and using the available historical range for crypto prices. News is pulled via a Go Search-based library (using the “news” segment) for each ticker and also for a general “news” keyword, then stored alongside timestamps, titles, and bodies. To keep experimentation efficient, the workflow caches everything into an SQLite database and builds helper functions that retrieve and optionally resample the data into daily, weekly, or monthly views.
On the technical side, the price dataset is enriched with indicators that are computed directly in Python using pandas-ta. Relative Strength Index (RSI) is calculated on a 14-day window to flag overbought/oversold regimes (above 70 vs. below 30). The system also adds Bollinger Bands and MACD, plus moving averages over 50 and 200 days, and it computes additional derived levels based on the “50% between a high and a low” concept across multiple horizons. For the news stream, the graph limits volume by sampling up to a maximum number of articles per day after grouping by date.
LangGraph then orchestrates the analysis through a typed state (App State) that carries the user’s ticker query, the retrieved price/news data, and intermediate agent outputs. A ticker extractor normalizes the user input into a canonical symbol/keyword. Two branches run in parallel: a price retriever fetches and indicator-enriches the last 24 weeks of weekly data, while a news retriever pulls the relevant articles. Next, a price analyst produces a report that incorporates the indicator set and money-supply context to estimate near-term direction (including four-week predictions) and a bullishness assessment. In parallel, a news analyst converts the article set into a single sentiment score from 0–100 with a short justification.
Finally, a financial reporter merges both agent reports into a structured deliverable: buy/hold/sell recommendation, bullishness score (0 extremely bearish to 100 extremely bullish), trend classification (up/neutral/down), sentiment label (neutral/fear/greed), four-week price prediction, and a brief one-to-three-sentence market summary. In a live example for Ethereum, the merged output lands on a “hold” recommendation with a bullishness score of 72, describing a bearish short-term trend but a bullish longer-term outlook—illustrating how the system can reconcile conflicting signals from technical indicators and news sentiment. The same graph can be rerun for other prompts, such as comparing Ethereum vs. Solana for a one-year maximum-return scenario.
Cornell Notes
The workflow uses LangGraph to answer crypto market questions by combining cached historical prices, technical indicators, macro money-supply data, and recent news. After storing data in SQLite, it builds helper functions to retrieve and resample prices/news into daily/weekly/monthly views. Two agents run in parallel: a price analyst (RSI, Bollinger Bands, MACD, moving averages, and derived “50%” levels) and a news analyst (converts article sets into a single 0–100 sentiment score). A final financial reporter merges both outputs into a structured result: buy/hold/sell, bullishness score, trend and sentiment labels, and a multi-week price outlook. This matters because it turns messy market inputs into repeatable, query-driven reports without re-fetching external data each time.
How does the system avoid repeatedly hitting external APIs while still supporting iterative analysis?
What technical indicators are added to the price data, and what role do they play in the price analyst’s output?
How does the news pipeline control volume and keep the sentiment signal manageable?
What does the LangGraph state (App State) contain, and how does it flow through the graph?
How are the two analysis branches combined into a single recommendation?
What is the practical output format a user receives after running the graph?
Review Questions
- If a user asks for a weekly vs. monthly analysis, which parts of the pipeline must support resampling, and how does the system aggregate high/low/close and volume?
- Why might caching data in SQLite improve both cost and iteration speed when experimenting with agent prompts and indicator settings?
- In the Ethereum example, how did conflicting signals from technical indicators and news sentiment lead to a “hold” recommendation rather than a single-direction call?
Key Points
- 1
The system caches OpenBB historical prices, OpenBB money-supply series (M1/M2), and Go Search news into SQLite to avoid repeated API calls during experimentation.
- 2
LangGraph runs a ticker extractor first, then executes price retrieval/analysis and news retrieval/analysis in parallel before merging results.
- 3
pandas-ta adds RSI (14-day), Bollinger Bands, MACD, and 50/200-day moving averages to the price dataset used by the price analyst.
- 4
News retrieval filters by ticker keyword plus a general “new” category, then limits articles per day to keep sentiment analysis tractable.
- 5
The price analyst computes horizon-based “50% between high and low” levels (e.g., 4, 12, 26 weeks) and combines them with money-supply context for direction and four-week predictions.
- 6
The final financial reporter produces a structured deliverable: buy/hold/sell, bullishness score (0–100), trend label, sentiment label, four-week price outlook, and a short summary.
- 7
Because the graph is prompt-driven, the same workflow can be rerun for different tickers and time-horizon questions (e.g., Ethereum vs. Solana over one year).