Commit
·
929ee61
1
Parent(s):
472bae0
Fixing x axis order
Browse files- app.py +11 -13
- tabs/metrics.py +80 -0
- tabs/trades.py +11 -200
app.py
CHANGED
|
@@ -15,8 +15,14 @@ from tabs.trades import (
|
|
| 15 |
plot_trades_per_market_by_week,
|
| 16 |
plot_winning_trades_by_week,
|
| 17 |
plot_winning_trades_per_market_by_week,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
plot_trade_details,
|
| 19 |
)
|
|
|
|
| 20 |
from tabs.tool_win import (
|
| 21 |
get_tool_winning_rate,
|
| 22 |
get_overall_winning_rate,
|
|
@@ -212,7 +218,7 @@ with demo:
|
|
| 212 |
)
|
| 213 |
with gr.Column(min_width=350):
|
| 214 |
all_wtrades_by_week = plot_winning_trades_per_market_by_week(
|
| 215 |
-
trades_df=
|
| 216 |
)
|
| 217 |
|
| 218 |
with gr.Row():
|
|
@@ -220,24 +226,16 @@ with demo:
|
|
| 220 |
with gr.Row():
|
| 221 |
trade_details_selector = gr.Dropdown(
|
| 222 |
label="Select a trade metric",
|
| 223 |
-
choices=
|
| 224 |
-
|
| 225 |
-
"collateral amount",
|
| 226 |
-
"earnings",
|
| 227 |
-
"net earnings",
|
| 228 |
-
"ROI",
|
| 229 |
-
],
|
| 230 |
-
value="mech calls",
|
| 231 |
)
|
| 232 |
with gr.Row():
|
| 233 |
trade_details_plot = plot_trade_details(
|
| 234 |
-
|
| 235 |
)
|
| 236 |
|
| 237 |
def update_trade_details(trade_detail):
|
| 238 |
-
return plot_trade_details(
|
| 239 |
-
trade_detail=trade_detail, trades_df=trades_df
|
| 240 |
-
)
|
| 241 |
|
| 242 |
trade_details_selector.change(
|
| 243 |
update_trade_details,
|
|
|
|
| 15 |
plot_trades_per_market_by_week,
|
| 16 |
plot_winning_trades_by_week,
|
| 17 |
plot_winning_trades_per_market_by_week,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
from tabs.metrics import (
|
| 21 |
+
metric_choices,
|
| 22 |
+
default_metric,
|
| 23 |
plot_trade_details,
|
| 24 |
)
|
| 25 |
+
|
| 26 |
from tabs.tool_win import (
|
| 27 |
get_tool_winning_rate,
|
| 28 |
get_overall_winning_rate,
|
|
|
|
| 218 |
)
|
| 219 |
with gr.Column(min_width=350):
|
| 220 |
all_wtrades_by_week = plot_winning_trades_per_market_by_week(
|
| 221 |
+
trades_df=winning_trades_by_market, market_type="all"
|
| 222 |
)
|
| 223 |
|
| 224 |
with gr.Row():
|
|
|
|
| 226 |
with gr.Row():
|
| 227 |
trade_details_selector = gr.Dropdown(
|
| 228 |
label="Select a trade metric",
|
| 229 |
+
choices=metric_choices,
|
| 230 |
+
value=default_metric,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
)
|
| 232 |
with gr.Row():
|
| 233 |
trade_details_plot = plot_trade_details(
|
| 234 |
+
metric_name=default_metric, trades_df=trades_df
|
| 235 |
)
|
| 236 |
|
| 237 |
def update_trade_details(trade_detail):
|
| 238 |
+
return plot_trade_details(metric_name=trade_detail, trades_df=trades_df)
|
|
|
|
|
|
|
| 239 |
|
| 240 |
trade_details_selector.change(
|
| 241 |
update_trade_details,
|
tabs/metrics.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
metric_choices = [
|
| 5 |
+
"mech calls",
|
| 6 |
+
"collateral amount",
|
| 7 |
+
"earnings",
|
| 8 |
+
"net earnings",
|
| 9 |
+
"ROI",
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
default_metric = "ROI"
|
| 13 |
+
|
| 14 |
+
HEIGHT = 600
|
| 15 |
+
WIDTH = 1000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def plot_trade_details(metric_name: str, trades_df: pd.DataFrame) -> gr.LinePlot:
|
| 19 |
+
"""Plots the trade details for the given trade detail."""
|
| 20 |
+
column_name = metric_name
|
| 21 |
+
if metric_name == "mech calls":
|
| 22 |
+
metric_name = "mech_calls"
|
| 23 |
+
column_name = "num_mech_calls"
|
| 24 |
+
elif metric_name == "ROI":
|
| 25 |
+
column_name = "roi"
|
| 26 |
+
|
| 27 |
+
# this is to filter out the data before 2023-09-01
|
| 28 |
+
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
| 29 |
+
trades_filtered = (
|
| 30 |
+
trades_filtered.groupby("month_year_week")[column_name]
|
| 31 |
+
.quantile([0.25, 0.5, 0.75])
|
| 32 |
+
.unstack()
|
| 33 |
+
)
|
| 34 |
+
trades_filtered.columns = trades_filtered.columns.astype(str)
|
| 35 |
+
trades_filtered.reset_index(inplace=True)
|
| 36 |
+
trades_filtered.columns = [
|
| 37 |
+
"month_year_week",
|
| 38 |
+
"25th_percentile",
|
| 39 |
+
"50th_percentile",
|
| 40 |
+
"75th_percentile",
|
| 41 |
+
]
|
| 42 |
+
# reformat the data as percentile, date, value
|
| 43 |
+
trades_filtered = trades_filtered.melt(
|
| 44 |
+
id_vars=["month_year_week"], var_name="percentile", value_name=metric_name
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
return gr.LinePlot(
|
| 48 |
+
value=trades_filtered,
|
| 49 |
+
x="month_year_week",
|
| 50 |
+
y=metric_name,
|
| 51 |
+
color="percentile",
|
| 52 |
+
show_label=True,
|
| 53 |
+
interactive=True,
|
| 54 |
+
show_actions_button=True,
|
| 55 |
+
tooltip=["month_year_week", "percentile", metric_name],
|
| 56 |
+
height=HEIGHT,
|
| 57 |
+
width=WIDTH,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def plot_average_roi_per_market_by_week(trades_df: pd.DataFrame) -> gr.LinePlot:
|
| 62 |
+
|
| 63 |
+
mean_roi_per_market_by_week = (
|
| 64 |
+
trades_df.groupby(["market_creator", "month_year_week"])["roi"]
|
| 65 |
+
.mean()
|
| 66 |
+
.reset_index()
|
| 67 |
+
)
|
| 68 |
+
mean_roi_per_market_by_week.rename(columns={"roi": "mean_roi"}, inplace=True)
|
| 69 |
+
return gr.LinePlot(
|
| 70 |
+
value=mean_roi_per_market_by_week,
|
| 71 |
+
x="month_year_week",
|
| 72 |
+
y="ROI",
|
| 73 |
+
color="market_creator",
|
| 74 |
+
show_label=True,
|
| 75 |
+
interactive=True,
|
| 76 |
+
show_actions_button=True,
|
| 77 |
+
tooltip=["month_year_week", "market_creator", "mean_roi"],
|
| 78 |
+
height=HEIGHT,
|
| 79 |
+
width=WIDTH,
|
| 80 |
+
)
|
tabs/trades.py
CHANGED
|
@@ -13,6 +13,7 @@ def prepare_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
|
| 13 |
trades_df["creation_timestamp"] = trades_df["creation_timestamp"].dt.tz_convert(
|
| 14 |
"UTC"
|
| 15 |
)
|
|
|
|
| 16 |
trades_df["month_year"] = (
|
| 17 |
trades_df["creation_timestamp"].dt.to_period("M").astype(str)
|
| 18 |
)
|
|
@@ -34,7 +35,9 @@ def get_overall_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
|
| 34 |
def get_overall_by_market_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
| 35 |
"""Gets the overall trades data"""
|
| 36 |
trades_count = (
|
| 37 |
-
trades_df.groupby(["
|
|
|
|
|
|
|
| 38 |
)
|
| 39 |
trades_count.columns = trades_count.columns.astype(str)
|
| 40 |
trades_count.rename(columns={"0": "trades"}, inplace=True)
|
|
@@ -58,8 +61,10 @@ def get_overall_winning_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
|
| 58 |
def get_overall_winning_by_market_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
| 59 |
"""Gets the overall winning trades data for the given tools and calculates the winning percentage."""
|
| 60 |
winning_trades = (
|
| 61 |
-
trades_df.groupby(["
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
"winning_trade"
|
| 64 |
].count()
|
| 65 |
* 100
|
|
@@ -67,206 +72,11 @@ def get_overall_winning_by_market_trades(trades_df: pd.DataFrame) -> pd.DataFram
|
|
| 67 |
# winning_trades is a series, give it a dataframe
|
| 68 |
winning_trades = winning_trades.reset_index()
|
| 69 |
winning_trades.columns = winning_trades.columns.astype(str)
|
| 70 |
-
winning_trades.columns = ["
|
| 71 |
print(winning_trades.head())
|
| 72 |
return winning_trades
|
| 73 |
|
| 74 |
|
| 75 |
-
def plot_trade_details(trade_detail: str, trades_df: pd.DataFrame) -> gr.LinePlot:
|
| 76 |
-
"""Plots the trade details for the given trade detail."""
|
| 77 |
-
if trade_detail == "mech calls":
|
| 78 |
-
# this is to filter out the data before 2023-09-01
|
| 79 |
-
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
| 80 |
-
trades_filtered = (
|
| 81 |
-
trades_filtered.groupby("month_year_week")["num_mech_calls"]
|
| 82 |
-
.quantile([0.25, 0.5, 0.75])
|
| 83 |
-
.unstack()
|
| 84 |
-
)
|
| 85 |
-
trades_filtered.columns = trades_filtered.columns.astype(str)
|
| 86 |
-
trades_filtered.reset_index(inplace=True)
|
| 87 |
-
trades_filtered.columns = [
|
| 88 |
-
"month_year_week",
|
| 89 |
-
"25th_percentile",
|
| 90 |
-
"50th_percentile",
|
| 91 |
-
"75th_percentile",
|
| 92 |
-
]
|
| 93 |
-
# reformat the data as percentile, date, value
|
| 94 |
-
trades_filtered = trades_filtered.melt(
|
| 95 |
-
id_vars=["month_year_week"], var_name="percentile", value_name="mech_calls"
|
| 96 |
-
)
|
| 97 |
-
|
| 98 |
-
return gr.LinePlot(
|
| 99 |
-
value=trades_filtered,
|
| 100 |
-
x="month_year_week",
|
| 101 |
-
y="mech_calls",
|
| 102 |
-
color="percentile",
|
| 103 |
-
show_label=True,
|
| 104 |
-
interactive=True,
|
| 105 |
-
show_actions_button=True,
|
| 106 |
-
tooltip=["month_year_week", "percentile", "mech_calls"],
|
| 107 |
-
height=HEIGHT,
|
| 108 |
-
width=WIDTH,
|
| 109 |
-
)
|
| 110 |
-
|
| 111 |
-
if trade_detail == "collateral amount":
|
| 112 |
-
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
| 113 |
-
trades_filtered = (
|
| 114 |
-
trades_filtered.groupby("month_year_week")["collateral_amount"]
|
| 115 |
-
.quantile([0.25, 0.5, 0.75])
|
| 116 |
-
.unstack()
|
| 117 |
-
)
|
| 118 |
-
trades_filtered.columns = trades_filtered.columns.astype(str)
|
| 119 |
-
trades_filtered.reset_index(inplace=True)
|
| 120 |
-
trades_filtered.columns = [
|
| 121 |
-
"month_year_week",
|
| 122 |
-
"25th_percentile",
|
| 123 |
-
"50th_percentile",
|
| 124 |
-
"75th_percentile",
|
| 125 |
-
]
|
| 126 |
-
# reformat the data as percentile, date, value
|
| 127 |
-
trades_filtered = trades_filtered.melt(
|
| 128 |
-
id_vars=["month_year_week"],
|
| 129 |
-
var_name="percentile",
|
| 130 |
-
value_name="collateral_amount",
|
| 131 |
-
)
|
| 132 |
-
|
| 133 |
-
return gr.LinePlot(
|
| 134 |
-
value=trades_filtered,
|
| 135 |
-
x="month_year_week",
|
| 136 |
-
y="collateral_amount",
|
| 137 |
-
color="percentile",
|
| 138 |
-
show_label=True,
|
| 139 |
-
interactive=True,
|
| 140 |
-
show_actions_button=True,
|
| 141 |
-
tooltip=["month_year_week", "percentile", "collateral_amount"],
|
| 142 |
-
height=HEIGHT,
|
| 143 |
-
width=WIDTH,
|
| 144 |
-
)
|
| 145 |
-
|
| 146 |
-
if trade_detail == "earnings":
|
| 147 |
-
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
| 148 |
-
trades_filtered = (
|
| 149 |
-
trades_filtered.groupby("month_year_week")["earnings"]
|
| 150 |
-
.quantile([0.25, 0.5, 0.75])
|
| 151 |
-
.unstack()
|
| 152 |
-
)
|
| 153 |
-
trades_filtered.columns = trades_filtered.columns.astype(str)
|
| 154 |
-
trades_filtered.reset_index(inplace=True)
|
| 155 |
-
trades_filtered.columns = [
|
| 156 |
-
"month_year_week",
|
| 157 |
-
"25th_percentile",
|
| 158 |
-
"50th_percentile",
|
| 159 |
-
"75th_percentile",
|
| 160 |
-
]
|
| 161 |
-
# reformat the data as percentile, date, value
|
| 162 |
-
trades_filtered = trades_filtered.melt(
|
| 163 |
-
id_vars=["month_year_week"], var_name="percentile", value_name="earnings"
|
| 164 |
-
)
|
| 165 |
-
|
| 166 |
-
return gr.LinePlot(
|
| 167 |
-
value=trades_filtered,
|
| 168 |
-
x="month_year_week",
|
| 169 |
-
y="earnings",
|
| 170 |
-
color="percentile",
|
| 171 |
-
show_label=True,
|
| 172 |
-
interactive=True,
|
| 173 |
-
show_actions_button=True,
|
| 174 |
-
tooltip=["month_year_week", "percentile", "earnings"],
|
| 175 |
-
height=HEIGHT,
|
| 176 |
-
width=WIDTH,
|
| 177 |
-
)
|
| 178 |
-
|
| 179 |
-
if trade_detail == "net earnings":
|
| 180 |
-
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
| 181 |
-
trades_filtered = (
|
| 182 |
-
trades_filtered.groupby("month_year_week")["net_earnings"]
|
| 183 |
-
.quantile([0.25, 0.5, 0.75])
|
| 184 |
-
.unstack()
|
| 185 |
-
)
|
| 186 |
-
trades_filtered.columns = trades_filtered.columns.astype(str)
|
| 187 |
-
trades_filtered.reset_index(inplace=True)
|
| 188 |
-
trades_filtered.columns = [
|
| 189 |
-
"month_year_week",
|
| 190 |
-
"25th_percentile",
|
| 191 |
-
"50th_percentile",
|
| 192 |
-
"75th_percentile",
|
| 193 |
-
]
|
| 194 |
-
# reformat the data as percentile, date, value
|
| 195 |
-
trades_filtered = trades_filtered.melt(
|
| 196 |
-
id_vars=["month_year_week"],
|
| 197 |
-
var_name="percentile",
|
| 198 |
-
value_name="net_earnings",
|
| 199 |
-
)
|
| 200 |
-
|
| 201 |
-
return gr.LinePlot(
|
| 202 |
-
value=trades_filtered,
|
| 203 |
-
x="month_year_week",
|
| 204 |
-
y="net_earnings",
|
| 205 |
-
color="percentile",
|
| 206 |
-
show_label=True,
|
| 207 |
-
interactive=True,
|
| 208 |
-
show_actions_button=True,
|
| 209 |
-
tooltip=["month_year_week", "percentile", "net_earnings"],
|
| 210 |
-
height=HEIGHT,
|
| 211 |
-
width=WIDTH,
|
| 212 |
-
)
|
| 213 |
-
|
| 214 |
-
if trade_detail == "ROI":
|
| 215 |
-
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
| 216 |
-
trades_filtered = (
|
| 217 |
-
trades_filtered.groupby("month_year_week")["roi"]
|
| 218 |
-
.quantile([0.25, 0.5, 0.75])
|
| 219 |
-
.unstack()
|
| 220 |
-
)
|
| 221 |
-
trades_filtered.columns = trades_filtered.columns.astype(str)
|
| 222 |
-
trades_filtered.reset_index(inplace=True)
|
| 223 |
-
trades_filtered.columns = [
|
| 224 |
-
"month_year_week",
|
| 225 |
-
"25th_percentile",
|
| 226 |
-
"50th_percentile",
|
| 227 |
-
"75th_percentile",
|
| 228 |
-
]
|
| 229 |
-
# reformat the data as percentile, date, value
|
| 230 |
-
trades_filtered = trades_filtered.melt(
|
| 231 |
-
id_vars=["month_year_week"], var_name="percentile", value_name="ROI"
|
| 232 |
-
)
|
| 233 |
-
|
| 234 |
-
return gr.LinePlot(
|
| 235 |
-
value=trades_filtered,
|
| 236 |
-
x="month_year_week",
|
| 237 |
-
y="ROI",
|
| 238 |
-
color="percentile",
|
| 239 |
-
show_label=True,
|
| 240 |
-
interactive=True,
|
| 241 |
-
show_actions_button=True,
|
| 242 |
-
tooltip=["month_year_week", "percentile", "ROI"],
|
| 243 |
-
height=HEIGHT,
|
| 244 |
-
width=WIDTH,
|
| 245 |
-
)
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
def plot_average_roi_per_market_by_week(trades_df: pd.DataFrame) -> gr.LinePlot:
|
| 249 |
-
|
| 250 |
-
mean_roi_per_market_by_week = (
|
| 251 |
-
trades_df.groupby(["market_creator", "month_year_week"])["roi"]
|
| 252 |
-
.mean()
|
| 253 |
-
.reset_index()
|
| 254 |
-
)
|
| 255 |
-
mean_roi_per_market_by_week.rename(columns={"roi": "mean_roi"}, inplace=True)
|
| 256 |
-
return gr.LinePlot(
|
| 257 |
-
value=mean_roi_per_market_by_week,
|
| 258 |
-
x="month_year_week",
|
| 259 |
-
y="ROI",
|
| 260 |
-
color="market_creator",
|
| 261 |
-
show_label=True,
|
| 262 |
-
interactive=True,
|
| 263 |
-
show_actions_button=True,
|
| 264 |
-
tooltip=["month_year_week", "market_creator", "mean_roi"],
|
| 265 |
-
height=HEIGHT,
|
| 266 |
-
width=WIDTH,
|
| 267 |
-
)
|
| 268 |
-
|
| 269 |
-
|
| 270 |
def plot_trades_by_week(trades_df: pd.DataFrame) -> gr.BarPlot:
|
| 271 |
"""Plots the trades data for the given tools and calculates the winning percentage."""
|
| 272 |
return gr.BarPlot(
|
|
@@ -309,6 +119,7 @@ def plot_trades_per_market_by_week(
|
|
| 309 |
fig.update_layout(
|
| 310 |
xaxis_title="Week",
|
| 311 |
yaxis_title="Weekly nr of trades",
|
|
|
|
| 312 |
)
|
| 313 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 314 |
return gr.Plot(
|
|
@@ -357,7 +168,7 @@ def plot_winning_trades_per_market_by_week(
|
|
| 357 |
fig.update_layout(
|
| 358 |
xaxis_title="Week",
|
| 359 |
yaxis_title="Weekly % of winning trades",
|
| 360 |
-
#
|
| 361 |
)
|
| 362 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 363 |
return gr.Plot(
|
|
|
|
| 13 |
trades_df["creation_timestamp"] = trades_df["creation_timestamp"].dt.tz_convert(
|
| 14 |
"UTC"
|
| 15 |
)
|
| 16 |
+
trades_df = trades_df.sort_values(by="creation_timestamp", ascending=True)
|
| 17 |
trades_df["month_year"] = (
|
| 18 |
trades_df["creation_timestamp"].dt.to_period("M").astype(str)
|
| 19 |
)
|
|
|
|
| 35 |
def get_overall_by_market_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
| 36 |
"""Gets the overall trades data"""
|
| 37 |
trades_count = (
|
| 38 |
+
trades_df.groupby(["month_year_week", "market_creator"], sort=False)
|
| 39 |
+
.size()
|
| 40 |
+
.reset_index()
|
| 41 |
)
|
| 42 |
trades_count.columns = trades_count.columns.astype(str)
|
| 43 |
trades_count.rename(columns={"0": "trades"}, inplace=True)
|
|
|
|
| 61 |
def get_overall_winning_by_market_trades(trades_df: pd.DataFrame) -> pd.DataFrame:
|
| 62 |
"""Gets the overall winning trades data for the given tools and calculates the winning percentage."""
|
| 63 |
winning_trades = (
|
| 64 |
+
trades_df.groupby(["month_year_week", "market_creator"], sort=False)[
|
| 65 |
+
"winning_trade"
|
| 66 |
+
].sum()
|
| 67 |
+
/ trades_df.groupby(["month_year_week", "market_creator"], sort=False)[
|
| 68 |
"winning_trade"
|
| 69 |
].count()
|
| 70 |
* 100
|
|
|
|
| 72 |
# winning_trades is a series, give it a dataframe
|
| 73 |
winning_trades = winning_trades.reset_index()
|
| 74 |
winning_trades.columns = winning_trades.columns.astype(str)
|
| 75 |
+
winning_trades.columns = ["month_year_week", "market_creator", "winning_trade"]
|
| 76 |
print(winning_trades.head())
|
| 77 |
return winning_trades
|
| 78 |
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
def plot_trades_by_week(trades_df: pd.DataFrame) -> gr.BarPlot:
|
| 81 |
"""Plots the trades data for the given tools and calculates the winning percentage."""
|
| 82 |
return gr.BarPlot(
|
|
|
|
| 119 |
fig.update_layout(
|
| 120 |
xaxis_title="Week",
|
| 121 |
yaxis_title="Weekly nr of trades",
|
| 122 |
+
# xaxis_type="category",
|
| 123 |
)
|
| 124 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 125 |
return gr.Plot(
|
|
|
|
| 168 |
fig.update_layout(
|
| 169 |
xaxis_title="Week",
|
| 170 |
yaxis_title="Weekly % of winning trades",
|
| 171 |
+
# xaxis_type="category",
|
| 172 |
)
|
| 173 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 174 |
return gr.Plot(
|