85 lines
2.7 KiB
Python
85 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify all 5 pivot levels are being calculated
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import logging
|
|
|
|
# Add the project root to the Python path
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from core.data_provider import DataProvider
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def test_pivot_levels():
|
|
"""Test all 5 pivot levels calculation"""
|
|
try:
|
|
logger.info("Initializing DataProvider...")
|
|
data_provider = DataProvider()
|
|
|
|
# Wait for initial data to load
|
|
import time
|
|
time.sleep(3)
|
|
|
|
# Test pivot levels for ETH/USDT
|
|
symbol = 'ETH/USDT'
|
|
logger.info(f"\nTesting Williams pivot levels for {symbol}:")
|
|
|
|
# Get pivot levels
|
|
pivot_levels = data_provider.get_williams_pivot_levels(symbol, base_timeframe='1m', limit=5000)
|
|
|
|
if not pivot_levels:
|
|
logger.error(f" NO PIVOT LEVELS for {symbol}")
|
|
return False
|
|
|
|
logger.info(f" Found {len(pivot_levels)} pivot levels")
|
|
|
|
for level_num in sorted(pivot_levels.keys()):
|
|
trend_level = pivot_levels[level_num]
|
|
pivot_count = len(getattr(trend_level, 'pivot_points', []))
|
|
direction = getattr(trend_level, 'trend_direction', 'unknown')
|
|
strength = getattr(trend_level, 'trend_strength', 0.0)
|
|
|
|
logger.info(f" Level {level_num}: {pivot_count} pivots, {direction} ({strength:.1%})")
|
|
|
|
if pivot_count > 0:
|
|
# Show sample of pivot types
|
|
high_count = sum(1 for p in trend_level.pivot_points if getattr(p, 'pivot_type', '') == 'high')
|
|
low_count = sum(1 for p in trend_level.pivot_points if getattr(p, 'pivot_type', '') == 'low')
|
|
logger.info(f" High pivots: {high_count}, Low pivots: {low_count}")
|
|
|
|
# Check if we have all levels
|
|
expected_levels = {1, 2, 3, 4, 5}
|
|
actual_levels = set(pivot_levels.keys())
|
|
|
|
if expected_levels.issubset(actual_levels):
|
|
logger.info(" ALL 5 PIVOT LEVELS PRESENT!")
|
|
else:
|
|
missing = expected_levels - actual_levels
|
|
logger.warning(f" MISSING LEVELS: {missing}")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
logger.error(f"Test failed with error: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = test_pivot_levels()
|
|
if success:
|
|
print("\n🎉 Pivot levels test completed!")
|
|
else:
|
|
print("\n Pivot levels test failed!")
|
|
sys.exit(1)
|
|
|