cyberosa
commited on
Commit
Β·
3d497f3
1
Parent(s):
1c9dfec
Adding better description and same y axis for retention graphs
Browse files- app.py +11 -0
- notebooks/closed_markets.ipynb +6 -2
- notebooks/retention_metrics.ipynb +580 -40
- notebooks/unknown_traders.ipynb +556 -8
- scripts/retention_metrics.py +20 -8
app.py
CHANGED
@@ -427,6 +427,7 @@ with demo:
|
|
427 |
with gr.Row():
|
428 |
gr.Markdown(
|
429 |
"""
|
|
|
430 |
- Olas trader: agent using Mech, with a service ID and the corresponding safe in the registry
|
431 |
- Non-Olas trader: agent using Mech, with no service ID
|
432 |
- Unclassified trader: agent (safe/EOAs) not using Mechs
|
@@ -457,6 +458,16 @@ with demo:
|
|
457 |
gr.Markdown(
|
458 |
"The Cohort groups are organized by cohort weeks. A trader is part of a cohort group/week where it was detected the FIRST activity ever of that trader."
|
459 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
with gr.Row():
|
461 |
with gr.Column(scale=1):
|
462 |
gr.Markdown("## Cohort retention of π Olas traders")
|
|
|
427 |
with gr.Row():
|
428 |
gr.Markdown(
|
429 |
"""
|
430 |
+
Activity based on mech interactions for Olas and non_Olas traders and based on trading acitivity for the unclassified ones.
|
431 |
- Olas trader: agent using Mech, with a service ID and the corresponding safe in the registry
|
432 |
- Non-Olas trader: agent using Mech, with no service ID
|
433 |
- Unclassified trader: agent (safe/EOAs) not using Mechs
|
|
|
458 |
gr.Markdown(
|
459 |
"The Cohort groups are organized by cohort weeks. A trader is part of a cohort group/week where it was detected the FIRST activity ever of that trader."
|
460 |
)
|
461 |
+
with gr.Row():
|
462 |
+
gr.Markdown(
|
463 |
+
"""
|
464 |
+
Week 0 for a cohort group is the same cohort week of the FIRST detected activity ever of that trader.
|
465 |
+
Only two values are possible for this Week 0:
|
466 |
+
|
467 |
+
1. 100% if the cohort size is > 0, meaning all traders active that first cohort week
|
468 |
+
2. 0% if the cohort size = 0, meaning no totally new traders started activity that cohort week.
|
469 |
+
"""
|
470 |
+
)
|
471 |
with gr.Row():
|
472 |
with gr.Column(scale=1):
|
473 |
gr.Markdown("## Cohort retention of π Olas traders")
|
notebooks/closed_markets.ipynb
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
},
|
12 |
{
|
13 |
"cell_type": "code",
|
14 |
-
"execution_count":
|
15 |
"metadata": {},
|
16 |
"outputs": [
|
17 |
{
|
@@ -354,7 +354,11 @@
|
|
354 |
"execution_count": null,
|
355 |
"metadata": {},
|
356 |
"outputs": [],
|
357 |
-
"source": [
|
|
|
|
|
|
|
|
|
358 |
},
|
359 |
{
|
360 |
"cell_type": "code",
|
|
|
11 |
},
|
12 |
{
|
13 |
"cell_type": "code",
|
14 |
+
"execution_count": 1,
|
15 |
"metadata": {},
|
16 |
"outputs": [
|
17 |
{
|
|
|
354 |
"execution_count": null,
|
355 |
"metadata": {},
|
356 |
"outputs": [],
|
357 |
+
"source": [
|
358 |
+
"filtered_traders[\"month_year_week\"] =(\n",
|
359 |
+
" pd.to_datetime(filtered_traders[\"creation_timestamp\"]).dt.to_period(\"W\").dt.strftime(\"%b-%d-%Y\")\n",
|
360 |
+
")"
|
361 |
+
]
|
362 |
},
|
363 |
{
|
364 |
"cell_type": "code",
|
notebooks/retention_metrics.ipynb
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
},
|
22 |
{
|
23 |
"cell_type": "code",
|
24 |
-
"execution_count":
|
25 |
"metadata": {},
|
26 |
"outputs": [],
|
27 |
"source": [
|
@@ -50,7 +50,7 @@
|
|
50 |
},
|
51 |
{
|
52 |
"cell_type": "code",
|
53 |
-
"execution_count":
|
54 |
"metadata": {},
|
55 |
"outputs": [
|
56 |
{
|
@@ -61,7 +61,7 @@
|
|
61 |
" dtype='object')"
|
62 |
]
|
63 |
},
|
64 |
-
"execution_count":
|
65 |
"metadata": {},
|
66 |
"output_type": "execute_result"
|
67 |
}
|
@@ -72,27 +72,27 @@
|
|
72 |
},
|
73 |
{
|
74 |
"cell_type": "code",
|
75 |
-
"execution_count":
|
76 |
"metadata": {},
|
77 |
"outputs": [
|
78 |
{
|
79 |
"data": {
|
80 |
"text/plain": [
|
81 |
"month_year_week\n",
|
82 |
-
"Jan-
|
83 |
-
"Dec-
|
84 |
-
"Dec-
|
85 |
-
"
|
86 |
-
"Dec-
|
87 |
-
"Dec-
|
88 |
-
"Nov-
|
89 |
-
"
|
90 |
-
"Jan-
|
91 |
-
"Nov-
|
92 |
"Name: count, dtype: int64"
|
93 |
]
|
94 |
},
|
95 |
-
"execution_count":
|
96 |
"metadata": {},
|
97 |
"output_type": "execute_result"
|
98 |
}
|
@@ -103,55 +103,303 @@
|
|
103 |
},
|
104 |
{
|
105 |
"cell_type": "code",
|
106 |
-
"execution_count":
|
107 |
"metadata": {},
|
108 |
"outputs": [
|
109 |
{
|
110 |
"data": {
|
111 |
"text/plain": [
|
112 |
-
"
|
113 |
-
"Jan-14-2025 30424\n",
|
114 |
-
"Jan-01-2025 28494\n",
|
115 |
-
"Jan-07-2025 28200\n",
|
116 |
-
"Jan-11-2025 26174\n",
|
117 |
-
"Jan-09-2025 22810\n",
|
118 |
-
" ... \n",
|
119 |
-
"Nov-14-2024 8757\n",
|
120 |
-
"Nov-25-2024 8112\n",
|
121 |
-
"Nov-15-2024 7658\n",
|
122 |
-
"Nov-17-2024 4967\n",
|
123 |
-
"Jan-15-2025 3728\n",
|
124 |
-
"Name: count, Length: 63, dtype: int64"
|
125 |
]
|
126 |
},
|
127 |
-
"execution_count":
|
128 |
"metadata": {},
|
129 |
"output_type": "execute_result"
|
130 |
}
|
131 |
],
|
132 |
"source": [
|
133 |
-
"retention_df.month_year_week
|
|
|
134 |
]
|
135 |
},
|
136 |
{
|
137 |
"cell_type": "code",
|
138 |
-
"execution_count":
|
139 |
"metadata": {},
|
140 |
"outputs": [
|
141 |
{
|
142 |
"data": {
|
143 |
"text/plain": [
|
144 |
-
"
|
|
|
|
|
|
|
|
|
|
|
145 |
]
|
146 |
},
|
147 |
-
"execution_count":
|
148 |
"metadata": {},
|
149 |
"output_type": "execute_result"
|
150 |
}
|
151 |
],
|
152 |
"source": [
|
153 |
-
"
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
]
|
156 |
},
|
157 |
{
|
@@ -5686,17 +5934,309 @@
|
|
5686 |
},
|
5687 |
{
|
5688 |
"cell_type": "code",
|
5689 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5690 |
"metadata": {},
|
5691 |
"outputs": [],
|
5692 |
-
"source": [
|
|
|
|
|
|
|
5693 |
},
|
5694 |
{
|
5695 |
"cell_type": "code",
|
5696 |
-
"execution_count":
|
5697 |
"metadata": {},
|
5698 |
"outputs": [],
|
5699 |
-
"source": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5700 |
},
|
5701 |
{
|
5702 |
"cell_type": "code",
|
|
|
21 |
},
|
22 |
{
|
23 |
"cell_type": "code",
|
24 |
+
"execution_count": 230,
|
25 |
"metadata": {},
|
26 |
"outputs": [],
|
27 |
"source": [
|
|
|
50 |
},
|
51 |
{
|
52 |
"cell_type": "code",
|
53 |
+
"execution_count": 231,
|
54 |
"metadata": {},
|
55 |
"outputs": [
|
56 |
{
|
|
|
61 |
" dtype='object')"
|
62 |
]
|
63 |
},
|
64 |
+
"execution_count": 231,
|
65 |
"metadata": {},
|
66 |
"output_type": "execute_result"
|
67 |
}
|
|
|
72 |
},
|
73 |
{
|
74 |
"cell_type": "code",
|
75 |
+
"execution_count": 232,
|
76 |
"metadata": {},
|
77 |
"outputs": [
|
78 |
{
|
79 |
"data": {
|
80 |
"text/plain": [
|
81 |
"month_year_week\n",
|
82 |
+
"Jan-06-2025 148192\n",
|
83 |
+
"Dec-09-2024 136640\n",
|
84 |
+
"Dec-16-2024 136529\n",
|
85 |
+
"Dec-30-2024 136190\n",
|
86 |
+
"Dec-23-2024 128665\n",
|
87 |
+
"Dec-02-2024 109545\n",
|
88 |
+
"Nov-18-2024 72777\n",
|
89 |
+
"Nov-25-2024 67851\n",
|
90 |
+
"Jan-13-2025 53165\n",
|
91 |
+
"Nov-11-2024 31089\n",
|
92 |
"Name: count, dtype: int64"
|
93 |
]
|
94 |
},
|
95 |
+
"execution_count": 232,
|
96 |
"metadata": {},
|
97 |
"output_type": "execute_result"
|
98 |
}
|
|
|
103 |
},
|
104 |
{
|
105 |
"cell_type": "code",
|
106 |
+
"execution_count": 233,
|
107 |
"metadata": {},
|
108 |
"outputs": [
|
109 |
{
|
110 |
"data": {
|
111 |
"text/plain": [
|
112 |
+
"148192"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
]
|
114 |
},
|
115 |
+
"execution_count": 233,
|
116 |
"metadata": {},
|
117 |
"output_type": "execute_result"
|
118 |
}
|
119 |
],
|
120 |
"source": [
|
121 |
+
"jan6 = retention_df.loc[retention_df[\"month_year_week\"]==\"Jan-06-2025\"]\n",
|
122 |
+
"len(jan6)"
|
123 |
]
|
124 |
},
|
125 |
{
|
126 |
"cell_type": "code",
|
127 |
+
"execution_count": 234,
|
128 |
"metadata": {},
|
129 |
"outputs": [
|
130 |
{
|
131 |
"data": {
|
132 |
"text/plain": [
|
133 |
+
"staking\n",
|
134 |
+
"non_Olas 112597\n",
|
135 |
+
"non_staking 23586\n",
|
136 |
+
"pearl 7657\n",
|
137 |
+
"quickstart 4352\n",
|
138 |
+
"Name: count, dtype: int64"
|
139 |
]
|
140 |
},
|
141 |
+
"execution_count": 234,
|
142 |
"metadata": {},
|
143 |
"output_type": "execute_result"
|
144 |
}
|
145 |
],
|
146 |
"source": [
|
147 |
+
"jan6.staking.value_counts()"
|
148 |
+
]
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"cell_type": "code",
|
152 |
+
"execution_count": 235,
|
153 |
+
"metadata": {},
|
154 |
+
"outputs": [
|
155 |
+
{
|
156 |
+
"data": {
|
157 |
+
"text/plain": [
|
158 |
+
"185"
|
159 |
+
]
|
160 |
+
},
|
161 |
+
"execution_count": 235,
|
162 |
+
"metadata": {},
|
163 |
+
"output_type": "execute_result"
|
164 |
+
}
|
165 |
+
],
|
166 |
+
"source": [
|
167 |
+
"olas_jan6 = jan6.loc[jan6[\"staking\"]!= \"non_Olas\"]\n",
|
168 |
+
"olas_jan6.trader_address.nunique()"
|
169 |
+
]
|
170 |
+
},
|
171 |
+
{
|
172 |
+
"cell_type": "code",
|
173 |
+
"execution_count": 237,
|
174 |
+
"metadata": {},
|
175 |
+
"outputs": [],
|
176 |
+
"source": [
|
177 |
+
"retention_df[\"trader_type\"] = retention_df[\"staking\"].apply(\n",
|
178 |
+
" lambda x: \"non_Olas\" if x == \"non_Olas\" else \"Olas\"\n",
|
179 |
+
" )"
|
180 |
+
]
|
181 |
+
},
|
182 |
+
{
|
183 |
+
"cell_type": "code",
|
184 |
+
"execution_count": 238,
|
185 |
+
"metadata": {},
|
186 |
+
"outputs": [],
|
187 |
+
"source": [
|
188 |
+
" \n",
|
189 |
+
"active_traders = (\n",
|
190 |
+
" retention_df.groupby(by=[\"month_year_week\", \"trader_type\"])[\n",
|
191 |
+
" \"trader_address\"\n",
|
192 |
+
" ]\n",
|
193 |
+
" .nunique()\n",
|
194 |
+
" .reset_index(name=\"nr_traders\")\n",
|
195 |
+
")"
|
196 |
+
]
|
197 |
+
},
|
198 |
+
{
|
199 |
+
"cell_type": "code",
|
200 |
+
"execution_count": 239,
|
201 |
+
"metadata": {},
|
202 |
+
"outputs": [
|
203 |
+
{
|
204 |
+
"data": {
|
205 |
+
"text/html": [
|
206 |
+
"<div>\n",
|
207 |
+
"<style scoped>\n",
|
208 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
209 |
+
" vertical-align: middle;\n",
|
210 |
+
" }\n",
|
211 |
+
"\n",
|
212 |
+
" .dataframe tbody tr th {\n",
|
213 |
+
" vertical-align: top;\n",
|
214 |
+
" }\n",
|
215 |
+
"\n",
|
216 |
+
" .dataframe thead th {\n",
|
217 |
+
" text-align: right;\n",
|
218 |
+
" }\n",
|
219 |
+
"</style>\n",
|
220 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
221 |
+
" <thead>\n",
|
222 |
+
" <tr style=\"text-align: right;\">\n",
|
223 |
+
" <th></th>\n",
|
224 |
+
" <th>month_year_week</th>\n",
|
225 |
+
" <th>trader_type</th>\n",
|
226 |
+
" <th>nr_traders</th>\n",
|
227 |
+
" </tr>\n",
|
228 |
+
" </thead>\n",
|
229 |
+
" <tbody>\n",
|
230 |
+
" <tr>\n",
|
231 |
+
" <th>0</th>\n",
|
232 |
+
" <td>Dec-02-2024</td>\n",
|
233 |
+
" <td>Olas</td>\n",
|
234 |
+
" <td>233</td>\n",
|
235 |
+
" </tr>\n",
|
236 |
+
" <tr>\n",
|
237 |
+
" <th>1</th>\n",
|
238 |
+
" <td>Dec-02-2024</td>\n",
|
239 |
+
" <td>non_Olas</td>\n",
|
240 |
+
" <td>324</td>\n",
|
241 |
+
" </tr>\n",
|
242 |
+
" <tr>\n",
|
243 |
+
" <th>2</th>\n",
|
244 |
+
" <td>Dec-09-2024</td>\n",
|
245 |
+
" <td>Olas</td>\n",
|
246 |
+
" <td>227</td>\n",
|
247 |
+
" </tr>\n",
|
248 |
+
" <tr>\n",
|
249 |
+
" <th>3</th>\n",
|
250 |
+
" <td>Dec-09-2024</td>\n",
|
251 |
+
" <td>non_Olas</td>\n",
|
252 |
+
" <td>325</td>\n",
|
253 |
+
" </tr>\n",
|
254 |
+
" <tr>\n",
|
255 |
+
" <th>4</th>\n",
|
256 |
+
" <td>Dec-16-2024</td>\n",
|
257 |
+
" <td>Olas</td>\n",
|
258 |
+
" <td>214</td>\n",
|
259 |
+
" </tr>\n",
|
260 |
+
" <tr>\n",
|
261 |
+
" <th>5</th>\n",
|
262 |
+
" <td>Dec-16-2024</td>\n",
|
263 |
+
" <td>non_Olas</td>\n",
|
264 |
+
" <td>344</td>\n",
|
265 |
+
" </tr>\n",
|
266 |
+
" <tr>\n",
|
267 |
+
" <th>6</th>\n",
|
268 |
+
" <td>Dec-23-2024</td>\n",
|
269 |
+
" <td>Olas</td>\n",
|
270 |
+
" <td>194</td>\n",
|
271 |
+
" </tr>\n",
|
272 |
+
" <tr>\n",
|
273 |
+
" <th>7</th>\n",
|
274 |
+
" <td>Dec-23-2024</td>\n",
|
275 |
+
" <td>non_Olas</td>\n",
|
276 |
+
" <td>353</td>\n",
|
277 |
+
" </tr>\n",
|
278 |
+
" <tr>\n",
|
279 |
+
" <th>8</th>\n",
|
280 |
+
" <td>Dec-30-2024</td>\n",
|
281 |
+
" <td>Olas</td>\n",
|
282 |
+
" <td>193</td>\n",
|
283 |
+
" </tr>\n",
|
284 |
+
" <tr>\n",
|
285 |
+
" <th>9</th>\n",
|
286 |
+
" <td>Dec-30-2024</td>\n",
|
287 |
+
" <td>non_Olas</td>\n",
|
288 |
+
" <td>360</td>\n",
|
289 |
+
" </tr>\n",
|
290 |
+
" <tr>\n",
|
291 |
+
" <th>10</th>\n",
|
292 |
+
" <td>Jan-06-2025</td>\n",
|
293 |
+
" <td>Olas</td>\n",
|
294 |
+
" <td>185</td>\n",
|
295 |
+
" </tr>\n",
|
296 |
+
" <tr>\n",
|
297 |
+
" <th>11</th>\n",
|
298 |
+
" <td>Jan-06-2025</td>\n",
|
299 |
+
" <td>non_Olas</td>\n",
|
300 |
+
" <td>358</td>\n",
|
301 |
+
" </tr>\n",
|
302 |
+
" <tr>\n",
|
303 |
+
" <th>12</th>\n",
|
304 |
+
" <td>Jan-13-2025</td>\n",
|
305 |
+
" <td>Olas</td>\n",
|
306 |
+
" <td>153</td>\n",
|
307 |
+
" </tr>\n",
|
308 |
+
" <tr>\n",
|
309 |
+
" <th>13</th>\n",
|
310 |
+
" <td>Jan-13-2025</td>\n",
|
311 |
+
" <td>non_Olas</td>\n",
|
312 |
+
" <td>344</td>\n",
|
313 |
+
" </tr>\n",
|
314 |
+
" <tr>\n",
|
315 |
+
" <th>14</th>\n",
|
316 |
+
" <td>Nov-11-2024</td>\n",
|
317 |
+
" <td>Olas</td>\n",
|
318 |
+
" <td>202</td>\n",
|
319 |
+
" </tr>\n",
|
320 |
+
" <tr>\n",
|
321 |
+
" <th>15</th>\n",
|
322 |
+
" <td>Nov-11-2024</td>\n",
|
323 |
+
" <td>non_Olas</td>\n",
|
324 |
+
" <td>180</td>\n",
|
325 |
+
" </tr>\n",
|
326 |
+
" <tr>\n",
|
327 |
+
" <th>16</th>\n",
|
328 |
+
" <td>Nov-18-2024</td>\n",
|
329 |
+
" <td>Olas</td>\n",
|
330 |
+
" <td>221</td>\n",
|
331 |
+
" </tr>\n",
|
332 |
+
" <tr>\n",
|
333 |
+
" <th>17</th>\n",
|
334 |
+
" <td>Nov-18-2024</td>\n",
|
335 |
+
" <td>non_Olas</td>\n",
|
336 |
+
" <td>186</td>\n",
|
337 |
+
" </tr>\n",
|
338 |
+
" <tr>\n",
|
339 |
+
" <th>18</th>\n",
|
340 |
+
" <td>Nov-25-2024</td>\n",
|
341 |
+
" <td>Olas</td>\n",
|
342 |
+
" <td>202</td>\n",
|
343 |
+
" </tr>\n",
|
344 |
+
" <tr>\n",
|
345 |
+
" <th>19</th>\n",
|
346 |
+
" <td>Nov-25-2024</td>\n",
|
347 |
+
" <td>non_Olas</td>\n",
|
348 |
+
" <td>196</td>\n",
|
349 |
+
" </tr>\n",
|
350 |
+
" </tbody>\n",
|
351 |
+
"</table>\n",
|
352 |
+
"</div>"
|
353 |
+
],
|
354 |
+
"text/plain": [
|
355 |
+
" month_year_week trader_type nr_traders\n",
|
356 |
+
"0 Dec-02-2024 Olas 233\n",
|
357 |
+
"1 Dec-02-2024 non_Olas 324\n",
|
358 |
+
"2 Dec-09-2024 Olas 227\n",
|
359 |
+
"3 Dec-09-2024 non_Olas 325\n",
|
360 |
+
"4 Dec-16-2024 Olas 214\n",
|
361 |
+
"5 Dec-16-2024 non_Olas 344\n",
|
362 |
+
"6 Dec-23-2024 Olas 194\n",
|
363 |
+
"7 Dec-23-2024 non_Olas 353\n",
|
364 |
+
"8 Dec-30-2024 Olas 193\n",
|
365 |
+
"9 Dec-30-2024 non_Olas 360\n",
|
366 |
+
"10 Jan-06-2025 Olas 185\n",
|
367 |
+
"11 Jan-06-2025 non_Olas 358\n",
|
368 |
+
"12 Jan-13-2025 Olas 153\n",
|
369 |
+
"13 Jan-13-2025 non_Olas 344\n",
|
370 |
+
"14 Nov-11-2024 Olas 202\n",
|
371 |
+
"15 Nov-11-2024 non_Olas 180\n",
|
372 |
+
"16 Nov-18-2024 Olas 221\n",
|
373 |
+
"17 Nov-18-2024 non_Olas 186\n",
|
374 |
+
"18 Nov-25-2024 Olas 202\n",
|
375 |
+
"19 Nov-25-2024 non_Olas 196"
|
376 |
+
]
|
377 |
+
},
|
378 |
+
"execution_count": 239,
|
379 |
+
"metadata": {},
|
380 |
+
"output_type": "execute_result"
|
381 |
+
}
|
382 |
+
],
|
383 |
+
"source": [
|
384 |
+
"active_traders"
|
385 |
+
]
|
386 |
+
},
|
387 |
+
{
|
388 |
+
"cell_type": "code",
|
389 |
+
"execution_count": 236,
|
390 |
+
"metadata": {},
|
391 |
+
"outputs": [],
|
392 |
+
"source": [
|
393 |
+
"olas_data = retention_df.loc[retention_df[\"staking\"]!= \"non_Olas\"]"
|
394 |
+
]
|
395 |
+
},
|
396 |
+
{
|
397 |
+
"cell_type": "code",
|
398 |
+
"execution_count": null,
|
399 |
+
"metadata": {},
|
400 |
+
"outputs": [],
|
401 |
+
"source": [
|
402 |
+
"olas_data.groupby([\"month_year_week\"])[\"trader_address\"].nunique"
|
403 |
]
|
404 |
},
|
405 |
{
|
|
|
5934 |
},
|
5935 |
{
|
5936 |
"cell_type": "code",
|
5937 |
+
"execution_count": 217,
|
5938 |
+
"metadata": {},
|
5939 |
+
"outputs": [
|
5940 |
+
{
|
5941 |
+
"name": "stdout",
|
5942 |
+
"output_type": "stream",
|
5943 |
+
"text": [
|
5944 |
+
"start of the week = 2025-01-12 00:00:00\n"
|
5945 |
+
]
|
5946 |
+
}
|
5947 |
+
],
|
5948 |
+
"source": [
|
5949 |
+
"from datetime import timedelta\n",
|
5950 |
+
"now = datetime.now()\n",
|
5951 |
+
"\n",
|
5952 |
+
"# Get start of the current week (Sunday)\n",
|
5953 |
+
"start_of_week = now - timedelta(days=(now.weekday()) + 1)\n",
|
5954 |
+
"start_of_week = start_of_week.replace(hour=0, minute=0, second=0, microsecond=0)\n",
|
5955 |
+
"print(f\"start of the week = {start_of_week}\")"
|
5956 |
+
]
|
5957 |
+
},
|
5958 |
+
{
|
5959 |
+
"cell_type": "code",
|
5960 |
+
"execution_count": 218,
|
5961 |
+
"metadata": {},
|
5962 |
+
"outputs": [
|
5963 |
+
{
|
5964 |
+
"data": {
|
5965 |
+
"text/plain": [
|
5966 |
+
"Timestamp('2025-01-15 14:11:00+0000', tz='UTC')"
|
5967 |
+
]
|
5968 |
+
},
|
5969 |
+
"execution_count": 218,
|
5970 |
+
"metadata": {},
|
5971 |
+
"output_type": "execute_result"
|
5972 |
+
}
|
5973 |
+
],
|
5974 |
+
"source": [
|
5975 |
+
"max(retention_df.creation_timestamp)"
|
5976 |
+
]
|
5977 |
+
},
|
5978 |
+
{
|
5979 |
+
"cell_type": "code",
|
5980 |
+
"execution_count": 219,
|
5981 |
"metadata": {},
|
5982 |
"outputs": [],
|
5983 |
+
"source": [
|
5984 |
+
"all_traders[\"creation_date\"] = all_traders[\"creation_timestamp\"].dt.date\n",
|
5985 |
+
"all_traders[\"creation_date\"] = pd.to_datetime(all_traders[\"creation_date\"])"
|
5986 |
+
]
|
5987 |
},
|
5988 |
{
|
5989 |
"cell_type": "code",
|
5990 |
+
"execution_count": 222,
|
5991 |
"metadata": {},
|
5992 |
"outputs": [],
|
5993 |
+
"source": [
|
5994 |
+
"filtered_traders = all_traders[all_traders[\"creation_date\"] < start_of_week]\n"
|
5995 |
+
]
|
5996 |
+
},
|
5997 |
+
{
|
5998 |
+
"cell_type": "code",
|
5999 |
+
"execution_count": 223,
|
6000 |
+
"metadata": {},
|
6001 |
+
"outputs": [
|
6002 |
+
{
|
6003 |
+
"data": {
|
6004 |
+
"text/plain": [
|
6005 |
+
"Timestamp('2025-01-11 00:00:00')"
|
6006 |
+
]
|
6007 |
+
},
|
6008 |
+
"execution_count": 223,
|
6009 |
+
"metadata": {},
|
6010 |
+
"output_type": "execute_result"
|
6011 |
+
}
|
6012 |
+
],
|
6013 |
+
"source": [
|
6014 |
+
"max(filtered_traders.creation_date)"
|
6015 |
+
]
|
6016 |
+
},
|
6017 |
+
{
|
6018 |
+
"cell_type": "code",
|
6019 |
+
"execution_count": 228,
|
6020 |
+
"metadata": {},
|
6021 |
+
"outputs": [
|
6022 |
+
{
|
6023 |
+
"name": "stderr",
|
6024 |
+
"output_type": "stream",
|
6025 |
+
"text": [
|
6026 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_51242/777837414.py:2: UserWarning:\n",
|
6027 |
+
"\n",
|
6028 |
+
"Converting to PeriodArray/Index representation will drop timezone information.\n",
|
6029 |
+
"\n"
|
6030 |
+
]
|
6031 |
+
},
|
6032 |
+
{
|
6033 |
+
"name": "stdout",
|
6034 |
+
"output_type": "stream",
|
6035 |
+
"text": [
|
6036 |
+
"['Nov-17-2024' 'Nov-24-2024' 'Dec-01-2024' 'Dec-08-2024' 'Dec-15-2024'\n",
|
6037 |
+
" 'Dec-22-2024' 'Dec-29-2024' 'Jan-05-2025' 'Jan-12-2025']\n"
|
6038 |
+
]
|
6039 |
+
},
|
6040 |
+
{
|
6041 |
+
"name": "stderr",
|
6042 |
+
"output_type": "stream",
|
6043 |
+
"text": [
|
6044 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_51242/777837414.py:1: SettingWithCopyWarning:\n",
|
6045 |
+
"\n",
|
6046 |
+
"\n",
|
6047 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
6048 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
6049 |
+
"\n",
|
6050 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
6051 |
+
"\n"
|
6052 |
+
]
|
6053 |
+
}
|
6054 |
+
],
|
6055 |
+
"source": [
|
6056 |
+
"filtered_traders[\"month_year_week\"] =(\n",
|
6057 |
+
" pd.to_datetime(filtered_traders[\"creation_timestamp\"]).dt.to_period(\"W\").dt.strftime(\"%b-%d-%Y\")\n",
|
6058 |
+
")\n",
|
6059 |
+
"\n",
|
6060 |
+
"print(filtered_traders.month_year_week.unique())"
|
6061 |
+
]
|
6062 |
+
},
|
6063 |
+
{
|
6064 |
+
"cell_type": "code",
|
6065 |
+
"execution_count": 229,
|
6066 |
+
"metadata": {},
|
6067 |
+
"outputs": [
|
6068 |
+
{
|
6069 |
+
"data": {
|
6070 |
+
"text/html": [
|
6071 |
+
"<div>\n",
|
6072 |
+
"<style scoped>\n",
|
6073 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
6074 |
+
" vertical-align: middle;\n",
|
6075 |
+
" }\n",
|
6076 |
+
"\n",
|
6077 |
+
" .dataframe tbody tr th {\n",
|
6078 |
+
" vertical-align: top;\n",
|
6079 |
+
" }\n",
|
6080 |
+
"\n",
|
6081 |
+
" .dataframe thead th {\n",
|
6082 |
+
" text-align: right;\n",
|
6083 |
+
" }\n",
|
6084 |
+
"</style>\n",
|
6085 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
6086 |
+
" <thead>\n",
|
6087 |
+
" <tr style=\"text-align: right;\">\n",
|
6088 |
+
" <th></th>\n",
|
6089 |
+
" <th>trader_type</th>\n",
|
6090 |
+
" <th>market_creator</th>\n",
|
6091 |
+
" <th>trader_address</th>\n",
|
6092 |
+
" <th>creation_timestamp</th>\n",
|
6093 |
+
" <th>month_year_week</th>\n",
|
6094 |
+
" <th>creation_date</th>\n",
|
6095 |
+
" </tr>\n",
|
6096 |
+
" </thead>\n",
|
6097 |
+
" <tbody>\n",
|
6098 |
+
" <tr>\n",
|
6099 |
+
" <th>819286</th>\n",
|
6100 |
+
" <td>non_Olas</td>\n",
|
6101 |
+
" <td>quickstart</td>\n",
|
6102 |
+
" <td>0xd37ea497bfc5303eba99756c700b701443cb9c3d</td>\n",
|
6103 |
+
" <td>2025-01-06 00:00:10+00:00</td>\n",
|
6104 |
+
" <td>Jan-12-2025</td>\n",
|
6105 |
+
" <td>2025-01-06</td>\n",
|
6106 |
+
" </tr>\n",
|
6107 |
+
" <tr>\n",
|
6108 |
+
" <th>819287</th>\n",
|
6109 |
+
" <td>Olas</td>\n",
|
6110 |
+
" <td>quickstart</td>\n",
|
6111 |
+
" <td>0x080a6922f4d85e288f956402bebe6310b13af8e6</td>\n",
|
6112 |
+
" <td>2025-01-06 00:00:25+00:00</td>\n",
|
6113 |
+
" <td>Jan-12-2025</td>\n",
|
6114 |
+
" <td>2025-01-06</td>\n",
|
6115 |
+
" </tr>\n",
|
6116 |
+
" <tr>\n",
|
6117 |
+
" <th>819289</th>\n",
|
6118 |
+
" <td>non_Olas</td>\n",
|
6119 |
+
" <td>quickstart</td>\n",
|
6120 |
+
" <td>0x5f35a67f81f7278e0e61ae797fc1f34969055b3e</td>\n",
|
6121 |
+
" <td>2025-01-06 00:00:45+00:00</td>\n",
|
6122 |
+
" <td>Jan-12-2025</td>\n",
|
6123 |
+
" <td>2025-01-06</td>\n",
|
6124 |
+
" </tr>\n",
|
6125 |
+
" <tr>\n",
|
6126 |
+
" <th>819288</th>\n",
|
6127 |
+
" <td>Olas</td>\n",
|
6128 |
+
" <td>quickstart</td>\n",
|
6129 |
+
" <td>0x17c17ca981b7e244d0bad80b632a082dc1db36e5</td>\n",
|
6130 |
+
" <td>2025-01-06 00:00:45+00:00</td>\n",
|
6131 |
+
" <td>Jan-12-2025</td>\n",
|
6132 |
+
" <td>2025-01-06</td>\n",
|
6133 |
+
" </tr>\n",
|
6134 |
+
" <tr>\n",
|
6135 |
+
" <th>819291</th>\n",
|
6136 |
+
" <td>non_Olas</td>\n",
|
6137 |
+
" <td>quickstart</td>\n",
|
6138 |
+
" <td>0xb5f3e3e2738035eead5f3e332c04d9951b95cab2</td>\n",
|
6139 |
+
" <td>2025-01-06 00:00:50+00:00</td>\n",
|
6140 |
+
" <td>Jan-12-2025</td>\n",
|
6141 |
+
" <td>2025-01-06</td>\n",
|
6142 |
+
" </tr>\n",
|
6143 |
+
" <tr>\n",
|
6144 |
+
" <th>...</th>\n",
|
6145 |
+
" <td>...</td>\n",
|
6146 |
+
" <td>...</td>\n",
|
6147 |
+
" <td>...</td>\n",
|
6148 |
+
" <td>...</td>\n",
|
6149 |
+
" <td>...</td>\n",
|
6150 |
+
" <td>...</td>\n",
|
6151 |
+
" </tr>\n",
|
6152 |
+
" <tr>\n",
|
6153 |
+
" <th>950521</th>\n",
|
6154 |
+
" <td>non_Olas</td>\n",
|
6155 |
+
" <td>quickstart</td>\n",
|
6156 |
+
" <td>0xb43b4aee8b0d09244fb5f8df72714595c9f307bb</td>\n",
|
6157 |
+
" <td>2025-01-11 23:59:20+00:00</td>\n",
|
6158 |
+
" <td>Jan-12-2025</td>\n",
|
6159 |
+
" <td>2025-01-11</td>\n",
|
6160 |
+
" </tr>\n",
|
6161 |
+
" <tr>\n",
|
6162 |
+
" <th>950522</th>\n",
|
6163 |
+
" <td>non_Olas</td>\n",
|
6164 |
+
" <td>quickstart</td>\n",
|
6165 |
+
" <td>0x8b61e3164f546880ae26f433d51db788addc4d70</td>\n",
|
6166 |
+
" <td>2025-01-11 23:59:35+00:00</td>\n",
|
6167 |
+
" <td>Jan-12-2025</td>\n",
|
6168 |
+
" <td>2025-01-11</td>\n",
|
6169 |
+
" </tr>\n",
|
6170 |
+
" <tr>\n",
|
6171 |
+
" <th>950523</th>\n",
|
6172 |
+
" <td>non_Olas</td>\n",
|
6173 |
+
" <td>quickstart</td>\n",
|
6174 |
+
" <td>0x0b3db72453ebce8af6f577e9cf85f56bd07e05db</td>\n",
|
6175 |
+
" <td>2025-01-11 23:59:45+00:00</td>\n",
|
6176 |
+
" <td>Jan-12-2025</td>\n",
|
6177 |
+
" <td>2025-01-11</td>\n",
|
6178 |
+
" </tr>\n",
|
6179 |
+
" <tr>\n",
|
6180 |
+
" <th>950524</th>\n",
|
6181 |
+
" <td>non_Olas</td>\n",
|
6182 |
+
" <td>quickstart</td>\n",
|
6183 |
+
" <td>0x4aebc783154b7763093adb94f4f162bc0bc6d77d</td>\n",
|
6184 |
+
" <td>2025-01-11 23:59:50+00:00</td>\n",
|
6185 |
+
" <td>Jan-12-2025</td>\n",
|
6186 |
+
" <td>2025-01-11</td>\n",
|
6187 |
+
" </tr>\n",
|
6188 |
+
" <tr>\n",
|
6189 |
+
" <th>950525</th>\n",
|
6190 |
+
" <td>Olas</td>\n",
|
6191 |
+
" <td>quickstart</td>\n",
|
6192 |
+
" <td>0x080a6922f4d85e288f956402bebe6310b13af8e6</td>\n",
|
6193 |
+
" <td>2025-01-11 23:59:50+00:00</td>\n",
|
6194 |
+
" <td>Jan-12-2025</td>\n",
|
6195 |
+
" <td>2025-01-11</td>\n",
|
6196 |
+
" </tr>\n",
|
6197 |
+
" </tbody>\n",
|
6198 |
+
"</table>\n",
|
6199 |
+
"<p>131701 rows Γ 6 columns</p>\n",
|
6200 |
+
"</div>"
|
6201 |
+
],
|
6202 |
+
"text/plain": [
|
6203 |
+
" trader_type market_creator trader_address \\\n",
|
6204 |
+
"819286 non_Olas quickstart 0xd37ea497bfc5303eba99756c700b701443cb9c3d \n",
|
6205 |
+
"819287 Olas quickstart 0x080a6922f4d85e288f956402bebe6310b13af8e6 \n",
|
6206 |
+
"819289 non_Olas quickstart 0x5f35a67f81f7278e0e61ae797fc1f34969055b3e \n",
|
6207 |
+
"819288 Olas quickstart 0x17c17ca981b7e244d0bad80b632a082dc1db36e5 \n",
|
6208 |
+
"819291 non_Olas quickstart 0xb5f3e3e2738035eead5f3e332c04d9951b95cab2 \n",
|
6209 |
+
"... ... ... ... \n",
|
6210 |
+
"950521 non_Olas quickstart 0xb43b4aee8b0d09244fb5f8df72714595c9f307bb \n",
|
6211 |
+
"950522 non_Olas quickstart 0x8b61e3164f546880ae26f433d51db788addc4d70 \n",
|
6212 |
+
"950523 non_Olas quickstart 0x0b3db72453ebce8af6f577e9cf85f56bd07e05db \n",
|
6213 |
+
"950524 non_Olas quickstart 0x4aebc783154b7763093adb94f4f162bc0bc6d77d \n",
|
6214 |
+
"950525 Olas quickstart 0x080a6922f4d85e288f956402bebe6310b13af8e6 \n",
|
6215 |
+
"\n",
|
6216 |
+
" creation_timestamp month_year_week creation_date \n",
|
6217 |
+
"819286 2025-01-06 00:00:10+00:00 Jan-12-2025 2025-01-06 \n",
|
6218 |
+
"819287 2025-01-06 00:00:25+00:00 Jan-12-2025 2025-01-06 \n",
|
6219 |
+
"819289 2025-01-06 00:00:45+00:00 Jan-12-2025 2025-01-06 \n",
|
6220 |
+
"819288 2025-01-06 00:00:45+00:00 Jan-12-2025 2025-01-06 \n",
|
6221 |
+
"819291 2025-01-06 00:00:50+00:00 Jan-12-2025 2025-01-06 \n",
|
6222 |
+
"... ... ... ... \n",
|
6223 |
+
"950521 2025-01-11 23:59:20+00:00 Jan-12-2025 2025-01-11 \n",
|
6224 |
+
"950522 2025-01-11 23:59:35+00:00 Jan-12-2025 2025-01-11 \n",
|
6225 |
+
"950523 2025-01-11 23:59:45+00:00 Jan-12-2025 2025-01-11 \n",
|
6226 |
+
"950524 2025-01-11 23:59:50+00:00 Jan-12-2025 2025-01-11 \n",
|
6227 |
+
"950525 2025-01-11 23:59:50+00:00 Jan-12-2025 2025-01-11 \n",
|
6228 |
+
"\n",
|
6229 |
+
"[131701 rows x 6 columns]"
|
6230 |
+
]
|
6231 |
+
},
|
6232 |
+
"execution_count": 229,
|
6233 |
+
"metadata": {},
|
6234 |
+
"output_type": "execute_result"
|
6235 |
+
}
|
6236 |
+
],
|
6237 |
+
"source": [
|
6238 |
+
"filtered_traders.loc[filtered_traders[\"month_year_week\"]==\"Jan-12-2025\"]"
|
6239 |
+
]
|
6240 |
},
|
6241 |
{
|
6242 |
"cell_type": "code",
|
notebooks/unknown_traders.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
@@ -14,7 +14,7 @@
|
|
14 |
},
|
15 |
{
|
16 |
"cell_type": "code",
|
17 |
-
"execution_count":
|
18 |
"metadata": {},
|
19 |
"outputs": [],
|
20 |
"source": [
|
@@ -32,7 +32,7 @@
|
|
32 |
},
|
33 |
{
|
34 |
"cell_type": "code",
|
35 |
-
"execution_count":
|
36 |
"metadata": {},
|
37 |
"outputs": [
|
38 |
{
|
@@ -43,11 +43,11 @@
|
|
43 |
" 'trade_fee_amount', 'outcomes_tokens_traded', 'current_answer',\n",
|
44 |
" 'is_invalid', 'winning_trade', 'earnings', 'redeemed',\n",
|
45 |
" 'redeemed_amount', 'num_mech_calls', 'mech_fee_amount', 'net_earnings',\n",
|
46 |
-
" 'roi', 'staking'],\n",
|
47 |
" dtype='object')"
|
48 |
]
|
49 |
},
|
50 |
-
"execution_count":
|
51 |
"metadata": {},
|
52 |
"output_type": "execute_result"
|
53 |
}
|
@@ -138,7 +138,7 @@
|
|
138 |
},
|
139 |
{
|
140 |
"cell_type": "code",
|
141 |
-
"execution_count":
|
142 |
"metadata": {},
|
143 |
"outputs": [],
|
144 |
"source": [
|
@@ -149,7 +149,7 @@
|
|
149 |
},
|
150 |
{
|
151 |
"cell_type": "code",
|
152 |
-
"execution_count":
|
153 |
"metadata": {},
|
154 |
"outputs": [],
|
155 |
"source": [
|
@@ -186,7 +186,7 @@
|
|
186 |
},
|
187 |
{
|
188 |
"cell_type": "code",
|
189 |
-
"execution_count":
|
190 |
"metadata": {},
|
191 |
"outputs": [
|
192 |
{
|
@@ -201,6 +201,554 @@
|
|
201 |
"unknown_traders = add_creation_date(unknown_traders)"
|
202 |
]
|
203 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
{
|
205 |
"cell_type": "code",
|
206 |
"execution_count": 36,
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
14 |
},
|
15 |
{
|
16 |
"cell_type": "code",
|
17 |
+
"execution_count": 3,
|
18 |
"metadata": {},
|
19 |
"outputs": [],
|
20 |
"source": [
|
|
|
32 |
},
|
33 |
{
|
34 |
"cell_type": "code",
|
35 |
+
"execution_count": 4,
|
36 |
"metadata": {},
|
37 |
"outputs": [
|
38 |
{
|
|
|
43 |
" 'trade_fee_amount', 'outcomes_tokens_traded', 'current_answer',\n",
|
44 |
" 'is_invalid', 'winning_trade', 'earnings', 'redeemed',\n",
|
45 |
" 'redeemed_amount', 'num_mech_calls', 'mech_fee_amount', 'net_earnings',\n",
|
46 |
+
" 'roi', 'staking', 'nr_mech_calls'],\n",
|
47 |
" dtype='object')"
|
48 |
]
|
49 |
},
|
50 |
+
"execution_count": 4,
|
51 |
"metadata": {},
|
52 |
"output_type": "execute_result"
|
53 |
}
|
|
|
138 |
},
|
139 |
{
|
140 |
"cell_type": "code",
|
141 |
+
"execution_count": 6,
|
142 |
"metadata": {},
|
143 |
"outputs": [],
|
144 |
"source": [
|
|
|
149 |
},
|
150 |
{
|
151 |
"cell_type": "code",
|
152 |
+
"execution_count": 5,
|
153 |
"metadata": {},
|
154 |
"outputs": [],
|
155 |
"source": [
|
|
|
186 |
},
|
187 |
{
|
188 |
"cell_type": "code",
|
189 |
+
"execution_count": 7,
|
190 |
"metadata": {},
|
191 |
"outputs": [
|
192 |
{
|
|
|
201 |
"unknown_traders = add_creation_date(unknown_traders)"
|
202 |
]
|
203 |
},
|
204 |
+
{
|
205 |
+
"cell_type": "code",
|
206 |
+
"execution_count": 8,
|
207 |
+
"metadata": {},
|
208 |
+
"outputs": [
|
209 |
+
{
|
210 |
+
"name": "stderr",
|
211 |
+
"output_type": "stream",
|
212 |
+
"text": [
|
213 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_6876/1622588175.py:2: UserWarning: Converting to PeriodArray/Index representation will drop timezone information.\n",
|
214 |
+
" pd.to_datetime(unknown_traders[\"creation_timestamp\"]).dt.to_period(\"W\").dt.strftime(\"%b-%d-%Y\")\n"
|
215 |
+
]
|
216 |
+
}
|
217 |
+
],
|
218 |
+
"source": [
|
219 |
+
"unknown_traders[\"month_year_week\"] =(\n",
|
220 |
+
" pd.to_datetime(unknown_traders[\"creation_timestamp\"]).dt.to_period(\"W\").dt.strftime(\"%b-%d-%Y\")\n",
|
221 |
+
")"
|
222 |
+
]
|
223 |
+
},
|
224 |
+
{
|
225 |
+
"cell_type": "code",
|
226 |
+
"execution_count": 9,
|
227 |
+
"metadata": {},
|
228 |
+
"outputs": [
|
229 |
+
{
|
230 |
+
"data": {
|
231 |
+
"text/html": [
|
232 |
+
"<div>\n",
|
233 |
+
"<style scoped>\n",
|
234 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
235 |
+
" vertical-align: middle;\n",
|
236 |
+
" }\n",
|
237 |
+
"\n",
|
238 |
+
" .dataframe tbody tr th {\n",
|
239 |
+
" vertical-align: top;\n",
|
240 |
+
" }\n",
|
241 |
+
"\n",
|
242 |
+
" .dataframe thead th {\n",
|
243 |
+
" text-align: right;\n",
|
244 |
+
" }\n",
|
245 |
+
"</style>\n",
|
246 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
247 |
+
" <thead>\n",
|
248 |
+
" <tr style=\"text-align: right;\">\n",
|
249 |
+
" <th></th>\n",
|
250 |
+
" <th>trader_address</th>\n",
|
251 |
+
" <th>market_creator</th>\n",
|
252 |
+
" <th>trade_id</th>\n",
|
253 |
+
" <th>creation_timestamp</th>\n",
|
254 |
+
" <th>title</th>\n",
|
255 |
+
" <th>market_status</th>\n",
|
256 |
+
" <th>collateral_amount</th>\n",
|
257 |
+
" <th>outcome_index</th>\n",
|
258 |
+
" <th>trade_fee_amount</th>\n",
|
259 |
+
" <th>outcomes_tokens_traded</th>\n",
|
260 |
+
" <th>...</th>\n",
|
261 |
+
" <th>redeemed</th>\n",
|
262 |
+
" <th>redeemed_amount</th>\n",
|
263 |
+
" <th>num_mech_calls</th>\n",
|
264 |
+
" <th>mech_fee_amount</th>\n",
|
265 |
+
" <th>net_earnings</th>\n",
|
266 |
+
" <th>roi</th>\n",
|
267 |
+
" <th>staking</th>\n",
|
268 |
+
" <th>nr_mech_calls</th>\n",
|
269 |
+
" <th>creation_date</th>\n",
|
270 |
+
" <th>month_year_week</th>\n",
|
271 |
+
" </tr>\n",
|
272 |
+
" </thead>\n",
|
273 |
+
" <tbody>\n",
|
274 |
+
" <tr>\n",
|
275 |
+
" <th>0</th>\n",
|
276 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
277 |
+
" <td>quickstart</td>\n",
|
278 |
+
" <td>0x083c9f03dfc4072082b9e10aa2137151346f6fd30x05...</td>\n",
|
279 |
+
" <td>2025-01-12 12:21:40+00:00</td>\n",
|
280 |
+
" <td>Will federal prosecutors announce any new char...</td>\n",
|
281 |
+
" <td>CLOSED</td>\n",
|
282 |
+
" <td>0.204245</td>\n",
|
283 |
+
" <td>1</td>\n",
|
284 |
+
" <td>0.002042</td>\n",
|
285 |
+
" <td>0.279142</td>\n",
|
286 |
+
" <td>...</td>\n",
|
287 |
+
" <td>True</td>\n",
|
288 |
+
" <td>0.279142</td>\n",
|
289 |
+
" <td>0</td>\n",
|
290 |
+
" <td>0.0</td>\n",
|
291 |
+
" <td>0.072854</td>\n",
|
292 |
+
" <td>0.353167</td>\n",
|
293 |
+
" <td>non_Olas</td>\n",
|
294 |
+
" <td>NaN</td>\n",
|
295 |
+
" <td>2025-01-12</td>\n",
|
296 |
+
" <td>Jan-12-2025</td>\n",
|
297 |
+
" </tr>\n",
|
298 |
+
" <tr>\n",
|
299 |
+
" <th>1</th>\n",
|
300 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
301 |
+
" <td>quickstart</td>\n",
|
302 |
+
" <td>0x0b52672f29f059b1d0c3a297b28670fb8d92c4bd0x05...</td>\n",
|
303 |
+
" <td>2024-12-27 00:21:40+00:00</td>\n",
|
304 |
+
" <td>Will a third fight between Usyk and Fury be of...</td>\n",
|
305 |
+
" <td>CLOSED</td>\n",
|
306 |
+
" <td>0.943883</td>\n",
|
307 |
+
" <td>1</td>\n",
|
308 |
+
" <td>0.009439</td>\n",
|
309 |
+
" <td>1.302968</td>\n",
|
310 |
+
" <td>...</td>\n",
|
311 |
+
" <td>True</td>\n",
|
312 |
+
" <td>1.302968</td>\n",
|
313 |
+
" <td>0</td>\n",
|
314 |
+
" <td>0.0</td>\n",
|
315 |
+
" <td>0.349646</td>\n",
|
316 |
+
" <td>0.366766</td>\n",
|
317 |
+
" <td>non_Olas</td>\n",
|
318 |
+
" <td>NaN</td>\n",
|
319 |
+
" <td>2024-12-27</td>\n",
|
320 |
+
" <td>Dec-29-2024</td>\n",
|
321 |
+
" </tr>\n",
|
322 |
+
" <tr>\n",
|
323 |
+
" <th>2</th>\n",
|
324 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
325 |
+
" <td>quickstart</td>\n",
|
326 |
+
" <td>0x0de08cc50fa523de23b95ce7ad773e038fb8590d0x05...</td>\n",
|
327 |
+
" <td>2025-01-09 06:21:15+00:00</td>\n",
|
328 |
+
" <td>Will record-low temperatures be recorded in at...</td>\n",
|
329 |
+
" <td>CLOSED</td>\n",
|
330 |
+
" <td>2.185557</td>\n",
|
331 |
+
" <td>1</td>\n",
|
332 |
+
" <td>0.021856</td>\n",
|
333 |
+
" <td>3.456138</td>\n",
|
334 |
+
" <td>...</td>\n",
|
335 |
+
" <td>True</td>\n",
|
336 |
+
" <td>0.000000</td>\n",
|
337 |
+
" <td>0</td>\n",
|
338 |
+
" <td>0.0</td>\n",
|
339 |
+
" <td>-2.207412</td>\n",
|
340 |
+
" <td>-1.000000</td>\n",
|
341 |
+
" <td>non_Olas</td>\n",
|
342 |
+
" <td>NaN</td>\n",
|
343 |
+
" <td>2025-01-09</td>\n",
|
344 |
+
" <td>Jan-12-2025</td>\n",
|
345 |
+
" </tr>\n",
|
346 |
+
" <tr>\n",
|
347 |
+
" <th>3</th>\n",
|
348 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
349 |
+
" <td>quickstart</td>\n",
|
350 |
+
" <td>0x0f90a2ea8a8b0fbca021405563e763acb9f7d9460x05...</td>\n",
|
351 |
+
" <td>2024-12-27 18:21:35+00:00</td>\n",
|
352 |
+
" <td>Will any new unfair labor practice charges be ...</td>\n",
|
353 |
+
" <td>CLOSED</td>\n",
|
354 |
+
" <td>0.430373</td>\n",
|
355 |
+
" <td>0</td>\n",
|
356 |
+
" <td>0.004304</td>\n",
|
357 |
+
" <td>0.586244</td>\n",
|
358 |
+
" <td>...</td>\n",
|
359 |
+
" <td>True</td>\n",
|
360 |
+
" <td>0.586244</td>\n",
|
361 |
+
" <td>0</td>\n",
|
362 |
+
" <td>0.0</td>\n",
|
363 |
+
" <td>0.151567</td>\n",
|
364 |
+
" <td>0.348688</td>\n",
|
365 |
+
" <td>non_Olas</td>\n",
|
366 |
+
" <td>NaN</td>\n",
|
367 |
+
" <td>2024-12-27</td>\n",
|
368 |
+
" <td>Dec-29-2024</td>\n",
|
369 |
+
" </tr>\n",
|
370 |
+
" <tr>\n",
|
371 |
+
" <th>4</th>\n",
|
372 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
373 |
+
" <td>quickstart</td>\n",
|
374 |
+
" <td>0x13e42a5f5422df80a05c4b7b8d01bd21be82289b0x05...</td>\n",
|
375 |
+
" <td>2025-01-08 18:22:00+00:00</td>\n",
|
376 |
+
" <td>Will the Israeli government publicly acknowled...</td>\n",
|
377 |
+
" <td>CLOSED</td>\n",
|
378 |
+
" <td>3.227216</td>\n",
|
379 |
+
" <td>1</td>\n",
|
380 |
+
" <td>0.032272</td>\n",
|
381 |
+
" <td>7.405353</td>\n",
|
382 |
+
" <td>...</td>\n",
|
383 |
+
" <td>True</td>\n",
|
384 |
+
" <td>7.405353</td>\n",
|
385 |
+
" <td>0</td>\n",
|
386 |
+
" <td>0.0</td>\n",
|
387 |
+
" <td>4.145865</td>\n",
|
388 |
+
" <td>1.271938</td>\n",
|
389 |
+
" <td>non_Olas</td>\n",
|
390 |
+
" <td>NaN</td>\n",
|
391 |
+
" <td>2025-01-08</td>\n",
|
392 |
+
" <td>Jan-12-2025</td>\n",
|
393 |
+
" </tr>\n",
|
394 |
+
" </tbody>\n",
|
395 |
+
"</table>\n",
|
396 |
+
"<p>5 rows Γ 24 columns</p>\n",
|
397 |
+
"</div>"
|
398 |
+
],
|
399 |
+
"text/plain": [
|
400 |
+
" trader_address market_creator \\\n",
|
401 |
+
"0 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
402 |
+
"1 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
403 |
+
"2 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
404 |
+
"3 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
405 |
+
"4 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
406 |
+
"\n",
|
407 |
+
" trade_id \\\n",
|
408 |
+
"0 0x083c9f03dfc4072082b9e10aa2137151346f6fd30x05... \n",
|
409 |
+
"1 0x0b52672f29f059b1d0c3a297b28670fb8d92c4bd0x05... \n",
|
410 |
+
"2 0x0de08cc50fa523de23b95ce7ad773e038fb8590d0x05... \n",
|
411 |
+
"3 0x0f90a2ea8a8b0fbca021405563e763acb9f7d9460x05... \n",
|
412 |
+
"4 0x13e42a5f5422df80a05c4b7b8d01bd21be82289b0x05... \n",
|
413 |
+
"\n",
|
414 |
+
" creation_timestamp \\\n",
|
415 |
+
"0 2025-01-12 12:21:40+00:00 \n",
|
416 |
+
"1 2024-12-27 00:21:40+00:00 \n",
|
417 |
+
"2 2025-01-09 06:21:15+00:00 \n",
|
418 |
+
"3 2024-12-27 18:21:35+00:00 \n",
|
419 |
+
"4 2025-01-08 18:22:00+00:00 \n",
|
420 |
+
"\n",
|
421 |
+
" title market_status \\\n",
|
422 |
+
"0 Will federal prosecutors announce any new char... CLOSED \n",
|
423 |
+
"1 Will a third fight between Usyk and Fury be of... CLOSED \n",
|
424 |
+
"2 Will record-low temperatures be recorded in at... CLOSED \n",
|
425 |
+
"3 Will any new unfair labor practice charges be ... CLOSED \n",
|
426 |
+
"4 Will the Israeli government publicly acknowled... CLOSED \n",
|
427 |
+
"\n",
|
428 |
+
" collateral_amount outcome_index trade_fee_amount outcomes_tokens_traded \\\n",
|
429 |
+
"0 0.204245 1 0.002042 0.279142 \n",
|
430 |
+
"1 0.943883 1 0.009439 1.302968 \n",
|
431 |
+
"2 2.185557 1 0.021856 3.456138 \n",
|
432 |
+
"3 0.430373 0 0.004304 0.586244 \n",
|
433 |
+
"4 3.227216 1 0.032272 7.405353 \n",
|
434 |
+
"\n",
|
435 |
+
" ... redeemed redeemed_amount num_mech_calls mech_fee_amount \\\n",
|
436 |
+
"0 ... True 0.279142 0 0.0 \n",
|
437 |
+
"1 ... True 1.302968 0 0.0 \n",
|
438 |
+
"2 ... True 0.000000 0 0.0 \n",
|
439 |
+
"3 ... True 0.586244 0 0.0 \n",
|
440 |
+
"4 ... True 7.405353 0 0.0 \n",
|
441 |
+
"\n",
|
442 |
+
" net_earnings roi staking nr_mech_calls creation_date \\\n",
|
443 |
+
"0 0.072854 0.353167 non_Olas NaN 2025-01-12 \n",
|
444 |
+
"1 0.349646 0.366766 non_Olas NaN 2024-12-27 \n",
|
445 |
+
"2 -2.207412 -1.000000 non_Olas NaN 2025-01-09 \n",
|
446 |
+
"3 0.151567 0.348688 non_Olas NaN 2024-12-27 \n",
|
447 |
+
"4 4.145865 1.271938 non_Olas NaN 2025-01-08 \n",
|
448 |
+
"\n",
|
449 |
+
" month_year_week \n",
|
450 |
+
"0 Jan-12-2025 \n",
|
451 |
+
"1 Dec-29-2024 \n",
|
452 |
+
"2 Jan-12-2025 \n",
|
453 |
+
"3 Dec-29-2024 \n",
|
454 |
+
"4 Jan-12-2025 \n",
|
455 |
+
"\n",
|
456 |
+
"[5 rows x 24 columns]"
|
457 |
+
]
|
458 |
+
},
|
459 |
+
"execution_count": 9,
|
460 |
+
"metadata": {},
|
461 |
+
"output_type": "execute_result"
|
462 |
+
}
|
463 |
+
],
|
464 |
+
"source": [
|
465 |
+
"unknown_traders.head()"
|
466 |
+
]
|
467 |
+
},
|
468 |
+
{
|
469 |
+
"cell_type": "code",
|
470 |
+
"execution_count": 15,
|
471 |
+
"metadata": {},
|
472 |
+
"outputs": [
|
473 |
+
{
|
474 |
+
"name": "stderr",
|
475 |
+
"output_type": "stream",
|
476 |
+
"text": [
|
477 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_6876/928490420.py:2: UserWarning: Converting to PeriodArray/Index representation will drop timezone information.\n",
|
478 |
+
" pd.to_datetime(unknown_traders[\"creation_timestamp\"]).dt.to_period(\"W\").dt.start_time.dt.strftime(\"%b-%d-%Y\")\n"
|
479 |
+
]
|
480 |
+
}
|
481 |
+
],
|
482 |
+
"source": [
|
483 |
+
"unknown_traders[\"month_year_week\"] = (\n",
|
484 |
+
" pd.to_datetime(unknown_traders[\"creation_timestamp\"]).dt.to_period(\"W\").dt.start_time.dt.strftime(\"%b-%d-%Y\")\n",
|
485 |
+
" )"
|
486 |
+
]
|
487 |
+
},
|
488 |
+
{
|
489 |
+
"cell_type": "code",
|
490 |
+
"execution_count": 12,
|
491 |
+
"metadata": {},
|
492 |
+
"outputs": [
|
493 |
+
{
|
494 |
+
"name": "stderr",
|
495 |
+
"output_type": "stream",
|
496 |
+
"text": [
|
497 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_6876/589443447.py:2: UserWarning: Converting to PeriodArray/Index representation will drop timezone information.\n",
|
498 |
+
" unknown_traders[\"creation_timestamp\"].dt.to_period(\"W\")\n"
|
499 |
+
]
|
500 |
+
}
|
501 |
+
],
|
502 |
+
"source": [
|
503 |
+
"unknown_traders[\"month_year_week\"] =(\n",
|
504 |
+
" unknown_traders[\"creation_timestamp\"].dt.to_period(\"W\")\n",
|
505 |
+
")"
|
506 |
+
]
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"cell_type": "code",
|
510 |
+
"execution_count": 16,
|
511 |
+
"metadata": {},
|
512 |
+
"outputs": [
|
513 |
+
{
|
514 |
+
"data": {
|
515 |
+
"text/html": [
|
516 |
+
"<div>\n",
|
517 |
+
"<style scoped>\n",
|
518 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
519 |
+
" vertical-align: middle;\n",
|
520 |
+
" }\n",
|
521 |
+
"\n",
|
522 |
+
" .dataframe tbody tr th {\n",
|
523 |
+
" vertical-align: top;\n",
|
524 |
+
" }\n",
|
525 |
+
"\n",
|
526 |
+
" .dataframe thead th {\n",
|
527 |
+
" text-align: right;\n",
|
528 |
+
" }\n",
|
529 |
+
"</style>\n",
|
530 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
531 |
+
" <thead>\n",
|
532 |
+
" <tr style=\"text-align: right;\">\n",
|
533 |
+
" <th></th>\n",
|
534 |
+
" <th>trader_address</th>\n",
|
535 |
+
" <th>market_creator</th>\n",
|
536 |
+
" <th>trade_id</th>\n",
|
537 |
+
" <th>creation_timestamp</th>\n",
|
538 |
+
" <th>title</th>\n",
|
539 |
+
" <th>market_status</th>\n",
|
540 |
+
" <th>collateral_amount</th>\n",
|
541 |
+
" <th>outcome_index</th>\n",
|
542 |
+
" <th>trade_fee_amount</th>\n",
|
543 |
+
" <th>outcomes_tokens_traded</th>\n",
|
544 |
+
" <th>...</th>\n",
|
545 |
+
" <th>redeemed</th>\n",
|
546 |
+
" <th>redeemed_amount</th>\n",
|
547 |
+
" <th>num_mech_calls</th>\n",
|
548 |
+
" <th>mech_fee_amount</th>\n",
|
549 |
+
" <th>net_earnings</th>\n",
|
550 |
+
" <th>roi</th>\n",
|
551 |
+
" <th>staking</th>\n",
|
552 |
+
" <th>nr_mech_calls</th>\n",
|
553 |
+
" <th>creation_date</th>\n",
|
554 |
+
" <th>month_year_week</th>\n",
|
555 |
+
" </tr>\n",
|
556 |
+
" </thead>\n",
|
557 |
+
" <tbody>\n",
|
558 |
+
" <tr>\n",
|
559 |
+
" <th>0</th>\n",
|
560 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
561 |
+
" <td>quickstart</td>\n",
|
562 |
+
" <td>0x083c9f03dfc4072082b9e10aa2137151346f6fd30x05...</td>\n",
|
563 |
+
" <td>2025-01-12 12:21:40+00:00</td>\n",
|
564 |
+
" <td>Will federal prosecutors announce any new char...</td>\n",
|
565 |
+
" <td>CLOSED</td>\n",
|
566 |
+
" <td>0.204245</td>\n",
|
567 |
+
" <td>1</td>\n",
|
568 |
+
" <td>0.002042</td>\n",
|
569 |
+
" <td>0.279142</td>\n",
|
570 |
+
" <td>...</td>\n",
|
571 |
+
" <td>True</td>\n",
|
572 |
+
" <td>0.279142</td>\n",
|
573 |
+
" <td>0</td>\n",
|
574 |
+
" <td>0.0</td>\n",
|
575 |
+
" <td>0.072854</td>\n",
|
576 |
+
" <td>0.353167</td>\n",
|
577 |
+
" <td>non_Olas</td>\n",
|
578 |
+
" <td>NaN</td>\n",
|
579 |
+
" <td>2025-01-12</td>\n",
|
580 |
+
" <td>Jan-06-2025</td>\n",
|
581 |
+
" </tr>\n",
|
582 |
+
" <tr>\n",
|
583 |
+
" <th>1</th>\n",
|
584 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
585 |
+
" <td>quickstart</td>\n",
|
586 |
+
" <td>0x0b52672f29f059b1d0c3a297b28670fb8d92c4bd0x05...</td>\n",
|
587 |
+
" <td>2024-12-27 00:21:40+00:00</td>\n",
|
588 |
+
" <td>Will a third fight between Usyk and Fury be of...</td>\n",
|
589 |
+
" <td>CLOSED</td>\n",
|
590 |
+
" <td>0.943883</td>\n",
|
591 |
+
" <td>1</td>\n",
|
592 |
+
" <td>0.009439</td>\n",
|
593 |
+
" <td>1.302968</td>\n",
|
594 |
+
" <td>...</td>\n",
|
595 |
+
" <td>True</td>\n",
|
596 |
+
" <td>1.302968</td>\n",
|
597 |
+
" <td>0</td>\n",
|
598 |
+
" <td>0.0</td>\n",
|
599 |
+
" <td>0.349646</td>\n",
|
600 |
+
" <td>0.366766</td>\n",
|
601 |
+
" <td>non_Olas</td>\n",
|
602 |
+
" <td>NaN</td>\n",
|
603 |
+
" <td>2024-12-27</td>\n",
|
604 |
+
" <td>Dec-23-2024</td>\n",
|
605 |
+
" </tr>\n",
|
606 |
+
" <tr>\n",
|
607 |
+
" <th>2</th>\n",
|
608 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
609 |
+
" <td>quickstart</td>\n",
|
610 |
+
" <td>0x0de08cc50fa523de23b95ce7ad773e038fb8590d0x05...</td>\n",
|
611 |
+
" <td>2025-01-09 06:21:15+00:00</td>\n",
|
612 |
+
" <td>Will record-low temperatures be recorded in at...</td>\n",
|
613 |
+
" <td>CLOSED</td>\n",
|
614 |
+
" <td>2.185557</td>\n",
|
615 |
+
" <td>1</td>\n",
|
616 |
+
" <td>0.021856</td>\n",
|
617 |
+
" <td>3.456138</td>\n",
|
618 |
+
" <td>...</td>\n",
|
619 |
+
" <td>True</td>\n",
|
620 |
+
" <td>0.000000</td>\n",
|
621 |
+
" <td>0</td>\n",
|
622 |
+
" <td>0.0</td>\n",
|
623 |
+
" <td>-2.207412</td>\n",
|
624 |
+
" <td>-1.000000</td>\n",
|
625 |
+
" <td>non_Olas</td>\n",
|
626 |
+
" <td>NaN</td>\n",
|
627 |
+
" <td>2025-01-09</td>\n",
|
628 |
+
" <td>Jan-06-2025</td>\n",
|
629 |
+
" </tr>\n",
|
630 |
+
" <tr>\n",
|
631 |
+
" <th>3</th>\n",
|
632 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
633 |
+
" <td>quickstart</td>\n",
|
634 |
+
" <td>0x0f90a2ea8a8b0fbca021405563e763acb9f7d9460x05...</td>\n",
|
635 |
+
" <td>2024-12-27 18:21:35+00:00</td>\n",
|
636 |
+
" <td>Will any new unfair labor practice charges be ...</td>\n",
|
637 |
+
" <td>CLOSED</td>\n",
|
638 |
+
" <td>0.430373</td>\n",
|
639 |
+
" <td>0</td>\n",
|
640 |
+
" <td>0.004304</td>\n",
|
641 |
+
" <td>0.586244</td>\n",
|
642 |
+
" <td>...</td>\n",
|
643 |
+
" <td>True</td>\n",
|
644 |
+
" <td>0.586244</td>\n",
|
645 |
+
" <td>0</td>\n",
|
646 |
+
" <td>0.0</td>\n",
|
647 |
+
" <td>0.151567</td>\n",
|
648 |
+
" <td>0.348688</td>\n",
|
649 |
+
" <td>non_Olas</td>\n",
|
650 |
+
" <td>NaN</td>\n",
|
651 |
+
" <td>2024-12-27</td>\n",
|
652 |
+
" <td>Dec-23-2024</td>\n",
|
653 |
+
" </tr>\n",
|
654 |
+
" <tr>\n",
|
655 |
+
" <th>4</th>\n",
|
656 |
+
" <td>0x05e8bbdb89c84a14d05194bbbae81caf2340db72</td>\n",
|
657 |
+
" <td>quickstart</td>\n",
|
658 |
+
" <td>0x13e42a5f5422df80a05c4b7b8d01bd21be82289b0x05...</td>\n",
|
659 |
+
" <td>2025-01-08 18:22:00+00:00</td>\n",
|
660 |
+
" <td>Will the Israeli government publicly acknowled...</td>\n",
|
661 |
+
" <td>CLOSED</td>\n",
|
662 |
+
" <td>3.227216</td>\n",
|
663 |
+
" <td>1</td>\n",
|
664 |
+
" <td>0.032272</td>\n",
|
665 |
+
" <td>7.405353</td>\n",
|
666 |
+
" <td>...</td>\n",
|
667 |
+
" <td>True</td>\n",
|
668 |
+
" <td>7.405353</td>\n",
|
669 |
+
" <td>0</td>\n",
|
670 |
+
" <td>0.0</td>\n",
|
671 |
+
" <td>4.145865</td>\n",
|
672 |
+
" <td>1.271938</td>\n",
|
673 |
+
" <td>non_Olas</td>\n",
|
674 |
+
" <td>NaN</td>\n",
|
675 |
+
" <td>2025-01-08</td>\n",
|
676 |
+
" <td>Jan-06-2025</td>\n",
|
677 |
+
" </tr>\n",
|
678 |
+
" </tbody>\n",
|
679 |
+
"</table>\n",
|
680 |
+
"<p>5 rows Γ 24 columns</p>\n",
|
681 |
+
"</div>"
|
682 |
+
],
|
683 |
+
"text/plain": [
|
684 |
+
" trader_address market_creator \\\n",
|
685 |
+
"0 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
686 |
+
"1 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
687 |
+
"2 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
688 |
+
"3 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
689 |
+
"4 0x05e8bbdb89c84a14d05194bbbae81caf2340db72 quickstart \n",
|
690 |
+
"\n",
|
691 |
+
" trade_id \\\n",
|
692 |
+
"0 0x083c9f03dfc4072082b9e10aa2137151346f6fd30x05... \n",
|
693 |
+
"1 0x0b52672f29f059b1d0c3a297b28670fb8d92c4bd0x05... \n",
|
694 |
+
"2 0x0de08cc50fa523de23b95ce7ad773e038fb8590d0x05... \n",
|
695 |
+
"3 0x0f90a2ea8a8b0fbca021405563e763acb9f7d9460x05... \n",
|
696 |
+
"4 0x13e42a5f5422df80a05c4b7b8d01bd21be82289b0x05... \n",
|
697 |
+
"\n",
|
698 |
+
" creation_timestamp \\\n",
|
699 |
+
"0 2025-01-12 12:21:40+00:00 \n",
|
700 |
+
"1 2024-12-27 00:21:40+00:00 \n",
|
701 |
+
"2 2025-01-09 06:21:15+00:00 \n",
|
702 |
+
"3 2024-12-27 18:21:35+00:00 \n",
|
703 |
+
"4 2025-01-08 18:22:00+00:00 \n",
|
704 |
+
"\n",
|
705 |
+
" title market_status \\\n",
|
706 |
+
"0 Will federal prosecutors announce any new char... CLOSED \n",
|
707 |
+
"1 Will a third fight between Usyk and Fury be of... CLOSED \n",
|
708 |
+
"2 Will record-low temperatures be recorded in at... CLOSED \n",
|
709 |
+
"3 Will any new unfair labor practice charges be ... CLOSED \n",
|
710 |
+
"4 Will the Israeli government publicly acknowled... CLOSED \n",
|
711 |
+
"\n",
|
712 |
+
" collateral_amount outcome_index trade_fee_amount outcomes_tokens_traded \\\n",
|
713 |
+
"0 0.204245 1 0.002042 0.279142 \n",
|
714 |
+
"1 0.943883 1 0.009439 1.302968 \n",
|
715 |
+
"2 2.185557 1 0.021856 3.456138 \n",
|
716 |
+
"3 0.430373 0 0.004304 0.586244 \n",
|
717 |
+
"4 3.227216 1 0.032272 7.405353 \n",
|
718 |
+
"\n",
|
719 |
+
" ... redeemed redeemed_amount num_mech_calls mech_fee_amount \\\n",
|
720 |
+
"0 ... True 0.279142 0 0.0 \n",
|
721 |
+
"1 ... True 1.302968 0 0.0 \n",
|
722 |
+
"2 ... True 0.000000 0 0.0 \n",
|
723 |
+
"3 ... True 0.586244 0 0.0 \n",
|
724 |
+
"4 ... True 7.405353 0 0.0 \n",
|
725 |
+
"\n",
|
726 |
+
" net_earnings roi staking nr_mech_calls creation_date \\\n",
|
727 |
+
"0 0.072854 0.353167 non_Olas NaN 2025-01-12 \n",
|
728 |
+
"1 0.349646 0.366766 non_Olas NaN 2024-12-27 \n",
|
729 |
+
"2 -2.207412 -1.000000 non_Olas NaN 2025-01-09 \n",
|
730 |
+
"3 0.151567 0.348688 non_Olas NaN 2024-12-27 \n",
|
731 |
+
"4 4.145865 1.271938 non_Olas NaN 2025-01-08 \n",
|
732 |
+
"\n",
|
733 |
+
" month_year_week \n",
|
734 |
+
"0 Jan-06-2025 \n",
|
735 |
+
"1 Dec-23-2024 \n",
|
736 |
+
"2 Jan-06-2025 \n",
|
737 |
+
"3 Dec-23-2024 \n",
|
738 |
+
"4 Jan-06-2025 \n",
|
739 |
+
"\n",
|
740 |
+
"[5 rows x 24 columns]"
|
741 |
+
]
|
742 |
+
},
|
743 |
+
"execution_count": 16,
|
744 |
+
"metadata": {},
|
745 |
+
"output_type": "execute_result"
|
746 |
+
}
|
747 |
+
],
|
748 |
+
"source": [
|
749 |
+
"unknown_traders.head()"
|
750 |
+
]
|
751 |
+
},
|
752 |
{
|
753 |
"cell_type": "code",
|
754 |
"execution_count": 36,
|
scripts/retention_metrics.py
CHANGED
@@ -46,7 +46,6 @@ def calculate_wow_retention_by_type(
|
|
46 |
for key in week_to_number.keys()
|
47 |
if week_to_number[key] == previous_week_number
|
48 |
][0]
|
49 |
-
# previous_week = type_data.iloc[i-1]['month_year_week']
|
50 |
# print(f"previous week = {previous_week}")
|
51 |
|
52 |
# Get traders in both weeks for this type
|
@@ -134,10 +133,12 @@ def calculate_cohort_retention(
|
|
134 |
|
135 |
# Get all unique weeks and cohorts
|
136 |
all_cohorts = cohort_data["cohort_week"].unique()
|
|
|
137 |
# print(f"all cohorts = {all_cohorts}")
|
138 |
retention_data = []
|
139 |
max_weeks = 8
|
140 |
-
for cohort in all_cohorts:
|
|
|
141 |
# print(f"analyzing cohort {cohort}")
|
142 |
# Get all traders in this cohort
|
143 |
cohort_traders = set(
|
@@ -146,15 +147,26 @@ def calculate_cohort_retention(
|
|
146 |
cohort_size = len(cohort_traders)
|
147 |
# print(f"cohort size = {cohort_size}")
|
148 |
|
149 |
-
if cohort_size == 0:
|
150 |
-
print(f"NO new traders for cohort week={cohort}")
|
151 |
-
continue
|
152 |
-
|
153 |
# Calculate retention for each week after the cohort week
|
154 |
for week_idx, week in enumerate(all_weeks):
|
155 |
# print(f"Analyzing week = {week}")
|
156 |
-
weeks_since_cohort = week_idx -
|
157 |
-
if weeks_since_cohort < 0 or weeks_since_cohort >
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
continue
|
159 |
# Get active traders from the cohort in current week
|
160 |
current_traders = set(
|
|
|
46 |
for key in week_to_number.keys()
|
47 |
if week_to_number[key] == previous_week_number
|
48 |
][0]
|
|
|
49 |
# print(f"previous week = {previous_week}")
|
50 |
|
51 |
# Get traders in both weeks for this type
|
|
|
133 |
|
134 |
# Get all unique weeks and cohorts
|
135 |
all_cohorts = cohort_data["cohort_week"].unique()
|
136 |
+
# extend the cohort
|
137 |
# print(f"all cohorts = {all_cohorts}")
|
138 |
retention_data = []
|
139 |
max_weeks = 8
|
140 |
+
# for cohort in all_cohorts:
|
141 |
+
for cohort_week_idx, cohort in enumerate(all_weeks):
|
142 |
# print(f"analyzing cohort {cohort}")
|
143 |
# Get all traders in this cohort
|
144 |
cohort_traders = set(
|
|
|
147 |
cohort_size = len(cohort_traders)
|
148 |
# print(f"cohort size = {cohort_size}")
|
149 |
|
|
|
|
|
|
|
|
|
150 |
# Calculate retention for each week after the cohort week
|
151 |
for week_idx, week in enumerate(all_weeks):
|
152 |
# print(f"Analyzing week = {week}")
|
153 |
+
weeks_since_cohort = week_idx - cohort_week_idx
|
154 |
+
if weeks_since_cohort < 0 or weeks_since_cohort > max_weeks:
|
155 |
+
continue
|
156 |
+
if cohort_size == 0:
|
157 |
+
print(f"NO new traders for cohort week={cohort}")
|
158 |
+
retention_data.append(
|
159 |
+
{
|
160 |
+
"cohort_week": cohort,
|
161 |
+
"week": week,
|
162 |
+
"weeks_since_cohort": weeks_since_cohort,
|
163 |
+
"cohort_size": cohort_size,
|
164 |
+
"active_traders": 0,
|
165 |
+
"retained_traders": 0,
|
166 |
+
"previous_traders": 0,
|
167 |
+
"retention_rate": round(0, 2),
|
168 |
+
}
|
169 |
+
)
|
170 |
continue
|
171 |
# Get active traders from the cohort in current week
|
172 |
current_traders = set(
|