fix: Handle missing keys and correct max drawdown metric in backtest results
This commit is contained in:
parent
7fab19c9d6
commit
a18bc66b19
@ -247,7 +247,7 @@ def run_optimization(df: pd.DataFrame, indicator_settings: Dict) -> List:
|
|||||||
'parameters': params,
|
'parameters': params,
|
||||||
'Return [%]': stats['Return [%]'],
|
'Return [%]': stats['Return [%]'],
|
||||||
'Sharpe Ratio': stats['Sharpe Ratio'],
|
'Sharpe Ratio': stats['Sharpe Ratio'],
|
||||||
'Max Drawdown [%]': stats['Max Drawdown [%]'],
|
'Max Drawdown [%]': stats['Max. Drawdown [%]'], # Updated key
|
||||||
'Win Rate [%]': stats['Win Rate [%]']
|
'Win Rate [%]': stats['Win Rate [%]']
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -307,13 +307,13 @@ def display_backtest_results(results: Dict):
|
|||||||
# Display key metrics
|
# Display key metrics
|
||||||
col1, col2, col3, col4 = st.columns(4)
|
col1, col2, col3, col4 = st.columns(4)
|
||||||
with col1:
|
with col1:
|
||||||
st.metric("Return", f"{results['Return [%]']:.2f}%")
|
st.metric("Return", f"{results.get('Return [%]', 0):.2f}%")
|
||||||
with col2:
|
with col2:
|
||||||
st.metric("Sharpe Ratio", f"{results['Sharpe Ratio']:.2f}")
|
st.metric("Sharpe Ratio", f"{results.get('Sharpe Ratio', 0):.2f}")
|
||||||
with col3:
|
with col3:
|
||||||
st.metric("Max Drawdown", f"{results['Max Drawdown [%]']:.2f}%")
|
st.metric("Max Drawdown", f"{results.get('Max. Drawdown [%]', 0):.2f}%")
|
||||||
with col4:
|
with col4:
|
||||||
st.metric("Win Rate", f"{results['Win Rate [%]']:.2f}%")
|
st.metric("Win Rate", f"{results.get('Win Rate [%]', 0):.2f}%")
|
||||||
|
|
||||||
# Display full results in expandable section
|
# Display full results in expandable section
|
||||||
with st.expander("See detailed results"):
|
with st.expander("See detailed results"):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user