cyberosa commited on
Commit
cd2003a
·
1 Parent(s): 1ed82ec

updating description of trader types

Browse files
app.py CHANGED
@@ -177,7 +177,7 @@ with demo:
177
  traders_df=weekly_metrics_by_market_creator,
178
  )
179
  with gr.Column(scale=1):
180
- trade_details_text = get_metrics_text()
181
 
182
  def update_trader_details(trader_detail):
183
  return plot_trader_metrics_by_market_creator(
@@ -207,7 +207,7 @@ with demo:
207
  traders_df=weekly_o_metrics_by_market_creator,
208
  )
209
  with gr.Column(scale=1):
210
- trade_details_text = get_metrics_text()
211
 
212
  def update_a_trader_details(trader_detail):
213
  return plot_trader_metrics_by_market_creator(
@@ -238,7 +238,7 @@ with demo:
238
  traders_df=weekly_non_olas_metrics_by_market_creator,
239
  )
240
  with gr.Column(scale=1):
241
- trade_details_text = get_metrics_text()
242
 
243
  def update_no_trader_details(trader_detail):
244
  return plot_trader_metrics_by_market_creator(
@@ -254,7 +254,7 @@ with demo:
254
  # Unknown traders graph
255
  if weekly_unknown_trader_metrics_by_market_creator is not None:
256
  with gr.Row():
257
- gr.Markdown("# Weekly metrics of Unknown traders")
258
  with gr.Row():
259
  trader_u_details_selector = gr.Dropdown(
260
  label="Select a weekly trader metric",
@@ -269,7 +269,9 @@ with demo:
269
  traders_df=weekly_unknown_trader_metrics_by_market_creator,
270
  )
271
  with gr.Column(scale=1):
272
- trade_details_text = get_metrics_text()
 
 
273
 
274
  def update_u_trader_details(trader_detail):
275
  return plot_trader_metrics_by_market_creator(
 
177
  traders_df=weekly_metrics_by_market_creator,
178
  )
179
  with gr.Column(scale=1):
180
+ trade_details_text = get_metrics_text(trader_type=None)
181
 
182
  def update_trader_details(trader_detail):
183
  return plot_trader_metrics_by_market_creator(
 
207
  traders_df=weekly_o_metrics_by_market_creator,
208
  )
209
  with gr.Column(scale=1):
210
+ trade_details_text = get_metrics_text(trader_type="Olas")
211
 
212
  def update_a_trader_details(trader_detail):
213
  return plot_trader_metrics_by_market_creator(
 
238
  traders_df=weekly_non_olas_metrics_by_market_creator,
239
  )
240
  with gr.Column(scale=1):
241
+ trade_details_text = get_metrics_text(trader_type="non_Olas")
242
 
243
  def update_no_trader_details(trader_detail):
244
  return plot_trader_metrics_by_market_creator(
 
254
  # Unknown traders graph
255
  if weekly_unknown_trader_metrics_by_market_creator is not None:
256
  with gr.Row():
257
+ gr.Markdown("# Weekly metrics of Unclassified traders")
258
  with gr.Row():
259
  trader_u_details_selector = gr.Dropdown(
260
  label="Select a weekly trader metric",
 
269
  traders_df=weekly_unknown_trader_metrics_by_market_creator,
270
  )
271
  with gr.Column(scale=1):
272
+ trade_details_text = get_metrics_text(
273
+ trader_type="unclassified"
274
+ )
275
 
276
  def update_u_trader_details(trader_detail):
277
  return plot_trader_metrics_by_market_creator(
scripts/metrics.py CHANGED
@@ -1,7 +1,6 @@
1
  import pandas as pd
2
  from tqdm import tqdm
3
  from scripts.num_mech_calls import (
4
- get_daily_total_mech_calls,
5
  get_weekly_total_mech_calls,
6
  )
7
 
@@ -23,8 +22,8 @@ def compute_metrics(
23
  agg_metrics["trader_address"] = trader_address
24
  total_bet_amounts = trader_data.collateral_amount.sum()
25
  if live_metrics:
26
- # the total can be computed from daily_info.parquet
27
- total_nr_mech_calls_all_markets = get_daily_total_mech_calls(trader_data)
28
  elif unknown_trader:
29
  # num of mech calls is always zero
30
  total_nr_mech_calls_all_markets = 0
 
1
  import pandas as pd
2
  from tqdm import tqdm
3
  from scripts.num_mech_calls import (
 
4
  get_weekly_total_mech_calls,
5
  )
6
 
 
22
  agg_metrics["trader_address"] = trader_address
23
  total_bet_amounts = trader_data.collateral_amount.sum()
24
  if live_metrics:
25
+ # the total is already computed in daily_info per trader address and trading day
26
+ total_nr_mech_calls_all_markets = trader_data["num_mech_calls"].iloc[0]
27
  elif unknown_trader:
28
  # num of mech calls is always zero
29
  total_nr_mech_calls_all_markets = 0
scripts/num_mech_calls.py CHANGED
@@ -8,23 +8,6 @@ def transform_to_datetime(x):
8
  return datetime.fromtimestamp(int(x), tz=timezone.utc)
9
 
10
 
11
- def get_daily_total_mech_calls(trader_data: pd.DataFrame) -> int:
12
- """Function to compute the total daily number of mech calls for all markets
13
- that the trader bet upon"""
14
- daily_markets = trader_data.title.unique()
15
- trading_day = trader_data.creation_date.unique()
16
- if len(trading_day) > 1:
17
- raise ValueError("The trader data should contain only one day information")
18
- total_mech_calls = 0
19
- for market in daily_markets:
20
- # in num_mech_calls we have the total mech calls done for that market that day
21
- total_mech_calls_on_market = trader_data.loc[
22
- trader_data["title"] == market, "num_mech_calls"
23
- ].iloc[0]
24
- total_mech_calls += total_mech_calls_on_market
25
- return total_mech_calls
26
-
27
-
28
  def get_weekly_total_mech_calls(trader_data: pd.DataFrame) -> int:
29
  """Function to compute the total weekly number of mech calls for all markets
30
  that the trader bet upon"""
 
8
  return datetime.fromtimestamp(int(x), tz=timezone.utc)
9
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  def get_weekly_total_mech_calls(trader_data: pd.DataFrame) -> int:
12
  """Function to compute the total weekly number of mech calls for all markets
13
  that the trader bet upon"""
tabs/trader_plots.py CHANGED
@@ -15,14 +15,7 @@ trader_metric_choices = [
15
  default_trader_metric = "ROI"
16
 
17
 
18
- def get_metrics_text(daily: bool = False) -> gr.Markdown:
19
- metric_text = """
20
- ## Metrics at the graph
21
- These metrics are computed weekly. The statistical measures are:
22
- * min, max, 25th(q1), 50th(median) and 75th(q2) percentiles
23
- * the upper and lower fences to delimit possible outliers
24
- * the average values as the dotted lines
25
- """
26
  if daily:
27
  metric_text = """
28
  ## Metrics at the graph
@@ -31,6 +24,44 @@ def get_metrics_text(daily: bool = False) -> gr.Markdown:
31
  * the upper and lower fences to delimit possible outliers
32
  * the average values as the dotted lines
33
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  return gr.Markdown(metric_text)
35
 
36
 
 
15
  default_trader_metric = "ROI"
16
 
17
 
18
+ def get_metrics_text(trader_type: str = None, daily: bool = False) -> gr.Markdown:
 
 
 
 
 
 
 
19
  if daily:
20
  metric_text = """
21
  ## Metrics at the graph
 
24
  * the upper and lower fences to delimit possible outliers
25
  * the average values as the dotted lines
26
  """
27
+ elif trader_type is None:
28
+ metric_text = """
29
+ ## Description of the graph
30
+ These metrics are computed weekly. The statistical measures are:
31
+ * min, max, 25th(q1), 50th(median) and 75th(q2) percentiles
32
+ * the upper and lower fences to delimit possible outliers
33
+ * the average values as the dotted lines
34
+ """
35
+ elif trader_type == "Olas":
36
+ metric_text = """
37
+ ## Definition of Olas trader
38
+ Agents using Mech, with a service ID and the corresponding safe in the registry
39
+ ## Description of the graph
40
+ These metrics are computed weekly. The statistical measures are:
41
+ * min, max, 25th(q1), 50th(median) and 75th(q2) percentiles
42
+ * the upper and lower fences to delimit possible outliers
43
+ * the average values as the dotted lines
44
+ """
45
+ elif trader_type == "non_Olas":
46
+ metric_text = """
47
+ ## Definition of non-Olas trader
48
+ Agents using Mech, with no service ID
49
+ ## Description of the graph
50
+ These metrics are computed weekly. The statistical measures are:
51
+ * min, max, 25th(q1), 50th(median) and 75th(q2) percentiles
52
+ * the upper and lower fences to delimit possible outliers
53
+ * the average values as the dotted lines
54
+ """
55
+ else: # Unclassified
56
+ metric_text = """
57
+ ## Definition of unclassified trader
58
+ Agents (safe/EOAs) not using Mechs
59
+ ## Description of the graph
60
+ These metrics are computed weekly. The statistical measures are:
61
+ * min, max, 25th(q1), 50th(median) and 75th(q2) percentiles
62
+ * the upper and lower fences to delimit possible outliers
63
+ * the average values as the dotted lines
64
+ """
65
  return gr.Markdown(metric_text)
66
 
67