James McCool
commited on
Commit
·
06c4d25
1
Parent(s):
8a560d8
Enhance portfolio trimming logic in trim_portfolio.py by adding calculation for maximum ownership type value when conditions are not met. This adjustment improves the accuracy of the trimming process by ensuring all relevant ownership metrics are considered.
Browse files
global_func/trim_portfolio.py
CHANGED
@@ -25,6 +25,8 @@ def trim_portfolio(portfolio: pd.DataFrame, trim_slack: float, performance_type:
|
|
25 |
working_portfolio.loc[i, own_type] > own_threshold_low and \
|
26 |
working_portfolio.loc[i, own_type] <= own_threshold_high:
|
27 |
rows_to_drop.append(i)
|
|
|
|
|
28 |
|
29 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
30 |
return working_portfolio
|
|
|
25 |
working_portfolio.loc[i, own_type] > own_threshold_low and \
|
26 |
working_portfolio.loc[i, own_type] <= own_threshold_high:
|
27 |
rows_to_drop.append(i)
|
28 |
+
else:
|
29 |
+
curr_own_type_max = working_portfolio.loc[i, own_type] + (trim_slack * working_portfolio.loc[i, own_type])
|
30 |
|
31 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
32 |
return working_portfolio
|