Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -132,22 +132,44 @@ def equity_curve_plot(df, label="Equity Curve"):
|
|
| 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 |
-
|
| 137 |
for name, config in strategy_presets.items():
|
| 138 |
-
_
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|
|
|
|
| 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", runs=100):
|
| 136 |
+
all_metrics = []
|
| 137 |
for name, config in strategy_presets.items():
|
| 138 |
+
for _ in range(runs):
|
| 139 |
+
_, summary = simulate_tp_strategy_full(
|
| 140 |
+
config["starting_balance"], config["trades_min"], config["trades_max"], config["weeks"],
|
| 141 |
+
config["tp1_prob"], config["tp2_prob"], config["tp1_r"], config["tp2_r"],
|
| 142 |
+
config["base_risk_pct"], config["profit_target"], config["fatigue"], config["trump_vol"]
|
| 143 |
+
)
|
| 144 |
+
if metric in summary:
|
| 145 |
+
all_metrics.append({
|
| 146 |
+
"Strategy": name,
|
| 147 |
+
metric: summary[metric]
|
| 148 |
+
})
|
| 149 |
+
|
| 150 |
+
df = pd.DataFrame(all_metrics)
|
| 151 |
+
|
| 152 |
+
fig = px.histogram(
|
| 153 |
+
df,
|
| 154 |
+
x=metric,
|
| 155 |
+
color="Strategy",
|
| 156 |
+
marginal="box",
|
| 157 |
+
opacity=0.75,
|
| 158 |
+
barmode="overlay",
|
| 159 |
+
nbins=30,
|
| 160 |
+
title=f"π Distribution of {metric} Across Strategies"
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
fig.update_layout(
|
| 164 |
+
xaxis_title=metric,
|
| 165 |
+
yaxis_title="Count",
|
| 166 |
+
bargap=0.1,
|
| 167 |
+
height=500
|
| 168 |
+
)
|
| 169 |
|
|
|
|
|
|
|
| 170 |
return fig
|
| 171 |
|
| 172 |
+
|
| 173 |
def histogram_viewer_ui(metric):
|
| 174 |
return generate_histogram(metric)
|
| 175 |
|