Skip to content

Commit

Permalink
Fix for #1467 (Forecast weight bug with auto-grouping)
Browse files Browse the repository at this point in the history
Construct an empty DataFrame with a Datetime index instead of using concat.
  • Loading branch information
Vishal Grover committed Nov 28, 2024
1 parent 4e86ee2 commit 31c79ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions syscore/pandas/frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def interpolate_for_a_single_day(


def reindex_last_monthly_include_first_date(df: pd.DataFrame) -> pd.DataFrame:
if df.empty:
return df

df_monthly_index = list(df.resample("1M").last().index) ## last day in month
df_first_date_in_index = df.index[0]
df_monthly_index = [df_first_date_in_index] + df_monthly_index
Expand Down
6 changes: 6 additions & 0 deletions systems/forecast_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def get_unsmoothed_forecast_weights(self, instrument_code: str):
monthly_forecast_weights=monthly_forecast_weights,
)

if forecast_weights_fixed_to_forecasts.empty:
return forecast_weights_fixed_to_forecasts

# Remap to business day frequency so the smoothing makes sense also space saver
daily_forecast_weights_fixed_to_forecasts_unsmoothed = (
forecast_weights_fixed_to_forecasts.resample("1B").mean()
Expand Down Expand Up @@ -445,6 +448,9 @@ def get_forecasts_given_rule_list(
for rule_variation_name in rule_variation_list
]

if not forecasts:
return pd.DataFrame(index=pd.DatetimeIndex([]))

forecasts = pd.concat(forecasts, axis=1)

forecasts.columns = rule_variation_list
Expand Down

0 comments on commit 31c79ed

Please sign in to comment.