rosacastillo
commited on
Commit
·
67d9b84
1
Parent(s):
6012e5c
updating order of categories and extra metrics text
Browse files- app.py +27 -14
- tabs/metrics.py +15 -1
- tabs/trades.py +5 -2
app.py
CHANGED
@@ -30,6 +30,7 @@ from tabs.metrics import (
|
|
30 |
WIDTH,
|
31 |
HEIGHT,
|
32 |
plot_tool_metrics,
|
|
|
33 |
)
|
34 |
|
35 |
from tabs.tool_win import (
|
@@ -222,32 +223,44 @@ with demo:
|
|
222 |
choices=trade_metric_choices,
|
223 |
value=default_trade_metric,
|
224 |
)
|
|
|
225 |
with gr.Row():
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
def update_trade_details(trade_detail):
|
234 |
-
return
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
240 |
|
241 |
trade_details_selector.change(
|
242 |
update_trade_details,
|
243 |
inputs=trade_details_selector,
|
244 |
-
outputs=trade_details_plot,
|
245 |
)
|
246 |
|
247 |
with gr.Row():
|
248 |
trade_details_selector
|
249 |
with gr.Row():
|
250 |
-
|
|
|
|
|
|
|
251 |
|
252 |
with gr.TabItem("🚀 Tool Winning Dashboard"):
|
253 |
with gr.Row():
|
|
|
30 |
WIDTH,
|
31 |
HEIGHT,
|
32 |
plot_tool_metrics,
|
33 |
+
get_trade_metrics_text,
|
34 |
)
|
35 |
|
36 |
from tabs.tool_win import (
|
|
|
223 |
choices=trade_metric_choices,
|
224 |
value=default_trade_metric,
|
225 |
)
|
226 |
+
|
227 |
with gr.Row():
|
228 |
+
with gr.Column(scale=3):
|
229 |
+
trade_details_plot = plot_trade_metrics(
|
230 |
+
metric_name=default_trade_metric,
|
231 |
+
trades_df=trades_df,
|
232 |
+
height=400,
|
233 |
+
width=1400,
|
234 |
+
)
|
235 |
+
with gr.Column(scale=1):
|
236 |
+
trade_details_text = get_trade_metrics_text(
|
237 |
+
metric_name=default_trade_metric
|
238 |
+
)
|
239 |
|
240 |
def update_trade_details(trade_detail):
|
241 |
+
return [
|
242 |
+
plot_trade_metrics(
|
243 |
+
metric_name=trade_detail,
|
244 |
+
trades_df=trades_df,
|
245 |
+
height=400,
|
246 |
+
width=1400,
|
247 |
+
),
|
248 |
+
get_trade_metrics_text(metric_name=trade_detail),
|
249 |
+
]
|
250 |
|
251 |
trade_details_selector.change(
|
252 |
update_trade_details,
|
253 |
inputs=trade_details_selector,
|
254 |
+
outputs=[trade_details_plot, trade_details_text],
|
255 |
)
|
256 |
|
257 |
with gr.Row():
|
258 |
trade_details_selector
|
259 |
with gr.Row():
|
260 |
+
with gr.Column(scale=3):
|
261 |
+
trade_details_plot
|
262 |
+
with gr.Column(scale=1):
|
263 |
+
trade_details_text
|
264 |
|
265 |
with gr.TabItem("🚀 Tool Winning Dashboard"):
|
266 |
with gr.Row():
|
tabs/metrics.py
CHANGED
@@ -186,7 +186,8 @@ def plot_trade_metrics(
|
|
186 |
x="month_year_week",
|
187 |
y=column_name,
|
188 |
color="market_creator",
|
189 |
-
color_discrete_sequence=["
|
|
|
190 |
)
|
191 |
fig.update_traces(boxmean=True)
|
192 |
fig.update_layout(
|
@@ -236,3 +237,16 @@ def plot_tool_metrics(wins_df: pd.DataFrame, winning_selector: str) -> gr.Plot:
|
|
236 |
else: # "total_request"
|
237 |
column_name = metric_name
|
238 |
yaxis_title = "Gross profit per trade (xDAI)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
x="month_year_week",
|
187 |
y=column_name,
|
188 |
color="market_creator",
|
189 |
+
color_discrete_sequence=["purple", "goldenrod", "darkgreen"],
|
190 |
+
category_orders={"market_creator": ["pearl", "quickstart", "all"]},
|
191 |
)
|
192 |
fig.update_traces(boxmean=True)
|
193 |
fig.update_layout(
|
|
|
237 |
else: # "total_request"
|
238 |
column_name = metric_name
|
239 |
yaxis_title = "Gross profit per trade (xDAI)"
|
240 |
+
|
241 |
+
|
242 |
+
def get_trade_metrics_text(metric_name: str) -> gr.Text:
|
243 |
+
metric_text = (
|
244 |
+
"This "
|
245 |
+
+ metric_name
|
246 |
+
+ " metric is computed weekly and the graph shows the different statistical measures including "
|
247 |
+
+ "the min, max, median (line inside the box), mean(dotted line) and several percentiles:"
|
248 |
+
+ " the lower (first) quartile, q1, is the median of the bottom half, and the upper (third) quartile, q3, is the median of the top half."
|
249 |
+
+ " The whiskers correspond to the boxes' edges +/- 1.5 times the interquartile range (IQR: Q3-Q1)"
|
250 |
+
)
|
251 |
+
|
252 |
+
return gr.Text(label=metric_text)
|
tabs/trades.py
CHANGED
@@ -144,8 +144,10 @@ def integrated_plot_trades_per_market_by_week(trades_df: pd.DataFrame) -> gr.Plo
|
|
144 |
y="trades",
|
145 |
color="market_creator",
|
146 |
barmode="group",
|
147 |
-
color_discrete_sequence=["
|
|
|
148 |
)
|
|
|
149 |
fig.update_layout(
|
150 |
xaxis_title="Week",
|
151 |
yaxis_title="Weekly nr of trades",
|
@@ -175,7 +177,8 @@ def integrated_plot_winning_trades_per_market_by_week(
|
|
175 |
y="winning_trade",
|
176 |
color="market_creator",
|
177 |
barmode="group",
|
178 |
-
color_discrete_sequence=["
|
|
|
179 |
)
|
180 |
fig.update_layout(
|
181 |
xaxis_title="Week",
|
|
|
144 |
y="trades",
|
145 |
color="market_creator",
|
146 |
barmode="group",
|
147 |
+
color_discrete_sequence=["purple", "goldenrod", "darkgreen"],
|
148 |
+
category_orders={"market_creator": ["pearl", "quickstart", "all"]},
|
149 |
)
|
150 |
+
|
151 |
fig.update_layout(
|
152 |
xaxis_title="Week",
|
153 |
yaxis_title="Weekly nr of trades",
|
|
|
177 |
y="winning_trade",
|
178 |
color="market_creator",
|
179 |
barmode="group",
|
180 |
+
color_discrete_sequence=["purple", "goldenrod", "darkgreen"],
|
181 |
+
category_orders={"market_creator": ["pearl", "quickstart", "all"]},
|
182 |
)
|
183 |
fig.update_layout(
|
184 |
xaxis_title="Week",
|