Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,40 +151,38 @@ def run_manual_sim(starting_balance, trades_min, trades_max, weeks,
|
|
| 151 |
# π₯ Battle Tab
|
| 152 |
def battle_strategies(style1, style2):
|
| 153 |
if style1 == "None" or style2 == "None":
|
| 154 |
-
|
| 155 |
-
return pd.DataFrame([{"β οΈ Error": "Please select two valid strategies before submitting."}]), go.Figure()
|
| 156 |
|
| 157 |
if style1 == style2:
|
| 158 |
-
return pd.DataFrame([{"β οΈ Error": "Please select two different strategies
|
| 159 |
|
| 160 |
try:
|
| 161 |
-
# Run simulations for both
|
| 162 |
df1, s1 = simulate_tp_strategy_full(**{k: v for k, v in strategy_presets[style1].items() if k != "description"})
|
| 163 |
df2, s2 = simulate_tp_strategy_full(**{k: v for k, v in strategy_presets[style2].items() if k != "description"})
|
| 164 |
|
| 165 |
s1["Strategy"] = style1
|
| 166 |
s2["Strategy"] = style2
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
|
| 171 |
-
#
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
# Plot chart
|
| 179 |
fig = go.Figure()
|
| 180 |
fig.add_trace(go.Scatter(x=df1["Week"], y=df1["End Balance"], name=style1))
|
| 181 |
fig.add_trace(go.Scatter(x=df2["Week"], y=df2["End Balance"], name=style2))
|
| 182 |
-
fig.update_layout(title=f"π₯ {style1} vs {style2}
|
| 183 |
|
| 184 |
-
return
|
| 185 |
|
| 186 |
except Exception as e:
|
| 187 |
-
return pd.DataFrame([{"
|
| 188 |
|
| 189 |
|
| 190 |
# π Leaderboard Tab
|
|
|
|
| 151 |
# π₯ Battle Tab
|
| 152 |
def battle_strategies(style1, style2):
|
| 153 |
if style1 == "None" or style2 == "None":
|
| 154 |
+
return pd.DataFrame([{"β οΈ Error": "Please select two valid strategies."}]), go.Figure()
|
|
|
|
| 155 |
|
| 156 |
if style1 == style2:
|
| 157 |
+
return pd.DataFrame([{"β οΈ Error": "Please select two different strategies."}]), go.Figure()
|
| 158 |
|
| 159 |
try:
|
|
|
|
| 160 |
df1, s1 = simulate_tp_strategy_full(**{k: v for k, v in strategy_presets[style1].items() if k != "description"})
|
| 161 |
df2, s2 = simulate_tp_strategy_full(**{k: v for k, v in strategy_presets[style2].items() if k != "description"})
|
| 162 |
|
| 163 |
s1["Strategy"] = style1
|
| 164 |
s2["Strategy"] = style2
|
| 165 |
|
| 166 |
+
comparison_df = pd.DataFrame([s1, s2])
|
| 167 |
+
comparison_df = comparison_df[["Strategy", "Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]]
|
| 168 |
|
| 169 |
+
# Add π for each best column
|
| 170 |
+
for col in ["Final Balance", "Sharpe Ratio", "EdgeCast Score"]:
|
| 171 |
+
best_val = comparison_df[col].max()
|
| 172 |
+
comparison_df[col] = [
|
| 173 |
+
f"{val} π" if val == best_val else f"{val}" for val in comparison_df[col]
|
| 174 |
+
]
|
| 175 |
|
| 176 |
+
# Chart both curves
|
|
|
|
|
|
|
| 177 |
fig = go.Figure()
|
| 178 |
fig.add_trace(go.Scatter(x=df1["Week"], y=df1["End Balance"], name=style1))
|
| 179 |
fig.add_trace(go.Scatter(x=df2["Week"], y=df2["End Balance"], name=style2))
|
| 180 |
+
fig.update_layout(title=f"π₯ {style1} vs {style2}", xaxis_title="Week", yaxis_title="Balance")
|
| 181 |
|
| 182 |
+
return comparison_df, fig
|
| 183 |
|
| 184 |
except Exception as e:
|
| 185 |
+
return pd.DataFrame([{"Error": str(e)}]), go.Figure()
|
| 186 |
|
| 187 |
|
| 188 |
# π Leaderboard Tab
|