Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -307,31 +307,20 @@ def equity_curve_plot(df, label="Equity Curve"):
|
|
| 307 |
|
| 308 |
# π― Preset Tab
|
| 309 |
|
| 310 |
-
def
|
| 311 |
-
|
| 312 |
-
if style not in strategy_presets:
|
| 313 |
-
|
| 314 |
-
return pd.DataFrame(), {}, go.Figure(), "Please select a strategy to begin."
|
| 315 |
-
|
| 316 |
config = strategy_presets[style]
|
|
|
|
|
|
|
| 317 |
|
| 318 |
df, summary = simulate_tp_strategy_full(
|
| 319 |
-
|
| 320 |
config["starting_balance"], config["trades_min"], config["trades_max"], config["weeks"],
|
| 321 |
-
|
| 322 |
config["tp1_prob"], config["tp2_prob"], config["tp1_r"], config["tp2_r"],
|
| 323 |
-
|
| 324 |
-
config["base_risk_pct"], config["profit_target"],
|
| 325 |
-
|
| 326 |
-
fatigue=fatigue, trump_vol=trump_vol
|
| 327 |
-
|
| 328 |
)
|
| 329 |
|
| 330 |
return df, summary, equity_curve_plot(df, style), config["description"]
|
| 331 |
|
| 332 |
|
| 333 |
-
|
| 334 |
-
|
| 335 |
# π οΈ Manual Tab
|
| 336 |
|
| 337 |
def run_manual_sim(starting_balance, trades_min, trades_max, weeks,
|
|
@@ -351,8 +340,6 @@ def run_manual_sim(starting_balance, trades_min, trades_max, weeks,
|
|
| 351 |
return df, summary, chart
|
| 352 |
|
| 353 |
|
| 354 |
-
|
| 355 |
-
|
| 356 |
# βοΈ Manual Battle Mode (Dual Sim)
|
| 357 |
|
| 358 |
def dual_manual_battle(
|
|
@@ -646,27 +633,17 @@ app = gr.TabbedInterface(
|
|
| 646 |
# π― Preset Mode
|
| 647 |
|
| 648 |
gr.Interface(
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
),
|
| 661 |
-
|
| 662 |
-
outputs=["dataframe", "json", gr.Plot(), "text"],
|
| 663 |
-
|
| 664 |
-
title="π― Preset Mode"
|
| 665 |
-
|
| 666 |
-
),
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
|
| 671 |
# π οΈ Manual Config
|
| 672 |
|
|
|
|
| 307 |
|
| 308 |
# π― Preset Tab
|
| 309 |
|
| 310 |
+
def run_preset_strategy_with_toggle(style, enable_fatigue, fatigue, enable_trump, trump_vol):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
config = strategy_presets[style]
|
| 312 |
+
applied_fatigue = fatigue if enable_fatigue else 0.0
|
| 313 |
+
applied_trump = trump_vol if enable_trump else 0.0
|
| 314 |
|
| 315 |
df, summary = simulate_tp_strategy_full(
|
|
|
|
| 316 |
config["starting_balance"], config["trades_min"], config["trades_max"], config["weeks"],
|
|
|
|
| 317 |
config["tp1_prob"], config["tp2_prob"], config["tp1_r"], config["tp2_r"],
|
| 318 |
+
config["base_risk_pct"], config["profit_target"], applied_fatigue, applied_trump
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
)
|
| 320 |
|
| 321 |
return df, summary, equity_curve_plot(df, style), config["description"]
|
| 322 |
|
| 323 |
|
|
|
|
|
|
|
| 324 |
# π οΈ Manual Tab
|
| 325 |
|
| 326 |
def run_manual_sim(starting_balance, trades_min, trades_max, weeks,
|
|
|
|
| 340 |
return df, summary, chart
|
| 341 |
|
| 342 |
|
|
|
|
|
|
|
| 343 |
# βοΈ Manual Battle Mode (Dual Sim)
|
| 344 |
|
| 345 |
def dual_manual_battle(
|
|
|
|
| 633 |
# π― Preset Mode
|
| 634 |
|
| 635 |
gr.Interface(
|
| 636 |
+
fn=run_preset_strategy_with_toggle,
|
| 637 |
+
inputs=[
|
| 638 |
+
gr.Dropdown(choices=list(strategy_presets.keys()), label="Select Strategy"),
|
| 639 |
+
gr.Checkbox(label="Enable Fatigue"),
|
| 640 |
+
gr.Slider(0, 1, 0.0, step=0.1, label="Fatigue Level"),
|
| 641 |
+
gr.Checkbox(label="Enable Trump Volatility"),
|
| 642 |
+
gr.Slider(0, 1, 0.0, step=0.1, label="Trump Volatility Index")
|
| 643 |
+
],
|
| 644 |
+
outputs=["dataframe", "json", gr.Plot(), "text"],
|
| 645 |
+
title="π― Preset Mode"
|
| 646 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 647 |
|
| 648 |
# π οΈ Manual Config
|
| 649 |
|