Status: Advanced algorithmic trading system with AI-powered market analysis - enterprise-grade risk management and capital preservation focus.
A capital-preserving AI trading agent focused on steady, consistent returns through multi-tier asset allocation and robust risk management.
- Capital Preservation First: Never risk more than 2% per trade
- Steady Returns: Target 8-15% monthly returns through diversified strategies
- AI-Driven Decisions: Use LLMs for market analysis with confidence scoring
- Bulletproof Risk Management: Hard limits, circuit breakers, and real-time monitoring
- Foundation Layer (50%): BTC, ETH, SOL - Low risk, steady growth
- Growth Layer (30%): Top 20-100 altcoins - Medium risk, higher returns
- Opportunity Layer (20%): High-quality memecoins - High risk, asymmetric upside
See strategy.jsx and architecture.jsx for detailed strategy documentation.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Arbitra Trading System β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Data Feeds β β AI Engine β β Risk Manager β β
β β β β β β β β
β β β’ Helius ββ β β’ Gemini AI ββ β β’ Position β β
β β β’ Birdeye β β β’ Analysis β β Sizing β β
β β β’ DexScreenerβ β β’ Confidence β β β’ Stop Loss β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Execution Engine β β
β β β’ Jupiter Aggregator β β
β β β’ Wallet Management β β
β β β’ Transaction Monitoring β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Monitoring & Logging β β
β β β’ PostgreSQL (trades, metrics) β β
β β β’ Redis (state management) β β
β β β’ Prometheus/Grafana β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Language: Python 3.11+
- Framework: FastAPI (async trading operations)
- AI Models: Google Gemini (gemini-2.0-flash-exp, gemini-1.5-pro)
- Blockchain: Solana Web3.py
- Database: PostgreSQL 15+ (trade logs, analytics)
- Cache: Redis 7+ (real-time state)
- Vector DB: Pinecone (trade memory)
- Blockchain Data: Helius, QuickNode
- Market Data: Birdeye, DexScreener, CoinGecko
- DEX Aggregator: Jupiter API
- Token Analysis: RugCheck, Token Sniffer
- Containerization: Podman + Podman Compose (Docker-free alternative)
- Monitoring: Prometheus, Grafana
- Logging: Structlog
- Testing: Pytest, Hypothesis (property testing)
arbitra/
βββ README.md # This file
βββ architecture.jsx # System design reference
βββ strategy.jsx # Trading strategy reference
βββ podman-compose.yml # Infrastructure setup (Podman)
βββ requirements.txt # Python dependencies
βββ pyproject.toml # Project config
β
βββ src/
β βββ __init__.py
β β
β βββ risk/ # π΄ CRITICAL: Risk management
β β βββ __init__.py
β β βββ manager.py # Main risk manager
β β βββ position_sizing.py # Kelly criterion, position limits
β β βββ circuit_breaker.py # Emergency stop mechanisms
β β βββ portfolio.py # Portfolio-level risk
β β βββ validators.py # Pre-trade validation
β β
β βββ ai/ # AI decision engine
β β βββ __init__.py
β β βββ agent.py # Main AI agent
β β βββ prompts.py # LLM prompt templates
β β βββ confidence.py # Confidence scoring
β β βββ memory.py # Trade memory/learning
β β
β βββ data/ # Data collection
β β βββ __init__.py
β β βββ feeds.py # Data feed aggregator
β β βββ solana.py # Solana blockchain data
β β βββ market.py # Market data (prices, volume)
β β βββ social.py # Social sentiment
β β
β βββ execution/ # Trade execution
β β βββ __init__.py
β β βββ engine.py # Main execution engine
β β βββ jupiter.py # Jupiter DEX integration
β β βββ wallet.py # Wallet management
β β βββ monitor.py # Transaction monitoring
β β
β βββ strategies/ # Trading strategies
β β βββ __init__.py
β β βββ base.py # Base strategy class
β β βββ foundation.py # BTC/ETH/SOL strategies
β β βββ growth.py # Altcoin strategies
β β βββ opportunity.py # Memecoin strategies
β β
β βββ models/ # Data models
β β βββ __init__.py
β β βββ trade.py
β β βββ asset.py
β β βββ portfolio.py
β β
β βββ database/ # Database layer
β β βββ __init__.py
β β βββ postgres.py
β β βββ redis.py
β β βββ migrations/
β β
β βββ utils/ # Utilities
β βββ __init__.py
β βββ logging.py
β βββ metrics.py
β βββ config.py
β
βββ tests/
β βββ __init__.py
β βββ conftest.py # Pytest fixtures
β β
β βββ risk/ # Risk module tests
β β βββ test_manager.py
β β βββ test_position_sizing.py
β β βββ test_circuit_breaker.py
β β βββ test_portfolio.py
β β βββ test_validators.py
β β
β βββ ai/
β βββ data/
β βββ execution/
β βββ strategies/
β
βββ scripts/ # Utility scripts
β βββ backtest.py # Backtesting framework
β βββ paper_trade.py # Paper trading mode
β βββ deploy.sh # Deployment script
β
βββ config/ # Configuration files
β βββ config.yaml # Main config
β βββ strategies.yaml # Strategy parameters
β βββ risk.yaml # Risk limits
β
βββ docs/ # Documentation
βββ setup.md
βββ strategies.md
βββ risk-management.md
βββ api.md
Objective: Build bulletproof risk management and core infrastructure
-
Risk Management Module π΄ CRITICAL
- Position sizing (Kelly criterion)
- Stop-loss automation
- Portfolio-level limits
- Circuit breakers
- Pre-trade validation
- Status: In Progress
-
Database Setup
- PostgreSQL schema
- Redis configuration
- Database migrations
-
Basic Data Feeds
- Market data integration
- Price feeds
- Basic on-chain data
- β Risk module passes 100% of tests
- β Circuit breakers trigger correctly
- β Position sizing calculations verified
- β Database can handle 1000+ trades/day
- β Data feeds maintain <1s latency
Objective: Implement AI decision-making with confidence scoring using Google Gemini
-
AI Agent Core
- Google Gemini API integration (gemini-2.0-flash-exp for speed, gemini-1.5-pro for complex analysis)
- Prompt engineering for trading analysis
- Structured JSON output parsing
- Retry logic and error handling
-
Confidence Scoring
- Multi-factor confidence calculation (technical indicators, sentiment, risk factors)
- Historical accuracy tracking
- Confidence calibration against actual outcomes
- Dynamic confidence adjustment
-
Trade Memory
- Vector database setup (Pinecone)
- Similar trade retrieval using embeddings
- Learning from past trades
- Pattern recognition
- AI generates valid trade recommendations with >90% structural accuracy
- Confidence scores correlate with outcomes (RΒ² > 0.6)
- Memory system retrieves relevant trades (<500ms)
- Avg response time <2s for flash model, <5s for pro model
Objective: Implement low-risk BTC/ETH/SOL strategies
-
Mean Reversion
- Support/resistance detection
- RSI-based entries
- Take-profit automation
-
DCA & Accumulation
- Time-based buying
- Dip buying logic
- Cost averaging
-
Staking Integration
- Staking rewards tracking
- Auto-compounding
- Strategies tested on 6+ months historical data
- Win rate >60%
- Max drawdown <8%
- Sharpe ratio >1.5
Objective: Build reliable trade execution
-
Jupiter Integration
- Route optimization
- Slippage control
- Transaction retry logic
-
Wallet Management
- Secure key storage
- Multi-wallet support
- Balance tracking
-
Transaction Monitoring
- Confirmation tracking
- Failed transaction handling
- Gas optimization
- 99%+ transaction success rate
- <5s avg execution time
- Slippage <0.5% of target
Objective: Add medium-risk altcoin strategies
-
Momentum Trading
- Breakout detection
- Volume analysis
- Trend following
-
Sector Rotation
- Narrative tracking
- Sector strength analysis
- Rotation signals
-
Event-Driven
- Protocol launch tracking
- Partnership announcements
- Token unlock monitoring
- Strategy mix provides 10-20% monthly returns
- Correlation with BTC <0.7
- Individual strategy win rate >55%
Objective: Add high-risk memecoin strategies (ONLY if Phase 5 successful)
-
Token Safety Scanner
- Contract analysis
- Honeypot detection
- Liquidity verification
- Ownership analysis
-
Viral Momentum Detection
- Social signal processing
- Engagement velocity
- Influencer tracking
-
Quick Execution
- <500ms execution
- Aggressive take-profits
- 24-72hr max hold time
- Token scanner catches 95%+ scams
- Social signals predict pumps with >40% accuracy
- Even with 50% loss rate, net positive returns
- HARD RULE: Never hold >72 hours
Objective: Validate system with realistic simulation before live trading
-
Paper Trading Engine
- Real market data with simulated execution
- Realistic slippage and fees
- Stop-loss and take-profit automation
- Comprehensive performance tracking
-
Performance Analytics
- Win rate and profit factor
- Sharpe ratio and max drawdown
- Strategy comparison
- Risk metrics dashboard
-
Validation Framework
- Minimum 2 weeks continuous operation
- Performance benchmarks
- System stability testing
- Trade-by-trade analysis
- Minimum 2 weeks paper trading
- Win rate >55%
- Max drawdown <10%
- Sharpe ratio >1.2
- System uptime >99%
Objective: Build intuitive native macOS app for monitoring and control
-
Dashboard
- Real-time portfolio value
- Daily/total P/L
- Performance charts
- Position monitoring
-
Trade Management
- View active positions
- Manual trade execution
- Trade history
- Performance analytics
-
System Control
- Start/stop trading
- Emergency stop button
- Settings configuration
- Alert management
- Native Swift/SwiftUI implementation
- <100ms response time
- Real-time WebSocket updates
- Full dark mode support
- Keyboard shortcuts for power users
Objective: Continuous improvement and monitoring
-
Enhanced Monitoring
- Real-time P/L tracking
- Strategy performance comparison
- Risk metrics dashboard
- AI confidence calibration
-
Advanced Features
- Multi-model consensus (Flash + Pro)
- Market regime detection
- Correlation-based limits
- Dynamic position sizing
-
Safety Enhancements
- Portfolio rebalancing
- Sector concentration limits
- Time-based restrictions
- Recovery mode after losses
-
Alerting
- Circuit breaker triggers
- Large losses
- System errors
- Performance degradation
# Per-Trade Limits
max_position_size_pct: 2.0 # % of portfolio per trade
max_portfolio_risk_pct: 10.0 # % of portfolio at risk
stop_loss_pct: 5.0 # Stop loss from entry
# Portfolio Limits
max_daily_loss_pct: 5.0 # Daily loss limit
max_weekly_loss_pct: 10.0 # Weekly loss limit
max_drawdown_pct: 15.0 # Max drawdown before pause
# Asset-Specific Limits
foundation_max_pct: 60.0 # Max in BTC/ETH/SOL
growth_max_pct: 40.0 # Max in altcoins
opportunity_max_pct: 20.0 # Max in memecoins
# Memecoin-Specific
memecoin_max_hold_hours: 72 # NEVER exceed
memecoin_min_liquidity: 100000 # Min $100k liquidity
memecoin_max_position: 1.0 # Max 1% per memecoin- Daily Loss Breaker: Stop trading if daily loss >5%
- Drawdown Breaker: Pause if drawdown >15%
- Volatility Breaker: Reduce size if VIX equivalent >100
- Liquidity Breaker: No trades if liquidity <$50k
- API Failure Breaker: Stop if data feeds fail
- Target Return: 5-8% monthly
- Max Drawdown: <8%
- Win Rate: >60%
- Sharpe Ratio: >1.5
- Target Return: 10-15% monthly
- Max Drawdown: <12%
- Win Rate: >55%
- Sharpe Ratio: >1.3
- Target Return: 15-25% monthly
- Max Drawdown: <15%
- Win Rate: >50%
- Sharpe Ratio: >1.2
- 100% coverage for risk module
- Property-based testing (Hypothesis)
- Edge case validation
- End-to-end trade flow
- API integration tests
- Database transaction tests
- 12+ months historical data
- Multiple market conditions
- Walk-forward validation
- Minimum 2 weeks before live
- Real-time execution testing
- Risk validation
- Encrypted wallet keys (KMS)
- API key rotation
- Rate limiting
- Audit logging
- No secrets in code
- Regular security audits
- Daily/Weekly/Monthly P&L
- Win rate by strategy
- Average win/loss
- Sharpe ratio
- Max drawdown
- Recovery time
- Position sizes
- Portfolio exposure
- Correlation matrix
- VaR (Value at Risk)
- Circuit breaker triggers
- API latency
- Transaction success rate
- Data feed uptime
- Error rates
- Memory/CPU usage
# Required
- Python 3.11+
- Podman & Podman Compose (Docker-free alternative)
OR native PostgreSQL 15+ and Redis 7+ installed locally
# Optional
- Solana CLI (for testing)
- Prometheus/Grafana (monitoring)Note: This project uses Podman instead of Docker. Podman is daemonless, rootless, and doesn't require elevated privileges. If you can't use containers at all, see the "Local Installation" section below.
# 1. Clone repository
git clone <repo-url>
cd arbitra
# 2. Set up Python environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
pip install -e . # Install in editable mode
# 4. Set up infrastructure (choose one option)
## Option A: Using Podman (recommended)
podman-compose up -d
## Option B: Local installation (no containers)
# Install PostgreSQL
brew install postgresql@15 # macOS
brew services start postgresql@15
# Install Redis
brew install redis
brew services start redis
# 5. Run database migrations (skip if using Option B initially)
# python scripts/migrate.py
# 6. Configure environment
cp config/config.example.yaml config/config.yaml
# Edit config.yaml with your API keys and database connection strings
# 7. Run tests (no infrastructure needed for unit tests)
pytest tests/risk/ -v --cov=src/risk# Run in paper trading mode
python scripts/paper_trade.py
# Run backtests
python scripts/backtest.py --start 2024-01-01 --end 2024-12-31
# Start live trading (after paper trading success)
python main.py --mode live- Installation Guide - Detailed setup options (Podman, local, or no infrastructure)
- Quick Start - Get up and running fast
- AI Engine - Google Gemini integration guide
- Phase 2 Testing - Complete test results and coverage report
- Trading Strategies
- Risk Management
- API Documentation
- Enhancement Summary - β START HERE - Complete overview of 30+ improvements
- Full Enhancement Guide - Detailed implementation guide with code examples
- Quick Enhancements - TL;DR reference and quick wins
- No Financial Advice: This is experimental software. Use at your own risk.
- Capital Loss Risk: Crypto trading involves significant risk of capital loss.
- No Guarantees: Past performance doesn't guarantee future results.
- Beta Software: This system is under active development.
See CONTRIBUTING.md for development guidelines.
MIT License - see LICENSE
Phase: 2 (AI Engine) β
COMPLETE
Test Coverage: 95% overall (99 tests, 100% passing)
Completed:
- β Phase 1 - Risk Management Module (100% test coverage, 62 tests)
- β
Phase 2 - AI Engine with Google Gemini (95% coverage, 37 tests)
- Trading agent with dual-model approach (Flash/Pro)
- Confidence scoring with Brier calibration
- Vector memory with Pinecone for pattern matching
Next Milestone: Phase 3 - Trading Strategies (Foundation layer: BTC/ETH/SOL)
Last Updated: October 8, 2025
- π Foundation layer implementation (BTC, ETH, SOL)
- π Strategy backtesting framework
- π Paper trading mode
- π Performance metrics and reporting
- π Jupiter aggregator integration
- π Wallet management and security
- π Transaction monitoring and logging
- π Slippage and MEV protection
- π Real-time price feeds (Helius, Birdeye, DexScreener)
- π On-chain analytics integration
- π Market sentiment analysis
- π Historical data management
- π Live trading with small capital
- π Monitoring and alerting (Grafana, Prometheus)
- π Database integration (PostgreSQL, Redis)
- π API endpoints for monitoring
- π Multi-strategy portfolio optimization
- π Automated rebalancing
- π Social trading features
- π Advanced risk analytics
- Capital Preservation: Max 2% loss per trade, <10% monthly drawdown
- Returns: Target 8-15% monthly with Sharpe ratio >1.5
- Win Rate: >55% profitable trades
- Uptime: >99% system availability
- Response Time: <100ms trade execution
- β Robust Risk Management: 100% test coverage with bulletproof position sizing and circuit breakers
- β AI-Powered Trading Engine: Google Gemini dual-model integration achieving 95% structural accuracy
- β Advanced Memory System: Vector database implementation with Pinecone for trade pattern recognition
- β Comprehensive Testing: 99 tests with 95% overall coverage ensuring production reliability
- β Multi-Asset Framework: Foundation for BTC/ETH/SOL, altcoins, and high-opportunity memecoin strategies
- β Confidence Calibration: Brier score-based AI confidence scoring with historical accuracy tracking
- β Capital Preservation: Never-exceed 2% per trade with automated stop-loss and drawdown protection
- November 2024: Completed Phase 2 AI Engine with dual Gemini model approach (Flash/Pro)
- October 2024: Achieved 100% risk management test coverage with Kelly criterion position sizing
- September 2024: Implemented vector memory system for trade pattern learning and optimization
- August 2024: Established foundation architecture with PostgreSQL, Redis, and Podman infrastructure
- Production Deployment: Live trading with small capital and real-time performance validation
- Advanced Strategies: Multi-tier asset allocation with sector rotation and momentum detection
- MEV Protection: Sandwich attack prevention and optimal routing through Jupiter aggregator
- Portfolio Optimization: Dynamic rebalancing with correlation-based position limits
- Cross-Chain Integration: Ethereum, BSC, and Polygon support with unified risk management
- Social Trading Features: Copy trading, strategy sharing, and community performance tracking
- Advanced Analytics: Sharpe ratio optimization, VaR modeling, and stress testing frameworks
- Mobile Application: Native iOS app for real-time monitoring and emergency controls
- Institutional Platform: Multi-user support with team management and compliance reporting
- API Marketplace: Third-party strategy integration and algorithmic trading infrastructure
- Regulatory Compliance: KYC/AML integration and institutional-grade security protocols
- Machine Learning Evolution: Adaptive AI models that improve from market regime changes
- Global Expansion: Multi-language support and regional compliance frameworks
Transform arbitra into the industry's most trusted AI-driven crypto trading platform, democratizing sophisticated trading strategies while maintaining uncompromising capital preservation standards. Target: $100M+ in managed assets and partnerships with major crypto institutions by 2027.
- Not Financial Advice: This is an educational/research project
- High Risk: Crypto trading carries significant risk of loss
- Use at Your Own Risk: No guarantees of profitability
- Start Small: Test with capital you can afford to lose
- Regulatory Compliance: Ensure compliance with local laws