This guide will help you migrate from ForexSmartBot v3.0.0 to v3.1.0.
v3.1.0 is backward compatible with v3.0.0. Your existing code will continue to work without changes. New features are opt-in.
pip install -r requirements.txtThis will install new optional dependencies:
- TensorFlow (for LSTM)
- PyTorch (for deep learning)
- Transformers (for transformer models)
- Gymnasium & Stable-Baselines3 (for RL)
- Optuna (for hyperparameter optimization)
- DEAP (for genetic algorithms)
from forexsmartbot.strategies import list_strategies
print(list_strategies())You should see new strategies like:
LSTM_StrategySVM_StrategyEnsemble_ML_StrategyTransformer_StrategyRL_StrategyMulti_Timeframe
Your existing code will work as-is:
# This still works exactly as before
from forexsmartbot.strategies import get_strategy
strategy = get_strategy('SMA_Crossover', fast_period=20, slow_period=50)# Old way (still works)
strategy = get_strategy('ML_Adaptive_SuperTrend')
# New way (optional)
strategy = get_strategy('LSTM_Strategy', lookback_period=60)
strategy = get_strategy('Ensemble_ML_Strategy', n_estimators=100)# New feature - optimize your existing strategies
from forexsmartbot.optimization import GeneticOptimizer
param_bounds = {
'fast_period': (10, 30),
'slow_period': (40, 80)
}
optimizer = GeneticOptimizer(param_bounds)
best_params, fitness = optimizer.optimize(fitness_function)# New feature - monitor strategy health
from forexsmartbot.monitoring import StrategyMonitor
monitor = StrategyMonitor()
monitor.register_strategy("MyStrategy")
monitor.record_signal("MyStrategy", execution_time=0.1)- ✅ Existing strategies work without changes
- ✅ Existing backtests work without changes
- ✅ Existing UI code works without changes
- ✅ Configuration files remain compatible
- Install new dependencies (if using ML strategies)
- Update strategy selection to include ML strategies
- Add optimization workflow
- Integrate monitoring system
- Use strategy builder for custom strategies
No changes required. Your code continues to work:
# v3.0.0 code - still works in v3.1.0
from forexsmartbot.strategies import get_strategy
from forexsmartbot.services.backtest import BacktestService
from forexsmartbot.adapters.data import YFinanceProvider
strategy = get_strategy('SMA_Crossover', fast_period=20, slow_period=50)
service = BacktestService(YFinanceProvider())
results = service.run_backtest(strategy, 'EURUSD=X', '2023-01-01', '2023-12-31')Optional enhancement:
# New in v3.1.0
strategy = get_strategy('Ensemble_ML_Strategy',
lookback_period=50,
n_estimators=100
)New feature:
# v3.0.0: Manual parameter tuning
strategy = get_strategy('SMA_Crossover', fast_period=20, slow_period=50)
# v3.1.0: Automated optimization
from forexsmartbot.optimization import GeneticOptimizer
def fitness(params):
strategy = get_strategy('SMA_Crossover', **params)
# ... run backtest and return Sharpe ratio ...
return sharpe_ratio
optimizer = GeneticOptimizer({'fast_period': (10, 30), 'slow_period': (40, 80)})
best_params, _ = optimizer.optimize(fitness)
strategy = get_strategy('SMA_Crossover', **best_params)New feature:
# v3.0.0: No monitoring
# Just run strategies
# v3.1.0: Add monitoring
from forexsmartbot.monitoring import StrategyMonitor, HealthChecker
monitor = StrategyMonitor()
monitor.register_strategy("MyStrategy")
# In your trading loop
monitor.record_signal("MyStrategy", execution_time=0.1)
# Check health
health_checker = HealthChecker(monitor)
health = health_checker.check("MyStrategy")Symptom: Import errors for ML strategies
Solution:
pip install tensorflow torch transformers gymnasium stable-baselines3 optuna deapSymptom: ValueError: Unknown strategy: LSTM_Strategy
Solution: Check if dependencies are installed. Strategies are conditionally loaded:
from forexsmartbot.strategies import STRATEGIES
print('LSTM_Strategy' in STRATEGIES) # Should be True if TensorFlow installedSymptom: Slower execution with ML strategies
Solution: ML strategies require more computation. Consider:
- Using simpler strategies for real-time trading
- Running ML strategies on separate threads
- Using optimization tools during development, not production
# Run your existing code
# Should work without any changesfrom forexsmartbot.strategies import list_strategies
from forexsmartbot.optimization import GeneticOptimizer
from forexsmartbot.monitoring import StrategyMonitor
# Should not raise errors
strategies = list_strategies()
print(f"Available strategies: {len(strategies)}")try:
from forexsmartbot.strategies import get_strategy
strategy = get_strategy('LSTM_Strategy')
print("✓ ML strategies available")
except (ImportError, ValueError):
print("⚠ ML strategies require additional dependencies")- Read Quick Start:
docs/QUICK_START_V3.1.0.md - Try Examples:
examples/comprehensive_example.py - Explore Features: Review
docs/V3.1.0_FEATURES.md - Optimize Strategies: Use
scripts/optimize_strategy.py
If you encounter issues:
- Check dependencies:
pip list | grep -E "tensorflow|torch|optuna|deap" - Review error messages
- Check documentation:
docs/QUICK_START_V3.1.0.md - Review examples:
examples/
Once you've:
- ✅ Installed new dependencies (optional)
- ✅ Verified existing code works
- ✅ Tried new features (optional)
You're ready to use v3.1.0!
Remember: v3.1.0 is backward compatible. You can migrate gradually, using new features as needed.