This agentic market analysis system is a Python-based framework that combines technical analysis with artificial intelligence to provide comprehensive market insights. At its core, the system implements a modular architecture that seamlessly integrates statistical analysis methods with natural language processing capabilities.
The system's foundation is built upon two primary technical indicators: the Relative Strength Index (RSI) and Bollinger Bands. The RSI implementation provides momentum analysis through a configurable calculation window (default: 14 periods), employing dynamic gain/loss computation and rolling averages to measure the velocity and magnitude of price movements. This is complemented by a Bollinger Bands implementation that utilizes Simple Moving Averages (SMA) and dynamic standard deviation calculations to create adaptive volatility bands that automatically adjust to market conditions.
Market data acquisition is handled through an integration with the Alpaca API, providing access to historical price data across various timeframes. The system employs Polars for high-performance data manipulation, leveraging its columnar storage format and lazy evaluation capabilities to efficiently process large datasets.
The AI integration layer bridges technical analysis with natural language processing using the Qwen2.5-72B-Instruct model via the Hugging Face API. This enables sophisticated market analysis by combining traditional technical indicators with real-time news sentiment analysis through DuckDuckGo search integration.
The project uses a Makefile system for setup and development:
- Initial Setup
make init
- Development Environment
make run
- Code Quality Checks
make check
Required environment variables in .env
:
ALPACA_API_KEY=your_api_key
ALPACA_API_SECRET=your_api_secret
The following example demonstrates comprehensive market analysis combining technical indicators with AI-powered insights:
import os
from datetime import datetime
from smolagents import DuckDuckGoSearchTool, HfApiModel
from smolagents.agents import ToolCallingAgent
# Initialize AI model
model = HfApiModel(
"Qwen/Qwen2.5-72B-Instruct",
token="hf_"
)
# Set up market analysis tools
api_key = os.getenv("ALPACA_API_KEY")
secret_key = os.getenv("ALPACA_API_SECRET")
market_analysis_tool = FinancialTool(
alpaca_api_key=api_key,
alpaca_api_secret=secret_key
)
# Configure search capability
search_tool = DuckDuckGoSearchTool()
# Create analysis agent
agent = ToolCallingAgent(
tools=[market_analysis_tool, search_tool],
model=model
)
# Execute comprehensive analysis
analysis = agent.run(
"""Please give me a detailed analysis of the market conditions for NVDA.
Include:
- Technical indicators (RSI, Bollinger Bands)
- Current news sentiment
- PE ratio comparison with industry
- Market trend analysis
"""
)
If you use this code in your research, please use the following BibTeX entry.
@misc{louisbrulenaudet2025,
author = {Louis Brulé Naudet},
title = {Barebones tool built upon Hugging Face smolagents and Alpaca for financial analysis automation},
howpublished = {\url{https://github.com/louisbrulenaudet/agentic-market-tool}},
year = {2025}
}
If you have any feedback, please reach out at [email protected].