2025-06-03 12:49:46 +08:00
|
|
|
"""
|
|
|
|
|
Modular Chart System for Crypto Trading Bot Dashboard
|
|
|
|
|
|
|
|
|
|
This package provides a flexible, strategy-driven chart system that supports:
|
|
|
|
|
- Technical indicator overlays (SMA, EMA, Bollinger Bands)
|
|
|
|
|
- Subplot management (RSI, MACD)
|
|
|
|
|
- Strategy-specific configurations
|
|
|
|
|
- Future bot signal integration
|
|
|
|
|
|
|
|
|
|
Main Components:
|
|
|
|
|
- ChartBuilder: Main orchestrator for chart creation
|
|
|
|
|
- Layer System: Modular rendering components
|
|
|
|
|
- Configuration System: Strategy-driven chart configs
|
|
|
|
|
"""
|
|
|
|
|
|
2025-06-03 13:56:15 +08:00
|
|
|
import plotly.graph_objects as go
|
2025-06-04 13:01:57 +08:00
|
|
|
from typing import List
|
2025-06-03 12:49:46 +08:00
|
|
|
from .builder import ChartBuilder
|
|
|
|
|
from .utils import (
|
|
|
|
|
validate_market_data,
|
|
|
|
|
prepare_chart_data,
|
|
|
|
|
get_indicator_colors
|
|
|
|
|
)
|
2025-06-03 13:56:15 +08:00
|
|
|
from .config import (
|
|
|
|
|
get_available_indicators,
|
|
|
|
|
calculate_indicators,
|
|
|
|
|
get_overlay_indicators,
|
|
|
|
|
get_subplot_indicators,
|
|
|
|
|
get_indicator_display_config
|
|
|
|
|
)
|
|
|
|
|
from .data_integration import (
|
|
|
|
|
MarketDataIntegrator,
|
|
|
|
|
DataIntegrationConfig,
|
|
|
|
|
get_market_data_integrator,
|
|
|
|
|
fetch_indicator_data,
|
|
|
|
|
check_symbol_data_quality
|
|
|
|
|
)
|
|
|
|
|
from .error_handling import (
|
|
|
|
|
ChartErrorHandler,
|
|
|
|
|
ChartError,
|
|
|
|
|
ErrorSeverity,
|
|
|
|
|
InsufficientDataError,
|
|
|
|
|
DataValidationError,
|
|
|
|
|
IndicatorCalculationError,
|
|
|
|
|
DataConnectionError,
|
|
|
|
|
check_data_sufficiency,
|
|
|
|
|
get_error_message,
|
|
|
|
|
create_error_annotation
|
|
|
|
|
)
|
2025-06-11 18:36:34 +08:00
|
|
|
from .chart_data import (
|
|
|
|
|
get_supported_symbols,
|
|
|
|
|
get_supported_timeframes,
|
|
|
|
|
get_market_statistics,
|
|
|
|
|
check_data_availability,
|
|
|
|
|
create_data_status_indicator
|
|
|
|
|
)
|
|
|
|
|
from .chart_creation import (
|
|
|
|
|
create_candlestick_chart,
|
|
|
|
|
create_strategy_chart,
|
|
|
|
|
create_error_chart,
|
|
|
|
|
create_basic_chart,
|
|
|
|
|
create_indicator_chart,
|
|
|
|
|
create_chart_with_indicators
|
|
|
|
|
)
|
2025-06-03 13:56:15 +08:00
|
|
|
|
|
|
|
|
# Layer imports with error handling
|
|
|
|
|
from .layers.base import (
|
|
|
|
|
LayerConfig,
|
|
|
|
|
BaseLayer,
|
|
|
|
|
CandlestickLayer,
|
|
|
|
|
VolumeLayer,
|
|
|
|
|
LayerManager
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from .layers.indicators import (
|
|
|
|
|
IndicatorLayerConfig,
|
|
|
|
|
BaseIndicatorLayer,
|
|
|
|
|
SMALayer,
|
|
|
|
|
EMALayer,
|
|
|
|
|
BollingerBandsLayer
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from .layers.subplots import (
|
|
|
|
|
SubplotLayerConfig,
|
|
|
|
|
BaseSubplotLayer,
|
|
|
|
|
RSILayer,
|
|
|
|
|
MACDLayer
|
|
|
|
|
)
|
2025-06-03 12:49:46 +08:00
|
|
|
|
|
|
|
|
# Version information
|
|
|
|
|
__version__ = "0.1.0"
|
|
|
|
|
__package_name__ = "charts"
|
|
|
|
|
|
|
|
|
|
# Public API exports
|
|
|
|
|
__all__ = [
|
2025-06-03 13:56:15 +08:00
|
|
|
# Core components
|
2025-06-03 12:49:46 +08:00
|
|
|
"ChartBuilder",
|
|
|
|
|
"validate_market_data",
|
|
|
|
|
"prepare_chart_data",
|
|
|
|
|
"get_indicator_colors",
|
2025-06-03 13:56:15 +08:00
|
|
|
|
|
|
|
|
# Chart creation functions
|
2025-06-03 12:49:46 +08:00
|
|
|
"create_candlestick_chart",
|
|
|
|
|
"create_strategy_chart",
|
2025-06-03 13:56:15 +08:00
|
|
|
"create_empty_chart",
|
|
|
|
|
"create_error_chart",
|
2025-06-11 18:36:34 +08:00
|
|
|
"create_basic_chart",
|
|
|
|
|
"create_indicator_chart",
|
|
|
|
|
"create_chart_with_indicators",
|
2025-06-03 13:56:15 +08:00
|
|
|
|
|
|
|
|
# Data integration
|
|
|
|
|
"MarketDataIntegrator",
|
|
|
|
|
"DataIntegrationConfig",
|
|
|
|
|
"get_market_data_integrator",
|
|
|
|
|
"fetch_indicator_data",
|
|
|
|
|
"check_symbol_data_quality",
|
|
|
|
|
|
|
|
|
|
# Error handling
|
|
|
|
|
"ChartErrorHandler",
|
|
|
|
|
"ChartError",
|
|
|
|
|
"ErrorSeverity",
|
|
|
|
|
"InsufficientDataError",
|
|
|
|
|
"DataValidationError",
|
|
|
|
|
"IndicatorCalculationError",
|
|
|
|
|
"DataConnectionError",
|
|
|
|
|
"check_data_sufficiency",
|
|
|
|
|
"get_error_message",
|
|
|
|
|
"create_error_annotation",
|
|
|
|
|
|
2025-06-11 18:36:34 +08:00
|
|
|
# Data-related utility functions
|
2025-06-03 13:56:15 +08:00
|
|
|
"get_supported_symbols",
|
|
|
|
|
"get_supported_timeframes",
|
2025-06-03 12:49:46 +08:00
|
|
|
"get_market_statistics",
|
|
|
|
|
"check_data_availability",
|
|
|
|
|
"create_data_status_indicator",
|
2025-06-03 13:56:15 +08:00
|
|
|
|
|
|
|
|
# Base layers
|
|
|
|
|
"LayerConfig",
|
|
|
|
|
"BaseLayer",
|
|
|
|
|
"CandlestickLayer",
|
|
|
|
|
"VolumeLayer",
|
|
|
|
|
"LayerManager",
|
|
|
|
|
|
|
|
|
|
# Indicator layers
|
|
|
|
|
"IndicatorLayerConfig",
|
|
|
|
|
"BaseIndicatorLayer",
|
|
|
|
|
"SMALayer",
|
|
|
|
|
"EMALayer",
|
|
|
|
|
"BollingerBandsLayer",
|
|
|
|
|
|
|
|
|
|
# Subplot layers
|
|
|
|
|
"SubplotLayerConfig",
|
|
|
|
|
"BaseSubplotLayer",
|
|
|
|
|
"RSILayer",
|
|
|
|
|
"MACDLayer",
|
2025-06-05 12:54:41 +08:00
|
|
|
|
2025-06-11 18:36:34 +08:00
|
|
|
]
|