gogo2/test_indicators.py
Dobromir Popov b181d11923 new_2
2025-05-24 02:15:25 +03:00

82 lines
3.4 KiB
Python

#!/usr/bin/env python3
"""
Test script for enhanced technical indicators
"""
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
from core.config import setup_logging
from core.data_provider import DataProvider
def main():
setup_logging()
print("Testing Enhanced Technical Indicators")
print("=" * 50)
# Initialize data provider
dp = DataProvider(['ETH/USDT', 'BTC/USDT'], ['1m', '1h', '4h', '1d'])
# Test with fresh data
print("Fetching fresh data with all indicators...")
df = dp.get_historical_data('ETH/USDT', '1h', refresh=True, limit=100)
if df is not None:
print(f"Data shape: {df.shape}")
print(f"Total columns: {len(df.columns)}")
print("\nAvailable indicators:")
# Categorize indicators
basic_cols = ['timestamp', 'open', 'high', 'low', 'close', 'volume']
indicator_cols = [col for col in df.columns if col not in basic_cols]
print(f" Basic OHLCV: {len(basic_cols)} columns")
print(f" Technical indicators: {len(indicator_cols)} columns")
# Group indicators by type
trend_indicators = [col for col in indicator_cols if any(x in col.lower() for x in ['sma', 'ema', 'macd', 'adx', 'psar'])]
momentum_indicators = [col for col in indicator_cols if any(x in col.lower() for x in ['rsi', 'stoch', 'williams', 'cci'])]
volatility_indicators = [col for col in indicator_cols if any(x in col.lower() for x in ['bb_', 'atr', 'keltner'])]
volume_indicators = [col for col in indicator_cols if any(x in col.lower() for x in ['volume', 'obv', 'vpt', 'mfi', 'ad_line', 'vwap'])]
custom_indicators = [col for col in indicator_cols if any(x in col.lower() for x in ['trend_strength', 'momentum_composite', 'volatility_regime', 'price_position'])]
print(f"\nIndicator breakdown:")
print(f" Trend: {len(trend_indicators)} - {trend_indicators}")
print(f" Momentum: {len(momentum_indicators)} - {momentum_indicators}")
print(f" Volatility: {len(volatility_indicators)} - {volatility_indicators}")
print(f" Volume: {len(volume_indicators)} - {volume_indicators}")
print(f" Custom: {len(custom_indicators)} - {custom_indicators}")
# Test feature matrix creation
print("\nTesting multi-timeframe feature matrix...")
feature_matrix = dp.get_feature_matrix('ETH/USDT', ['1h', '4h'], window_size=20)
if feature_matrix is not None:
print(f"Feature matrix shape: {feature_matrix.shape}")
print(f" Timeframes: {feature_matrix.shape[0]}")
print(f" Window size: {feature_matrix.shape[1]}")
print(f" Features: {feature_matrix.shape[2]}")
else:
print("Failed to create feature matrix")
# Test multi-symbol feature matrix
print("\nTesting multi-symbol feature matrix...")
multi_symbol_matrix = dp.get_multi_symbol_feature_matrix(['ETH/USDT'], ['1h'], window_size=20)
if multi_symbol_matrix is not None:
print(f"Multi-symbol matrix shape: {multi_symbol_matrix.shape}")
else:
print("Failed to create multi-symbol feature matrix")
print("\n✅ All tests completed successfully!")
else:
print("❌ Failed to fetch data")
if __name__ == "__main__":
main()