Skip to content

Commit

Permalink
handle relevant date that is after the latest index value
Browse files Browse the repository at this point in the history
  • Loading branch information
bug-or-feature committed Nov 30, 2024
1 parent 1e3fa59 commit 1ff1b05
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions sysquant/estimators/stdev_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ def list_of_keys(self) -> list:
class seriesOfStdevEstimates(pd.DataFrame):
def get_stdev_on_date(self, relevant_date: datetime.datetime) -> stdevEstimates:
if relevant_date < self.index[0]:
stdev_as_dict = get_row_of_df_aligned_to_weights_as_dict(
df=self, relevant_date=self.index[0]
)

else:
stdev_as_dict = get_row_of_df_aligned_to_weights_as_dict(
df=self, relevant_date=relevant_date
)
relevant_date = self.index[0]
if relevant_date > self.index[-1]:
relevant_date = self.index[-1]

stdev_as_dict = get_row_of_df_aligned_to_weights_as_dict(
df=self, relevant_date=relevant_date
)
return stdevEstimates(stdev_as_dict)

def shocked(self, shock_quantile=0.99, roll_years=10, bfill=True):
Expand Down

0 comments on commit 1ff1b05

Please sign in to comment.