From dc58d48becd193dc2a1a128083398152586473c4 Mon Sep 17 00:00:00 2001 From: "wenwen.tang@thizgroup.com" <wenwen.tang@thizgroup.com> Date: Wed, 3 Apr 2024 18:50:38 +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 --- portfolios/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/portfolios/utils.py b/portfolios/utils.py index 575f948..3035282 100644 --- a/portfolios/utils.py +++ b/portfolios/utils.py @@ -41,9 +41,9 @@ def format_weight(weight: dict, to=1) -> dict: low = get_config('portfolios.solver.mpt.low-weight') high = get_config('portfolios.solver.mpt.high-weight')[0] # 低风险 - minidx = [i for i in id_sort if weight[i] < high][0] + minidx = [i for i in id_sort if weight_series[i] < high][0] # 高风险 - maxidx = [i for i in id_sort if weight[i] > low][-1] + maxidx = [i for i in id_sort if weight_series[i] > low][-1] if weight_series.sum() < to: weight_series[minidx] += to - weight_series.sum() elif weight_series.sum() > to: -- 2.18.1