Skip to content

Commit

Permalink
Caching changes to rawdata; catch empty rule list in report_system_cl…
Browse files Browse the repository at this point in the history
…assic
  • Loading branch information
Vishal Grover committed Dec 13, 2024
1 parent 437a828 commit cec5ca5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions sysproduction/strategy_code/report_system_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def get_forecast_matrix(
for instrument_code in instrument_codes:
stage = getattr(data_backtest.system, stage_name)
method = getattr(stage, method_name)
value = method(instrument_code, rule_name).ffill()[:datetime_cutoff][-1]
value = method(instrument_code, rule_name).ffill()[:datetime_cutoff].iloc[-1]
value_dict[rule_name].append(value)

value_df = pd.DataFrame(value_dict, index=instrument_codes)
Expand All @@ -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/rawdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_fx_for_instrument(self, instrument_code: str, base_currency: str):
instrument_code=instrument_code, base_currency=base_currency
)

@input
@output()
def get_daily_prices(self, instrument_code) -> pd.Series:
"""
Gets daily prices
Expand Down

0 comments on commit cec5ca5

Please sign in to comment.