folder stricture reorganize
This commit is contained in:
83
tests/test_enhanced_rl_fix.py
Normal file
83
tests/test_enhanced_rl_fix.py
Normal file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test Enhanced RL Fix - Verify comprehensive state building and reward calculation
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
project_root = Path(__file__).parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
def test_enhanced_orchestrator():
|
||||
"""Test enhanced orchestrator methods"""
|
||||
print("=== TESTING ENHANCED RL FIXES ===")
|
||||
|
||||
try:
|
||||
from core.enhanced_orchestrator import EnhancedTradingOrchestrator
|
||||
from core.data_provider import DataProvider
|
||||
print("✓ Enhanced orchestrator imported successfully")
|
||||
|
||||
# Create orchestrator with enhanced RL enabled
|
||||
dp = DataProvider()
|
||||
eo = EnhancedTradingOrchestrator(
|
||||
data_provider=dp,
|
||||
enhanced_rl_training=True,
|
||||
symbols=['ETH/USDT', 'BTC/USDT']
|
||||
)
|
||||
print("✓ Enhanced orchestrator created")
|
||||
|
||||
# Test method availability
|
||||
methods = ['build_comprehensive_rl_state', 'calculate_enhanced_pivot_reward', '_get_symbol_correlation']
|
||||
print("\nMethod availability:")
|
||||
for method in methods:
|
||||
available = hasattr(eo, method)
|
||||
print(f" {method}: {'✓' if available else '✗'}")
|
||||
|
||||
# Test comprehensive state building
|
||||
print("\nTesting comprehensive state building...")
|
||||
state = eo.build_comprehensive_rl_state('ETH/USDT')
|
||||
if state is not None:
|
||||
print(f"✓ Comprehensive state built: {len(state)} features")
|
||||
print(f" State type: {type(state)}")
|
||||
print(f" State shape: {state.shape if hasattr(state, 'shape') else 'No shape'}")
|
||||
else:
|
||||
print("✗ Comprehensive state returned None")
|
||||
|
||||
# Debug why state is None
|
||||
print("\nDEBUGGING STATE BUILDING...")
|
||||
print(f" Williams enabled: {hasattr(eo, 'williams_enabled')}")
|
||||
print(f" COB integration active: {hasattr(eo, 'cob_integration_active')}")
|
||||
print(f" Enhanced RL training: {getattr(eo, 'enhanced_rl_training', 'Not set')}")
|
||||
|
||||
# Test enhanced reward calculation
|
||||
print("\nTesting enhanced reward calculation...")
|
||||
trade_decision = {
|
||||
'action': 'BUY',
|
||||
'confidence': 0.75,
|
||||
'price': 2500.0,
|
||||
'timestamp': '2023-01-01 00:00:00'
|
||||
}
|
||||
trade_outcome = {
|
||||
'net_pnl': 50.0,
|
||||
'exit_price': 2550.0,
|
||||
'duration': '00:15:00'
|
||||
}
|
||||
market_data = {'symbol': 'ETH/USDT'}
|
||||
|
||||
try:
|
||||
reward = eo.calculate_enhanced_pivot_reward(trade_decision, market_data, trade_outcome)
|
||||
print(f"✓ Enhanced reward calculated: {reward}")
|
||||
except Exception as e:
|
||||
print(f"✗ Enhanced reward failed: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
print("\n=== TEST COMPLETE ===")
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Test failed: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_enhanced_orchestrator()
|
Reference in New Issue
Block a user