import dash
from dash import dcc, html
from utils.helpers import load_data
from layouts.main_layout import create_layout
from callbacks.backtest_callbacks import register_backtest_callbacks
from callbacks.strategy_callbacks import register_strategy_callbacks

# Create the Dash app
app = dash.Dash(__name__,
                prevent_initial_callbacks=True,
                suppress_callback_exceptions=True)

# Load data
try:
    full_data = load_data()
except Exception as e:
    raise Exception(f"Error: {str(e)}")

# Set up the layout
app.layout = create_layout(full_data)

# Register callbacks
register_backtest_callbacks(app)
register_strategy_callbacks(app)

if __name__ == '__main__':
    app.run_server(debug=True)