Skip to content

Commit 7ebe356

Browse files
committed
fix: plot forecasts from the same date as symbol price plot
Signed-off-by: ivelin <[email protected]>
1 parent e5eea02 commit 7ebe356

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/canswim/dashboard/charts.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def plot_forecast(self, ticker: str = None, lowq: int = 0.2):
318318
self.canswim_model.train_history
319319
)
320320
visible_target = target.drop_before(plot_start_date)
321-
saved_forecast_df_list = self.get_saved_forecasts(ticker=ticker)
321+
saved_forecast_df_list = self.get_saved_forecasts(ticker=ticker, start_date=plot_start_date)
322322
lq = (100 - lowq) / 100
323323
visible_target.plot(label=f"{ticker} Close actual")
324324
# logger.debug(f"Plotting saved forecast: {saved_forecast_df_list}")
@@ -352,19 +352,19 @@ def plot_forecast(self, ticker: str = None, lowq: int = 0.2):
352352
plt.legend()
353353
return {self.plotComponent: fig, self.rrTable: rr_df}
354354

355-
def get_saved_forecasts(self, ticker: str = None):
355+
def get_saved_forecasts(self, ticker: str = None, start_date = None):
356356
"""Load forecasts from storage to a list of individual forecast series with quantile sampling"""
357357
# load parquet partition for stock
358-
logger.info(f"Loading saved forecast for {ticker}")
358+
logger.info(f"Loading saved forecast for {ticker} starting after: {start_date}")
359359
with duckdb.connect(self.db_path) as db_con:
360360
sql_result = db_con.sql(
361361
f"""--sql
362362
SELECT *
363363
FROM forecast as f
364-
WHERE f.symbol = $ticker
364+
WHERE f.symbol = $ticker AND f.start_date >= $start_date
365365
ORDER BY f.symbol, f.start_date, f.date
366366
""",
367-
params={"ticker": ticker},
367+
params={"ticker": ticker, "start_date": start_date},
368368
)
369369
df = sql_result.df()
370370
# filters = [("symbol", "=", ticker)]

0 commit comments

Comments
 (0)