From d44f5c1eada931ae7d71196f9d41e66148e339e3 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Mon, 28 Oct 2024 11:25:04 -0700 Subject: [PATCH] Load a year's worth of data for signal generation but limit chart to 180 days --- dashboard.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dashboard.py b/dashboard.py index 96348d9..83150ee 100644 --- a/dashboard.py +++ b/dashboard.py @@ -28,7 +28,7 @@ signal_functions: List[Dict[str, SignalFunction]] = [ symbol = 'SPY' today = datetime.today() -data = ohlc(symbol = symbol, start_date = today - timedelta(days = 180), end_date = today) +data = ohlc(symbol = symbol, start_date = today - timedelta(days = 365), end_date = today) def calculate_signals(days: int = 12) -> DataFrame: signal_data = [] @@ -46,12 +46,13 @@ def calculate_signals(days: int = 12) -> DataFrame: return DataFrame(signal_data) def load_chart() -> dict: + chart_data = data.tail(180) candlestick_chart = CandlestickChart( - x = data['Date'], - opens = data['Open'], - highs = data['High'], - lows = data['Low'], - closes = data['Close'] + x = chart_data['Date'], + opens = chart_data['Open'], + highs = chart_data['High'], + lows = chart_data['Low'], + closes = chart_data['Close'] ) return figure_with_subplots([[candlestick_chart]])