Update page/complete_backtest.py
Browse files- page/complete_backtest.py +12 -11
page/complete_backtest.py
CHANGED
@@ -76,23 +76,24 @@ def complete_backtest():
|
|
76 |
# Button to run the analysis
|
77 |
if st.button("Run"):
|
78 |
start = time.time()
|
79 |
-
|
80 |
swing_hl=swing_hl, ema1=ema1, ema2=ema2,
|
81 |
close_on_crossover=close_on_crossover, cash=initial_cash,
|
82 |
commission=commission/100)
|
|
|
|
|
83 |
st.success(f"Analysis finished in {round(time.time()-start, 2)} seconds")
|
84 |
|
85 |
-
if "
|
86 |
# st.write("⬇️ Select a row in index column to get detailed information of the respective stock run.")
|
87 |
st.markdown(f"""
|
88 |
---
|
89 |
### :orange[{stock_list} stocks backtest result by using {strategy} strategy]
|
90 |
⬇️ Select rows in 'Select' column to get backtest plots of the selected stocks.
|
91 |
""")
|
92 |
-
st.session_state.results['Select'] = False
|
93 |
|
94 |
cols = ['Select', 'Stock', 'Sector', 'Start', 'End', 'Return [%]', 'Equity Final [₹]', 'Buy & Hold Return [%]', '# Trades', 'Win Rate [%]', 'Best Trade [%]', 'Worst Trade [%]', 'Avg. Trade [%]']
|
95 |
-
|
96 |
|
97 |
st.session_state.categorized_results_dict = {}
|
98 |
st.session_state.selected_stocks = {}
|
@@ -124,12 +125,12 @@ def complete_backtest():
|
|
124 |
""")
|
125 |
break
|
126 |
|
127 |
-
for selected_rows in st.session_state.selected_stocks.values():
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
135 |
complete_backtest()
|
|
|
76 |
# Button to run the analysis
|
77 |
if st.button("Run"):
|
78 |
start = time.time()
|
79 |
+
results = complete_test(stock_list, strategy, period, interval, multiprocess,
|
80 |
swing_hl=swing_hl, ema1=ema1, ema2=ema2,
|
81 |
close_on_crossover=close_on_crossover, cash=initial_cash,
|
82 |
commission=commission/100)
|
83 |
+
results['Select'] = False
|
84 |
+
st.session_state.categorized_results = categorize_df(results, 'Sector', 'Return [%]')
|
85 |
st.success(f"Analysis finished in {round(time.time()-start, 2)} seconds")
|
86 |
|
87 |
+
if "categorized_results" in st.session_state:
|
88 |
# st.write("⬇️ Select a row in index column to get detailed information of the respective stock run.")
|
89 |
st.markdown(f"""
|
90 |
---
|
91 |
### :orange[{stock_list} stocks backtest result by using {strategy} strategy]
|
92 |
⬇️ Select rows in 'Select' column to get backtest plots of the selected stocks.
|
93 |
""")
|
|
|
94 |
|
95 |
cols = ['Select', 'Stock', 'Sector', 'Start', 'End', 'Return [%]', 'Equity Final [₹]', 'Buy & Hold Return [%]', '# Trades', 'Win Rate [%]', 'Best Trade [%]', 'Worst Trade [%]', 'Avg. Trade [%]']
|
96 |
+
|
97 |
|
98 |
st.session_state.categorized_results_dict = {}
|
99 |
st.session_state.selected_stocks = {}
|
|
|
125 |
""")
|
126 |
break
|
127 |
|
128 |
+
# for selected_rows in st.session_state.selected_stocks.values():
|
129 |
+
# for row in selected_rows:
|
130 |
+
# ticker = st.session_state.results['Stock'].values[row]
|
131 |
+
# plot = st.session_state.results['plot'].values[row]
|
132 |
+
# color = "green" if st.session_state.results['Return [%]'].values[row] > 0 else "red"
|
133 |
+
# with st.expander(f":{color}[{ticker} backtest plot] 📊"):
|
134 |
+
# components.html(plot, height=900)
|
135 |
|
136 |
complete_backtest()
|