A newer version of the Gradio SDK is available: 6.13.0
title: cryptic
app_file: src/ui/app.py
sdk: gradio
sdk_version: 5.23.1
CrypticAI - Bitcoin Sentiment Analysis
An AI agentic workflow for Bitcoin price sentiment analysis that combines technical analysis strategies, news sentiment, and market context to provide trading recommendations with confidence scores.
Overview
CrypticAI uses a four-stage agentic workflow to analyze Bitcoin's market conditions:
- Technical Strategy Agent - Implements a 5-minute timeframe RSI + Bollinger Bands trading strategy to generate precise buy/sell signals
- Initial Analysis Agent - Examines the technical strategy signal alongside broader market indicators, news sentiment, and cryptocurrency market context
- Reflection Agent - Critically evaluates both the technical strategy and initial analysis to identify potential blind spots
- Final Synthesis Agent - Produces a final recommendation with confidence score and portfolio allocation percentage, and executes trades via Alpaca
Features
- Technical trading strategy using RSI and Bollinger Bands indicators
- Broader technical analysis using RSI, ADX, and Bollinger Bands across multiple timeframes
- News and social media sentiment analysis of Bitcoin and crypto markets
- Comprehensive cryptocurrency market context analysis including:
- BTC dominance metrics
- Market-wide trends across top cryptocurrencies
- Comparative performance data between Bitcoin and other major coins
- Multiple data sources including Alpaca and Yahoo Finance APIs
- Structured trading recommendations with confidence scores and portfolio allocation percentages
- Automatic trade execution through the Alpaca Crypto API
- Option to run in monitoring mode for continuous analysis
- Interactive Gradio UI for strategy tuning and order monitoring
- Enhanced error handling with exponential backoff retry mechanism
- Data validation and graceful degradation when data sources are unavailable
- Comprehensive logging for improved traceability
- Intelligent caching system to reduce API calls and handle temporary outages
Setup
Prerequisites
- Python 3.10 or higher
- API keys for:
- Alpaca (for Bitcoin price data and trade execution)
- OpenAI (for the LLM agents)
Installation
Clone the repository:
git clone https://github.com/yourusername/crypticai.git cd crypticaiCreate and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtCreate a
.envfile with your API keys:ALPACA_API_KEY=your_alpaca_api_key ALPACA_API_SECRET=your_alpaca_api_secret NEWS_API_KEY=your_newsapi_key OPENAI_API_KEY=your_openai_api_key
Usage
Single Analysis
To run a one-time analysis:
python main.py
Monitoring Mode
To run in monitoring mode (analysis every 4 hours):
python -m src.crypto_analysis.main monitor
Press Ctrl+C to exit monitoring mode.
Trading Dashboard UI
To launch the interactive trading dashboard UI:
python run_ui.py
The UI provides:
- Strategy Configuration - Adjust RSI thresholds and Bollinger Bands parameters
- Trading - Execute manual trades and view account information
- Monitoring - Track active positions and order history
- Automated Analysis - Run the strategy in the background (every 5 minutes)
Training Mode
To train the crew (experimental feature for improved performance):
python -m src.crypto_analysis.main train 5 # Run 5 training iterations
Output
The analysis produces a trading recommendation with:
- Signal: BUY, SELL, or HOLD
- Confidence: Confidence score as percentage (0-100%)
- Allocation: Suggested portfolio allocation percentage
- Reasoning: Concise explanation for the recommendation
- Tool Error Assessment: Information about any data retrieval issues
- Data Reliability: Assessment of the reliability of the data used
Results are displayed in the console and saved as JSON files in the results directory. Detailed logs are also saved to the logs directory.
Technical Strategies
5-Minute RSI + Bollinger Bands Strategy
The technical analysis agent implements a structured 5-minute timeframe strategy:
Buy Signal (Long)
- RSI falls below 40 (mildly oversold condition)
- Price touches or approaches the lower Bollinger Band
- Optimal entry when price starts bouncing up from the lower band
Sell Signal (Short)
- RSI rises above 60 (mildly overbought condition)
- Price touches or approaches the upper Bollinger Band
- Optimal entry when price starts reversing down from the upper band
Broader Technical Analysis
The system also evaluates:
- Market ranging/trending conditions using ADX
- RSI values across multiple timeframes
- Price positions relative to Bollinger Bands
- Support/resistance levels and trend lines
Market Context Analysis
The YahooCryptoMarketTool enhances analysis by providing:
- Market-wide cryptocurrency trends (bullish/bearish)
- Bitcoin dominance percentage of total market cap
- Comparative performance data for top 10 cryptocurrencies
- Day-over-day and week-over-week price changes across the market
Data Tools
The system leverages several specialized data tools:
- YahooBitcoinDataTool - Fetches Bitcoin price data from Yahoo Finance
- YahooCryptoMarketTool - Provides broader cryptocurrency market context
- RealBitcoinNewsTool - Gathers latest Bitcoin news and sentiment
- TechnicalAnalysisStrategy - Applies technical indicators to generate signals
- AlpacaCryptoOrderTool - Executes trade orders based on final recommendations
Reliability Features
Error Handling and Retry Logic
All API calls include robust error handling with configurable retry mechanisms:
- Exponential Backoff - Automatic retry with increasing wait times between attempts
- Alternative Data Sources - Fallback to alternative ticker symbols when primary ones fail
- Data Validation - Verification of data completeness and format before proceeding
- Graceful Degradation - The system continues to function with reduced confidence when some data sources are unavailable
Caching System
An intelligent caching system reduces API calls and improves reliability:
- Time-Based Caching - Results are cached for configurable time periods
- Cache Validation - Automatic detection of when cached data is stale
- Memory-Efficient Storage - Optimized storage of cached data to prevent memory issues
Comprehensive Logging
Enhanced logging provides traceability and debugging capabilities:
- Structured Logs - All system activities are logged with timestamps and contextual information
- Log Rotation - Daily log files to prevent excessive file sizes
- Error Tracebacks - Full error traces captured for debugging
- Status Monitoring - Tool state tracking throughout the analysis process
Extending the System
The system is designed to be modular and extensible:
- Add new tools in the
src/crypto_analysis/toolsdirectory - Modify agent configurations in
src/crypto_analysis/config/agents.yaml - Adjust task descriptions in
src/crypto_analysis/config/tasks.yaml - Add new technical strategies in
src/crypto_analysis/tools/technical_tools.py - Customize error handling in the
src/crypto_analysis/utils/api_helpers.pyfile
License
This project is licensed under the MIT License - see the LICENSE file for details.