cyberosa
commited on
Commit
·
f95e119
1
Parent(s):
46e0c31
updating daily info
Browse files- data/unknown_daily_traders.parquet +2 -2
- data/unknown_traders.parquet +2 -2
- notebooks/num_mech_calls.ipynb +66 -66
- scripts/metrics.py +6 -0
- scripts/num_mech_calls.py +11 -5
- scripts/utils.py +15 -0
data/unknown_daily_traders.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5228e7344adf08237bff1159c387f6435c0116e07378adf6981d5326750f9a1e
|
3 |
+
size 42386
|
data/unknown_traders.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3620eaba76778060f41059fb2b6ff6e92a6000eedfd9a9119b703f84cdda11ff
|
3 |
+
size 194084
|
notebooks/num_mech_calls.ipynb
CHANGED
@@ -114,38 +114,38 @@
|
|
114 |
" <tbody>\n",
|
115 |
" <tr>\n",
|
116 |
" <th>0</th>\n",
|
117 |
-
" <td>
|
118 |
-
" <td>
|
119 |
-
" <td>
|
120 |
-
" <td>
|
121 |
" </tr>\n",
|
122 |
" <tr>\n",
|
123 |
" <th>1</th>\n",
|
124 |
-
" <td>
|
125 |
-
" <td>
|
126 |
-
" <td>
|
127 |
-
" <td>
|
128 |
" </tr>\n",
|
129 |
" <tr>\n",
|
130 |
" <th>2</th>\n",
|
131 |
-
" <td>
|
132 |
-
" <td>
|
133 |
-
" <td>
|
134 |
-
" <td>
|
135 |
" </tr>\n",
|
136 |
" <tr>\n",
|
137 |
" <th>3</th>\n",
|
138 |
-
" <td>
|
139 |
-
" <td>
|
140 |
-
" <td>
|
141 |
-
" <td>
|
142 |
" </tr>\n",
|
143 |
" <tr>\n",
|
144 |
" <th>4</th>\n",
|
145 |
-
" <td>
|
146 |
-
" <td>
|
147 |
-
" <td>
|
148 |
-
" <td>
|
149 |
" </tr>\n",
|
150 |
" </tbody>\n",
|
151 |
"</table>\n",
|
@@ -153,18 +153,18 @@
|
|
153 |
],
|
154 |
"text/plain": [
|
155 |
" trader_address month_year_week total_trades \\\n",
|
156 |
-
"0
|
157 |
-
"1
|
158 |
-
"2
|
159 |
-
"3
|
160 |
-
"4
|
161 |
"\n",
|
162 |
" total_mech_calls \n",
|
163 |
-
"0
|
164 |
-
"1
|
165 |
-
"2
|
166 |
-
"3
|
167 |
-
"4
|
168 |
]
|
169 |
},
|
170 |
"execution_count": 4,
|
@@ -210,58 +210,58 @@
|
|
210 |
" </thead>\n",
|
211 |
" <tbody>\n",
|
212 |
" <tr>\n",
|
213 |
-
" <th>
|
214 |
-
" <td>
|
215 |
-
" <td>Nov-24</td>\n",
|
216 |
-
" <td>0</td>\n",
|
217 |
-
" <td>0</td>\n",
|
218 |
-
" </tr>\n",
|
219 |
-
" <tr>\n",
|
220 |
-
" <th>14364</th>\n",
|
221 |
-
" <td>0xf278dfdb02ecddc1214a151906426b9171460ec8</td>\n",
|
222 |
" <td>Dec-01</td>\n",
|
223 |
" <td>0</td>\n",
|
224 |
" <td>0</td>\n",
|
225 |
" </tr>\n",
|
226 |
" <tr>\n",
|
227 |
-
" <th>
|
228 |
-
" <td>
|
229 |
" <td>Dec-08</td>\n",
|
230 |
" <td>0</td>\n",
|
231 |
" <td>0</td>\n",
|
232 |
" </tr>\n",
|
233 |
" <tr>\n",
|
234 |
-
" <th>
|
235 |
-
" <td>
|
236 |
" <td>Dec-15</td>\n",
|
237 |
" <td>0</td>\n",
|
238 |
" <td>0</td>\n",
|
239 |
" </tr>\n",
|
240 |
" <tr>\n",
|
241 |
-
" <th>
|
242 |
-
" <td>
|
243 |
" <td>Dec-22</td>\n",
|
244 |
-
" <td>1</td>\n",
|
245 |
" <td>0</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
" </tr>\n",
|
247 |
" </tbody>\n",
|
248 |
"</table>\n",
|
249 |
"</div>"
|
250 |
],
|
251 |
"text/plain": [
|
252 |
-
"
|
253 |
-
"
|
254 |
-
"
|
255 |
-
"
|
256 |
-
"
|
257 |
-
"
|
258 |
"\n",
|
259 |
-
"
|
260 |
-
"
|
261 |
-
"
|
262 |
-
"
|
263 |
-
"
|
264 |
-
"
|
265 |
]
|
266 |
},
|
267 |
"execution_count": 5,
|
@@ -281,14 +281,14 @@
|
|
281 |
{
|
282 |
"data": {
|
283 |
"text/plain": [
|
284 |
-
"count
|
285 |
-
"mean
|
286 |
-
"std
|
287 |
-
"min
|
288 |
-
"25%
|
289 |
-
"50%
|
290 |
-
"75%
|
291 |
-
"max
|
292 |
"Name: total_mech_calls, dtype: float64"
|
293 |
]
|
294 |
},
|
|
|
114 |
" <tbody>\n",
|
115 |
" <tr>\n",
|
116 |
" <th>0</th>\n",
|
117 |
+
" <td>0x358e58683e54b2b1b0536727df52a001df5acdf8</td>\n",
|
118 |
+
" <td>Nov-03</td>\n",
|
119 |
+
" <td>3</td>\n",
|
120 |
+
" <td>45</td>\n",
|
121 |
" </tr>\n",
|
122 |
" <tr>\n",
|
123 |
" <th>1</th>\n",
|
124 |
+
" <td>0x358e58683e54b2b1b0536727df52a001df5acdf8</td>\n",
|
125 |
+
" <td>Nov-10</td>\n",
|
126 |
+
" <td>10</td>\n",
|
127 |
+
" <td>33</td>\n",
|
128 |
" </tr>\n",
|
129 |
" <tr>\n",
|
130 |
" <th>2</th>\n",
|
131 |
+
" <td>0x358e58683e54b2b1b0536727df52a001df5acdf8</td>\n",
|
132 |
+
" <td>Nov-17</td>\n",
|
133 |
+
" <td>10</td>\n",
|
134 |
+
" <td>22</td>\n",
|
135 |
" </tr>\n",
|
136 |
" <tr>\n",
|
137 |
" <th>3</th>\n",
|
138 |
+
" <td>0x358e58683e54b2b1b0536727df52a001df5acdf8</td>\n",
|
139 |
+
" <td>Nov-24</td>\n",
|
140 |
+
" <td>35</td>\n",
|
141 |
+
" <td>40</td>\n",
|
142 |
" </tr>\n",
|
143 |
" <tr>\n",
|
144 |
" <th>4</th>\n",
|
145 |
+
" <td>0x358e58683e54b2b1b0536727df52a001df5acdf8</td>\n",
|
146 |
+
" <td>Dec-01</td>\n",
|
147 |
+
" <td>6</td>\n",
|
148 |
+
" <td>11</td>\n",
|
149 |
" </tr>\n",
|
150 |
" </tbody>\n",
|
151 |
"</table>\n",
|
|
|
153 |
],
|
154 |
"text/plain": [
|
155 |
" trader_address month_year_week total_trades \\\n",
|
156 |
+
"0 0x358e58683e54b2b1b0536727df52a001df5acdf8 Nov-03 3 \n",
|
157 |
+
"1 0x358e58683e54b2b1b0536727df52a001df5acdf8 Nov-10 10 \n",
|
158 |
+
"2 0x358e58683e54b2b1b0536727df52a001df5acdf8 Nov-17 10 \n",
|
159 |
+
"3 0x358e58683e54b2b1b0536727df52a001df5acdf8 Nov-24 35 \n",
|
160 |
+
"4 0x358e58683e54b2b1b0536727df52a001df5acdf8 Dec-01 6 \n",
|
161 |
"\n",
|
162 |
" total_mech_calls \n",
|
163 |
+
"0 45 \n",
|
164 |
+
"1 33 \n",
|
165 |
+
"2 22 \n",
|
166 |
+
"3 40 \n",
|
167 |
+
"4 11 "
|
168 |
]
|
169 |
},
|
170 |
"execution_count": 4,
|
|
|
210 |
" </thead>\n",
|
211 |
" <tbody>\n",
|
212 |
" <tr>\n",
|
213 |
+
" <th>7573</th>\n",
|
214 |
+
" <td>0x5992ba3c19482e899521a0422132895d97a12f0c</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
" <td>Dec-01</td>\n",
|
216 |
" <td>0</td>\n",
|
217 |
" <td>0</td>\n",
|
218 |
" </tr>\n",
|
219 |
" <tr>\n",
|
220 |
+
" <th>7574</th>\n",
|
221 |
+
" <td>0x5992ba3c19482e899521a0422132895d97a12f0c</td>\n",
|
222 |
" <td>Dec-08</td>\n",
|
223 |
" <td>0</td>\n",
|
224 |
" <td>0</td>\n",
|
225 |
" </tr>\n",
|
226 |
" <tr>\n",
|
227 |
+
" <th>7575</th>\n",
|
228 |
+
" <td>0x5992ba3c19482e899521a0422132895d97a12f0c</td>\n",
|
229 |
" <td>Dec-15</td>\n",
|
230 |
" <td>0</td>\n",
|
231 |
" <td>0</td>\n",
|
232 |
" </tr>\n",
|
233 |
" <tr>\n",
|
234 |
+
" <th>7576</th>\n",
|
235 |
+
" <td>0x5992ba3c19482e899521a0422132895d97a12f0c</td>\n",
|
236 |
" <td>Dec-22</td>\n",
|
|
|
237 |
" <td>0</td>\n",
|
238 |
+
" <td>0</td>\n",
|
239 |
+
" </tr>\n",
|
240 |
+
" <tr>\n",
|
241 |
+
" <th>7577</th>\n",
|
242 |
+
" <td>0x5992ba3c19482e899521a0422132895d97a12f0c</td>\n",
|
243 |
+
" <td>Dec-29</td>\n",
|
244 |
+
" <td>1</td>\n",
|
245 |
+
" <td>21</td>\n",
|
246 |
" </tr>\n",
|
247 |
" </tbody>\n",
|
248 |
"</table>\n",
|
249 |
"</div>"
|
250 |
],
|
251 |
"text/plain": [
|
252 |
+
" trader_address month_year_week \\\n",
|
253 |
+
"7573 0x5992ba3c19482e899521a0422132895d97a12f0c Dec-01 \n",
|
254 |
+
"7574 0x5992ba3c19482e899521a0422132895d97a12f0c Dec-08 \n",
|
255 |
+
"7575 0x5992ba3c19482e899521a0422132895d97a12f0c Dec-15 \n",
|
256 |
+
"7576 0x5992ba3c19482e899521a0422132895d97a12f0c Dec-22 \n",
|
257 |
+
"7577 0x5992ba3c19482e899521a0422132895d97a12f0c Dec-29 \n",
|
258 |
"\n",
|
259 |
+
" total_trades total_mech_calls \n",
|
260 |
+
"7573 0 0 \n",
|
261 |
+
"7574 0 0 \n",
|
262 |
+
"7575 0 0 \n",
|
263 |
+
"7576 0 0 \n",
|
264 |
+
"7577 1 21 "
|
265 |
]
|
266 |
},
|
267 |
"execution_count": 5,
|
|
|
281 |
{
|
282 |
"data": {
|
283 |
"text/plain": [
|
284 |
+
"count 7578.000000\n",
|
285 |
+
"mean 106.832014\n",
|
286 |
+
"std 157.655569\n",
|
287 |
+
"min 0.000000\n",
|
288 |
+
"25% 0.000000\n",
|
289 |
+
"50% 12.000000\n",
|
290 |
+
"75% 244.000000\n",
|
291 |
+
"max 795.000000\n",
|
292 |
"Name: total_mech_calls, dtype: float64"
|
293 |
]
|
294 |
},
|
scripts/metrics.py
CHANGED
@@ -3,6 +3,7 @@ from tqdm import tqdm
|
|
3 |
from scripts.num_mech_calls import (
|
4 |
get_weekly_total_mech_calls,
|
5 |
)
|
|
|
6 |
|
7 |
DEFAULT_MECH_FEE = 0.01 # xDAI
|
8 |
|
@@ -183,7 +184,12 @@ def compute_weekly_metrics_by_market_creator(
|
|
183 |
and with different categories by market creator"""
|
184 |
contents = []
|
185 |
all_weeks = list(traders_data.month_year_week.unique())
|
|
|
|
|
186 |
for week in all_weeks:
|
|
|
|
|
|
|
187 |
weekly_data = traders_data.loc[traders_data["month_year_week"] == week]
|
188 |
print(f"Computing weekly metrics for week ={week} by market creator")
|
189 |
# traverse each trader
|
|
|
3 |
from scripts.num_mech_calls import (
|
4 |
get_weekly_total_mech_calls,
|
5 |
)
|
6 |
+
from scripts.utils import get_next_week
|
7 |
|
8 |
DEFAULT_MECH_FEE = 0.01 # xDAI
|
9 |
|
|
|
184 |
and with different categories by market creator"""
|
185 |
contents = []
|
186 |
all_weeks = list(traders_data.month_year_week.unique())
|
187 |
+
next_week = get_next_week()
|
188 |
+
print(f"next week = {next_week}")
|
189 |
for week in all_weeks:
|
190 |
+
# skip the next week since data is not complete
|
191 |
+
if week == next_week:
|
192 |
+
continue
|
193 |
weekly_data = traders_data.loc[traders_data["month_year_week"] == week]
|
194 |
print(f"Computing weekly metrics for week ={week} by market creator")
|
195 |
# traverse each trader
|
scripts/num_mech_calls.py
CHANGED
@@ -26,11 +26,17 @@ def get_weekly_total_mech_calls(trader_data: pd.DataFrame) -> int:
|
|
26 |
if len(trading_weeks) > 1:
|
27 |
raise ValueError("The trader data should contain only one week information")
|
28 |
trading_week = trading_weeks[0]
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
def compute_weekly_total_mech_calls(
|
|
|
26 |
if len(trading_weeks) > 1:
|
27 |
raise ValueError("The trader data should contain only one week information")
|
28 |
trading_week = trading_weeks[0]
|
29 |
+
try:
|
30 |
+
return all_mech_calls_df.loc[
|
31 |
+
(all_mech_calls_df["trader_address"] == trader_address)
|
32 |
+
& (all_mech_calls_df["month_year_week"] == trading_week),
|
33 |
+
"total_mech_calls",
|
34 |
+
].iloc[0]
|
35 |
+
except Exception as e:
|
36 |
+
print(
|
37 |
+
f"Error getting the number of mech calls for the trader {trader_address} and week {trading_week}"
|
38 |
+
)
|
39 |
+
return 280 # average number 40 mech calls in 7 days
|
40 |
|
41 |
|
42 |
def compute_weekly_total_mech_calls(
|
scripts/utils.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import pandas as pd
|
2 |
from pathlib import Path
|
|
|
3 |
|
4 |
SCRIPTS_DIR = Path(__file__).parent
|
5 |
ROOT_DIR = SCRIPTS_DIR.parent
|
@@ -14,3 +15,17 @@ def get_traders_family(row: pd.DataFrame) -> str:
|
|
14 |
return "pearl_agent"
|
15 |
# quickstart
|
16 |
return "quickstart_agent"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import pandas as pd
|
2 |
from pathlib import Path
|
3 |
+
from datetime import datetime, timedelta
|
4 |
|
5 |
SCRIPTS_DIR = Path(__file__).parent
|
6 |
ROOT_DIR = SCRIPTS_DIR.parent
|
|
|
15 |
return "pearl_agent"
|
16 |
# quickstart
|
17 |
return "quickstart_agent"
|
18 |
+
|
19 |
+
|
20 |
+
def get_current_week():
|
21 |
+
current_date = datetime.now()
|
22 |
+
|
23 |
+
# Get the start and end dates of the current week (starting on Sunday)
|
24 |
+
current_week_start = current_date - timedelta(days=current_date.weekday() + 1)
|
25 |
+
return current_week_start.strftime("%b-%d")
|
26 |
+
|
27 |
+
|
28 |
+
def get_next_week():
|
29 |
+
current_date = datetime.now()
|
30 |
+
next_week_start = current_date + timedelta(days=7 - (current_date.weekday() + 1))
|
31 |
+
return next_week_start.strftime("%b-%d")
|