zman35 commited on
Commit
914ce23
Β·
verified Β·
1 Parent(s): c8c97be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
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 for πŸ† awards
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
- # Apply πŸ† emojis to winners
207
- for col in ["Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]:
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 EdgeCast Score
211
- df = df.sort_values("EdgeCast Score", ascending=False).reset_index(drop=True)
 
212
 
213
- # Add πŸ… Rank column
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
- fn=analytics_dashboard,
293
- inputs=[],
294
- outputs="dataframe",
295
- title="πŸ“Š Analytics Leaderboard"
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,