arshy commited on
Commit
8eba8ff
·
1 Parent(s): ff9989e

remove copy

Browse files
Files changed (3) hide show
  1. tabs/error.py +3 -3
  2. tabs/tool_win.py +1 -1
  3. test.ipynb +24 -672
tabs/error.py CHANGED
@@ -16,7 +16,7 @@ def set_error(row: pd.Series) -> bool:
16
 
17
  def get_error_data(tools_df: pd.DataFrame, inc_tools: List[str]) -> pd.DataFrame:
18
  """Gets the error data for the given tools and calculates the error percentage."""
19
- tools_inc = tools_df[tools_df['tool'].isin(inc_tools)].copy()
20
  tools_inc['error'] = tools_inc.apply(set_error, axis=1)
21
  error = tools_inc.groupby(['tool', 'request_month_year_week', 'error']).size().unstack().fillna(0).reset_index()
22
  error['error_perc'] = (error[True] / (error[False] + error[True])) * 100
@@ -50,7 +50,7 @@ def plot_error_data(error_all_df: pd.DataFrame) -> gr.BarPlot:
50
 
51
  def plot_tool_error_data(error_df: pd.DataFrame, tool: str) -> gr.BarPlot:
52
  """Plots the error data for the given tool."""
53
- error_tool = error_df[error_df['tool'] == tool].copy()
54
  error_tool.columns = error_tool.columns.astype(str)
55
  error_tool['error_perc'] = error_tool['error_perc'].apply(lambda x: round(x, 4))
56
 
@@ -71,7 +71,7 @@ def plot_tool_error_data(error_df: pd.DataFrame, tool: str) -> gr.BarPlot:
71
 
72
  def plot_week_error_data(error_df: pd.DataFrame, week: str) -> gr.BarPlot:
73
  """Plots the error data for the given week."""
74
- error_week = error_df[error_df['request_month_year_week'] == week].copy()
75
  error_week.columns = error_week.columns.astype(str)
76
  error_week['error_perc'] = error_week['error_perc'].apply(lambda x: round(x, 4))
77
  return gr.BarPlot(
 
16
 
17
  def get_error_data(tools_df: pd.DataFrame, inc_tools: List[str]) -> pd.DataFrame:
18
  """Gets the error data for the given tools and calculates the error percentage."""
19
+ tools_inc = tools_df[tools_df['tool'].isin(inc_tools)]
20
  tools_inc['error'] = tools_inc.apply(set_error, axis=1)
21
  error = tools_inc.groupby(['tool', 'request_month_year_week', 'error']).size().unstack().fillna(0).reset_index()
22
  error['error_perc'] = (error[True] / (error[False] + error[True])) * 100
 
50
 
51
  def plot_tool_error_data(error_df: pd.DataFrame, tool: str) -> gr.BarPlot:
52
  """Plots the error data for the given tool."""
53
+ error_tool = error_df[error_df['tool'] == tool]
54
  error_tool.columns = error_tool.columns.astype(str)
55
  error_tool['error_perc'] = error_tool['error_perc'].apply(lambda x: round(x, 4))
56
 
 
71
 
72
  def plot_week_error_data(error_df: pd.DataFrame, week: str) -> gr.BarPlot:
73
  """Plots the error data for the given week."""
74
+ error_week = error_df[error_df['request_month_year_week'] == week]
75
  error_week.columns = error_week.columns.astype(str)
76
  error_week['error_perc'] = error_week['error_perc'].apply(lambda x: round(x, 4))
77
  return gr.BarPlot(
tabs/tool_win.py CHANGED
@@ -18,7 +18,7 @@ def set_error(row: pd.Series) -> bool:
18
 
19
  def get_tool_winning_rate(tools_df: pd.DataFrame, inc_tools: List[str]) -> pd.DataFrame:
20
  """Gets the tool winning rate data for the given tools and calculates the winning percentage."""
21
- tools_inc = tools_df[tools_df['tool'].isin(inc_tools)].copy()
22
  tools_inc['error'] = tools_inc.apply(set_error, axis=1)
23
  tools_non_error = tools_inc[tools_inc['error'] != True]
24
  tools_non_error.loc[:, 'currentAnswer'] = tools_non_error['currentAnswer'].replace({'no': 'No', 'yes': 'Yes'})
 
18
 
19
  def get_tool_winning_rate(tools_df: pd.DataFrame, inc_tools: List[str]) -> pd.DataFrame:
20
  """Gets the tool winning rate data for the given tools and calculates the winning percentage."""
21
+ tools_inc = tools_df[tools_df['tool'].isin(inc_tools)]
22
  tools_inc['error'] = tools_inc.apply(set_error, axis=1)
23
  tools_non_error = tools_inc[tools_inc['error'] != True]
24
  tools_non_error.loc[:, 'currentAnswer'] = tools_non_error['currentAnswer'].replace({'no': 'No', 'yes': 'Yes'})
test.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 1,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -25,584 +25,35 @@
25
  },
26
  {
27
  "cell_type": "code",
28
- "execution_count": 2,
29
- "metadata": {},
30
- "outputs": [],
31
- "source": [
32
- "tools = pd.read_parquet('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/data/tools.parquet')\n",
33
- "tools['trader_address'] = tools['trader_address'].str.lower()\n",
34
- "fpmmTrades = pd.read_parquet('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/data/fpmmTrades.parquet')\n",
35
- "# trades = pd.read_parquet('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/data/all_trades_profitability.parquet')"
36
- ]
37
- },
38
- {
39
- "cell_type": "code",
40
- "execution_count": null,
41
- "metadata": {},
42
- "outputs": [],
43
- "source": [
44
- "IRRELEVANT_TOOLS = [\n",
45
- " \"openai-text-davinci-002\",\n",
46
- " \"openai-text-davinci-003\",\n",
47
- " \"openai-gpt-3.5-turbo\",\n",
48
- " \"openai-gpt-4\",\n",
49
- " \"stabilityai-stable-diffusion-v1-5\",\n",
50
- " \"stabilityai-stable-diffusion-xl-beta-v2-2-2\",\n",
51
- " \"stabilityai-stable-diffusion-512-v2-1\",\n",
52
- " \"stabilityai-stable-diffusion-768-v2-1\",\n",
53
- " \"deepmind-optimization-strong\",\n",
54
- " \"deepmind-optimization\",\n",
55
- "]\n",
56
- "QUERY_BATCH_SIZE = 1000\n",
57
- "DUST_THRESHOLD = 10000000000000\n",
58
- "INVALID_ANSWER_HEX = (\n",
59
- " \"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\"\n",
60
- ")\n",
61
- "INVALID_ANSWER = -1\n",
62
- "FPMM_CREATOR = \"0x89c5cc945dd550bcffb72fe42bff002429f46fec\"\n",
63
- "DEFAULT_FROM_DATE = \"1970-01-01T00:00:00\"\n",
64
- "DEFAULT_TO_DATE = \"2038-01-19T03:14:07\"\n",
65
- "DEFAULT_FROM_TIMESTAMP = 0\n",
66
- "DEFAULT_TO_TIMESTAMP = 2147483647\n",
67
- "WXDAI_CONTRACT_ADDRESS = \"0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d\"\n",
68
- "DEFAULT_MECH_FEE = 0.01\n",
69
- "DUST_THRESHOLD = 10000000000000\n",
70
- "SCRIPTS_DIR = Path('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/scripts')\n",
71
- "ROOT_DIR = SCRIPTS_DIR.parent\n",
72
- "DATA_DIR = ROOT_DIR / \"data\"\n",
73
- "\n",
74
- "class MarketState(Enum):\n",
75
- " \"\"\"Market state\"\"\"\n",
76
- "\n",
77
- " OPEN = 1\n",
78
- " PENDING = 2\n",
79
- " FINALIZING = 3\n",
80
- " ARBITRATING = 4\n",
81
- " CLOSED = 5\n",
82
- "\n",
83
- " def __str__(self) -> str:\n",
84
- " \"\"\"Prints the market status.\"\"\"\n",
85
- " return self.name.capitalize()\n",
86
- "\n",
87
- "\n",
88
- "class MarketAttribute(Enum):\n",
89
- " \"\"\"Attribute\"\"\"\n",
90
- "\n",
91
- " NUM_TRADES = \"Num_trades\"\n",
92
- " WINNER_TRADES = \"Winner_trades\"\n",
93
- " NUM_REDEEMED = \"Num_redeemed\"\n",
94
- " INVESTMENT = \"Investment\"\n",
95
- " FEES = \"Fees\"\n",
96
- " MECH_CALLS = \"Mech_calls\"\n",
97
- " MECH_FEES = \"Mech_fees\"\n",
98
- " EARNINGS = \"Earnings\"\n",
99
- " NET_EARNINGS = \"Net_earnings\"\n",
100
- " REDEMPTIONS = \"Redemptions\"\n",
101
- " ROI = \"ROI\"\n",
102
- "\n",
103
- " def __str__(self) -> str:\n",
104
- " \"\"\"Prints the attribute.\"\"\"\n",
105
- " return self.value\n",
106
- "\n",
107
- " def __repr__(self) -> str:\n",
108
- " \"\"\"Prints the attribute representation.\"\"\"\n",
109
- " return self.name\n",
110
- "\n",
111
- " @staticmethod\n",
112
- " def argparse(s: str) -> \"MarketAttribute\":\n",
113
- " \"\"\"Performs string conversion to MarketAttribute.\"\"\"\n",
114
- " try:\n",
115
- " return MarketAttribute[s.upper()]\n",
116
- " except KeyError as e:\n",
117
- " raise ValueError(f\"Invalid MarketAttribute: {s}\") from e\n",
118
- "\n",
119
- "\n",
120
- "ALL_TRADES_STATS_DF_COLS = [\n",
121
- " \"trader_address\",\n",
122
- " \"trade_id\",\n",
123
- " \"creation_timestamp\",\n",
124
- " \"title\",\n",
125
- " \"market_status\",\n",
126
- " \"collateral_amount\",\n",
127
- " \"outcome_index\",\n",
128
- " \"trade_fee_amount\",\n",
129
- " \"outcomes_tokens_traded\",\n",
130
- " \"current_answer\",\n",
131
- " \"is_invalid\",\n",
132
- " \"winning_trade\",\n",
133
- " \"earnings\",\n",
134
- " \"redeemed\",\n",
135
- " \"redeemed_amount\",\n",
136
- " \"num_mech_calls\",\n",
137
- " \"mech_fee_amount\",\n",
138
- " \"net_earnings\",\n",
139
- " \"roi\",\n",
140
- "]\n",
141
- "\n",
142
- "SUMMARY_STATS_DF_COLS = [\n",
143
- " \"trader_address\",\n",
144
- " \"num_trades\",\n",
145
- " \"num_winning_trades\",\n",
146
- " \"num_redeemed\",\n",
147
- " \"total_investment\",\n",
148
- " \"total_trade_fees\",\n",
149
- " \"num_mech_calls\",\n",
150
- " \"total_mech_fees\",\n",
151
- " \"total_earnings\",\n",
152
- " \"total_redeemed_amount\",\n",
153
- " \"total_net_earnings\",\n",
154
- " \"total_net_earnings_wo_mech_fees\",\n",
155
- " \"total_roi\",\n",
156
- " \"total_roi_wo_mech_fees\",\n",
157
- " \"mean_mech_calls_per_trade\",\n",
158
- " \"mean_mech_fee_amount_per_trade\",\n",
159
- "]\n",
160
- "headers = {\n",
161
- " \"Accept\": \"application/json, multipart/mixed\",\n",
162
- " \"Content-Type\": \"application/json\",\n",
163
- "}\n",
164
- "\n",
165
- "\n",
166
- "omen_xdai_trades_query = Template(\n",
167
- " \"\"\"\n",
168
- " {\n",
169
- " fpmmTrades(\n",
170
- " where: {\n",
171
- " type: Buy,\n",
172
- " fpmm_: {\n",
173
- " creator: \"${fpmm_creator}\"\n",
174
- " creationTimestamp_gte: \"${fpmm_creationTimestamp_gte}\",\n",
175
- " creationTimestamp_lt: \"${fpmm_creationTimestamp_lte}\"\n",
176
- " },\n",
177
- " creationTimestamp_gte: \"${creationTimestamp_gte}\",\n",
178
- " creationTimestamp_lte: \"${creationTimestamp_lte}\"\n",
179
- " id_gt: \"${id_gt}\"\n",
180
- " }\n",
181
- " first: ${first}\n",
182
- " orderBy: id\n",
183
- " orderDirection: asc\n",
184
- " ) {\n",
185
- " id\n",
186
- " title\n",
187
- " collateralToken\n",
188
- " outcomeTokenMarginalPrice\n",
189
- " oldOutcomeTokenMarginalPrice\n",
190
- " type\n",
191
- " creator {\n",
192
- " id\n",
193
- " }\n",
194
- " creationTimestamp\n",
195
- " collateralAmount\n",
196
- " collateralAmountUSD\n",
197
- " feeAmount\n",
198
- " outcomeIndex\n",
199
- " outcomeTokensTraded\n",
200
- " transactionHash\n",
201
- " fpmm {\n",
202
- " id\n",
203
- " outcomes\n",
204
- " title\n",
205
- " answerFinalizedTimestamp\n",
206
- " currentAnswer\n",
207
- " isPendingArbitration\n",
208
- " arbitrationOccurred\n",
209
- " openingTimestamp\n",
210
- " condition {\n",
211
- " id\n",
212
- " }\n",
213
- " }\n",
214
- " }\n",
215
- " }\n",
216
- " \"\"\"\n",
217
- ")\n",
218
- "\n",
219
- "\n",
220
- "conditional_tokens_gc_user_query = Template(\n",
221
- " \"\"\"\n",
222
- " {\n",
223
- " user(id: \"${id}\") {\n",
224
- " userPositions(\n",
225
- " first: ${first}\n",
226
- " where: {\n",
227
- " id_gt: \"${userPositions_id_gt}\"\n",
228
- " }\n",
229
- " orderBy: id\n",
230
- " ) {\n",
231
- " balance\n",
232
- " id\n",
233
- " position {\n",
234
- " id\n",
235
- " conditionIds\n",
236
- " }\n",
237
- " totalBalance\n",
238
- " wrappedBalance\n",
239
- " }\n",
240
- " }\n",
241
- " }\n",
242
- " \"\"\"\n",
243
- ")\n",
244
- "\n",
245
- "\n",
246
- "def _to_content(q: str) -> dict[str, Any]:\n",
247
- " \"\"\"Convert the given query string to payload content, i.e., add it under a `queries` key and convert it to bytes.\"\"\"\n",
248
- " finalized_query = {\n",
249
- " \"query\": q,\n",
250
- " \"variables\": None,\n",
251
- " \"extensions\": {\"headers\": None},\n",
252
- " }\n",
253
- " return finalized_query\n",
254
- "\n",
255
- "\n",
256
- "def _query_omen_xdai_subgraph(\n",
257
- " from_timestamp: float,\n",
258
- " to_timestamp: float,\n",
259
- " fpmm_from_timestamp: float,\n",
260
- " fpmm_to_timestamp: float,\n",
261
- ") -> dict[str, Any]:\n",
262
- " \"\"\"Query the subgraph.\"\"\"\n",
263
- " url = \"https://api.thegraph.com/subgraphs/name/protofire/omen-xdai\"\n",
264
- "\n",
265
- " grouped_results = defaultdict(list)\n",
266
- " id_gt = \"\"\n",
267
- "\n",
268
- " while True:\n",
269
- " query = omen_xdai_trades_query.substitute(\n",
270
- " fpmm_creator=FPMM_CREATOR.lower(),\n",
271
- " creationTimestamp_gte=int(from_timestamp),\n",
272
- " creationTimestamp_lte=int(to_timestamp),\n",
273
- " fpmm_creationTimestamp_gte=int(fpmm_from_timestamp),\n",
274
- " fpmm_creationTimestamp_lte=int(fpmm_to_timestamp),\n",
275
- " first=QUERY_BATCH_SIZE,\n",
276
- " id_gt=id_gt,\n",
277
- " )\n",
278
- " content_json = _to_content(query)\n",
279
- " res = requests.post(url, headers=headers, json=content_json)\n",
280
- " result_json = res.json()\n",
281
- " user_trades = result_json.get(\"data\", {}).get(\"fpmmTrades\", [])\n",
282
- "\n",
283
- " if not user_trades:\n",
284
- " break\n",
285
- "\n",
286
- " for trade in user_trades:\n",
287
- " fpmm_id = trade.get(\"fpmm\", {}).get(\"id\")\n",
288
- " grouped_results[fpmm_id].append(trade)\n",
289
- "\n",
290
- " id_gt = user_trades[len(user_trades) - 1][\"id\"]\n",
291
- "\n",
292
- " all_results = {\n",
293
- " \"data\": {\n",
294
- " \"fpmmTrades\": [\n",
295
- " trade\n",
296
- " for trades_list in grouped_results.values()\n",
297
- " for trade in trades_list\n",
298
- " ]\n",
299
- " }\n",
300
- " }\n",
301
- "\n",
302
- " return all_results\n",
303
- "\n",
304
- "\n",
305
- "def _query_conditional_tokens_gc_subgraph(creator: str) -> dict[str, Any]:\n",
306
- " \"\"\"Query the subgraph.\"\"\"\n",
307
- " url = \"https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc\"\n",
308
- "\n",
309
- " all_results: dict[str, Any] = {\"data\": {\"user\": {\"userPositions\": []}}}\n",
310
- " userPositions_id_gt = \"\"\n",
311
- " while True:\n",
312
- " query = conditional_tokens_gc_user_query.substitute(\n",
313
- " id=creator.lower(),\n",
314
- " first=QUERY_BATCH_SIZE,\n",
315
- " userPositions_id_gt=userPositions_id_gt,\n",
316
- " )\n",
317
- " content_json = {\"query\": query}\n",
318
- " res = requests.post(url, headers=headers, json=content_json)\n",
319
- " result_json = res.json()\n",
320
- " user_data = result_json.get(\"data\", {}).get(\"user\", {})\n",
321
- "\n",
322
- " if not user_data:\n",
323
- " break\n",
324
- "\n",
325
- " user_positions = user_data.get(\"userPositions\", [])\n",
326
- "\n",
327
- " if user_positions:\n",
328
- " all_results[\"data\"][\"user\"][\"userPositions\"].extend(user_positions)\n",
329
- " userPositions_id_gt = user_positions[len(user_positions) - 1][\"id\"]\n",
330
- " else:\n",
331
- " break\n",
332
- "\n",
333
- " if len(all_results[\"data\"][\"user\"][\"userPositions\"]) == 0:\n",
334
- " return {\"data\": {\"user\": None}}\n",
335
- "\n",
336
- " return all_results\n",
337
- "\n",
338
- "\n",
339
- "def convert_hex_to_int(x: Union[str, float]) -> Union[int, float]:\n",
340
- " \"\"\"Convert hex to int\"\"\"\n",
341
- " if isinstance(x, float):\n",
342
- " return np.nan\n",
343
- " elif isinstance(x, str):\n",
344
- " if x == INVALID_ANSWER_HEX:\n",
345
- " return -1\n",
346
- " else:\n",
347
- " return int(x, 16)\n",
348
- "\n",
349
- "\n",
350
- "def wei_to_unit(wei: int) -> float:\n",
351
- " \"\"\"Converts wei to currency unit.\"\"\"\n",
352
- " return wei / 10**18\n",
353
- "\n",
354
- "\n",
355
- "def _is_redeemed(user_json: dict[str, Any], fpmmTrade: dict[str, Any]) -> bool:\n",
356
- " \"\"\"Returns whether the user has redeemed the position.\"\"\"\n",
357
- " user_positions = user_json[\"data\"][\"user\"][\"userPositions\"]\n",
358
- " outcomes_tokens_traded = int(fpmmTrade[\"outcomeTokensTraded\"])\n",
359
- " condition_id = fpmmTrade[\"fpmm.condition.id\"]\n",
360
- "\n",
361
- " for position in user_positions:\n",
362
- " position_condition_ids = position[\"position\"][\"conditionIds\"]\n",
363
- " balance = int(position[\"balance\"])\n",
364
- "\n",
365
- " if condition_id in position_condition_ids:\n",
366
- " if balance == 0:\n",
367
- " return True\n",
368
- " # return early\n",
369
- " return False\n",
370
- " return False\n"
371
- ]
372
- },
373
- {
374
- "cell_type": "code",
375
- "execution_count": null,
376
- "metadata": {},
377
- "outputs": [],
378
- "source": [
379
- "def determine_market_status(trade, current_answer):\n",
380
- " \"\"\"Determine the market status of a trade.\"\"\"\n",
381
- " if current_answer is np.nan and time.time() >= int(trade[\"fpmm.openingTimestamp\"]):\n",
382
- " return MarketState.PENDING\n",
383
- " elif current_answer == np.nan:\n",
384
- " return MarketState.OPEN\n",
385
- " elif trade[\"fpmm.isPendingArbitration\"]:\n",
386
- " return MarketState.ARBITRATING\n",
387
- " elif time.time() < int(trade[\"fpmm.answerFinalizedTimestamp\"]):\n",
388
- " return MarketState.FINALIZING\n",
389
- " return MarketState.CLOSED"
390
- ]
391
- },
392
- {
393
- "cell_type": "code",
394
- "execution_count": null,
395
- "metadata": {},
396
- "outputs": [],
397
- "source": [
398
- "all_traders = []\n",
399
- "\n",
400
- "for trader_address in tqdm(\n",
401
- " fpmmTrades[\"trader_address\"].unique(),\n",
402
- " total=len(fpmmTrades[\"trader_address\"].unique()),\n",
403
- " desc=\"Analysing creators\"\n",
404
- "):\n",
405
- " trades = fpmmTrades[fpmmTrades[\"trader_address\"] == trader_address]\n",
406
- " tools_usage = tools[tools[\"trader_address\"].str.lower() == trader_address]\n",
407
- "\n",
408
- " # Prepare the DataFrame\n",
409
- " trades_df = pd.DataFrame(columns=ALL_TRADES_STATS_DF_COLS)\n",
410
- "\n",
411
- " if trades.empty:\n",
412
- " continue\n",
413
- "\n",
414
- " # Fetch user's conditional tokens gc graph\n",
415
- " try:\n",
416
- " user_json = _query_conditional_tokens_gc_subgraph(trader_address)\n",
417
- " except Exception as e:\n",
418
- " print(f\"Error fetching user data: {e}\")\n",
419
- " raise e\n",
420
- " \n",
421
- " break"
422
- ]
423
- },
424
- {
425
- "cell_type": "code",
426
- "execution_count": null,
427
- "metadata": {},
428
- "outputs": [],
429
- "source": [
430
- "for i, trade in tqdm(trades.iterrows(), total=len(trades), desc=\"Analysing trades\"):\n",
431
- " if not trade['fpmm.currentAnswer']:\n",
432
- " print(f\"Skipping trade {i} because currentAnswer is NaN\")\n",
433
- " continue\n",
434
- "\n",
435
- " creation_timestamp_utc = datetime.datetime.fromtimestamp(\n",
436
- " int(trade[\"creationTimestamp\"]), tz=datetime.timezone.utc\n",
437
- " )\n",
438
- " collateral_amount = wei_to_unit(float(trade[\"collateralAmount\"]))\n",
439
- " fee_amount = wei_to_unit(float(trade[\"feeAmount\"]))\n",
440
- " outcome_tokens_traded = wei_to_unit(float(trade[\"outcomeTokensTraded\"]))\n",
441
- " earnings, winner_trade = (0, False)\n",
442
- " redemption = _is_redeemed(user_json, trade)\n",
443
- " current_answer = trade[\"fpmm.currentAnswer\"]\n",
444
- " # Determine market status\n",
445
- " market_status = determine_market_status(trade, current_answer)\n",
446
- "\n",
447
- " # Skip non-closed markets\n",
448
- " if market_status != MarketState.CLOSED:\n",
449
- " print(\n",
450
- " f\"Skipping trade {i} because market is not closed. Market Status: {market_status}\"\n",
451
- " )\n",
452
- " continue\n",
453
- " current_answer = convert_hex_to_int(current_answer)\n",
454
- "\n",
455
- " # Compute invalidity\n",
456
- " is_invalid = current_answer == INVALID_ANSWER\n",
457
- "\n",
458
- " # Compute earnings and winner trade status\n",
459
- " if is_invalid:\n",
460
- " earnings = collateral_amount\n",
461
- " winner_trade = False\n",
462
- " elif int(trade[\"outcomeIndex\"]) == current_answer:\n",
463
- " earnings = outcome_tokens_traded\n",
464
- " winner_trade = True\n",
465
- "\n",
466
- " # Compute mech calls\n",
467
- " num_mech_calls = (\n",
468
- " tools_usage[\"prompt_request\"].apply(lambda x: trade[\"title\"] in x).sum()\n",
469
- " )\n",
470
- " net_earnings = (\n",
471
- " earnings\n",
472
- " - fee_amount\n",
473
- " - (num_mech_calls * DEFAULT_MECH_FEE)\n",
474
- " - collateral_amount\n",
475
- " )\n",
476
- "\n",
477
- " break"
478
- ]
479
- },
480
- {
481
- "cell_type": "code",
482
- "execution_count": null,
483
  "metadata": {},
484
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
485
  "source": [
486
- "# all_traders = []\n",
487
- "# for trader_address in tqdm(\n",
488
- "# fpmmTrades[\"trader_address\"].unique(),\n",
489
- "# total=len(fpmmTrades[\"trader_address\"].unique()),\n",
490
- "# desc=\"Analysing creators\",\n",
491
- "# ):\n",
492
- "\n",
493
- "# trades = fpmmTrades[fpmmTrades[\"trader_address\"] == trader_address]\n",
494
- "# tools_usage = tools[tools[\"trader_address\"] == trader_address]\n",
495
  "\n",
496
- "# # Prepare the DataFrame\n",
497
- "# trades_df = pd.DataFrame(columns=ALL_TRADES_STATS_DF_COLS)\n",
498
- "# if trades.empty:\n",
499
- "# continue\n",
500
  "\n",
501
- "# # Fetch user's conditional tokens gc graph\n",
502
- "# try:\n",
503
- "# user_json = _query_conditional_tokens_gc_subgraph(trader_address)\n",
504
- "# except Exception as e:\n",
505
- "# print(f\"Error fetching user data: {e}\")\n",
506
- "# raise e\n",
507
- "\n",
508
- "# # Iterate over the trades\n",
509
- "# for i, trade in tqdm(trades.iterrows(), total=len(trades), desc=\"Analysing trades\"):\n",
510
- "# try:\n",
511
- "# if not trade['fpmm.currentAnswer']:\n",
512
- "# print(f\"Skipping trade {i} because currentAnswer is NaN\")\n",
513
- "# continue\n",
514
- "# # Parsing and computing shared values\n",
515
- "# creation_timestamp_utc = datetime.datetime.fromtimestamp(\n",
516
- "# int(trade[\"creationTimestamp\"]), tz=datetime.timezone.utc\n",
517
- "# )\n",
518
- "# collateral_amount = wei_to_unit(float(trade[\"collateralAmount\"]))\n",
519
- "# fee_amount = wei_to_unit(float(trade[\"feeAmount\"]))\n",
520
- "# outcome_tokens_traded = wei_to_unit(float(trade[\"outcomeTokensTraded\"]))\n",
521
- "# earnings, winner_trade = (0, False)\n",
522
- "# redemption = _is_redeemed(user_json, trade)\n",
523
- "# current_answer = trade[\"fpmm.currentAnswer\"]\n",
524
- "# # Determine market status\n",
525
- "# market_status = determine_market_status(trade, current_answer)\n",
526
- "\n",
527
- "# # Skip non-closed markets\n",
528
- "# if market_status != MarketState.CLOSED:\n",
529
- "# print(\n",
530
- "# f\"Skipping trade {i} because market is not closed. Market Status: {market_status}\"\n",
531
- "# )\n",
532
- "# continue\n",
533
- "# current_answer = convert_hex_to_int(current_answer)\n",
534
- "\n",
535
- "# # Compute invalidity\n",
536
- "# is_invalid = current_answer == INVALID_ANSWER\n",
537
- "\n",
538
- "# # Compute earnings and winner trade status\n",
539
- "# if is_invalid:\n",
540
- "# earnings = collateral_amount\n",
541
- "# winner_trade = False\n",
542
- "# elif trade[\"outcomeIndex\"] == current_answer:\n",
543
- "# earnings = outcome_tokens_traded\n",
544
- "# winner_trade = True\n",
545
- "\n",
546
- "# # Compute mech calls\n",
547
- "# num_mech_calls = (\n",
548
- "# tools_usage[\"prompt_request\"].apply(lambda x: trade[\"title\"] in x).sum()\n",
549
- "# )\n",
550
- "# net_earnings = (\n",
551
- "# earnings\n",
552
- "# - fee_amount\n",
553
- "# - (num_mech_calls * DEFAULT_MECH_FEE)\n",
554
- "# - collateral_amount\n",
555
- "# )\n",
556
- "\n",
557
- "# # Assign values to DataFrame\n",
558
- "# trades_df.loc[i] = {\n",
559
- "# \"trader_address\": trader_address,\n",
560
- "# \"trade_id\": trade[\"id\"],\n",
561
- "# \"market_status\": market_status.name,\n",
562
- "# \"creation_timestamp\": creation_timestamp_utc,\n",
563
- "# \"title\": trade[\"title\"],\n",
564
- "# \"collateral_amount\": collateral_amount,\n",
565
- "# \"outcome_index\": trade[\"outcomeIndex\"],\n",
566
- "# \"trade_fee_amount\": fee_amount,\n",
567
- "# \"outcomes_tokens_traded\": outcome_tokens_traded,\n",
568
- "# \"current_answer\": current_answer,\n",
569
- "# \"is_invalid\": is_invalid,\n",
570
- "# \"winning_trade\": winner_trade,\n",
571
- "# \"earnings\": earnings,\n",
572
- "# \"redeemed\": redemption,\n",
573
- "# \"redeemed_amount\": earnings if redemption else 0,\n",
574
- "# \"num_mech_calls\": num_mech_calls,\n",
575
- "# \"mech_fee_amount\": num_mech_calls * DEFAULT_MECH_FEE,\n",
576
- "# \"net_earnings\": net_earnings,\n",
577
- "# \"roi\": net_earnings / (collateral_amount + fee_amount + num_mech_calls * DEFAULT_MECH_FEE),\n",
578
- "# }\n",
579
- "# except Exception as e:\n",
580
- "# print(f\"Error processing trade {i}: {e}\")\n",
581
- "# raise e"
582
  ]
583
  },
584
  {
585
  "cell_type": "code",
586
- "execution_count": 1,
587
- "metadata": {},
588
- "outputs": [],
589
- "source": [
590
- "import pandas as pd"
591
- ]
592
- },
593
- {
594
- "cell_type": "code",
595
- "execution_count": 2,
596
- "metadata": {},
597
- "outputs": [],
598
- "source": [
599
- "trades = pd.read_parquet('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/data/all_trades_profitability.parquet')\n",
600
- "tools = pd.read_parquet('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/data/tools.parquet')"
601
- ]
602
- },
603
- {
604
- "cell_type": "code",
605
- "execution_count": 3,
606
  "metadata": {},
607
  "outputs": [
608
  {
@@ -617,112 +68,13 @@
617
  " dtype='object')"
618
  ]
619
  },
620
- "execution_count": 3,
621
  "metadata": {},
622
  "output_type": "execute_result"
623
  }
624
  ],
625
  "source": [
626
- "trades.columns"
627
- ]
628
- },
629
- {
630
- "cell_type": "code",
631
- "execution_count": 4,
632
- "metadata": {},
633
- "outputs": [],
634
- "source": [
635
- "trades = pd.read_parquet('/Users/arshath/play/openautonomy/olas-prediction-live-dashboard/data/all_trades_profitability.parquet')\n",
636
- "trades['creation_timestamp'] = pd.to_datetime(trades['creation_timestamp'], unit='s')\n",
637
- "trades = trades[trades['creation_timestamp'].dt.year == 2024]\n",
638
- "trades_winning = trades.groupby(['title','winning_trade']).size().unstack().fillna(0)\n",
639
- "trades_winning_perc = trades_winning[True] / (trades_winning[True] + trades_winning[False])\n",
640
- "trades_winning_perc = trades_winning_perc.reset_index()\n",
641
- "trades_winning_perc.columns = ['title', 'winning_trade_perc']\n",
642
- "def bucket_winning_trade_perc(x):\n",
643
- " if x < 0.1:\n",
644
- " return 0.1\n",
645
- " elif x < 0.2:\n",
646
- " return 0.2\n",
647
- " elif x < 0.3:\n",
648
- " return 0.3\n",
649
- " elif x < 0.4:\n",
650
- " return 0.4\n",
651
- " elif x < 0.5:\n",
652
- " return 0.5\n",
653
- " elif x < 0.6:\n",
654
- " return 0.6\n",
655
- " elif x < 0.7:\n",
656
- " return 0.7\n",
657
- " elif x < 0.8:\n",
658
- " return 0.8\n",
659
- " elif x < 0.9:\n",
660
- " return 0.9\n",
661
- " else:\n",
662
- " return 1\n",
663
- "\n",
664
- "trades_winning_perc['winning_trade_perc_bucket'] = trades_winning_perc['winning_trade_perc'].apply(bucket_winning_trade_perc)\n",
665
- "trades_winning_perc['winning_trade_perc_bucket'].plot(kind='hist', bins=10)"
666
- ]
667
- },
668
- {
669
- "cell_type": "code",
670
- "execution_count": 8,
671
- "metadata": {},
672
- "outputs": [],
673
- "source": []
674
- },
675
- {
676
- "cell_type": "code",
677
- "execution_count": 13,
678
- "metadata": {},
679
- "outputs": [],
680
- "source": []
681
- },
682
- {
683
- "cell_type": "code",
684
- "execution_count": 16,
685
- "metadata": {},
686
- "outputs": [],
687
- "source": [
688
- "\n"
689
- ]
690
- },
691
- {
692
- "cell_type": "code",
693
- "execution_count": 20,
694
- "metadata": {},
695
- "outputs": [],
696
- "source": []
697
- },
698
- {
699
- "cell_type": "code",
700
- "execution_count": 21,
701
- "metadata": {},
702
- "outputs": [
703
- {
704
- "data": {
705
- "text/plain": [
706
- "<Axes: ylabel='Frequency'>"
707
- ]
708
- },
709
- "execution_count": 21,
710
- "metadata": {},
711
- "output_type": "execute_result"
712
- },
713
- {
714
- "data": {
715
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAGdCAYAAAD0e7I1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAkx0lEQVR4nO3de3BU9f3/8deGsAvBXAiYbFIidxQEZASNEbAiGQJhKAgzFUEMNoWqiVUiKnhDxRJERdQitBYTmIIoLaICRiHcSg1eIoiCIlcjTTagSDaELyGX8/vDHzuuXCSbTXb58HzM7Iznsmff21ObZ8+eTWyWZVkCAAAwVEigBwAAAGhIxA4AADAasQMAAIxG7AAAAKMROwAAwGjEDgAAMBqxAwAAjEbsAAAAo4UGeoBgUFtbq+LiYoWHh8tmswV6HAAAcB4sy1J5ebni4+MVEnL26zfEjqTi4mIlJCQEegwAAOCD7777Tm3atDnrdmJHUnh4uKSf/sOKiIgI8DQAAOB8uN1uJSQkeH6Onw2xI3k+uoqIiCB2AAC4wPzaLSjcoAwAAIxG7AAAAKMROwAAwGjEDgAAMBqxAwAAjEbsAAAAoxE7AADAaMQOAAAwGrEDAACMRuwAAACjETsAAMBoxA4AADAasQMAAIxG7AAAAKOFBnoAAGho7aasCvQIdXZg5tBAjwAYgys7AADAaMQOAAAwGrEDAACMRuwAAACjETsAAMBoxA4AADAasQMAAIxG7AAAAKMROwAAwGjED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+Oxxx7TuHHj9Mc//lGS1KNHD1VUVGjixIl65JFHFBLC/+9vTE6n84znLyIiokGu6khc2bno2e129e7dW/n5+Z51tbW1ys/PV1JS0lmfN2vWLE2fPl15eXnq06dPY4x6Uajr+bjiiiv0xRdfaNu2bZ7H7373Ow0YMEDbtm1TQkJCY45vJF/+Henbt6/27NnjCU9J+uabbxQXF0fo1JMv5+P48eOnBc2pELX485CNLikpyev8SdKaNWvO+TOn3hrs1mdcMJYuXWo5HA4rNzfX2rlzpzVx4kQrKirKcrlclmVZ1rhx46wpU6Z49p85c6Zlt9utf/3rX1ZJSYnnUV5eHqi3YJS6no9f4ttY/lfXc1JUVGSFh4dbmZmZ1q5du6yVK1daMTEx1tNPPx2ot2CUup6PadOmWeHh4dbrr79u7du3z/rggw+sjh07Wr///e8D9RaMUl5ebm3dutXaunWrJcmaPXu2tXXrVuvbb7+1LMuypkyZYo0bN86z/6mvnj/wwAPWV199Zc2dO5evnqNxvPzyy9Zll11m2e1269prr7W2bNni2fbb3/7WSktL8yy3bdvWknTaY9q0aY0/uKHqcj5+idhpGHU9Jx9++KGVmJhoORwOq0OHDtZf/vIXq7q6upGnNlddzkdVVZX1xBNPWB07drSaNWtmJSQkWHfffbf1448/Nv7gBlq/fv0ZfyacOgdpaWnWb3/729Oe06tXL8tut1sdOnSwcnJyGnRGm2VxDQ8AAJiLe3YAAIDRiB0AAGA0YgcAABiN2AEAAEYjdgAAgNGIHQAAYDRiBwAAGI3YAQAARiN2AACA0YgdAABgNGIHAAAYjdgBAABG+39CA9s9W3ZlvQAAAABJRU5ErkJggg==",
716
- "text/plain": [
717
- "<Figure size 640x480 with 1 Axes>"
718
- ]
719
- },
720
- "metadata": {},
721
- "output_type": "display_data"
722
- }
723
- ],
724
- "source": [
725
- "\n"
726
  ]
727
  },
728
  {
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 2,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
25
  },
26
  {
27
  "cell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crashed while executing code in the current cell or a previous cell. \n",
37
+ "\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
38
+ "\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
39
+ "\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
40
+ ]
41
+ }
42
+ ],
43
  "source": [
44
+ "tools_df = pd.read_parquet(\"./data/tools.parquet\")\n",
45
+ "trades_df = pd.read_parquet(\"./data/all_trades_profitability.parquet\")\n",
 
 
 
 
 
 
 
46
  "\n",
47
+ "tools_df['request_time'] = pd.to_datetime(tools_df['request_time'])\n",
48
+ "tools_df = tools_df[tools_df['request_time'].dt.year == 2024]\n",
 
 
49
  "\n",
50
+ "trades_df['creation_timestamp'] = pd.to_datetime(trades_df['creation_timestamp'])\n",
51
+ "trades_df = trades_df[trades_df['creation_timestamp'].dt.year == 2024]"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  ]
53
  },
54
  {
55
  "cell_type": "code",
56
+ "execution_count": 5,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  "metadata": {},
58
  "outputs": [
59
  {
 
68
  " dtype='object')"
69
  ]
70
  },
71
+ "execution_count": 5,
72
  "metadata": {},
73
  "output_type": "execute_result"
74
  }
75
  ],
76
  "source": [
77
+ "trades_df.columns\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  ]
79
  },
80
  {