Skip to main content

Production-ready crypto trading analysis agent with LLM hardening

Project description

AutoDegen ๐Ÿš€

PyPI version Python 3.9+ License: MIT

Production-ready cryptocurrency trading analysis agent with enterprise-grade LLM hardening.

๐ŸŒŸ Features

๐Ÿ›ก๏ธ Enterprise-Grade LLM Security

  • Zero Meta Commentary: Complete elimination of "I'll analyze..." and "The key will be..." responses
  • Structured Output Enforcement: Guaranteed consistent report format with Pydantic validation
  • Production Hardening: Circuit breaker, retry logic, timeout handling, and tool call firewall

๐Ÿ“Š Comprehensive Market Analysis

  • Multi-Expert AI Coordination: Technical, market, and news sentiment analysis
  • Real-Time Data: Integration with Binance, DeFiLlama, and crypto news sources
  • Advanced Technical Indicators: RSI, MACD, moving averages, Smart Money Concepts
  • Multi-Timeframe Analysis: 1h, 4h, daily perspectives with confluence signals

โšก High-Performance Architecture

  • Async/Await: Non-blocking operations for maximum throughput
  • Resilience Patterns: Circuit breaker prevents cascade failures
  • Comprehensive Testing: 52+ test cases with 100% production readiness validation
  • Type Safety: Full type hints with mypy compatibility

๐Ÿš€ Quick Start

Installation

# Basic installation
pip install autodegen

# With CLI support  
pip install autodegen[cli]

# Development installation
pip install autodegen[dev]

Environment Setup

Create a .env file or set environment variables:

FIREWORKS_API_KEY=your_fireworks_api_key      # Required
OPENAI_API_KEY=your_openai_key               # Optional  
BINANCE_API_KEY=your_binance_key             # Optional
BINANCE_API_SECRET=your_binance_secret       # Optional

Python API Usage

import asyncio
from autodegen import TradingAgent

async def main():
    # Initialize agent
    agent = TradingAgent()
    
    # Get structured analysis
    analysis = await agent.analyze("BTC", timeframe="4h")
    
    print(analysis.title)        # **COMPREHENSIVE TECHNICAL ANALYSIS: BTC**
    print(analysis.market_state) # Current market conditions...
    print(analysis.outlook)      # Bullish bias maintained above...
    
    # Get market overview
    overview = await agent.get_market_overview()
    print(overview)

# Run analysis
asyncio.run(main())

CLI Usage

# Analyze a cryptocurrency
autodegen analyze BTC --timeframe 4h --format rich

# Get market overview  
autodegen market

# Check system health
autodegen health

# List supported symbols
autodegen symbols

๐Ÿ“– Advanced Usage

Structured vs Unstructured Output

# Structured output (recommended)
structured_analysis = await agent.analyze("ETH", structured=True)
print(f"Market State: {structured_analysis.market_state}")
print(f"Trading Levels: {structured_analysis.trading_levels}")

# Text output  
text_analysis = await agent.analyze("ETH", structured=False)
print(text_analysis)  # Raw markdown-formatted text

Error Handling

from autodegen import TradingAgent, APIError, ConfigurationError

try:
    agent = TradingAgent()
    result = await agent.analyze("BTC")
except ConfigurationError as e:
    print(f"Setup error: {e}")
except APIError as e:
    print(f"API error: {e} (status: {e.status_code})")
except Exception as e:
    print(f"Unexpected error: {e}")

Health Monitoring

# Check system health
health = await agent.health_check()

if health["status"] == "healthy":
    print("All systems operational")
else:
    print(f"System status: {health['status']}")
    for component, status in health["components"].items():
        print(f"  {component}: {status}")

๐Ÿ—๏ธ Architecture

AutoDegen
โ”œโ”€โ”€ ๐Ÿง  LLM Core (Production Hardened)
โ”‚   โ”œโ”€โ”€ Circuit Breaker Pattern
โ”‚   โ”œโ”€โ”€ Retry with Exponential Backoff  
โ”‚   โ”œโ”€โ”€ Tool Call Firewall
โ”‚   โ””โ”€โ”€ Structured Output Enforcement
โ”‚
โ”œโ”€โ”€ ๐Ÿ“Š Market Analysis Engine
โ”‚   โ”œโ”€โ”€ Technical Expert (Charts & Indicators)
โ”‚   โ”œโ”€โ”€ Market Expert (Liquidity & Volume)
โ”‚   โ””โ”€โ”€ News Expert (Sentiment Analysis)
โ”‚
โ”œโ”€โ”€ ๐Ÿ”Œ Data Sources
โ”‚   โ”œโ”€โ”€ Binance API (Price & Volume)
โ”‚   โ”œโ”€โ”€ DeFiLlama (DeFi Metrics)
โ”‚   โ””โ”€โ”€ News APIs (Market Sentiment)
โ”‚
โ””โ”€โ”€ ๐Ÿ›ก๏ธ Security & Reliability
    โ”œโ”€โ”€ Input Validation & Sanitization
    โ”œโ”€โ”€ Rate Limiting & Quotas
    โ””โ”€โ”€ Comprehensive Logging

๐Ÿ“ˆ Supported Cryptocurrencies

Major Coins: BTC, ETH, BNB, SOL, ADA, XRP, DOT, AVAX

DeFi Tokens: UNI, COMP, CRV, LINK, AAVE

Layer 1s: ATOM, NEAR, ALGO, FTM, ICP

And more: MATIC, VET, FLOW, SAND, MANA

Use autodegen symbols to see the full list

๐Ÿ”ง Configuration

API Keys Priority

  1. Constructor parameters
  2. Environment variables
  3. .env file (if python-dotenv installed)

Timeout & Retry Settings

agent = TradingAgent()

# Custom timeout and structured output
analysis = await agent.analyze(
    symbol="BTC",
    timeout=60.0,        # 60 second timeout
    structured=True      # Enforce schema validation
)

๐Ÿงช Production Hardening

This agent includes enterprise-grade production hardening tested with 52+ comprehensive test cases:

๐Ÿ›ก๏ธ LLM Response Security

  • Meta Commentary Elimination: Zero tolerance for "I'll analyze...", "The key will be..." responses
  • Structured Schema Enforcement: Guaranteed report format with required sections
  • Content Validation: Multi-layer filtering of banned tokens and meta statements

๐Ÿ”’ Security Features

  • Tool Call Firewall: Blocks dangerous function calls (execute_code, run_shell)
  • Input Sanitization: Automatic cleanup of potentially harmful content
  • Circuit Breaker: Prevents cascade failures with automatic recovery

โšก Reliability Patterns

  • Retry Logic: Exponential backoff with jitter (3 attempts default)
  • Timeout Handling: Graceful degradation on slow responses
  • Health Monitoring: Real-time component status checking

๐Ÿงช Testing & Quality

# Install development dependencies
pip install autodegen[dev]

# Run the production quality test battery  
python -m pytest tests/run_quality_battery.py

# Test specific components
python -m pytest tests/ -v

Quality Metrics:

  • โœ… 52/52 tests passing (100% success rate)
  • โœ… Zero meta commentary leakage
  • โœ… 100% structured output compliance
  • โœ… Enterprise resilience patterns validated

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide.

Development Setup

git clone https://github.com/taygundogan/cryptotrading-agent
cd cryptotrading-agent
pip install -e .[dev]

# Run tests
python tests/run_quality_battery.py

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built with production-grade LLM hardening techniques
  • Inspired by enterprise trading system architectures
  • Powered by Fireworks AI, OpenAI, and crypto data providers

๐Ÿ“ž Support


โš ๏ธ Disclaimer: This tool is for educational and informational purposes only. Cryptocurrency trading involves significant risk. Always do your own research and consider your risk tolerance before making trading decisions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autodegen-0.1.3.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autodegen-0.1.3-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file autodegen-0.1.3.tar.gz.

File metadata

  • Download URL: autodegen-0.1.3.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for autodegen-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c2c397320c90ed9c3a2df72ce4c9c4c853b18622e0d40956c9302a65e9a216c2
MD5 d2ffef653f5789b4e85a0a671ad8b4b3
BLAKE2b-256 fde6e199ceb63c95a93b07d371ff46ef263c30407e32646f6ea7bc9c9f86099e

See more details on using hashes here.

File details

Details for the file autodegen-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: autodegen-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for autodegen-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a05b3625c9e06a3c9f755968c0786f563546e3970136824ad0eb785bb0f8a389
MD5 55b4462501e884db95178c30997ab89d
BLAKE2b-256 944e2301d649f2e5a46ad19e100e3e40ab8cb15dd3181983be32e3d22ee038d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page