Skip to content

Commit

Permalink
feat: add a get method for rolling cov estimator
Browse files Browse the repository at this point in the history
  • Loading branch information
gavincyi committed Dec 15, 2023
1 parent 220ba02 commit da29453
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/fpm_risk_model/cov_estimator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from numpy import diag_indices_from, trace
from pandas import DataFrame, Series
from pandas import DataFrame, Series, Timestamp

from .risk_model import RiskModel
from .rolling_factor_risk_model import RollingFactorRiskModel
Expand Down Expand Up @@ -143,3 +143,18 @@ def cov(self, volatility: Optional[DataFrame] = None):
)
for date, risk_model in self._rolling_risk_model.items()
}

def get(self, date: Timestamp) -> CovarianceEstimator:
"""
Get the covariance estimator for a given date.
Parameters
----------
date : pd.Timestamp
Date.
"""
return CovarianceEstimator(
self._rolling_risk_model.get(date),
shrinkage_method=self.shrinkage_method,
delta=self.delta,
)

0 comments on commit da29453

Please sign in to comment.