Remove deprecated app_new.py and consolidate main application logic into main.py
- Deleted `app_new.py`, which was previously the main entry point for the dashboard application, to streamline the codebase. - Consolidated the application initialization and callback registration logic into `main.py`, enhancing modularity and maintainability. - Updated the logging and error handling practices in `main.py` to ensure consistent application behavior and improved debugging capabilities. These changes simplify the application structure, aligning with project standards for modularity and maintainability.
This commit is contained in:
@@ -6,13 +6,14 @@ from dash import Output, Input, html, dcc
|
||||
import dash_bootstrap_components as dbc
|
||||
from utils.logger import get_logger
|
||||
from dashboard.components.data_analysis import (
|
||||
VolumeAnalyzer,
|
||||
PriceMovementAnalyzer,
|
||||
create_volume_analysis_chart,
|
||||
create_price_movement_chart,
|
||||
create_volume_stats_display,
|
||||
create_price_stats_display
|
||||
create_price_stats_display,
|
||||
get_market_statistics,
|
||||
VolumeAnalyzer,
|
||||
PriceMovementAnalyzer
|
||||
)
|
||||
from database.operations import get_database_operations
|
||||
from datetime import datetime, timezone, timedelta
|
||||
|
||||
logger = get_logger("data_analysis_callbacks")
|
||||
|
||||
@@ -24,26 +25,38 @@ def register_data_analysis_callbacks(app):
|
||||
|
||||
# Initial callback to populate charts on load
|
||||
@app.callback(
|
||||
[Output('analysis-chart-container', 'children'),
|
||||
Output('analysis-stats-container', 'children')],
|
||||
[Input('analysis-type-selector', 'value'),
|
||||
Input('analysis-period-selector', 'value')],
|
||||
[Output('volume-analysis-chart', 'figure'),
|
||||
Output('price-movement-chart', 'figure'),
|
||||
Output('volume-stats-output', 'children'),
|
||||
Output('price-stats-output', 'children'),
|
||||
Output('market-statistics-output', 'children')],
|
||||
[Input('data-analysis-symbol-dropdown', 'value'),
|
||||
Input('data-analysis-timeframe-dropdown', 'value'),
|
||||
Input('data-analysis-days-back-dropdown', 'value')],
|
||||
prevent_initial_call=False
|
||||
)
|
||||
def update_data_analysis(analysis_type, period):
|
||||
def update_data_analysis(symbol, timeframe, days_back):
|
||||
"""Update data analysis with statistical cards only (no duplicate charts)."""
|
||||
logger.info(f"🎯 DATA ANALYSIS CALLBACK TRIGGERED! Type: {analysis_type}, Period: {period}")
|
||||
logger.info(f"🎯 DATA ANALYSIS CALLBACK TRIGGERED! Symbol: {symbol}, Timeframe: {timeframe}, Days Back: {days_back}")
|
||||
|
||||
db_ops = get_database_operations(logger)
|
||||
end_time = datetime.now(timezone.utc)
|
||||
start_time = end_time - timedelta(days=days_back)
|
||||
|
||||
# Return placeholder message since we're moving to enhanced market stats
|
||||
info_msg = dbc.Alert([
|
||||
html.H4("📊 Statistical Analysis", className="alert-heading"),
|
||||
html.P("Data analysis has been integrated into the Market Statistics section above."),
|
||||
html.P("The enhanced statistics now include volume analysis, price movement analysis, and trend indicators."),
|
||||
html.P("Change the symbol and timeframe in the main chart to see updated analysis."),
|
||||
html.Hr(),
|
||||
html.P("This section will be updated with additional analytical tools in future versions.", className="mb-0")
|
||||
], color="info")
|
||||
df = db_ops.market_data.get_candles_df(symbol, timeframe, start_time, end_time)
|
||||
|
||||
volume_analyzer = VolumeAnalyzer()
|
||||
price_analyzer = PriceMovementAnalyzer()
|
||||
|
||||
return info_msg, html.Div()
|
||||
volume_stats = volume_analyzer.get_volume_statistics(df)
|
||||
price_stats = price_analyzer.get_price_movement_statistics(df)
|
||||
|
||||
volume_stats_display = create_volume_stats_display(volume_stats)
|
||||
price_stats_display = create_price_stats_display(price_stats)
|
||||
market_stats_display = get_market_statistics(df, symbol, timeframe)
|
||||
|
||||
# Return empty figures for charts, as they are no longer the primary display
|
||||
# And the stats displays
|
||||
return {}, {}, volume_stats_display, price_stats_display, market_stats_display
|
||||
|
||||
logger.info("✅ Data analysis callbacks registered successfully")
|
||||
Reference in New Issue
Block a user