SableAI is a comprehensive Domain-Driven Design (DDD) framework for translating TradingView Pine Script strategies into Python code and running professional-grade backtests across multiple data sources. This framework implements the RBI method (Research, Backtest, Implement) with enterprise-grade architecture.
- Pine Script Translation - Convert TradingView Pine Script to Python
- Multi-Data Source Testing - Test across 25+ data sources and timeframes
- AI-Powered Strategy Generation - Natural language to code conversion
- Professional Data Access - OpenBB integration for enhanced financial data
- Concurrent Session Management - Cipher-BT integration for advanced trading
- Technical Analysis - BTA-Lib integration with 100+ indicators
- Domain-Driven Design - Clean, maintainable, enterprise-grade architecture
- Risk Management - Advanced risk controls and position sizing
- Performance Analysis - Comprehensive metrics and reporting
SableAI/
βββ domain_models.py # Core domain models and value objects
βββ domain_services.py # Domain services for business logic
βββ technical_analysis_service.py # BTA-Lib technical analysis service
βββ bta_integration.py # BTA-Lib integration
βββ bta_launcher.py # BTA-Lib command-line interface
βββ pinescript_translator.py # Pine Script to Python translator
βββ multi_data_backtester.py # Multi-data source backtesting framework
βββ tsa_enhanced_strategy.py # TSA Enhanced Strategy implementation
βββ strategy_launcher.py # Main launcher and orchestration
βββ results_analyzer.py # Results analysis and visualization
βββ openbb_integration.py # OpenBB integration for enhanced data
βββ openbb_launcher.py # Enhanced launcher with OpenBB
βββ openbb_example.py # OpenBB integration examples
βββ cipher_integration.py # Cipher-BT integration for concurrent sessions
βββ cipher_launcher.py # Enhanced launcher with Cipher-BT
βββ cipher_example.py # Cipher-BT integration examples
βββ backtestsh_integration.py # Backtest.sh AI integration
βββ backtestsh_launcher.py # AI-powered strategy launcher
βββ backtestsh_example.py # AI strategy generation examples
βββ example_usage.py # Comprehensive usage examples
βββ test_system.py # System testing
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore file
βββ LICENSE # MIT License
βββ OPENBB_SETUP.md # OpenBB integration setup guide
βββ CIPHER_SETUP.md # Cipher-BT integration setup guide
βββ BACKTESTSH_SETUP.md # Backtest.sh AI integration setup guide
βββ SYSTEM_SUMMARY.md # Complete system summary
βββ README.md # This file
git clone https://github.com/yourusername/ScypherAI.git
cd SableAIpip install -r requirements.txt# On Windows
pip install TA-Lib
# On macOS
brew install ta-lib
pip install TA-Lib
# On Linux
sudo apt-get install libta-lib-dev
pip install TA-Libpip install openbb
# Or with all extensions
pip install "openbb[all]"pip install cipher-bt
# Or with all extensions
pip install "cipher-bt[finplot,talib]"pip install openai
# Set OpenAI API key
export OPENAI_API_KEY="your-api-key-here"from pinescript_translator import PineScriptTranslator
translator = PineScriptTranslator()
python_code = translator.translate_to_python(pinescript_code)from strategy_launcher import StrategyLauncher
launcher = StrategyLauncher()
results = launcher.run_tsa_enhanced_backtest(
symbol="BTC-USD",
timeframe="1d",
start_date="2020-01-01",
end_date="2024-01-01"
)results = launcher.run_comprehensive_backtest(
strategy_params={'atr_length': 14, 'atr_multiplier': 3.0},
max_workers=4
)from backtestsh_launcher import BacktestSHAILauncher
ai_launcher = BacktestSHAILauncher()
result = ai_launcher.run_ai_strategy_generation(
description="Buy when RSI < 30, sell when RSI > 70",
symbol="BTC-USD",
strategy_type="mean_reversion"
)from bta_launcher import BTALauncher
bta_launcher = BTALauncher()
results = bta_launcher.run_enhanced_backtest(
strategy, market_data, Money(Decimal('10000'), "USD")
)# Run comprehensive backtest
python strategy_launcher.py --mode comprehensive --workers 4
# Run single backtest
python strategy_launcher.py --mode single --symbol BTC-USD --timeframe 1d
# Translate Pine Script
python strategy_launcher.py --mode translate --pinescript-file strategy.pine# Run OpenBB demo
python openbb_launcher.py --mode demo
# Single enhanced backtest
python openbb_launcher.py --mode single --symbol AAPL --market-type equity
# Comprehensive enhanced backtest
python openbb_launcher.py --mode comprehensive# Run Cipher-BT demo
python cipher_launcher.py --mode demo
# Single backtest with concurrent sessions
python cipher_launcher.py --mode single --symbol BTCUSDT --interval 1h
# Multi-symbol backtest
python cipher_launcher.py --mode multi --symbols BTCUSDT ETHUSDT ADAUSDT# Run AI demo
python backtestsh_launcher.py --mode demo
# Generate strategy from description
python backtestsh_launcher.py --mode generate --description "Your strategy here" --symbol BTC-USD
# Run AI backtest
python backtestsh_launcher.py --mode backtest --description "Moving average crossover" --symbol AAPL# Run BTA-Lib demo
python bta_launcher.py --mode demo
# Enhanced backtest with technical analysis
python bta_launcher.py --mode backtest --strategy tsa_enhanced --symbol BTC-USD
# Compare strategies
python bta_launcher.py --mode compare --symbol BTC-USD- Strategy - Trading strategy entities
- Trade - Individual trade execution
- Portfolio - Portfolio management
- MarketData - Market data entities
- BacktestResults - Backtest results
- Money - Monetary amounts with currency
- Price - Price with currency validation
- Quantity - Trade quantities
- Percentage - Percentage calculations
- Timeframe - Time frame validation
- RiskManager - Risk management logic
- StrategyAnalyzer - Strategy analysis
- BacktestExecutor - Backtest execution
- TechnicalIndicatorService - Technical analysis
- Professional-grade financial data
- Technical indicators (RSI, MACD, Bollinger Bands, ATR, ADX)
- Market sentiment analysis
- Fundamental data access
- Real-time data integration
- Multiple concurrent trading sessions
- Sophisticated exit strategies
- Multi-exchange data sources
- Built-in visualization
- Advanced session management
- AI-powered strategy generation
- Natural language to code conversion
- OpenAI GPT-3.5-turbo integration
- Batch strategy generation
- Strategy enhancement
- Comprehensive technical analysis
- 100+ technical indicators
- Pandas-based calculations
- Performance optimized
- Backtrader ecosystem integration
- 25+ Data Sources across multiple timeframes
- Parallel Processing for fast execution
- Comprehensive Results collection
- Statistical Analysis across markets
- Position Sizing based on risk parameters
- Stop Loss and Take Profit mechanisms
- Portfolio Risk analysis
- Correlation Analysis between positions
- Drawdown Protection
- Net Profit and Total Return
- Win Rate and Profit Factor
- Sharpe Ratio and Sortino Ratio
- Maximum Drawdown analysis
- Expectancy calculations
- Trade Analysis and statistics
- Convert Pine Script strategies to Python
- Test across multiple data sources
- Analyze performance metrics
- Compare strategy variations
- Generate strategies from natural language
- Enhance existing strategies with AI
- Batch process multiple strategies
- Automated strategy optimization
- Enterprise-grade backtesting
- Risk management systems
- Portfolio optimization
- Performance monitoring
- Learn algorithmic trading
- Understand strategy development
- Study market behavior
- Practice risk management
- README.md - This file
- OPENBB_SETUP.md - OpenBB integration setup
- CIPHER_SETUP.md - Cipher-BT integration setup
- BACKTESTSH_SETUP.md - Backtest.sh AI setup
- SYSTEM_SUMMARY.md - Complete system overview
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- TradingView for Pine Script platform
- OpenBB for professional financial data
- Cipher-BT for concurrent session management
- BTA-Lib for technical analysis
- Backtest.sh for AI-powered strategy generation
- Install the framework - Follow the installation guide
- Run tests -
python test_system.py - Try examples -
python example_usage.py - Translate your Pine Script - Use the translator
- Run comprehensive backtests - Test across multiple data sources
- Analyze results - Use the analysis tools
- Deploy professionally - Use OpenBB and Cipher-BT for production
This framework transforms your Pine Script strategies into a professional-grade Python backtesting system with access to the best financial data and analysis tools available! π