cyberosa commited on
Commit
6298cbe
·
1 Parent(s): 00d49a3

new daily graphs

Browse files
data/daily_info.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3efc44de285c7f330661d31354843e5c95f89323a04d32774971576bdf049dba
3
- size 390502
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa46e26ddf79ae4565e8572d489d377884e071f20eb19ea3c8d99684c2c00548
3
+ size 611323
tabs/daily_graphs.py CHANGED
@@ -121,6 +121,8 @@ def plot_daily_metrics(
121
  trades_filtered["trader_market"] = trades_filtered.apply(
122
  lambda x: (x["trader_type"], x["market_creator"]), axis=1
123
  )
 
 
124
  fig = px.box(
125
  trades_filtered,
126
  x="creation_date",
@@ -150,6 +152,8 @@ def plot_daily_metrics(
150
  # if axis.startswith("xaxis"):
151
  # fig.layout[axis].update(title="Day")
152
  fig.update_xaxes(tickformat="%b %d")
 
 
153
  return gr.Plot(
154
  value=fig,
155
  )
 
121
  trades_filtered["trader_market"] = trades_filtered.apply(
122
  lambda x: (x["trader_type"], x["market_creator"]), axis=1
123
  )
124
+
125
+ all_dates = sorted(trades_filtered["creation_date"].unique())
126
  fig = px.box(
127
  trades_filtered,
128
  x="creation_date",
 
152
  # if axis.startswith("xaxis"):
153
  # fig.layout[axis].update(title="Day")
154
  fig.update_xaxes(tickformat="%b %d")
155
+ # Update layout to force x-axis category order (hotfix for a sorting issue)
156
+ fig.update_layout(xaxis={"categoryorder": "array", "categoryarray": all_dates})
157
  return gr.Plot(
158
  value=fig,
159
  )
tabs/market_plots.py CHANGED
@@ -6,6 +6,7 @@ from plotly.subplots import make_subplots
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  from tabs.daily_graphs import color_mapping
 
9
 
10
  color_mapping = [
11
  "darkviolet",
@@ -130,7 +131,15 @@ def plot_total_bet_amount_per_trader_per_market(
130
  .sum()
131
  .reset_index(name="total_bet_amount")
132
  )
133
-
 
 
 
 
 
 
 
 
134
  fig = px.box(
135
  total_bet_amount,
136
  x="month_year_week",
@@ -162,6 +171,8 @@ def plot_total_bet_amount_per_trader_per_market(
162
  # if axis.startswith("xaxis"):
163
  # fig.layout[axis].update(title="Week")
164
  fig.update_xaxes(tickformat="%b %d\n%Y")
 
 
165
  return gr.Plot(
166
  value=fig,
167
  )
 
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  from tabs.daily_graphs import color_mapping
9
+ from datetime import datetime
10
 
11
  color_mapping = [
12
  "darkviolet",
 
131
  .sum()
132
  .reset_index(name="total_bet_amount")
133
  )
134
+ # Convert string dates to datetime and sort them
135
+ all_dates_dt = sorted(
136
+ [
137
+ datetime.strptime(date, "%b-%d")
138
+ for date in total_bet_amount["month_year_week"].unique()
139
+ ]
140
+ )
141
+ # Convert back to string format
142
+ all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
143
  fig = px.box(
144
  total_bet_amount,
145
  x="month_year_week",
 
171
  # if axis.startswith("xaxis"):
172
  # fig.layout[axis].update(title="Week")
173
  fig.update_xaxes(tickformat="%b %d\n%Y")
174
+ # Update layout to force x-axis category order (hotfix for a sorting issue)
175
+ fig.update_layout(xaxis={"categoryorder": "array", "categoryarray": all_dates})
176
  return gr.Plot(
177
  value=fig,
178
  )
tabs/trader_plots.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  import pandas as pd
3
  import plotly.express as px
4
  from tabs.market_plots import color_mapping
 
5
 
6
  trader_metric_choices = [
7
  "mech calls",
@@ -80,7 +81,15 @@ def plot_trader_metrics_by_market_creator(
80
  yaxis_title = "Total gross profit per trader (xDAI)"
81
 
82
  traders_filtered = traders_df[["month_year_week", "market_creator", column_name]]
83
-
 
 
 
 
 
 
 
 
84
  fig = px.box(
85
  traders_filtered,
86
  x="month_year_week",
@@ -96,6 +105,8 @@ def plot_trader_metrics_by_market_creator(
96
  legend=dict(yanchor="top", y=0.5),
97
  )
98
  fig.update_xaxes(tickformat="%b %d\n%Y")
 
 
99
 
100
  return gr.Plot(
101
  value=fig,
@@ -198,6 +209,15 @@ def plot_total_bet_amount(
198
  .sum()
199
  .reset_index(name="total_bet_amount")
200
  )
 
 
 
 
 
 
 
 
 
201
  total_bet_amount["trader_market"] = total_bet_amount.apply(
202
  lambda x: (x["trader_type"], x["market_creator"]), axis=1
203
  )
@@ -245,6 +265,8 @@ def plot_total_bet_amount(
245
  # if axis.startswith("xaxis"):
246
  # fig.layout[axis].update(title="Week")
247
  fig.update_xaxes(tickformat="%b %d")
 
 
248
  return gr.Plot(
249
  value=fig,
250
  )
 
2
  import pandas as pd
3
  import plotly.express as px
4
  from tabs.market_plots import color_mapping
5
+ from datetime import datetime
6
 
7
  trader_metric_choices = [
8
  "mech calls",
 
81
  yaxis_title = "Total gross profit per trader (xDAI)"
82
 
83
  traders_filtered = traders_df[["month_year_week", "market_creator", column_name]]
84
+ # Convert string dates to datetime and sort them
85
+ all_dates_dt = sorted(
86
+ [
87
+ datetime.strptime(date, "%b-%d")
88
+ for date in traders_filtered["month_year_week"].unique()
89
+ ]
90
+ )
91
+ # Convert back to string format
92
+ all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
93
  fig = px.box(
94
  traders_filtered,
95
  x="month_year_week",
 
105
  legend=dict(yanchor="top", y=0.5),
106
  )
107
  fig.update_xaxes(tickformat="%b %d\n%Y")
108
+ # Update layout to force x-axis category order (hotfix for a sorting issue)
109
+ fig.update_layout(xaxis={"categoryorder": "array", "categoryarray": all_dates})
110
 
111
  return gr.Plot(
112
  value=fig,
 
209
  .sum()
210
  .reset_index(name="total_bet_amount")
211
  )
212
+ # Convert string dates to datetime and sort them
213
+ all_dates_dt = sorted(
214
+ [
215
+ datetime.strptime(date, "%b-%d")
216
+ for date in total_bet_amount["month_year_week"].unique()
217
+ ]
218
+ )
219
+ # Convert back to string format
220
+ all_dates = [date.strftime("%b-%d") for date in all_dates_dt]
221
  total_bet_amount["trader_market"] = total_bet_amount.apply(
222
  lambda x: (x["trader_type"], x["market_creator"]), axis=1
223
  )
 
265
  # if axis.startswith("xaxis"):
266
  # fig.layout[axis].update(title="Week")
267
  fig.update_xaxes(tickformat="%b %d")
268
+ # Update layout to force x-axis category order (hotfix for a sorting issue)
269
+ fig.update_layout(xaxis={"categoryorder": "array", "categoryarray": all_dates})
270
  return gr.Plot(
271
  value=fig,
272
  )