From 1647ce653a832876351b0207f1440d2f7f730385 Mon Sep 17 00:00:00 2001 From: "wenwen.tang@thizgroup.com" <wenwen.tang@thizgroup.com> Date: Wed, 3 Apr 2024 15:59:24 +0800 Subject: [PATCH] =?UTF-8?q?https://www.tapd.cn/59187493/documents/show/115?= =?UTF-8?q?9187493001000730=20=E4=BE=9D=E7=85=A7=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=A8=A1=E5=9E=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asset_pool/asset_optimize.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/asset_pool/asset_optimize.py b/asset_pool/asset_optimize.py index 710a105..f34debd 100644 --- a/asset_pool/asset_optimize.py +++ b/asset_pool/asset_optimize.py @@ -218,7 +218,7 @@ class FundDividendSortinoAssetOptimize(SortinoAssetOptimize): def get_groups(self, day=None): funds = pd.DataFrame(self.get_filtered_funds(day)) if len(funds) < get_config('portfolios.solver.asset-count')[0]: - raise ValueError(f"基金优选个数å°äºŽ{get_config('portfolios.solver.asset-count')[0]}ï¼Œè¯·è°ƒæ•´å‚æ•°") + raise ValueError(f"{day}==基金优选个数å°äºŽ{get_config('portfolios.solver.asset-count')[0]}ï¼Œè¯·è°ƒæ•´å‚æ•°") result = [] if self.asset_include: include = list(self.asset_include.keys())[0] @@ -233,14 +233,15 @@ class FundDividendSortinoAssetOptimize(SortinoAssetOptimize): def get_pct_change(self, fund_ids, day): if not self._config: raise exception(f"find optimize, but not found sortino config.") - days = [day - relativedelta(days=1, **dict_remove(x, ('weight', 'name'))) for x in self._config] - days.append(day - relativedelta(days=1, **self.annual_volatility_section[0])) + days = [day - relativedelta(days=7, **dict_remove(x, ('weight', 'name'))) for x in self._config] + days.append(day - relativedelta(days=7, **self.annual_volatility_section[0])) start = filter_weekend(sorted(days)[0]) fund_navs = pd.DataFrame(self._navs.get_fund_navs(fund_ids=tuple(fund_ids), min_date=start, max_date=day)) if not fund_navs.empty: fund_navs.sort_values('nav_date', inplace=True) fund_navs = fund_navs.pivot_table(index='nav_date', columns='fund_id', values='nav_cal') fund_navs.fillna(method='ffill', inplace=True) + fund_navs = fund_navs.loc[fund_navs.index >= start + relativedelta(days=6)] fund_navs.dropna(axis=1, inplace=True) result = round(fund_navs.pct_change().dropna(), 4) result.reset_index(inplace=True) -- 2.18.1