zman35 commited on
Commit
f677063
Β·
verified Β·
1 Parent(s): 9170f1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +134 -233
app.py CHANGED
@@ -53,35 +53,29 @@ def get_strategy_presets():
53
 
54
  strategy_presets = get_strategy_presets()
55
 
56
- # === CORE SIMULATION ENGINE ===
57
  def simulate_tp_strategy_full(starting_balance, trades_min, trades_max, weeks,
58
  tp1_prob, tp2_prob, tp1_r, tp2_r, base_risk_pct,
59
  profit_target=None, fatigue=0.0, trump_vol=0.0):
60
  if tp1_prob + tp2_prob >= 1.0:
61
  return pd.DataFrame(), {"Error": "Invalid probability config. TP1 + TP2 must be < 1.0"}
62
-
63
  sl_prob = 1.0 - tp1_prob - tp2_prob
64
- balance = starting_balance
65
- peak = balance
66
- drawdown = 0
67
  tp1_hits = tp2_hits = sl_hits = 0
68
- max_win_streak = max_loss_streak = 0
69
- cur_win_streak = cur_loss_streak = 0
70
- log = []
71
-
72
  fatigue_multiplier = 1.0 - fatigue * 0.4
73
  trump_vol_factor = np.random.normal(1.0, 0.2 * trump_vol)
 
74
 
75
  for week in range(1, weeks + 1):
76
- if profit_target and balance >= profit_target:
77
- break
78
  week_start = balance
79
  num_trades = np.random.randint(trades_min, trades_max + 1)
 
80
  for _ in range(num_trades):
81
- risk_pct = base_risk_pct
82
- risk_amount = balance * risk_pct * np.random.uniform(0.9, 1.1)
83
  risk_amount *= trump_vol_factor
84
-
85
  if fatigue > 0.6 and cur_loss_streak >= 3 and np.random.rand() < fatigue * 0.25:
86
  outcome = "SL"
87
  else:
@@ -108,19 +102,16 @@ def simulate_tp_strategy_full(starting_balance, trades_min, trades_max, weeks,
108
  peak = max(peak, balance)
109
  drawdown = max(drawdown, (peak - balance) / peak * 100)
110
 
111
- weekly_return = (balance - week_start) / week_start * 100
112
  log.append({
113
  "Week": week, "Start Balance": round(week_start, 2),
114
  "End Balance": round(balance, 2),
115
- "Weekly Return (%)": round(weekly_return, 2)
116
  })
117
 
118
  df = pd.DataFrame(log)
119
  returns = df["End Balance"].pct_change().dropna()
120
- volatility = returns.std() * np.sqrt(52)
121
- sharpe_ratio = returns.mean() / returns.std() * np.sqrt(52) if returns.std() > 0 else 0
122
  score = balance / (1 + drawdown)
123
-
124
  summary = {
125
  "Final Balance": round(balance, 2),
126
  "TP1 Hits": tp1_hits,
@@ -129,271 +120,181 @@ def simulate_tp_strategy_full(starting_balance, trades_min, trades_max, weeks,
129
  "Max Drawdown %": round(drawdown, 2),
130
  "Max Win Streak": max_win_streak,
131
  "Max Loss Streak": max_loss_streak,
132
- "Sharpe Ratio": round(sharpe_ratio, 2),
133
  "EdgeCast Score": round(score, 2)
134
  }
135
-
136
  return df, summary
137
 
138
- # === HISTOGRAM SIMULATION (NEW) ===
139
- def simulate_multiple_runs(config, metric="EdgeCast Score", runs=100):
140
- metric_values = []
141
- for _ in range(runs):
142
- _, summary = simulate_tp_strategy_full(
143
- config["starting_balance"],
144
- config["trades_min"],
145
- config["trades_max"],
146
- config["weeks"],
147
- config["tp1_prob"],
148
- config["tp2_prob"],
149
- config["tp1_r"],
150
- config["tp2_r"],
151
- config["base_risk_pct"],
152
- config["profit_target"],
153
- config["fatigue"],
154
- config["trump_vol"]
155
- )
156
- metric_values.append(summary[metric])
157
- return pd.DataFrame({metric: metric_values})
158
-
159
- def plot_histogram(df, metric):
160
- fig = px.histogram(df, x=metric, nbins=30, title=f"{metric} Distribution")
161
- fig.update_layout(
162
- xaxis_title=metric,
163
- yaxis_title="Frequency",
164
- bargap=0.1,
165
- height=400
166
- )
167
- return fig
168
- # === PART 2: PLOTTING ===
169
-
170
  def equity_curve_plot(df, label="Equity Curve"):
171
  fig = go.Figure()
172
- fig.add_trace(go.Scatter(
173
- x=df["Week"],
174
- y=df["End Balance"],
175
- mode="lines+markers",
176
- name=label
177
- ))
178
- fig.update_layout(
179
- title=f"πŸ“ˆ {label}",
180
- xaxis_title="Week",
181
- yaxis_title="Balance ($)",
182
- height=400
183
- )
184
  return fig
185
 
186
-
187
- def generate_histogram(metric="Final Balance"):
188
  results = []
189
  for name, config in strategy_presets.items():
190
- _, summary = simulate_tp_strategy_full(**{k: v for k, v in config.items() if k != "description"})
 
 
 
 
191
  summary["Strategy"] = name
192
  results.append(summary)
193
-
194
  df = pd.DataFrame(results)
195
 
196
- if metric not in df.columns:
197
- return go.Figure()
198
-
199
- fig = px.histogram(
200
- df,
201
- x=metric,
202
- color="Strategy",
203
- barmode="overlay",
204
- nbins=25,
205
- title=f"πŸ“Š Histogram: {metric}",
206
- labels={metric: metric}
207
- )
208
-
209
- fig.update_layout(
210
- xaxis_title=metric,
211
- yaxis_title="Frequency",
212
- bargap=0.2
213
- )
214
-
215
  return fig
216
- # === PART 3: ANALYSIS TABS ===
217
 
218
- def show_descriptions():
219
- return pd.DataFrame([
220
- {"Strategy": name, "Description": config["description"]}
221
- for name, config in strategy_presets.items()
222
- ])
223
 
 
224
  def analytics_dashboard(rank_by="EdgeCast Score"):
225
  results = []
226
  for name, config in strategy_presets.items():
227
  _, summary = simulate_tp_strategy_full(**{k: v for k, v in config.items() if k != "description"})
228
  summary["Strategy"] = name
229
  results.append(summary)
230
-
231
  df = pd.DataFrame(results)
232
-
233
  winner_vals = {
234
  "Final Balance": df["Final Balance"].max(),
235
  "Sharpe Ratio": df["Sharpe Ratio"].max(),
236
  "EdgeCast Score": df["EdgeCast Score"].max(),
237
  "Max Drawdown %": df["Max Drawdown %"].min()
238
  }
239
-
240
- ascending = rank_by == "Max Drawdown %"
241
- df = df.sort_values(rank_by, ascending=ascending).reset_index(drop=True)
242
  df.insert(0, "πŸ… Rank", [f"#{i+1}" for i in df.index])
243
-
244
  for col in winner_vals:
245
- df[col] = df[col].apply(lambda x: f"{round(x, 2)} πŸ†" if x == winner_vals[col] else f"{round(x, 2)}")
246
-
247
  return df[["πŸ… Rank", "Strategy", "Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]]
248
 
 
 
249
 
250
  def generate_risk_matrix():
251
  names = list(strategy_presets.keys())
252
- scores = {
253
- name: simulate_tp_strategy_full(**{k: v for k, v in cfg.items() if k != "description"})[1]["EdgeCast Score"]
254
- for name, cfg in strategy_presets.items()
255
- }
256
- matrix = np.zeros((len(names), len(names)))
257
- for i, a in enumerate(names):
258
- for j, b in enumerate(names):
259
- matrix[i, j] = abs(scores[a] - scores[b])
260
 
261
- fig = px.imshow(
262
- matrix,
263
- x=names,
264
- y=names,
265
- text_auto=".2f",
266
- color_continuous_scale="RdYlGn_r",
267
- labels={"color": "Score Ξ”"},
268
- title="🧠 Risk Matrix (Ξ” Score Heatmap)"
269
  )
270
- fig.update_traces(
271
- hovertemplate="<b>%{y}</b> vs <b>%{x}</b><br>Ξ” Score: %{z:.2f}<extra></extra>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  )
273
- return fig
274
-
275
-
276
- def histogram_viewer_ui(metric):
277
- return generate_histogram(metric)
278
- # === PART 4: GRADIO INTERFACE ===
279
 
 
280
  app = gr.TabbedInterface(
281
  interface_list=[
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
- # 🎯 Preset Strategy Tab
284
- gr.Interface(
285
- fn=run_preset_strategy,
286
- inputs=[
287
- gr.Dropdown(choices=list(strategy_presets.keys()), label="Select Strategy"),
288
- gr.Slider(0, 1, 0.0, step=0.1, label="Fatigue Level"),
289
- gr.Slider(0, 1, 0.0, step=0.1, label="Trump Volatility Index")
290
- ],
291
- outputs=["dataframe", "json", gr.Plot(), "text"],
292
- title="🎯 Preset Strategy Mode"
293
- ),
294
-
295
- # πŸ› οΈ Manual Config Tab
296
- gr.Interface(
297
- fn=run_manual_sim,
298
- inputs=[
299
- gr.Slider(100, 20000, 2500, label="Start Balance"),
300
- gr.Slider(1, 10, 3, label="Trades Min"),
301
- gr.Slider(1, 15, 7, label="Trades Max"),
302
- gr.Slider(1, 52, 12, label="Weeks"),
303
- gr.Slider(0, 1, 0.3, step=0.05, label="TP1 %"),
304
- gr.Slider(0, 1, 0.3, step=0.05, label="TP2 %"),
305
- gr.Slider(0.1, 5.0, 1.0, step=0.1, label="TP1 R"),
306
- gr.Slider(0.1, 20.0, 2.0, step=0.1, label="TP2 R"),
307
- gr.Slider(0.001, 0.05, 0.01, step=0.001, label="Risk %"),
308
- gr.Slider(0, 100000, 0, step=500, label="Profit Target πŸ’°"),
309
- gr.Slider(0, 1, 0.0, step=0.1, label="Fatigue Level"),
310
- gr.Slider(0, 1, 0.0, step=0.1, label="Trump Volatility Index")
311
- ],
312
- outputs=["dataframe", "json", gr.Plot()],
313
- title="πŸ› οΈ Manual Config Mode"
314
- ),
315
-
316
- # πŸ§ͺ Manual Battle Tab
317
  get_manual_battle_interface(),
318
 
319
- # πŸ“Š Histogram Viewer
320
- gr.Interface(
321
- fn=histogram_viewer_ui,
322
- inputs=gr.Dropdown(
323
- choices=["Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"],
324
- label="Select Metric"
325
- ),
326
- outputs=gr.Plot(),
327
- title="πŸ“Š Histogram Viewer"
328
- ),
329
 
330
- # πŸ… Leaderboard
331
- gr.Interface(
332
- fn=analytics_dashboard,
333
- inputs=gr.Dropdown(
334
- choices=["EdgeCast Score", "Final Balance", "Sharpe Ratio", "Max Drawdown %"],
335
- value="EdgeCast Score",
336
- label="Sort leaderboard by:"
337
- ),
338
- outputs="dataframe",
339
- title="πŸ… Strategy Leaderboard"
340
- ),
341
 
342
- # πŸ“˜ Descriptions
343
- gr.Interface(
344
- fn=show_descriptions,
345
- inputs=[], outputs="dataframe",
346
- title="πŸ“˜ Strategy Descriptions"
347
- ),
348
 
349
- # πŸ”¬ Risk Matrix
350
- gr.Interface(
351
- fn=generate_risk_matrix,
352
- inputs=[], outputs=gr.Plot(),
353
- title="πŸ”¬ Risk Matrix"
354
- )
355
  ],
356
- tab_names=["Preset", "Manual", "Battle", "Histogram", "Leaderboard", "Descriptions", "Risk Matrix"],
357
  title="EdgeCast – Strategy Simulation Suite"
358
  )
359
 
360
  app.launch()
361
- # === PART 5: HISTOGRAM VIEWER ENGINE ===
362
-
363
- def generate_histogram(metric="EdgeCast Score"):
364
- results = []
365
- for name, config in strategy_presets.items():
366
- _, summary = simulate_tp_strategy_full(
367
- config["starting_balance"], config["trades_min"], config["trades_max"], config["weeks"],
368
- config["tp1_prob"], config["tp2_prob"], config["tp1_r"], config["tp2_r"],
369
- config["base_risk_pct"], config["profit_target"], config["fatigue"], config["trump_vol"]
370
- )
371
- summary["Strategy"] = name
372
- results.append(summary)
373
-
374
- df = pd.DataFrame(results)
375
-
376
- if metric not in df.columns:
377
- return go.Figure()
378
-
379
- fig = px.histogram(
380
- df,
381
- x=metric,
382
- color="Strategy",
383
- marginal="box",
384
- opacity=0.7,
385
- barmode="overlay",
386
- title=f"πŸ“Š Distribution of {metric} Across Strategies"
387
- )
388
-
389
- fig.update_layout(
390
- xaxis_title=metric,
391
- yaxis_title="Count",
392
- bargap=0.1,
393
- height=500
394
- )
395
-
396
- return fig
397
-
398
- def histogram_viewer_ui(metric):
399
- return generate_histogram(metric)
 
53
 
54
  strategy_presets = get_strategy_presets()
55
 
56
+ # === CORE SIMULATION ===
57
  def simulate_tp_strategy_full(starting_balance, trades_min, trades_max, weeks,
58
  tp1_prob, tp2_prob, tp1_r, tp2_r, base_risk_pct,
59
  profit_target=None, fatigue=0.0, trump_vol=0.0):
60
  if tp1_prob + tp2_prob >= 1.0:
61
  return pd.DataFrame(), {"Error": "Invalid probability config. TP1 + TP2 must be < 1.0"}
62
+
63
  sl_prob = 1.0 - tp1_prob - tp2_prob
64
+ balance, peak, drawdown = starting_balance, starting_balance, 0
 
 
65
  tp1_hits = tp2_hits = sl_hits = 0
66
+ max_win_streak = max_loss_streak = cur_win_streak = cur_loss_streak = 0
 
 
 
67
  fatigue_multiplier = 1.0 - fatigue * 0.4
68
  trump_vol_factor = np.random.normal(1.0, 0.2 * trump_vol)
69
+ log = []
70
 
71
  for week in range(1, weeks + 1):
72
+ if profit_target and balance >= profit_target: break
 
73
  week_start = balance
74
  num_trades = np.random.randint(trades_min, trades_max + 1)
75
+
76
  for _ in range(num_trades):
77
+ risk_amount = balance * base_risk_pct * np.random.uniform(0.9, 1.1)
 
78
  risk_amount *= trump_vol_factor
 
79
  if fatigue > 0.6 and cur_loss_streak >= 3 and np.random.rand() < fatigue * 0.25:
80
  outcome = "SL"
81
  else:
 
102
  peak = max(peak, balance)
103
  drawdown = max(drawdown, (peak - balance) / peak * 100)
104
 
 
105
  log.append({
106
  "Week": week, "Start Balance": round(week_start, 2),
107
  "End Balance": round(balance, 2),
108
+ "Weekly Return (%)": round((balance - week_start) / week_start * 100, 2)
109
  })
110
 
111
  df = pd.DataFrame(log)
112
  returns = df["End Balance"].pct_change().dropna()
113
+ sharpe = returns.mean() / returns.std() * np.sqrt(52) if returns.std() > 0 else 0
 
114
  score = balance / (1 + drawdown)
 
115
  summary = {
116
  "Final Balance": round(balance, 2),
117
  "TP1 Hits": tp1_hits,
 
120
  "Max Drawdown %": round(drawdown, 2),
121
  "Max Win Streak": max_win_streak,
122
  "Max Loss Streak": max_loss_streak,
123
+ "Sharpe Ratio": round(sharpe, 2),
124
  "EdgeCast Score": round(score, 2)
125
  }
 
126
  return df, summary
127
 
128
+ # === VISUALIZATION ===
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  def equity_curve_plot(df, label="Equity Curve"):
130
  fig = go.Figure()
131
+ fig.add_trace(go.Scatter(x=df["Week"], y=df["End Balance"], mode="lines+markers", name=label))
132
+ fig.update_layout(title=f"πŸ“ˆ {label}", xaxis_title="Week", yaxis_title="Balance ($)", height=400)
 
 
 
 
 
 
 
 
 
 
133
  return fig
134
 
135
+ def generate_histogram(metric="EdgeCast Score"):
 
136
  results = []
137
  for name, config in strategy_presets.items():
138
+ _, summary = simulate_tp_strategy_full(
139
+ config["starting_balance"], config["trades_min"], config["trades_max"], config["weeks"],
140
+ config["tp1_prob"], config["tp2_prob"], config["tp1_r"], config["tp2_r"],
141
+ config["base_risk_pct"], config["profit_target"], config["fatigue"], config["trump_vol"]
142
+ )
143
  summary["Strategy"] = name
144
  results.append(summary)
 
145
  df = pd.DataFrame(results)
146
 
147
+ fig = px.histogram(df, x=metric, color="Strategy", marginal="box", opacity=0.7, barmode="overlay")
148
+ fig.update_layout(title=f"πŸ“Š {metric} Histogram", xaxis_title=metric, yaxis_title="Count", height=500)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  return fig
 
150
 
151
+ def histogram_viewer_ui(metric):
152
+ return generate_histogram(metric)
 
 
 
153
 
154
+ # === ANALYSIS TOOLS ===
155
  def analytics_dashboard(rank_by="EdgeCast Score"):
156
  results = []
157
  for name, config in strategy_presets.items():
158
  _, summary = simulate_tp_strategy_full(**{k: v for k, v in config.items() if k != "description"})
159
  summary["Strategy"] = name
160
  results.append(summary)
 
161
  df = pd.DataFrame(results)
 
162
  winner_vals = {
163
  "Final Balance": df["Final Balance"].max(),
164
  "Sharpe Ratio": df["Sharpe Ratio"].max(),
165
  "EdgeCast Score": df["EdgeCast Score"].max(),
166
  "Max Drawdown %": df["Max Drawdown %"].min()
167
  }
168
+ df = df.sort_values(rank_by, ascending=(rank_by == "Max Drawdown %")).reset_index(drop=True)
 
 
169
  df.insert(0, "πŸ… Rank", [f"#{i+1}" for i in df.index])
 
170
  for col in winner_vals:
171
+ df[col] = df[col].apply(lambda x: f"{round(x,2)} πŸ†" if x == winner_vals[col] else f"{round(x,2)}")
 
172
  return df[["πŸ… Rank", "Strategy", "Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]]
173
 
174
+ def show_descriptions():
175
+ return pd.DataFrame([{"Strategy": name, "Description": cfg["description"]} for name, cfg in strategy_presets.items()])
176
 
177
  def generate_risk_matrix():
178
  names = list(strategy_presets.keys())
179
+ scores = {n: simulate_tp_strategy_full(**{k: v for k, v in cfg.items() if k != "description"})[1]["EdgeCast Score"] for n, cfg in strategy_presets.items()}
180
+ matrix = np.array([[abs(scores[a] - scores[b]) for b in names] for a in names])
181
+ fig = px.imshow(matrix, x=names, y=names, text_auto=".2f", color_continuous_scale="RdYlGn_r", labels={"color": "Ξ” Score"})
182
+ fig.update_layout(title="🧠 Risk Matrix (Score Ξ”)", height=600)
183
+ return fig
 
 
 
184
 
185
+ # === STRATEGY RUNNERS ===
186
+ def run_preset_strategy(style, fatigue=0.0, trump_vol=0.0):
187
+ config = strategy_presets[style]
188
+ df, summary = simulate_tp_strategy_full(
189
+ config["starting_balance"], config["trades_min"], config["trades_max"], config["weeks"],
190
+ config["tp1_prob"], config["tp2_prob"], config["tp1_r"], config["tp2_r"],
191
+ config["base_risk_pct"], config["profit_target"], fatigue, trump_vol
 
192
  )
193
+ return df, summary, equity_curve_plot(df, style), config["description"]
194
+
195
+ def run_manual_sim(starting_balance, trades_min, trades_max, weeks,
196
+ tp1_prob, tp2_prob, tp1_r, tp2_r, base_risk_pct, profit_target,
197
+ fatigue, trump_vol):
198
+ df, summary = simulate_tp_strategy_full(
199
+ starting_balance, trades_min, trades_max, weeks,
200
+ tp1_prob, tp2_prob, tp1_r, tp2_r, base_risk_pct,
201
+ profit_target, fatigue, trump_vol
202
+ )
203
+ return df, summary, equity_curve_plot(df, "Manual Config")
204
+
205
+ def dual_manual_battle(
206
+ sb1, tmin1, tmax1, w1, tp1a, tp2a, r1a, r2a, risk1, pt1, fat1, trump1,
207
+ sb2, tmin2, tmax2, w2, tp1b, tp2b, r1b, r2b, risk2, pt2, fat2, trump2
208
+ ):
209
+ df1, s1 = simulate_tp_strategy_full(sb1, tmin1, tmax1, w1, tp1a, tp2a, r1a, r2a, risk1, pt1, fat1, trump1)
210
+ df2, s2 = simulate_tp_strategy_full(sb2, tmin2, tmax2, w2, tp1b, tp2b, r1b, r2b, risk2, pt2, fat2, trump2)
211
+ s1["Strategy"], s2["Strategy"] = "Manual A", "Manual B"
212
+ df_summary = pd.DataFrame([s1, s2])[["Strategy", "Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"]]
213
+ for col in ["Final Balance", "Sharpe Ratio", "EdgeCast Score"]:
214
+ best = df_summary[col].astype(float).max()
215
+ df_summary[col] = [f"{val} πŸ†" if float(val) == best else val for val in df_summary[col]]
216
+ fig = go.Figure()
217
+ fig.add_trace(go.Scatter(x=df1["Week"], y=df1["End Balance"], name="Manual A"))
218
+ fig.add_trace(go.Scatter(x=df2["Week"], y=df2["End Balance"], name="Manual B"))
219
+ fig.update_layout(title="βš”οΈ Manual Strategy Battle", xaxis_title="Week", yaxis_title="Balance")
220
+ return df_summary, fig
221
+
222
+ def get_manual_battle_interface():
223
+ return gr.Interface(
224
+ fn=dual_manual_battle,
225
+ inputs=[
226
+ # A Config
227
+ gr.Slider(100, 20000, 2500, label="A: Start Balance"),
228
+ gr.Slider(1, 10, 3, label="A: Trades Min"),
229
+ gr.Slider(1, 15, 7, label="A: Trades Max"),
230
+ gr.Slider(1, 52, 12, label="A: Weeks"),
231
+ gr.Slider(0, 1, 0.3, step=0.05, label="A: TP1 %"),
232
+ gr.Slider(0, 1, 0.3, step=0.05, label="A: TP2 %"),
233
+ gr.Slider(0.1, 5.0, 1.0, step=0.1, label="A: TP1 R"),
234
+ gr.Slider(0.1, 20.0, 2.0, step=0.1, label="A: TP2 R"),
235
+ gr.Slider(0.001, 0.05, 0.01, step=0.001, label="A: Risk %"),
236
+ gr.Slider(0, 100000, 0, step=500, label="A: Profit Target"),
237
+ gr.Slider(0, 1, 0.0, step=0.1, label="A: Fatigue"),
238
+ gr.Slider(0, 1, 0.0, step=0.1, label="A: Trump Volatility"),
239
+ # B Config
240
+ gr.Slider(100, 20000, 2500, label="B: Start Balance"),
241
+ gr.Slider(1, 10, 3, label="B: Trades Min"),
242
+ gr.Slider(1, 15, 7, label="B: Trades Max"),
243
+ gr.Slider(1, 52, 12, label="B: Weeks"),
244
+ gr.Slider(0, 1, 0.3, step=0.05, label="B: TP1 %"),
245
+ gr.Slider(0, 1, 0.3, step=0.05, label="B: TP2 %"),
246
+ gr.Slider(0.1, 5.0, 1.0, step=0.1, label="B: TP1 R"),
247
+ gr.Slider(0.1, 20.0, 2.0, step=0.1, label="B: TP2 R"),
248
+ gr.Slider(0.001, 0.05, 0.01, step=0.001, label="B: Risk %"),
249
+ gr.Slider(0, 100000, 0, step=500, label="B: Profit Target"),
250
+ gr.Slider(0, 1, 0.0, step=0.1, label="B: Fatigue"),
251
+ gr.Slider(0, 1, 0.0, step=0.1, label="B: Trump Volatility")
252
+ ],
253
+ outputs=["dataframe", gr.Plot()],
254
+ title="πŸ§ͺ Manual Strategy Battle"
255
  )
 
 
 
 
 
 
256
 
257
+ # === LAUNCH INTERFACE ===
258
  app = gr.TabbedInterface(
259
  interface_list=[
260
+ gr.Interface(fn=run_preset_strategy, inputs=[
261
+ gr.Dropdown(choices=list(strategy_presets.keys()), label="Select Strategy"),
262
+ gr.Slider(0, 1, 0.0, step=0.1, label="Fatigue Level"),
263
+ gr.Slider(0, 1, 0.0, step=0.1, label="Trump Volatility Index")
264
+ ], outputs=["dataframe", "json", gr.Plot(), "text"], title="🎯 Preset Mode"),
265
+
266
+ gr.Interface(fn=run_manual_sim, inputs=[
267
+ gr.Slider(100, 20000, 2500, label="Start Balance"),
268
+ gr.Slider(1, 10, 3, label="Trades Min"),
269
+ gr.Slider(1, 15, 7, label="Trades Max"),
270
+ gr.Slider(1, 52, 12, label="Weeks"),
271
+ gr.Slider(0, 1, 0.3, step=0.05, label="TP1 %"),
272
+ gr.Slider(0, 1, 0.3, step=0.05, label="TP2 %"),
273
+ gr.Slider(0.1, 5.0, 1.0, step=0.1, label="TP1 R"),
274
+ gr.Slider(0.1, 20.0, 2.0, step=0.1, label="TP2 R"),
275
+ gr.Slider(0.001, 0.05, 0.01, step=0.001, label="Risk %"),
276
+ gr.Slider(0, 100000, 0, step=500, label="Profit Target πŸ’°"),
277
+ gr.Slider(0, 1, 0.0, step=0.1, label="Fatigue Level"),
278
+ gr.Slider(0, 1, 0.0, step=0.1, label="Trump Volatility Index")
279
+ ], outputs=["dataframe", "json", gr.Plot()], title="πŸ› οΈ Manual Config"),
280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  get_manual_battle_interface(),
282
 
283
+ gr.Interface(fn=histogram_viewer_ui, inputs=gr.Dropdown(
284
+ choices=["Final Balance", "Sharpe Ratio", "EdgeCast Score", "Max Drawdown %"],
285
+ label="Select Metric"
286
+ ), outputs=gr.Plot(), title="πŸ“Š Histogram Viewer"),
 
 
 
 
 
 
287
 
288
+ gr.Interface(fn=analytics_dashboard, inputs=gr.Dropdown(
289
+ choices=["EdgeCast Score", "Final Balance", "Sharpe Ratio", "Max Drawdown %"],
290
+ label="Sort leaderboard by:"
291
+ ), outputs="dataframe", title="πŸ… Leaderboard"),
 
 
 
 
 
 
 
292
 
293
+ gr.Interface(fn=show_descriptions, inputs=[], outputs="dataframe", title="πŸ“˜ Descriptions"),
 
 
 
 
 
294
 
295
+ gr.Interface(fn=generate_risk_matrix, inputs=[], outputs=gr.Plot(), title="πŸ”¬ Risk Matrix")
 
 
 
 
 
296
  ],
 
297
  title="EdgeCast – Strategy Simulation Suite"
298
  )
299
 
300
  app.launch()