Skip to content

Commit

Permalink
1) Fixed type signature for get_forecasts_given_rule_list
Browse files Browse the repository at this point in the history
2) Fixed sysproduction.strategy_code.report_system_classic to handle empty rule list
  • Loading branch information
Vishal Grover committed Dec 13, 2024
1 parent 31c79ed commit 0acedb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions sysproduction/strategy_code/report_system_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,16 @@ def get_forecast_matrix_over_code(
for instrument_code in instrument_codes:
stage = getattr(data_backtest.system, stage_name)
method = getattr(stage, method_name)
value_row = method(instrument_code).ffill()[:datetime_cutoff].iloc[-1]
values_by_rule = [
value_row.get(rule_name, np.nan) for rule_name in trading_rule_names
]
values = method(instrument_code).ffill()[:datetime_cutoff]

if not values.empty:
value_row = values.iloc[-1]
values_by_rule = [
value_row.get(rule_name, np.nan) for rule_name in trading_rule_names
]
else:
values_by_rule = [np.nan] * len(trading_rule_names)

value_dict[instrument_code] = values_by_rule

value_df = pd.DataFrame(value_dict, index=trading_rule_names)
Expand Down
2 changes: 1 addition & 1 deletion systems/forecast_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def get_trading_rule_list_for_estimated_weights(self, instrument_code: str) -> l
@diagnostic()
def get_forecasts_given_rule_list(
self, instrument_code: str, rule_variation_list: list
) -> pd.Series:
) -> pd.DataFrame:
"""
Convenience function to get a list of forecasts
Expand Down

0 comments on commit 0acedb8

Please sign in to comment.