Skip to content

Commit

Permalink
fix: insufficient returns in fitting rolling risk model
Browse files Browse the repository at this point in the history
  • Loading branch information
gavincyi committed Jun 23, 2023
1 parent fa59413 commit 96ca77b
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 68 deletions.
206 changes: 138 additions & 68 deletions examples/notebook/crypto_statistical_risk_model.ipynb

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/fpm_risk_model/rolling_factor_risk_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def transform(
validity_input = validity.loc[index]
y_input = y_input.loc[:, validity_input]

# Skip if the number of sample size is zero
if y_input.shape[1] == 0:
continue

risk_model = self.get(index)
values[index] = risk_model.transform(
y=y_input.fillna(0.0),
Expand Down
3 changes: 3 additions & 0 deletions src/fpm_risk_model/rolling_risk_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ def fit(
validity_input = validity.loc[index_name]
X_input = X_input.loc[:, validity_input]

if X_input.shape[1] == 0:
continue

params = {}
if weights_input is not None:
params["weights"] = weights_input
Expand Down

0 comments on commit 96ca77b

Please sign in to comment.