Skip to content

Commit

Permalink
Merge pull request #72 from ivelin/fix/dashboard
Browse files Browse the repository at this point in the history
fix: plot forecasts from the same date as symbol price plot
  • Loading branch information
ivelin authored Dec 23, 2024
2 parents e5eea02 + 7ebe356 commit b18ccfa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/canswim/dashboard/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def plot_forecast(self, ticker: str = None, lowq: int = 0.2):
self.canswim_model.train_history
)
visible_target = target.drop_before(plot_start_date)
saved_forecast_df_list = self.get_saved_forecasts(ticker=ticker)
saved_forecast_df_list = self.get_saved_forecasts(ticker=ticker, start_date=plot_start_date)
lq = (100 - lowq) / 100
visible_target.plot(label=f"{ticker} Close actual")
# logger.debug(f"Plotting saved forecast: {saved_forecast_df_list}")
Expand Down Expand Up @@ -352,19 +352,19 @@ def plot_forecast(self, ticker: str = None, lowq: int = 0.2):
plt.legend()
return {self.plotComponent: fig, self.rrTable: rr_df}

def get_saved_forecasts(self, ticker: str = None):
def get_saved_forecasts(self, ticker: str = None, start_date = None):
"""Load forecasts from storage to a list of individual forecast series with quantile sampling"""
# load parquet partition for stock
logger.info(f"Loading saved forecast for {ticker}")
logger.info(f"Loading saved forecast for {ticker} starting after: {start_date}")
with duckdb.connect(self.db_path) as db_con:
sql_result = db_con.sql(
f"""--sql
SELECT *
FROM forecast as f
WHERE f.symbol = $ticker
WHERE f.symbol = $ticker AND f.start_date >= $start_date
ORDER BY f.symbol, f.start_date, f.date
""",
params={"ticker": ticker},
params={"ticker": ticker, "start_date": start_date},
)
df = sql_result.df()
# filters = [("symbol", "=", ticker)]
Expand Down

0 comments on commit b18ccfa

Please sign in to comment.