Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -186,7 +186,7 @@ def battle_strategies(style1, style2):
|
|
| 186 |
|
| 187 |
|
| 188 |
# π Leaderboard Tab
|
| 189 |
-
def analytics_dashboard():
|
| 190 |
results = []
|
| 191 |
for name, config in strategy_presets.items():
|
| 192 |
_, summary = simulate_tp_strategy_full(**{k: v for k, v in config.items() if k != "description"})
|
|
@@ -195,7 +195,7 @@ def analytics_dashboard():
|
|
| 195 |
|
| 196 |
df = pd.DataFrame(results)
|
| 197 |
|
| 198 |
-
# Identify winners
|
| 199 |
winners = {
|
| 200 |
"Final Balance": df["Final Balance"].max(),
|
| 201 |
"Sharpe Ratio": df["Sharpe Ratio"].max(),
|
|
@@ -203,19 +203,21 @@ def analytics_dashboard():
|
|
| 203 |
"Max Drawdown %": df["Max Drawdown %"].min()
|
| 204 |
}
|
| 205 |
|
| 206 |
-
#
|
| 207 |
-
for col in
|
| 208 |
df[col] = df[col].apply(lambda x: f"{round(x, 2)} π" if x == winners[col] else f"{round(x, 2)}")
|
| 209 |
|
| 210 |
-
# Sort by
|
| 211 |
-
|
|
|
|
| 212 |
|
| 213 |
-
# Add
|
| 214 |
df.insert(0, "π
Rank", [f"#{i+1}" for i in df.index])
|
| 215 |
|
| 216 |
return df[["π
Rank", "Strategy", "Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]]
|
| 217 |
|
| 218 |
|
|
|
|
| 219 |
# π Description Tab
|
| 220 |
def show_descriptions():
|
| 221 |
return pd.DataFrame([{"Strategy": k, "Description": v["description"]} for k, v in strategy_presets.items()])
|
|
@@ -289,11 +291,15 @@ app = gr.TabbedInterface(
|
|
| 289 |
),
|
| 290 |
|
| 291 |
gr.Interface(
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
gr.Interface(
|
| 299 |
fn=show_descriptions,
|
|
|
|
| 186 |
|
| 187 |
|
| 188 |
# π Leaderboard Tab
|
| 189 |
+
def analytics_dashboard(rank_by="EdgeCast Score"):
|
| 190 |
results = []
|
| 191 |
for name, config in strategy_presets.items():
|
| 192 |
_, summary = simulate_tp_strategy_full(**{k: v for k, v in config.items() if k != "description"})
|
|
|
|
| 195 |
|
| 196 |
df = pd.DataFrame(results)
|
| 197 |
|
| 198 |
+
# Identify winners
|
| 199 |
winners = {
|
| 200 |
"Final Balance": df["Final Balance"].max(),
|
| 201 |
"Sharpe Ratio": df["Sharpe Ratio"].max(),
|
|
|
|
| 203 |
"Max Drawdown %": df["Max Drawdown %"].min()
|
| 204 |
}
|
| 205 |
|
| 206 |
+
# π Award emojis
|
| 207 |
+
for col in winners:
|
| 208 |
df[col] = df[col].apply(lambda x: f"{round(x, 2)} π" if x == winners[col] else f"{round(x, 2)}")
|
| 209 |
|
| 210 |
+
# Sort by selected column
|
| 211 |
+
ascending = True if rank_by == "Max Drawdown %" else False
|
| 212 |
+
df = df.sort_values(rank_by, ascending=ascending).reset_index(drop=True)
|
| 213 |
|
| 214 |
+
# Add rank column
|
| 215 |
df.insert(0, "π
Rank", [f"#{i+1}" for i in df.index])
|
| 216 |
|
| 217 |
return df[["π
Rank", "Strategy", "Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]]
|
| 218 |
|
| 219 |
|
| 220 |
+
|
| 221 |
# π Description Tab
|
| 222 |
def show_descriptions():
|
| 223 |
return pd.DataFrame([{"Strategy": k, "Description": v["description"]} for k, v in strategy_presets.items()])
|
|
|
|
| 291 |
),
|
| 292 |
|
| 293 |
gr.Interface(
|
| 294 |
+
fn=analytics_dashboard,
|
| 295 |
+
inputs=gr.Dropdown(
|
| 296 |
+
choices=["EdgeCast Score", "Final Balance", "Sharpe Ratio", "Max Drawdown %"],
|
| 297 |
+
value="EdgeCast Score",
|
| 298 |
+
label="Sort leaderboard by:"
|
| 299 |
+
),
|
| 300 |
+
outputs="dataframe",
|
| 301 |
+
title="π Analytics Leaderboard"
|
| 302 |
+
),
|
| 303 |
|
| 304 |
gr.Interface(
|
| 305 |
fn=show_descriptions,
|