diff --git a/components/charts.py b/components/charts.py index 4449e8f..0472465 100644 --- a/components/charts.py +++ b/components/charts.py @@ -31,7 +31,7 @@ def get_supported_symbols(): if candles: from database.operations import get_database_operations from utils.logger import get_logger - logger = get_logger("charts_symbols") + logger = get_logger("default_logger") try: db = get_database_operations(logger) @@ -52,7 +52,7 @@ def get_supported_timeframes(): if candles: from database.operations import get_database_operations from utils.logger import get_logger - logger = get_logger("charts_timeframes") + logger = get_logger("default_logger") try: db = get_database_operations(logger) @@ -109,7 +109,7 @@ def check_data_availability(symbol: str, timeframe: str): from utils.logger import get_logger try: - logger = get_logger("charts_data_check") + logger = get_logger("default_logger") db = get_database_operations(logger) latest_candle = db.market_data.get_latest_candle(symbol, timeframe) diff --git a/components/charts/__init__.py b/components/charts/__init__.py index fbfa014..f42f5bc 100644 --- a/components/charts/__init__.py +++ b/components/charts/__init__.py @@ -227,7 +227,7 @@ def get_supported_symbols(): if candles: from database.operations import get_database_operations from utils.logger import get_logger - logger = get_logger("charts_symbols") + logger = get_logger("default_logger") try: db = get_database_operations(logger) @@ -247,7 +247,7 @@ def get_supported_timeframes(): if candles: from database.operations import get_database_operations from utils.logger import get_logger - logger = get_logger("charts_timeframes") + logger = get_logger("default_logger") try: db = get_database_operations(logger) diff --git a/components/charts/builder.py b/components/charts/builder.py index ff7c9b8..e48e53f 100644 --- a/components/charts/builder.py +++ b/components/charts/builder.py @@ -17,7 +17,7 @@ from utils.logger import get_logger from .utils import validate_market_data, prepare_chart_data, get_indicator_colors # Initialize logger -logger = get_logger("chart_builder") +logger = get_logger("default_logger") class ChartBuilder: @@ -75,14 +75,14 @@ class ChartBuilder: exchange=exchange ) - self.logger.debug(f"Fetched {len(candles)} candles for {symbol} {timeframe}") + self.logger.debug(f"Chart builder: Fetched {len(candles)} candles for {symbol} {timeframe}") return candles except DatabaseOperationError as e: - self.logger.error(f"Database error fetching market data: {e}") + self.logger.error(f"Chart builder: Database error fetching market data: {e}") return [] except Exception as e: - self.logger.error(f"Unexpected error fetching market data: {e}") + self.logger.error(f"Chart builder: Unexpected error fetching market data: {e}") return [] def fetch_market_data_enhanced(self, symbol: str, timeframe: str, @@ -106,14 +106,14 @@ class ChartBuilder: ) if not raw_candles: - self.logger.warning(f"No market data available for {symbol} {timeframe}") + self.logger.warning(f"Chart builder: No market data available for {symbol} {timeframe}") return [] - self.logger.debug(f"Enhanced fetch: {len(raw_candles)} candles for {symbol} {timeframe}") + self.logger.debug(f"Chart builder: Enhanced fetch: {len(raw_candles)} candles for {symbol} {timeframe}") return raw_candles except Exception as e: - self.logger.error(f"Error in enhanced market data fetch: {e}") + self.logger.error(f"Chart builder: Error in enhanced market data fetch: {e}") # Fallback to original method return self.fetch_market_data(symbol, timeframe, days_back, exchange) @@ -137,12 +137,12 @@ class ChartBuilder: # Handle empty data if not candles: - self.logger.warning(f"No data available for {symbol} {timeframe}") + self.logger.warning(f"Chart builder: No data available for {symbol} {timeframe}") return self._create_empty_chart(f"No data available for {symbol} {timeframe}") # Validate and prepare data if not validate_market_data(candles): - self.logger.error(f"Invalid market data for {symbol} {timeframe}") + self.logger.error(f"Chart builder: Invalid market data for {symbol} {timeframe}") return self._create_error_chart("Invalid market data format") # Prepare chart data @@ -158,7 +158,7 @@ class ChartBuilder: return self._create_basic_candlestick(df, symbol, timeframe, **kwargs) except Exception as e: - self.logger.error(f"Error creating candlestick chart for {symbol} {timeframe}: {e}") + self.logger.error(f"Chart builder: Error creating candlestick chart for {symbol} {timeframe}: {e}") return self._create_error_chart(f"Error loading chart: {str(e)}") def _create_basic_candlestick(self, df: pd.DataFrame, symbol: str, @@ -193,7 +193,7 @@ class ChartBuilder: hovermode='x unified' ) - self.logger.debug(f"Created basic candlestick chart for {symbol} {timeframe} with {len(df)} candles") + self.logger.debug(f"Chart builder: Created basic candlestick chart for {symbol} {timeframe} with {len(df)} candles") return fig def _create_candlestick_with_volume(self, df: pd.DataFrame, symbol: str, @@ -258,7 +258,7 @@ class ChartBuilder: fig.update_yaxes(title_text="Volume", row=2, col=1) fig.update_xaxes(title_text="Time", row=2, col=1) - self.logger.debug(f"Created candlestick chart with volume for {symbol} {timeframe}") + self.logger.debug(f"Chart builder: Created candlestick chart with volume for {symbol} {timeframe}") return fig def _create_empty_chart(self, message: str = "No data available") -> go.Figure: @@ -323,7 +323,7 @@ class ChartBuilder: """ # For now, return a basic candlestick chart # This will be enhanced in later tasks with strategy configurations - self.logger.info(f"Creating strategy chart for {strategy_name} (basic implementation)") + self.logger.info(f"Chart builder: Creating strategy chart for {strategy_name} (basic implementation)") return self.create_candlestick_chart(symbol, timeframe, **kwargs) def check_data_quality(self, symbol: str, timeframe: str, @@ -342,7 +342,7 @@ class ChartBuilder: try: return self.data_integrator.check_data_availability(symbol, timeframe, exchange) except Exception as e: - self.logger.error(f"Error checking data quality: {e}") + self.logger.error(f"Chart builder: Error checking data quality: {e}") return { 'available': False, 'latest_timestamp': None, @@ -374,12 +374,12 @@ class ChartBuilder: candles = self.fetch_market_data_enhanced(symbol, timeframe, days_back) if not candles: - self.logger.warning(f"No data available for {symbol} {timeframe}") + self.logger.warning(f"Chart builder: No data available for {symbol} {timeframe}") return self._create_empty_chart(f"No data available for {symbol} {timeframe}") # Validate and prepare data if not validate_market_data(candles): - self.logger.error(f"Invalid market data for {symbol} {timeframe}") + self.logger.error(f"Chart builder: Invalid market data for {symbol} {timeframe}") return self._create_error_chart("Invalid market data format") df = prepare_chart_data(candles) @@ -512,7 +512,7 @@ class ChartBuilder: self.logger.debug(f"Added overlay indicator: {user_indicator.name}") except Exception as e: - self.logger.error(f"Error adding overlay indicator {indicator_id}: {e}") + self.logger.error(f"Chart builder: Error adding overlay indicator {indicator_id}: {e}") # Move to next row for volume if enabled if volume_enabled: @@ -572,7 +572,7 @@ class ChartBuilder: self.logger.debug(f"Added subplot indicator: {user_indicator.name}") except Exception as e: - self.logger.error(f"Error adding subplot indicator {indicator_id}: {e}") + self.logger.error(f"Chart builder: Error adding subplot indicator {indicator_id}: {e}") # Update layout height = kwargs.get('height', self.default_height) @@ -597,5 +597,5 @@ class ChartBuilder: return fig except Exception as e: - self.logger.error(f"Error creating chart with indicators: {e}") + self.logger.error(f"Chart builder: Error creating chart with indicators: {e}") return self._create_error_chart(f"Chart creation failed: {str(e)}") \ No newline at end of file diff --git a/components/charts/config/error_handling.py b/components/charts/config/error_handling.py index c616b6e..f3ec7cd 100644 --- a/components/charts/config/error_handling.py +++ b/components/charts/config/error_handling.py @@ -18,7 +18,7 @@ from .example_strategies import get_all_example_strategies from utils.logger import get_logger # Initialize logger -logger = get_logger("error_handling") +logger = get_logger("default_logger") class ErrorSeverity(str, Enum): @@ -133,7 +133,7 @@ class ConfigurationErrorHandler: self.indicator_names = set(self.available_indicators.keys()) self.strategy_names = set(self.available_strategies.keys()) - logger.info(f"Error handler initialized with {len(self.indicator_names)} indicators and {len(self.strategy_names)} strategies") + logger.info(f"Error Handling: Error handler initialized with {len(self.indicator_names)} indicators and {len(self.strategy_names)} strategies") def validate_strategy_exists(self, strategy_name: str) -> Optional[ConfigurationError]: """Check if a strategy exists and provide guidance if not.""" diff --git a/components/charts/config/indicator_defs.py b/components/charts/config/indicator_defs.py index 9210ef2..cf8345c 100644 --- a/components/charts/config/indicator_defs.py +++ b/components/charts/config/indicator_defs.py @@ -17,7 +17,7 @@ from data.common.data_types import OHLCVCandle from utils.logger import get_logger # Initialize logger -logger = get_logger("indicator_defs") +logger = get_logger("default_logger") class IndicatorType(str, Enum): @@ -466,10 +466,10 @@ def convert_database_candles_to_ohlcv(candles: List[Dict[str, Any]]) -> List[OHL ohlcv_candles.append(ohlcv_candle) except Exception as e: - logger.error(f"Error converting candle to OHLCV: {e}") + logger.error(f"Indicator Definitions: Error converting candle to OHLCV: {e}") continue - logger.debug(f"Converted {len(ohlcv_candles)} database candles to OHLCV format") + logger.debug(f"Indicator Definitions: Converted {len(ohlcv_candles)} database candles to OHLCV format") return ohlcv_candles @@ -488,13 +488,13 @@ def calculate_indicators(candles: List[Dict[str, Any]], Dictionary mapping indicator names to their calculation results """ if not candles: - logger.warning("No candles provided for indicator calculation") + logger.warning("Indicator Definitions: No candles provided for indicator calculation") return {} # Convert to OHLCV format ohlcv_candles = convert_database_candles_to_ohlcv(candles) if not ohlcv_candles: - logger.error("Failed to convert candles to OHLCV format") + logger.error("Indicator Definitions: Failed to convert candles to OHLCV format") return {} # Initialize technical indicators calculator @@ -511,20 +511,20 @@ def calculate_indicators(candles: List[Dict[str, Any]], chart_config = all_configs[indicator_name] configs_to_calculate[indicator_name] = chart_config.to_indicator_config() else: - logger.warning(f"Unknown indicator configuration: {indicator_name}") + logger.warning(f"Indicator Definitions: Unknown indicator configuration: {indicator_name}") if not configs_to_calculate: - logger.warning("No valid indicator configurations found") + logger.warning("Indicator Definitions: No valid indicator configurations found") return {} # Calculate indicators try: results = indicators_calc.calculate_multiple_indicators(ohlcv_candles, configs_to_calculate) - logger.debug(f"Calculated {len(results)} indicators successfully") + logger.debug(f"Indicator Definitions: Calculated {len(results)} indicators successfully") return results except Exception as e: - logger.error(f"Error calculating indicators: {e}") + logger.error(f"Indicator Definitions: Error calculating indicators: {e}") return {} diff --git a/components/charts/config/strategy_charts.py b/components/charts/config/strategy_charts.py index 51f8f75..07d39fd 100644 --- a/components/charts/config/strategy_charts.py +++ b/components/charts/config/strategy_charts.py @@ -22,7 +22,7 @@ from .defaults import ( from utils.logger import get_logger # Initialize logger -logger = get_logger("strategy_charts") +logger = get_logger("default_logger") class ChartLayout(str, Enum): @@ -117,11 +117,11 @@ class StrategyChartConfig: except ImportError: # Fallback to original validation if new system unavailable - logger.warning("Enhanced validation system unavailable, using basic validation") + logger.warning("Strategy Charts: Enhanced validation system unavailable, using basic validation") return self._basic_validate() except Exception as e: - logger.error(f"Validation error: {e}") - return False, [f"Validation system error: {e}"] + logger.error(f"Strategy Charts: Validation error: {e}") + return False, [f"Strategy Charts: Validation system error: {e}"] def validate_comprehensive(self) -> 'ValidationReport': """ @@ -173,7 +173,7 @@ class StrategyChartConfig: if indicator_name not in all_default_indicators: errors.append(f"Subplot indicator '{indicator_name}' not found in defaults") except Exception as e: - logger.warning(f"Could not validate indicator existence: {e}") + logger.warning(f"Strategy Charts: Could not validate indicator existence: {e}") # Validate subplot height ratios for i, subplot_config in enumerate(self.subplot_configs): diff --git a/components/charts/config/validation.py b/components/charts/config/validation.py index 709ebbf..da21544 100644 --- a/components/charts/config/validation.py +++ b/components/charts/config/validation.py @@ -17,7 +17,7 @@ from .strategy_charts import StrategyChartConfig, SubplotConfig, ChartStyle, Cha from utils.logger import get_logger # Initialize logger -logger = get_logger("config_validation") +logger = get_logger("default_logger") class ValidationLevel(str, Enum): @@ -131,7 +131,7 @@ class ConfigurationValidator: self.available_indicators = get_all_default_indicators() self.indicator_schemas = INDICATOR_SCHEMAS except Exception as e: - logger.warning(f"Failed to load indicator information: {e}") + logger.warning(f"Validation: Failed to load indicator information: {e}") self.available_indicators = {} self.indicator_schemas = {} diff --git a/components/charts/data_integration.py b/components/charts/data_integration.py index 2263b5b..4cf81b6 100644 --- a/components/charts/data_integration.py +++ b/components/charts/data_integration.py @@ -19,7 +19,7 @@ from components.charts.config.indicator_defs import convert_database_candles_to_ from utils.logger import get_logger # Initialize logger -logger = get_logger("data_integration") +logger = get_logger("default_logger") @dataclass @@ -87,7 +87,7 @@ class MarketDataIntegrator: cache_key = f"{symbol}_{timeframe}_{days_back}_{exchange}" cached_data = self._get_cached_data(cache_key) if cached_data: - self.logger.debug(f"Using cached data for {cache_key}") + self.logger.debug(f"Data Integration: Using cached data for {cache_key}") return cached_data['raw_candles'], cached_data['ohlcv_candles'] # Fetch from database @@ -103,7 +103,7 @@ class MarketDataIntegrator: ) if not raw_candles: - self.logger.warning(f"No market data found for {symbol} {timeframe}") + self.logger.warning(f"Data Integration: No market data found for {symbol} {timeframe}") return [], [] # Validate data if enabled @@ -124,14 +124,14 @@ class MarketDataIntegrator: 'timestamp': datetime.now(timezone.utc) }) - self.logger.debug(f"Fetched {len(raw_candles)} candles for {symbol} {timeframe}") + self.logger.debug(f"Data Integration: Fetched {len(raw_candles)} candles for {symbol} {timeframe}") return raw_candles, ohlcv_candles except DatabaseOperationError as e: - self.logger.error(f"Database error fetching market data: {e}") + self.logger.error(f"Data Integration: Database error fetching market data: {e}") return [], [] except Exception as e: - self.logger.error(f"Unexpected error fetching market data: {e}") + self.logger.error(f"Data Integration: Unexpected error fetching market data: {e}") return [], [] def calculate_indicators_for_symbol( @@ -162,7 +162,7 @@ class MarketDataIntegrator: ) if not ohlcv_candles: - self.logger.warning(f"No data available for indicator calculations: {symbol} {timeframe}") + self.logger.warning(f"Data Integration: No data available for indicator calculations: {symbol} {timeframe}") return {} # Check minimum data requirements @@ -186,16 +186,16 @@ class MarketDataIntegrator: results[indicator_name] = indicator_results self.logger.debug(f"Calculated {indicator_name}: {len(indicator_results)} points") else: - self.logger.warning(f"No results for indicator {indicator_name}") + self.logger.warning(f"Data Integration: No results for indicator {indicator_name}") except Exception as e: - self.logger.error(f"Error calculating indicator {indicator_name}: {e}") + self.logger.error(f"Data Integration: Error calculating indicator {indicator_name}: {e}") continue return results except Exception as e: - self.logger.error(f"Error calculating indicators for {symbol}: {e}") + self.logger.error(f"Data Integration: Error calculating indicators for {symbol}: {e}") return {} def get_latest_market_data( @@ -244,7 +244,7 @@ class MarketDataIntegrator: return raw_candles, ohlcv_candles except Exception as e: - self.logger.error(f"Error fetching latest market data: {e}") + self.logger.error(f"Data Integration: Error fetching latest market data: {e}") return [], [] def check_data_availability( @@ -310,7 +310,7 @@ class MarketDataIntegrator: } except Exception as e: - self.logger.error(f"Error checking data availability: {e}") + self.logger.error(f"Data Integration: Error checking data availability: {e}") return { 'available': False, 'latest_timestamp': None, @@ -355,7 +355,7 @@ class MarketDataIntegrator: return [] except Exception as e: - self.logger.error(f"Error calculating {indicator_type}: {e}") + self.logger.error(f"Data Integration: Error calculating {indicator_type}: {e}") return [] def _validate_and_clean_data(self, candles: List[Dict[str, Any]]) -> List[Dict[str, Any]]: @@ -367,29 +367,29 @@ class MarketDataIntegrator: # Check required fields required_fields = ['timestamp', 'open', 'high', 'low', 'close', 'volume'] if not all(field in candle for field in required_fields): - self.logger.warning(f"Missing fields in candle {i}") + self.logger.warning(f"Data Integration: Missing fields in candle {i}") continue # Validate OHLC relationships o, h, l, c = float(candle['open']), float(candle['high']), float(candle['low']), float(candle['close']) if not (h >= max(o, c) and l <= min(o, c)): - self.logger.warning(f"Invalid OHLC relationship in candle {i}") + self.logger.warning(f"Data Integration: Invalid OHLC relationship in candle {i}") continue # Validate positive values if any(val <= 0 for val in [o, h, l, c]): - self.logger.warning(f"Non-positive price in candle {i}") + self.logger.warning(f"Data Integration: Non-positive price in candle {i}") continue cleaned_candles.append(candle) except (ValueError, TypeError) as e: - self.logger.warning(f"Error validating candle {i}: {e}") + self.logger.warning(f"Data Integration: Error validating candle {i}: {e}") continue removed_count = len(candles) - len(cleaned_candles) if removed_count > 0: - self.logger.info(f"Removed {removed_count} invalid candles during validation") + self.logger.info(f"Data Integration: Removed {removed_count} invalid candles during validation") return cleaned_candles @@ -416,9 +416,6 @@ class MarketDataIntegrator: if actual_interval > expected_interval * 1.5: # Allow 50% tolerance gaps_detected += 1 - if gaps_detected > 0: - self.logger.info(f"Detected {gaps_detected} gaps in {timeframe} data (normal for sparse aggregation)") - return candles def _parse_timeframe_to_minutes(self, timeframe: str) -> int: @@ -458,7 +455,7 @@ class MarketDataIntegrator: def clear_cache(self) -> None: """Clear the data cache.""" self._cache.clear() - self.logger.debug("Data cache cleared") + self.logger.debug("Data Integration: Data cache cleared") # Convenience functions for common operations diff --git a/components/charts/error_handling.py b/components/charts/error_handling.py index 36fc0f5..b9ce24d 100644 --- a/components/charts/error_handling.py +++ b/components/charts/error_handling.py @@ -15,7 +15,7 @@ from enum import Enum from utils.logger import get_logger # Initialize logger -logger = get_logger("chart_error_handling") +logger = get_logger("default_logger") class ErrorSeverity(Enum): diff --git a/components/charts/indicator_defaults.py b/components/charts/indicator_defaults.py index bb87648..b591362 100644 --- a/components/charts/indicator_defaults.py +++ b/components/charts/indicator_defaults.py @@ -15,7 +15,7 @@ def create_default_indicators(): # Check if we already have indicators existing_indicators = manager.list_indicators() if existing_indicators: - manager.logger.info(f"Found {len(existing_indicators)} existing indicators, skipping defaults creation") + manager.logger.info(f"Indicator defaults: Found {len(existing_indicators)} existing indicators, skipping defaults creation") return # Define default indicators @@ -112,11 +112,11 @@ def create_default_indicators(): if indicator: created_count += 1 - manager.logger.info(f"Created default indicator: {indicator.name}") + manager.logger.info(f"Indicator defaults: Created default indicator: {indicator.name}") else: - manager.logger.error(f"Failed to create indicator: {indicator_config['name']}") + manager.logger.error(f"Indicator defaults: Failed to create indicator: {indicator_config['name']}") - manager.logger.info(f"Created {created_count} default indicators") + manager.logger.info(f"Indicator defaults: Created {created_count} default indicators") def ensure_default_indicators(): @@ -125,7 +125,7 @@ def ensure_default_indicators(): create_default_indicators() except Exception as e: manager = get_indicator_manager() - manager.logger.error(f"Error creating default indicators: {e}") + manager.logger.error(f"Indicator defaults: Error creating default indicators: {e}") if __name__ == "__main__": diff --git a/components/charts/indicator_manager.py b/components/charts/indicator_manager.py index 43cf095..f3a21f1 100644 --- a/components/charts/indicator_manager.py +++ b/components/charts/indicator_manager.py @@ -18,7 +18,7 @@ from enum import Enum from utils.logger import get_logger # Initialize logger -logger = get_logger("indicator_manager") +logger = get_logger("default_logger") # Base directory for indicators INDICATORS_DIR = Path("config/indicators") @@ -121,9 +121,9 @@ class IndicatorManager: try: USER_INDICATORS_DIR.mkdir(parents=True, exist_ok=True) TEMPLATES_DIR.mkdir(parents=True, exist_ok=True) - self.logger.debug("Indicator directories created/verified") + self.logger.debug("Indicator manager: Indicator directories created/verified") except Exception as e: - self.logger.error(f"Error creating indicator directories: {e}") + self.logger.error(f"Indicator manager: Error creating indicator directories: {e}") def _get_indicator_file_path(self, indicator_id: str) -> Path: """Get file path for an indicator.""" @@ -152,11 +152,11 @@ class IndicatorManager: with open(file_path, 'w', encoding='utf-8') as f: json.dump(indicator.to_dict(), f, indent=2, ensure_ascii=False) - self.logger.info(f"Saved indicator: {indicator.name} ({indicator.id})") + self.logger.info(f"Indicator manager: Saved indicator: {indicator.name} ({indicator.id})") return True except Exception as e: - self.logger.error(f"Error saving indicator {indicator.id}: {e}") + self.logger.error(f"Indicator manager: Error saving indicator {indicator.id}: {e}") return False def load_indicator(self, indicator_id: str) -> Optional[UserIndicator]: @@ -173,18 +173,18 @@ class IndicatorManager: file_path = self._get_indicator_file_path(indicator_id) if not file_path.exists(): - self.logger.warning(f"Indicator file not found: {indicator_id}") + self.logger.warning(f"Indicator manager: Indicator file not found: {indicator_id}") return None with open(file_path, 'r', encoding='utf-8') as f: data = json.load(f) indicator = UserIndicator.from_dict(data) - self.logger.debug(f"Loaded indicator: {indicator.name} ({indicator.id})") + self.logger.debug(f"Indicator manager: Loaded indicator: {indicator.name} ({indicator.id})") return indicator except Exception as e: - self.logger.error(f"Error loading indicator {indicator_id}: {e}") + self.logger.error(f"Indicator manager: Error loading indicator {indicator_id}: {e}") return None def list_indicators(self, visible_only: bool = False) -> List[UserIndicator]: @@ -213,7 +213,7 @@ class IndicatorManager: self.logger.debug(f"Listed {len(indicators)} indicators") except Exception as e: - self.logger.error(f"Error listing indicators: {e}") + self.logger.error(f"Indicator manager: Error listing indicators: {e}") return indicators @@ -232,14 +232,14 @@ class IndicatorManager: if file_path.exists(): file_path.unlink() - self.logger.info(f"Deleted indicator: {indicator_id}") + self.logger.info(f"Indicator manager: Deleted indicator: {indicator_id}") return True else: - self.logger.warning(f"Indicator file not found for deletion: {indicator_id}") + self.logger.warning(f"Indicator manager: Indicator file not found for deletion: {indicator_id}") return False except Exception as e: - self.logger.error(f"Error deleting indicator {indicator_id}: {e}") + self.logger.error(f"Indicator manager: Error deleting indicator {indicator_id}: {e}") return False def create_indicator(self, name: str, indicator_type: str, parameters: Dict[str, Any], @@ -283,13 +283,13 @@ class IndicatorManager: # Save to file if self.save_indicator(indicator): - self.logger.info(f"Created new indicator: {name} ({indicator_id})") + self.logger.info(f"Indicator manager: Created new indicator: {name} ({indicator_id})") return indicator else: return None except Exception as e: - self.logger.error(f"Error creating indicator: {e}") + self.logger.error(f"Indicator manager: Error creating indicator: {e}") return None def update_indicator(self, indicator_id: str, **updates) -> bool: @@ -322,7 +322,7 @@ class IndicatorManager: return self.save_indicator(indicator) except Exception as e: - self.logger.error(f"Error updating indicator {indicator_id}: {e}") + self.logger.error(f"Indicator manager: Error updating indicator {indicator_id}: {e}") return False def get_indicators_by_type(self, display_type: str) -> List[UserIndicator]: @@ -418,7 +418,7 @@ class IndicatorManager: json.dump(template_data, f, indent=2, ensure_ascii=False) self.logger.debug(f"Created template: {indicator_type}") except Exception as e: - self.logger.error(f"Error creating template {indicator_type}: {e}") + self.logger.error(f"Indicator manager: Error creating template {indicator_type}: {e}") def get_template(self, indicator_type: str) -> Optional[Dict[str, Any]]: """Get indicator template by type.""" @@ -433,7 +433,7 @@ class IndicatorManager: return None except Exception as e: - self.logger.error(f"Error loading template {indicator_type}: {e}") + self.logger.error(f"Indicator manager: Error loading template {indicator_type}: {e}") return None diff --git a/components/charts/layers/base.py b/components/charts/layers/base.py index ade5485..8786c22 100644 --- a/components/charts/layers/base.py +++ b/components/charts/layers/base.py @@ -20,7 +20,7 @@ from ..error_handling import ( ) # Initialize logger -logger = get_logger("chart_layers") +logger = get_logger("default_logger") @dataclass @@ -45,7 +45,7 @@ class BaseLayer: def __init__(self, config: LayerConfig): self.config = config - self.logger = get_logger(f"chart_layer_{self.__class__.__name__.lower()}") + self.logger = get_logger('default_logger') self.error_handler = ChartErrorHandler() self.traces = [] self._is_valid = False @@ -90,7 +90,7 @@ class BaseLayer: return is_sufficient except Exception as e: - self.logger.error(f"Data validation error in {self.__class__.__name__}: {e}") + self.logger.error(f"Base layer: Data validation error in {self.__class__.__name__}: {e}") error = ChartError( code='VALIDATION_EXCEPTION', message=f'Validation error: {str(e)}', @@ -293,7 +293,7 @@ class CandlestickLayer(BaseLayer): return parent_valid and len(self.error_handler.errors) == 0 except Exception as e: - self.logger.error(f"Error validating candlestick data: {e}") + self.logger.error(f"Candlestick layer: Error validating candlestick data: {e}") error = ChartError( code='CANDLESTICK_VALIDATION_ERROR', message=f'Candlestick validation failed: {str(e)}', @@ -318,7 +318,7 @@ class CandlestickLayer(BaseLayer): try: # Validate data if not self.validate_data(data): - self.logger.error("Invalid data for candlestick layer") + self.logger.error("Candlestick layer: Invalid data for candlestick layer") # Add error annotation to figure if self.error_handler.errors: @@ -375,7 +375,7 @@ class CandlestickLayer(BaseLayer): try: fig.add_trace(candlestick) except Exception as fallback_error: - self.logger.error(f"Failed to add candlestick trace: {fallback_error}") + self.logger.error(f"Candlestick layer: Failed to add candlestick trace: {fallback_error}") fig.add_annotation(create_error_annotation( f"Failed to add candlestick trace: {str(fallback_error)}", position='center' @@ -399,7 +399,7 @@ class CandlestickLayer(BaseLayer): return fig except Exception as e: - self.logger.error(f"Error rendering candlestick layer: {e}") + self.logger.error(f"Candlestick layer: Error rendering candlestick layer: {e}") fig.add_annotation(create_error_annotation( f"Candlestick render error: {str(e)}", position='center' @@ -436,7 +436,7 @@ class CandlestickLayer(BaseLayer): return clean_data except Exception as e: - self.logger.error(f"Error cleaning candlestick data: {e}") + self.logger.error(f"Candlestick layer: Error cleaning candlestick data: {e}") return pd.DataFrame() @@ -556,7 +556,7 @@ class VolumeLayer(BaseLayer): return parent_valid and valid_volume_count > 0 except Exception as e: - self.logger.error(f"Error validating volume data: {e}") + self.logger.error(f"Volume layer: Error validating volume data: {e}") error = ChartError( code='VOLUME_VALIDATION_ERROR', message=f'Volume validation failed: {str(e)}', @@ -586,7 +586,7 @@ class VolumeLayer(BaseLayer): self.logger.debug("Skipping volume layer due to warnings") return fig else: - self.logger.error("Invalid data for volume layer") + self.logger.error("Volume layer: Invalid data for volume layer") return fig # Clean and prepare data @@ -622,11 +622,11 @@ class VolumeLayer(BaseLayer): fig.add_trace(volume_bars, row=row, col=col) - self.logger.debug(f"Rendered volume layer with {len(clean_data)} bars") + self.logger.debug(f"Volume layer: Rendered volume layer with {len(clean_data)} bars") return fig except Exception as e: - self.logger.error(f"Error rendering volume layer: {e}") + self.logger.error(f"Volume layer: Error rendering volume layer: {e}") return fig def _clean_volume_data(self, data: pd.DataFrame) -> pd.DataFrame: @@ -653,7 +653,7 @@ class VolumeLayer(BaseLayer): return clean_data except Exception as e: - self.logger.error(f"Error cleaning volume data: {e}") + self.logger.error(f"Volume layer: Error cleaning volume data: {e}") return pd.DataFrame() @@ -890,7 +890,7 @@ class LayerManager: return fig except Exception as e: - self.logger.error(f"Error rendering layers: {e}") + self.logger.error(f"Layer manager: Error rendering layers: {e}") # Return empty figure on error return go.Figure() @@ -949,4 +949,4 @@ class LayerManager: ) except Exception as e: - self.logger.error(f"Error applying layout styling: {e}") \ No newline at end of file + self.logger.error(f"Layer manager: Error applying layout styling: {e}") \ No newline at end of file diff --git a/components/charts/layers/indicators.py b/components/charts/layers/indicators.py index c555869..d7789f3 100644 --- a/components/charts/layers/indicators.py +++ b/components/charts/layers/indicators.py @@ -22,7 +22,7 @@ from components.charts.utils import get_indicator_colors from utils.logger import get_logger # Initialize logger -logger = get_logger("chart_indicators") +logger = get_logger("default_logger") @dataclass @@ -94,7 +94,7 @@ class BaseIndicatorLayer(BaseLayer): return candles except Exception as e: - self.logger.error(f"Error preparing indicator data: {e}") + self.logger.error(f"Indicators: Error preparing indicator data: {e}") return [] def validate_indicator_data(self, data: Union[pd.DataFrame, List[Dict[str, Any]]], @@ -159,7 +159,7 @@ class BaseIndicatorLayer(BaseLayer): return True except Exception as e: - self.logger.error(f"Error validating indicator data: {e}") + self.logger.error(f"Indicators: Error validating indicator data: {e}") error = ChartError( code='INDICATOR_VALIDATION_ERROR', message=f'Indicator validation failed: {str(e)}', @@ -222,7 +222,7 @@ class BaseIndicatorLayer(BaseLayer): return result except Exception as e: - self.logger.error(f"Error calculating {self.config.indicator_type}: {e}") + self.logger.error(f"Indicators: Error calculating {self.config.indicator_type}: {e}") # Try to apply error recovery recovery_strategy = ErrorRecoveryStrategies.handle_insufficient_data( @@ -239,7 +239,7 @@ class BaseIndicatorLayer(BaseLayer): # Try with adjusted parameters try: modified_config = recovery_strategy.get('modified_config', {}) - self.logger.info(f"Retrying indicator calculation with adjusted parameters: {modified_config}") + self.logger.info(f"Indicators: Retrying indicator calculation with adjusted parameters: {modified_config}") # Update parameters temporarily original_params = self.config.parameters.copy() if self.config.parameters else {} @@ -264,7 +264,7 @@ class BaseIndicatorLayer(BaseLayer): return result except Exception as retry_error: - self.logger.error(f"Retry with adjusted parameters also failed: {retry_error}") + self.logger.error(f"Indicators: Retry with adjusted parameters also failed: {retry_error}") # Final error if all recovery attempts fail error = ChartError( @@ -349,7 +349,7 @@ class SMALayer(BaseIndicatorLayer): return self.traces except Exception as e: - error_msg = f"Error creating SMA traces: {str(e)}" + error_msg = f"Indicators: Error creating SMA traces: {str(e)}" self.logger.error(error_msg) return [self.create_error_trace(error_msg)] @@ -391,7 +391,7 @@ class SMALayer(BaseIndicatorLayer): fig.add_trace(trace) return fig except Exception as e: - self.logger.error(f"Error rendering SMA layer: {e}") + self.logger.error(f"Indicators: Error rendering SMA layer: {e}") return fig @@ -448,7 +448,7 @@ class EMALayer(BaseIndicatorLayer): return self.traces except Exception as e: - error_msg = f"Error creating EMA traces: {str(e)}" + error_msg = f"Indicators: Error creating EMA traces: {str(e)}" self.logger.error(error_msg) return [self.create_error_trace(error_msg)] @@ -492,7 +492,7 @@ class EMALayer(BaseIndicatorLayer): fig.add_trace(trace) return fig except Exception as e: - self.logger.error(f"Error rendering EMA layer: {e}") + self.logger.error(f"Indicators: Error rendering EMA layer: {e}") return fig @@ -580,7 +580,7 @@ class BollingerBandsLayer(BaseIndicatorLayer): return self.traces except Exception as e: - error_msg = f"Error creating Bollinger Bands traces: {str(e)}" + error_msg = f"Indicators: Error creating Bollinger Bands traces: {str(e)}" self.logger.error(error_msg) return [self.create_error_trace(error_msg)] @@ -631,7 +631,7 @@ class BollingerBandsLayer(BaseIndicatorLayer): fig.add_trace(trace) return fig except Exception as e: - self.logger.error(f"Error rendering Bollinger Bands layer: {e}") + self.logger.error(f"Indicators: Error rendering Bollinger Bands layer: {e}") return fig diff --git a/components/charts/layers/subplots.py b/components/charts/layers/subplots.py index 35b9469..d45de36 100644 --- a/components/charts/layers/subplots.py +++ b/components/charts/layers/subplots.py @@ -24,7 +24,7 @@ from ..error_handling import ( ) # Initialize logger -logger = get_logger("subplot_layers") +logger = get_logger("default_logger") @dataclass @@ -108,7 +108,7 @@ class BaseSubplotLayer(BaseIndicatorLayer): ) except Exception as e: - self.logger.warning(f"Could not add reference lines: {e}") + self.logger.warning(f"Subplot layers: Could not add reference lines: {e}") class RSILayer(BaseSubplotLayer): @@ -233,7 +233,7 @@ class RSILayer(BaseSubplotLayer): return fig except Exception as e: - self.logger.error(f"Error rendering RSI layer: {e}") + self.logger.error(f"Subplot layers: Error rendering RSI layer: {e}") return fig @@ -371,7 +371,7 @@ class MACDLayer(BaseSubplotLayer): return fig except Exception as e: - self.logger.error(f"Error rendering MACD layer: {e}") + self.logger.error(f"Subplot layers: Error rendering MACD layer: {e}") return fig diff --git a/components/charts/utils.py b/components/charts/utils.py index 64414c2..a4d4996 100644 --- a/components/charts/utils.py +++ b/components/charts/utils.py @@ -13,7 +13,7 @@ from decimal import Decimal from utils.logger import get_logger # Initialize logger -logger = get_logger("chart_utils") +logger = get_logger("default_logger") # Default color scheme for charts DEFAULT_CHART_COLORS = { @@ -44,7 +44,7 @@ def validate_market_data(candles: List[Dict[str, Any]]) -> bool: True if data is valid, False otherwise """ if not candles: - logger.warning("Empty candles data") + logger.warning("Chart utils: Empty candles data") return False # Check required fields in first candle @@ -53,7 +53,7 @@ def validate_market_data(candles: List[Dict[str, Any]]) -> bool: for field in required_fields: if field not in first_candle: - logger.error(f"Missing required field: {field}") + logger.error(f"Chart utils: Missing required field: {field}") return False # Validate data types and values @@ -61,42 +61,42 @@ def validate_market_data(candles: List[Dict[str, Any]]) -> bool: try: # Validate timestamp if not isinstance(candle['timestamp'], (datetime, str)): - logger.error(f"Invalid timestamp type at index {i}") + logger.error(f"Chart utils: Invalid timestamp type at index {i}") return False # Validate OHLC values for field in ['open', 'high', 'low', 'close']: value = candle[field] if value is None: - logger.error(f"Null value for {field} at index {i}") + logger.error(f"Chart utils: Null value for {field} at index {i}") return False # Convert to float for validation try: float_val = float(value) if float_val <= 0: - logger.error(f"Non-positive value for {field} at index {i}: {float_val}") + logger.error(f"Chart utils: Non-positive value for {field} at index {i}: {float_val}") return False except (ValueError, TypeError): - logger.error(f"Invalid numeric value for {field} at index {i}: {value}") + logger.error(f"Chart utils: Invalid numeric value for {field} at index {i}: {value}") return False # Validate OHLC relationships (high >= low, etc.) try: o, h, l, c = float(candle['open']), float(candle['high']), float(candle['low']), float(candle['close']) if not (h >= max(o, c) and l <= min(o, c)): - logger.warning(f"Invalid OHLC relationship at index {i}: O={o}, H={h}, L={l}, C={c}") + logger.warning(f"Chart utils: Invalid OHLC relationship at index {i}: O={o}, H={h}, L={l}, C={c}") # Don't fail validation for this, just warn except (ValueError, TypeError): - logger.error(f"Error validating OHLC relationships at index {i}") + logger.error(f"Chart utils: Error validating OHLC relationships at index {i}") return False except Exception as e: - logger.error(f"Error validating candle at index {i}: {e}") + logger.error(f"Chart utils: Error validating candle at index {i}: {e}") return False - logger.debug(f"Market data validation passed for {len(candles)} candles") + logger.debug(f"Chart utils: Market data validation passed for {len(candles)} candles") return True @@ -137,11 +137,11 @@ def prepare_chart_data(candles: List[Dict[str, Any]]) -> pd.DataFrame: # Fill any NaN values with forward fill, then backward fill df = df.ffill().bfill() - logger.debug(f"Prepared chart data: {len(df)} rows, columns: {list(df.columns)}") + logger.debug(f"Chart utils: Prepared chart data: {len(df)} rows, columns: {list(df.columns)}") return df except Exception as e: - logger.error(f"Error preparing chart data: {e}") + logger.error(f"Chart utils: Error preparing chart data: {e}") # Return empty DataFrame with expected structure return pd.DataFrame(columns=['timestamp', 'open', 'high', 'low', 'close', 'volume']) diff --git a/dashboard/callbacks/charts.py b/dashboard/callbacks/charts.py index 0112b31..ee224df 100644 --- a/dashboard/callbacks/charts.py +++ b/dashboard/callbacks/charts.py @@ -15,7 +15,7 @@ from components.charts.config import get_all_example_strategies from database.connection import DatabaseManager from dash import html -logger = get_logger("chart_callbacks") +logger = get_logger("default_logger") def register_chart_callbacks(app): @@ -36,7 +36,7 @@ def register_chart_callbacks(app): # If a strategy is selected, use strategy chart if selected_strategy and selected_strategy != 'basic': fig = create_strategy_chart(symbol, timeframe, selected_strategy) - logger.debug(f"Created strategy chart for {symbol} ({timeframe}) with strategy: {selected_strategy}") + logger.debug(f"Chart callback: Created strategy chart for {symbol} ({timeframe}) with strategy: {selected_strategy}") else: # Create chart with dynamically selected indicators fig = create_chart_with_indicators( @@ -48,7 +48,7 @@ def register_chart_callbacks(app): ) indicator_count = len(overlay_indicators or []) + len(subplot_indicators or []) - logger.debug(f"Created dynamic chart for {symbol} ({timeframe}) with {indicator_count} indicators") + logger.debug(f"Chart callback: Created dynamic chart for {symbol} ({timeframe}) with {indicator_count} indicators") return fig @@ -82,14 +82,14 @@ def register_chart_callbacks(app): for subplot_config in config.subplot_configs or []: subplot_indicators.extend(subplot_config.indicators or []) - logger.debug(f"Loaded strategy {selected_strategy}: {len(overlay_indicators)} overlays, {len(subplot_indicators)} subplots") + logger.debug(f"Chart callback: Loaded strategy {selected_strategy}: {len(overlay_indicators)} overlays, {len(subplot_indicators)} subplots") return overlay_indicators, subplot_indicators else: - logger.warning(f"Strategy {selected_strategy} not found") + logger.warning(f"Chart callback: Strategy {selected_strategy} not found") return [], [] except Exception as e: - logger.error(f"Error loading strategy indicators: {e}") + logger.error(f"Chart callback: Error loading strategy indicators: {e}") return [], [] # Market statistics callback @@ -115,7 +115,7 @@ def register_chart_callbacks(app): ]) except Exception as e: - logger.error(f"Error updating market stats: {e}") + logger.error(f"Chart callback: Error updating market stats: {e}") return html.Div("Error loading market statistics") - logger.info("Chart callbacks registered successfully") \ No newline at end of file + logger.info("Chart callback: Chart callbacks registered successfully") \ No newline at end of file diff --git a/dashboard/callbacks/indicators.py b/dashboard/callbacks/indicators.py index d409be7..ed98eff 100644 --- a/dashboard/callbacks/indicators.py +++ b/dashboard/callbacks/indicators.py @@ -7,7 +7,7 @@ from dash import Output, Input, State, html, dcc, callback_context import json from utils.logger import get_logger -logger = get_logger("indicator_callbacks") +logger = get_logger("default_logger") def register_indicator_callbacks(app): @@ -282,7 +282,7 @@ def register_indicator_callbacks(app): return success_msg, overlay_options, subplot_options except Exception as e: - logger.error(f"Error saving indicator: {e}") + logger.error(f"Indicator callback: Error saving indicator: {e}") error_msg = html.Div([ html.Span("❌ ", style={'color': '#dc3545'}), html.Span(f"Error: {str(e)}", style={'color': '#dc3545'}) @@ -475,7 +475,7 @@ def register_indicator_callbacks(app): return error_msg, dash.no_update, dash.no_update except Exception as e: - logger.error(f"Error deleting indicator: {e}") + logger.error(f"Indicator callback: Error deleting indicator: {e}") error_msg = html.Div([ html.Span("❌ ", style={'color': '#dc3545'}), html.Span(f"Error: {str(e)}", style={'color': '#dc3545'}) @@ -572,7 +572,7 @@ def register_indicator_callbacks(app): return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update except Exception as e: - logger.error(f"Error loading indicator for edit: {e}") + logger.error(f"Indicator callback: Error loading indicator for edit: {e}") return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update # Reset modal form when closed @@ -603,4 +603,4 @@ def register_indicator_callbacks(app): return "", None, "", "#007bff", 2, "📊 Add New Indicator", None, 20, 12, 14, 12, 26, 9, 20, 2.0 return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update - logger.info("Indicator callbacks registered successfully") \ No newline at end of file + logger.info("Indicator callbacks: registered successfully") \ No newline at end of file diff --git a/dashboard/callbacks/system_health.py b/dashboard/callbacks/system_health.py index 66acda4..a87d0f7 100644 --- a/dashboard/callbacks/system_health.py +++ b/dashboard/callbacks/system_health.py @@ -8,7 +8,7 @@ from utils.logger import get_logger from database.connection import DatabaseManager from components.charts import create_data_status_indicator, check_data_availability -logger = get_logger("system_health_callbacks") +logger = get_logger("default_logger") def register_system_health_callbacks(app): @@ -40,7 +40,7 @@ def register_system_health_callbacks(app): ]) except Exception as e: - logger.error(f"Database status check failed: {e}") + logger.error(f"System health callback: Database status check failed: {e}") return html.Div([ html.Span("🔴 Connection Failed", style={'color': '#e74c3c', 'font-weight': 'bold'}), html.P(f"Error: {str(e)}", style={'color': '#7f8c8d', 'font-size': '12px'}) @@ -68,7 +68,7 @@ def register_system_health_callbacks(app): ], style={'background-color': '#f8f9fa', 'padding': '15px', 'border-radius': '5px'}) except Exception as e: - logger.error(f"Error updating data status: {e}") + logger.error(f"System health callback: Error updating data status: {e}") return html.Div([ html.Span("🔴 Status Check Failed", style={'color': '#e74c3c', 'font-weight': 'bold'}), html.P(f"Error: {str(e)}", style={'color': '#7f8c8d', 'margin': '5px 0'}) @@ -87,10 +87,10 @@ def register_system_health_callbacks(app): html.P("Redis integration pending", style={'color': '#7f8c8d', 'margin': '5px 0'}) ]) except Exception as e: - logger.error(f"Redis status check failed: {e}") + logger.error(f"System health callback: Redis status check failed: {e}") return html.Div([ html.Span("🔴 Check Failed", style={'color': '#e74c3c', 'font-weight': 'bold'}), html.P(f"Error: {str(e)}", style={'color': '#7f8c8d', 'font-size': '12px'}) ]) - logger.info("System health callbacks registered successfully") \ No newline at end of file + logger.info("System health callback: System health callbacks registered successfully") \ No newline at end of file diff --git a/dashboard/components/chart_controls.py b/dashboard/components/chart_controls.py index 05702fe..d30c504 100644 --- a/dashboard/components/chart_controls.py +++ b/dashboard/components/chart_controls.py @@ -5,7 +5,7 @@ Chart control components for the market data layout. from dash import html, dcc from utils.logger import get_logger -logger = get_logger("chart_controls") +logger = get_logger("default_logger") def create_chart_config_panel(strategy_options, overlay_options, subplot_options): diff --git a/dashboard/layouts/market_data.py b/dashboard/layouts/market_data.py index b1c099f..c006fa3 100644 --- a/dashboard/layouts/market_data.py +++ b/dashboard/layouts/market_data.py @@ -13,7 +13,7 @@ from dashboard.components.chart_controls import ( create_auto_update_control ) -logger = get_logger("market_data_layout") +logger = get_logger("default_logger") def get_market_data_layout(): @@ -72,7 +72,7 @@ def get_market_data_layout(): subplot_options.append({'label': display_name, 'value': indicator.id}) except Exception as e: - logger.warning(f"Error loading indicator options: {e}") + logger.warning(f"Market data layout: Error loading indicator options: {e}") strategy_options = [{'label': 'Basic Chart', 'value': 'basic'}] overlay_options = [] subplot_options = []