Market Data Connectors
The market data connectors serve as the bridge between the trading agents and external data providers. These components abstract the complexity of API interactions, providing a standardized interface for fetching financial news, real-time price action, and historical market data.
News and Sentiment Data
The system uses a multi-layered approach to fetch news, ensuring high availability by falling back to free RSS feeds if paid API limits are reached.
NewsAPIConnector
The NewsAPIConnector aggregates financial news from NewsAPI, Google News RSS, and dedicated crypto outlets like CoinTelegraph and CoinDesk.
Initialization:
from data_connectors.newsapi_connector import NewsAPIConnector
# Automatically uses NEWSAPI_KEY from environment variables
connector = NewsAPIConnector(api_key="your_api_key_here")
Public Methods:
| Method | Description | Return Type |
| :--- | :--- | :--- |
| get_bitcoin_news(language, limit) | Fetches recent crypto news. Prioritizes Google News RSS and CoinTelegraph/CoinDesk before falling back to NewsAPI. | List[Dict] |
Data Structure: The returned articles follow a consistent dictionary format:
{
"title": "Bitcoin Hits New High...",
"description": "Cleaned text content without HTML tags...",
"url": "https://source-link.com/article",
"published_at": "RFC 2822 or ISO format string",
"source": "cointelegraph.com"
}
Price and Historical Data
Price data is sourced through dedicated tools that agents use to calculate technical indicators and valuation metrics.
CoinGecko Integration
Used primarily for spot price verification and historical data snapshots.
- Real-time Pricing: Fetches the current USD value of assets (e.g., Ethereum, Bitcoin).
- Historical Snapshots: Retrieves market data for specific past dates to support backtesting and fundamental analysis.
# Example Tool Usage
@tool
def get_price(crypto: str) -> str:
"""Get the current price of a crypto from CoinGecko API"""
# Returns: "The price for ethereum is {'ethereum': {'usd': 2450.12}}."
Integration with Agents
Data connectors are registered as LangChain Tools. This allows agents to autonomously decide when they need fresh market context.
Usage in Decision Making
- Technical Agent: Pulls OHLCV (Open, High, Low, Close, Volume) data to calculate RSI, MACD, and Support/Resistance levels.
- Sentiment Agent: Queries the
NewsAPIConnectorto gauge market mood and processes the text through an LLM to determine a sentiment score. - Fundamental Agent: Uses historical data connectors to analyze network growth and on-chain activity over time.
Configuration and Authentication
Connectors rely on environment variables for authentication. Ensure your .env file contains the following keys:
| Variable | Source | Required |
| :--- | :--- | :--- |
| NEWSAPI_KEY | NewsAPI.org | Optional (Falls back to RSS) |
| BINANCE_API_KEY | Binance | Required for execution/private data |
| BINANCE_SECRET_KEY | Binance | Required for execution/private data |
Note: While the
NewsAPIConnectorprovides a fallback to Google News RSS (which requires no key), using a dedicatedNEWSAPI_KEYis recommended for higher-quality metadata and broader source coverage.