python scripts/validate_installation.pyThis will check:
- All modules are importable
- Dependencies are installed
- Strategies are available
- Tools are functional
Cause: TensorFlow not installed
Solution:
pip install tensorflowNote: Only needed for LSTM strategies
Cause: Optuna not installed
Solution:
pip install optunaNote: Only needed for hyperparameter optimization
Cause: DEAP not installed
Solution:
pip install deapNote: Only needed for genetic algorithm optimization
Cause: Module not found
Solution: Check Python path and ensure you're in the project directory
Possible Causes:
- Dependencies not installed (TensorFlow)
- Strategy not in registry
- Import error in strategy file
Solutions:
# Check if strategy is available
from forexsmartbot.strategies import STRATEGIES
print('LSTM_Strategy' in STRATEGIES) # Should be True
# Check dependencies
try:
import tensorflow
print("TensorFlow installed")
except ImportError:
print("Install TensorFlow: pip install tensorflow")Possible Causes:
- Insufficient data (< 200 samples)
- Training failed silently
- Prediction threshold too high
Solutions:
# Check data length
print(f"Data length: {len(df)}")
# Check if trained
print(f"Is trained: {strategy._is_trained}")
# Check prediction threshold
print(f"Threshold: {strategy._prediction_threshold}")
# Ensure enough data
if len(df) < strategy._min_samples:
print(f"Need at least {strategy._min_samples} samples")Possible Causes:
- Parameter bounds too narrow
- Fitness function not sensitive
- Not enough generations/trials
- Stuck in local optimum
Solutions:
# Widen parameter bounds
param_bounds = {
'fast_period': (5, 50), # Wider range
'slow_period': (20, 100)
}
# Increase generations
optimizer = GeneticOptimizer(
param_bounds,
population_size=100, # Larger population
generations=50 # More generations
)
# Check fitness function
def fitness(params):
# Ensure function is sensitive to parameters
result = run_backtest(params)
return result # Should vary with paramsSolutions:
# Reduce population size
optimizer = GeneticOptimizer(
param_bounds,
population_size=20, # Smaller
generations=10 # Fewer
)
# Use smaller dataset for optimization
results = backtest_service.run_backtest(
strategy, symbol, '2023-01-01', '2023-06-30' # Shorter period
)Cause: Data provider can't fetch data
Solutions:
# Check data provider
data_provider = YFinanceProvider()
df = data_provider.get_data('EURUSD=X', '2023-01-01', '2023-12-31', '1h')
print(f"Data fetched: {len(df)} rows")
# Try different symbol format
# Some providers need 'EURUSD=X', others need 'EURUSD'
# Check date format
# Use 'YYYY-MM-DD' formatCause: Data format issue
Solutions:
# Check column names
print(df.columns)
# Ensure proper case
df.columns = df.columns.str.title()
# Check for required columns
required = ['Open', 'High', 'Low', 'Close']
missing = [col for col in required if col not in df.columns]
if missing:
print(f"Missing columns: {missing}")Possible Causes:
- Large dataset
- ML strategies training
- Complex calculations
Solutions:
# Use smaller dataset
df = df.tail(1000) # Last 1000 rows
# Disable ML training for quick tests
# Use simpler strategies
# Use parallel processing
service = EnhancedBacktestService(
data_provider,
use_parallel=True,
max_workers=4
)Solutions:
# Process data in chunks
for chunk in pd.read_csv('data.csv', chunksize=1000):
process(chunk)
# Clear cache
import gc
gc.collect()
# Use simpler strategies
# ML strategies use more memoryCause: No signals recorded
Solutions:
# Ensure signals are being recorded
monitor.record_signal("MyStrategy", execution_time=0.1)
# Check registration
monitor.register_strategy("MyStrategy")
# Check health after recording
health = monitor.get_health("MyStrategy")
print(health.status)Cause: No trades recorded
Solutions:
# Record trades
tracker.record_trade("MyStrategy", {
'profit': 100.0,
'entry_price': 1.1000,
'exit_price': 1.1100,
'entry_time': datetime.now(),
'exit_time': datetime.now()
})
# Calculate metrics
metrics = tracker.calculate_metrics("MyStrategy")Cause: Invalid component connections
Solutions:
# Validate strategy before generating
is_valid, errors = builder.validate_strategy()
if not is_valid:
print(f"Errors: {errors}")
# Fix errors before generating code
# Check component connections
structure = builder.get_strategy_structure()
for comp_id, comp_data in structure['components'].items():
print(f"{comp_id}: {comp_data['connections']}")Cause: Permission or path issue
Solutions:
# Check storage path
marketplace = StrategyMarketplace(storage_path="marketplace")
print(f"Storage path: {marketplace.storage_path}")
# Check permissions
import os
print(f"Writable: {os.access(marketplace.storage_path, os.W_OK)}")
# Use absolute path
marketplace = StrategyMarketplace(storage_path="/absolute/path/marketplace")import logging
logging.basicConfig(level=logging.DEBUG)
# Or for specific module
logger = logging.getLogger('forexsmartbot')
logger.setLevel(logging.DEBUG)# Check strategy parameters
print(strategy.params)
# Check if trained (for ML)
if hasattr(strategy, '_is_trained'):
print(f"Trained: {strategy._is_trained}")
# Check model (for ML)
if hasattr(strategy, '_model'):
print(f"Model: {strategy._model is not None}")# Check data quality
print(f"Rows: {len(df)}")
print(f"NaN values: {df.isna().sum().sum()}")
print(f"Columns: {df.columns.tolist()}")
print(f"Date range: {df.index.min()} to {df.index.max()}")# Test strategy indicators
df_with_indicators = strategy.indicators(df)
print(df_with_indicators.columns)
# Test signal generation
signal = strategy.signal(df_with_indicators)
print(f"Signal: {signal}")
# Test volatility
volatility = strategy.volatility(df_with_indicators)
print(f"Volatility: {volatility}")python scripts/validate_installation.py- Quick Start:
docs/QUICK_START_V3.1.0.md - FAQ:
docs/FAQ.md - Quick Reference:
docs/QUICK_REFERENCE.md
- Comprehensive:
examples/comprehensive_example.py - Integration:
examples/integration_example.py
- Look for error messages
- Check execution traces
- Review performance metrics
# Test minimal case
strategy = get_strategy('SMA_Crossover', fast_period=20, slow_period=50)
print(f"Strategy created: {strategy.name}")
# Test with minimal data
import pandas as pd
df = pd.DataFrame({
'Open': [1.0, 1.1, 1.2],
'High': [1.1, 1.2, 1.3],
'Low': [0.9, 1.0, 1.1],
'Close': [1.05, 1.15, 1.25]
})
df = strategy.indicators(df)
signal = strategy.signal(df)
print(f"Signal: {signal}")| Error | Meaning | Solution |
|---|---|---|
ModuleNotFoundError |
Dependency missing | Install with pip |
ValueError: Unknown strategy |
Strategy not in registry | Check dependencies or strategy name |
KeyError: 'Close' |
Data format issue | Check column names |
No data available |
Data fetch failed | Check symbol, dates, data provider |
Training error |
ML training failed | Check data quality and quantity |
Optimization timeout |
Too slow | Reduce parameters or dataset |
- Reduce dataset size
- Use simpler strategies
- Disable ML training
- Use parallel processing
- Cache indicator calculations
- Process in chunks
- Use simpler strategies
- Clear cache regularly
- Reduce dataset size
- Close unused resources
- Reduce population size
- Fewer generations/trials
- Smaller parameter space
- Shorter backtest period
- Use faster fitness function
Still having issues? Check the FAQ (docs/FAQ.md) or review the examples.