James McCool
commited on
Commit
·
232eb2a
1
Parent(s):
607dd10
Update app.py and trim_portfolio.py to change threshold parameters from integers to floats, enhancing precision in portfolio trimming functionality and ensuring consistent data handling.
Browse files- app.py +4 -4
- global_func/trim_portfolio.py +1 -1
app.py
CHANGED
|
@@ -912,10 +912,10 @@ with tab2:
|
|
| 912 |
with st.form(key='trim_form'):
|
| 913 |
performance_type = st.selectbox("Select Sorting variable", ['median', 'Finish_percentile'])
|
| 914 |
own_type = st.selectbox("Select trimming variable", ['Own', 'Geomean', 'Weighted Own'])
|
| 915 |
-
performance_threshold_high = st.number_input("Select performance threshold (will only trim if sorting variable is lower than this)", value=st.session_state['portfolio'][performance_type].max(), min_value=0, step=1)
|
| 916 |
-
performance_threshold_low = st.number_input("Select performance threshold (will only trim if sorting variable is higher than this)", value=0, min_value=0, step=1)
|
| 917 |
-
own_threshold_high = st.number_input("Select own threshold (will only trim if trimming variable is lower than this)", value=st.session_state['portfolio'][own_type].max(), min_value=0, step=1)
|
| 918 |
-
own_threshold_low = st.number_input("Select own threshold (will only trim if trimming variable is higher than this)", value=0, min_value=0, step=1)
|
| 919 |
submitted = st.form_submit_button("Trim")
|
| 920 |
if submitted:
|
| 921 |
st.write('initiated')
|
|
|
|
| 912 |
with st.form(key='trim_form'):
|
| 913 |
performance_type = st.selectbox("Select Sorting variable", ['median', 'Finish_percentile'])
|
| 914 |
own_type = st.selectbox("Select trimming variable", ['Own', 'Geomean', 'Weighted Own'])
|
| 915 |
+
performance_threshold_high = st.number_input("Select performance threshold (will only trim if sorting variable is lower than this)", value=st.session_state['portfolio'][performance_type].max(), min_value=0.0, step=1.0)
|
| 916 |
+
performance_threshold_low = st.number_input("Select performance threshold (will only trim if sorting variable is higher than this)", value=0.0, min_value=0.0, step=1.0)
|
| 917 |
+
own_threshold_high = st.number_input("Select own threshold (will only trim if trimming variable is lower than this)", value=st.session_state['portfolio'][own_type].max(), min_value=0.0, step=1.0)
|
| 918 |
+
own_threshold_low = st.number_input("Select own threshold (will only trim if trimming variable is higher than this)", value=0.0, min_value=0.0, step=1.0)
|
| 919 |
submitted = st.form_submit_button("Trim")
|
| 920 |
if submitted:
|
| 921 |
st.write('initiated')
|
global_func/trim_portfolio.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
|
| 3 |
-
def trim_portfolio(portfolio: pd.DataFrame, performance_type: str, own_type: str, performance_threshold_high:
|
| 4 |
if performance_type == 'Finish_percentile':
|
| 5 |
working_portfolio = portfolio.sort_values(by=performance_type, ascending = True).reset_index(drop=True)
|
| 6 |
else:
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
|
| 3 |
+
def trim_portfolio(portfolio: pd.DataFrame, performance_type: str, own_type: str, performance_threshold_high: float, performance_threshold_low: float, own_threshold_high: float, own_threshold_low: float):
|
| 4 |
if performance_type == 'Finish_percentile':
|
| 5 |
working_portfolio = portfolio.sort_values(by=performance_type, ascending = True).reset_index(drop=True)
|
| 6 |
else:
|