cyberosa
commited on
Commit
·
0e4b180
1
Parent(s):
309bf92
Adding new time evolution graph of mean dist gap for all markets
Browse files- app.py +9 -21
- notebooks/analysis_of_markets_data.ipynb +171 -165
- tabs/dist_gap.py +27 -0
- tabs/{tokens_pwc_dist.py → tokens_dist.py} +0 -0
app.py
CHANGED
@@ -4,11 +4,12 @@ import pandas as pd
|
|
4 |
import duckdb
|
5 |
import logging
|
6 |
|
7 |
-
from tabs.
|
8 |
get_extreme_cases,
|
9 |
)
|
10 |
from tabs.dist_gap import (
|
11 |
get_distribution_plot,
|
|
|
12 |
get_correlation_map,
|
13 |
get_kde_with_trades,
|
14 |
get_kde_with_total_bet_amount,
|
@@ -76,16 +77,6 @@ with demo:
|
|
76 |
f"Market id = {best_market_id} Dist gap = {round(best_gap,2)}"
|
77 |
)
|
78 |
with gr.Row():
|
79 |
-
# with gr.Column(min_width=350):
|
80 |
-
# gr.Markdown("# Evolution of outcomes probability based on tokens")
|
81 |
-
# best_market_tokens_dist = get_based_tokens_distribution(
|
82 |
-
# best_market_id, live_markets_data
|
83 |
-
# )
|
84 |
-
# with gr.Column(min_width=350):
|
85 |
-
# gr.Markdown("# Evolution of outcomes probability based on votes")
|
86 |
-
# best_market_votes_dist = get_based_votes_distribution(
|
87 |
-
# best_market_id, live_markets_data
|
88 |
-
# )
|
89 |
best_case = get_dist_gap_time_evolution(
|
90 |
best_market_id, live_markets_data
|
91 |
)
|
@@ -98,19 +89,16 @@ with demo:
|
|
98 |
)
|
99 |
|
100 |
with gr.Row():
|
101 |
-
# with gr.Column(min_width=350):
|
102 |
-
# # gr.Markdown("# Evolution of outcomes probability based on tokens")
|
103 |
-
# worst_market_tokens_dist = get_based_tokens_distribution(
|
104 |
-
# worst_market_id, live_markets_data
|
105 |
-
# )
|
106 |
-
# with gr.Column(min_width=350):
|
107 |
-
# worst_market_votes_dist = get_based_votes_distribution(
|
108 |
-
# worst_market_id, live_markets_data
|
109 |
-
# )
|
110 |
-
|
111 |
worst_case = get_dist_gap_time_evolution(
|
112 |
worst_market_id, live_markets_data
|
113 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
with gr.TabItem("📏 Distribution gap metric for all markets"):
|
116 |
# remove samples with no trades
|
|
|
4 |
import duckdb
|
5 |
import logging
|
6 |
|
7 |
+
from olas_predict_live_markets.tabs.tokens_dist import (
|
8 |
get_extreme_cases,
|
9 |
)
|
10 |
from tabs.dist_gap import (
|
11 |
get_distribution_plot,
|
12 |
+
get_avg_gap_time_evolution,
|
13 |
get_correlation_map,
|
14 |
get_kde_with_trades,
|
15 |
get_kde_with_total_bet_amount,
|
|
|
77 |
f"Market id = {best_market_id} Dist gap = {round(best_gap,2)}"
|
78 |
)
|
79 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
best_case = get_dist_gap_time_evolution(
|
81 |
best_market_id, live_markets_data
|
82 |
)
|
|
|
89 |
)
|
90 |
|
91 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
worst_case = get_dist_gap_time_evolution(
|
93 |
worst_market_id, live_markets_data
|
94 |
)
|
95 |
+
with gr.Row():
|
96 |
+
gr.Markdown(
|
97 |
+
"Time evolution of the average distribution gap percentage of all markets"
|
98 |
+
)
|
99 |
+
|
100 |
+
with gr.Row():
|
101 |
+
mean_plot = get_avg_gap_time_evolution(markets_data)
|
102 |
|
103 |
with gr.TabItem("📏 Distribution gap metric for all markets"):
|
104 |
# remove samples with no trades
|
notebooks/analysis_of_markets_data.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 |
{
|
@@ -49,8 +49,6 @@
|
|
49 |
" <th>open</th>\n",
|
50 |
" <th>total_trades</th>\n",
|
51 |
" <th>...</th>\n",
|
52 |
-
" <th>votes_second_outcome_perc</th>\n",
|
53 |
-
" <th>first_outcome</th>\n",
|
54 |
" <th>second_outcome</th>\n",
|
55 |
" <th>sample_datetime</th>\n",
|
56 |
" <th>first_token_perc</th>\n",
|
@@ -59,6 +57,8 @@
|
|
59 |
" <th>total_bet_amount</th>\n",
|
60 |
" <th>price_weighted_first_outcome_perc</th>\n",
|
61 |
" <th>price_weighted_second_outcome_perc</th>\n",
|
|
|
|
|
62 |
" </tr>\n",
|
63 |
" </thead>\n",
|
64 |
" <tbody>\n",
|
@@ -66,121 +66,121 @@
|
|
66 |
" <th>0</th>\n",
|
67 |
" <td>1724201135</td>\n",
|
68 |
" <td>0x241d212b45ae3ecb2809421df1f3cff2bb2988f0</td>\n",
|
69 |
-
" <td>
|
70 |
-
" <td>
|
71 |
" <td>1724630400</td>\n",
|
72 |
-
" <td>[
|
73 |
" <td>Will SpaceX successfully send four people on a...</td>\n",
|
74 |
-
" <td>
|
75 |
" <td>True</td>\n",
|
76 |
-
" <td>
|
77 |
" <td>...</td>\n",
|
78 |
-
" <td>0.0</td>\n",
|
79 |
-
" <td>Yes</td>\n",
|
80 |
" <td>No</td>\n",
|
81 |
-
" <td>2024-08-
|
82 |
-
" <td>
|
83 |
-
" <td>
|
84 |
-
" <td>0.
|
85 |
-
" <td>
|
86 |
-
" <td>67
|
87 |
-
" <td>
|
|
|
|
|
88 |
" </tr>\n",
|
89 |
" <tr>\n",
|
90 |
" <th>1</th>\n",
|
91 |
-
" <td>
|
92 |
-
" <td>
|
93 |
-
" <td>
|
94 |
-
" <td>
|
95 |
-
" <td>
|
96 |
-
" <td>[
|
97 |
-
" <td>Will
|
98 |
-
" <td>
|
99 |
" <td>True</td>\n",
|
100 |
-
" <td>
|
101 |
" <td>...</td>\n",
|
102 |
-
" <td>0.0</td>\n",
|
103 |
-
" <td>Yes</td>\n",
|
104 |
" <td>No</td>\n",
|
105 |
-
" <td>2024-08-
|
106 |
-
" <td>
|
107 |
-
" <td>
|
108 |
-
" <td>
|
109 |
-
" <td>
|
110 |
-
" <td>
|
111 |
-
" <td>
|
|
|
|
|
112 |
" </tr>\n",
|
113 |
" <tr>\n",
|
114 |
" <th>2</th>\n",
|
115 |
-
" <td>
|
116 |
-
" <td>
|
117 |
-
" <td>
|
118 |
" <td>7000000000000000003</td>\n",
|
119 |
-
" <td>
|
120 |
-
" <td>[
|
121 |
-
" <td>Will
|
122 |
-
" <td>
|
123 |
" <td>True</td>\n",
|
124 |
-
" <td>
|
125 |
" <td>...</td>\n",
|
126 |
-
" <td>0.0</td>\n",
|
127 |
-
" <td>Yes</td>\n",
|
128 |
" <td>No</td>\n",
|
129 |
-
" <td>2024-08-
|
130 |
-
" <td>
|
131 |
-
" <td>
|
132 |
-
" <td>
|
133 |
-
" <td>6.
|
134 |
-
" <td>
|
135 |
-
" <td>
|
|
|
|
|
136 |
" </tr>\n",
|
137 |
" <tr>\n",
|
138 |
" <th>3</th>\n",
|
139 |
-
" <td>
|
140 |
-
" <td>
|
141 |
-
" <td>
|
142 |
" <td>7000000000000000001</td>\n",
|
143 |
-
" <td>
|
144 |
-
" <td>[
|
145 |
-
" <td>Will the
|
146 |
-
" <td>
|
147 |
" <td>True</td>\n",
|
148 |
-
" <td>
|
149 |
" <td>...</td>\n",
|
150 |
-
" <td>0.0</td>\n",
|
151 |
-
" <td>Yes</td>\n",
|
152 |
" <td>No</td>\n",
|
153 |
-
" <td>2024-08-
|
154 |
-
" <td>
|
155 |
-
" <td>
|
156 |
-
" <td>
|
157 |
-
" <td>2.
|
158 |
-
" <td>
|
159 |
-
" <td>
|
|
|
|
|
160 |
" </tr>\n",
|
161 |
" <tr>\n",
|
162 |
" <th>4</th>\n",
|
163 |
-
" <td>
|
164 |
-
" <td>
|
165 |
-
" <td>
|
166 |
-
" <td>
|
167 |
-
" <td>
|
168 |
-
" <td>[
|
169 |
-
" <td>Will
|
170 |
-
" <td>
|
171 |
" <td>True</td>\n",
|
172 |
-
" <td>
|
173 |
" <td>...</td>\n",
|
174 |
-
" <td>0.0</td>\n",
|
175 |
-
" <td>Yes</td>\n",
|
176 |
" <td>No</td>\n",
|
177 |
-
" <td>2024-08-
|
178 |
-
" <td>
|
179 |
-
" <td>
|
180 |
-
" <td>
|
181 |
-
" <td>5.
|
182 |
-
" <td>
|
183 |
-
" <td>
|
|
|
|
|
184 |
" </tr>\n",
|
185 |
" </tbody>\n",
|
186 |
"</table>\n",
|
@@ -190,64 +190,64 @@
|
|
190 |
"text/plain": [
|
191 |
" creationTimestamp id \\\n",
|
192 |
"0 1724201135 0x241d212b45ae3ecb2809421df1f3cff2bb2988f0 \n",
|
193 |
-
"1
|
194 |
-
"2
|
195 |
-
"3
|
196 |
-
"4
|
197 |
"\n",
|
198 |
" liquidityMeasure liquidityParameter openingTimestamp \\\n",
|
199 |
-
"0
|
200 |
-
"1
|
201 |
-
"2
|
202 |
-
"3
|
203 |
-
"4
|
204 |
"\n",
|
205 |
" outcomeTokenAmounts \\\n",
|
206 |
-
"0 [
|
207 |
-
"1
|
208 |
-
"2 [
|
209 |
-
"3 [
|
210 |
-
"4 [
|
211 |
"\n",
|
212 |
" title sample_timestamp open \\\n",
|
213 |
-
"0 Will SpaceX successfully send four people on a...
|
214 |
-
"1 Will
|
215 |
-
"2 Will
|
216 |
-
"3 Will the
|
217 |
-
"4 Will
|
218 |
"\n",
|
219 |
-
" total_trades ...
|
220 |
-
"0
|
221 |
-
"1
|
222 |
-
"2
|
223 |
-
"3
|
224 |
-
"4
|
225 |
"\n",
|
226 |
-
"
|
227 |
-
"0
|
228 |
-
"1
|
229 |
-
"2
|
230 |
-
"3
|
231 |
-
"4
|
232 |
"\n",
|
233 |
-
"
|
234 |
-
"0
|
235 |
-
"1
|
236 |
-
"2
|
237 |
-
"3
|
238 |
-
"4
|
239 |
"\n",
|
240 |
-
"
|
241 |
-
"0
|
242 |
-
"1
|
243 |
-
"2
|
244 |
-
"3
|
245 |
-
"4
|
246 |
"\n",
|
247 |
"[5 rows x 22 columns]"
|
248 |
]
|
249 |
},
|
250 |
-
"execution_count":
|
251 |
"metadata": {},
|
252 |
"output_type": "execute_result"
|
253 |
}
|
@@ -259,7 +259,7 @@
|
|
259 |
},
|
260 |
{
|
261 |
"cell_type": "code",
|
262 |
-
"execution_count":
|
263 |
"metadata": {},
|
264 |
"outputs": [
|
265 |
{
|
@@ -276,8 +276,6 @@
|
|
276 |
"open 0\n",
|
277 |
"total_trades 0\n",
|
278 |
"dist_gap_perc 0\n",
|
279 |
-
"votes_first_outcome_perc 0\n",
|
280 |
-
"votes_second_outcome_perc 0\n",
|
281 |
"first_outcome 0\n",
|
282 |
"second_outcome 0\n",
|
283 |
"sample_datetime 0\n",
|
@@ -287,10 +285,12 @@
|
|
287 |
"total_bet_amount 0\n",
|
288 |
"price_weighted_first_outcome_perc 0\n",
|
289 |
"price_weighted_second_outcome_perc 0\n",
|
|
|
|
|
290 |
"dtype: int64"
|
291 |
]
|
292 |
},
|
293 |
-
"execution_count":
|
294 |
"metadata": {},
|
295 |
"output_type": "execute_result"
|
296 |
}
|
@@ -301,7 +301,14 @@
|
|
301 |
},
|
302 |
{
|
303 |
"cell_type": "code",
|
304 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
"metadata": {},
|
306 |
"outputs": [
|
307 |
{
|
@@ -309,34 +316,34 @@
|
|
309 |
"output_type": "stream",
|
310 |
"text": [
|
311 |
"<class 'pandas.core.frame.DataFrame'>\n",
|
312 |
-
"RangeIndex:
|
313 |
"Data columns (total 22 columns):\n",
|
314 |
" # Column Non-Null Count Dtype \n",
|
315 |
"--- ------ -------------- ----- \n",
|
316 |
-
" 0 creationTimestamp
|
317 |
-
" 1 id
|
318 |
-
" 2 liquidityMeasure
|
319 |
-
" 3 liquidityParameter
|
320 |
-
" 4 openingTimestamp
|
321 |
-
" 5 outcomeTokenAmounts
|
322 |
-
" 6 title
|
323 |
-
" 7 sample_timestamp
|
324 |
-
" 8 open
|
325 |
-
" 9 total_trades
|
326 |
-
" 10 dist_gap_perc
|
327 |
-
" 11
|
328 |
-
" 12
|
329 |
-
" 13
|
330 |
-
" 14
|
331 |
-
" 15
|
332 |
-
" 16
|
333 |
-
" 17
|
334 |
-
" 18
|
335 |
-
" 19
|
336 |
-
" 20
|
337 |
-
" 21
|
338 |
"dtypes: bool(1), datetime64[ns](1), float64(9), int64(3), object(8)\n",
|
339 |
-
"memory usage:
|
340 |
]
|
341 |
}
|
342 |
],
|
@@ -346,19 +353,18 @@
|
|
346 |
},
|
347 |
{
|
348 |
"cell_type": "code",
|
349 |
-
"execution_count":
|
350 |
"metadata": {},
|
351 |
"outputs": [
|
352 |
{
|
353 |
"data": {
|
354 |
"text/plain": [
|
355 |
"sample_timestamp\n",
|
356 |
-
"
|
357 |
-
"1724253161 41\n",
|
358 |
"Name: count, dtype: int64"
|
359 |
]
|
360 |
},
|
361 |
-
"execution_count":
|
362 |
"metadata": {},
|
363 |
"output_type": "execute_result"
|
364 |
}
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 30,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
14 |
},
|
15 |
{
|
16 |
"cell_type": "code",
|
17 |
+
"execution_count": 32,
|
18 |
"metadata": {},
|
19 |
"outputs": [
|
20 |
{
|
|
|
49 |
" <th>open</th>\n",
|
50 |
" <th>total_trades</th>\n",
|
51 |
" <th>...</th>\n",
|
|
|
|
|
52 |
" <th>second_outcome</th>\n",
|
53 |
" <th>sample_datetime</th>\n",
|
54 |
" <th>first_token_perc</th>\n",
|
|
|
57 |
" <th>total_bet_amount</th>\n",
|
58 |
" <th>price_weighted_first_outcome_perc</th>\n",
|
59 |
" <th>price_weighted_second_outcome_perc</th>\n",
|
60 |
+
" <th>bought_tokens_first_perc</th>\n",
|
61 |
+
" <th>bought_tokens_second_perc</th>\n",
|
62 |
" </tr>\n",
|
63 |
" </thead>\n",
|
64 |
" <tbody>\n",
|
|
|
66 |
" <th>0</th>\n",
|
67 |
" <td>1724201135</td>\n",
|
68 |
" <td>0x241d212b45ae3ecb2809421df1f3cff2bb2988f0</td>\n",
|
69 |
+
" <td>6861664707883062434</td>\n",
|
70 |
+
" <td>7000000000000000008</td>\n",
|
71 |
" <td>1724630400</td>\n",
|
72 |
+
" <td>[5728447658624505774, 8553800771178854358]</td>\n",
|
73 |
" <td>Will SpaceX successfully send four people on a...</td>\n",
|
74 |
+
" <td>1724320709</td>\n",
|
75 |
" <td>True</td>\n",
|
76 |
+
" <td>25</td>\n",
|
77 |
" <td>...</td>\n",
|
|
|
|
|
78 |
" <td>No</td>\n",
|
79 |
+
" <td>2024-08-22 11:58:29</td>\n",
|
80 |
+
" <td>59.89</td>\n",
|
81 |
+
" <td>40.11</td>\n",
|
82 |
+
" <td>0.398600</td>\n",
|
83 |
+
" <td>9.965</td>\n",
|
84 |
+
" <td>62.67</td>\n",
|
85 |
+
" <td>37.33</td>\n",
|
86 |
+
" <td>57.34</td>\n",
|
87 |
+
" <td>42.66</td>\n",
|
88 |
" </tr>\n",
|
89 |
" <tr>\n",
|
90 |
" <th>1</th>\n",
|
91 |
+
" <td>1724286555</td>\n",
|
92 |
+
" <td>0x2ed5a1a207b1e9b1c17a1c2baf64647c3db9d1f6</td>\n",
|
93 |
+
" <td>6764194343046296637</td>\n",
|
94 |
+
" <td>7000000000000000001</td>\n",
|
95 |
+
" <td>1724716800</td>\n",
|
96 |
+
" <td>[9108406198169923801, 5379645893465440960]</td>\n",
|
97 |
+
" <td>Will there be a significant increase in the pu...</td>\n",
|
98 |
+
" <td>1724320709</td>\n",
|
99 |
" <td>True</td>\n",
|
100 |
+
" <td>6</td>\n",
|
101 |
" <td>...</td>\n",
|
|
|
|
|
102 |
" <td>No</td>\n",
|
103 |
+
" <td>2024-08-22 11:58:29</td>\n",
|
104 |
+
" <td>37.13</td>\n",
|
105 |
+
" <td>62.87</td>\n",
|
106 |
+
" <td>0.411333</td>\n",
|
107 |
+
" <td>2.468</td>\n",
|
108 |
+
" <td>6.48</td>\n",
|
109 |
+
" <td>93.52</td>\n",
|
110 |
+
" <td>7.13</td>\n",
|
111 |
+
" <td>92.87</td>\n",
|
112 |
" </tr>\n",
|
113 |
" <tr>\n",
|
114 |
" <th>2</th>\n",
|
115 |
+
" <td>1724199465</td>\n",
|
116 |
+
" <td>0x320f9768e0fe0d328a9a2c8464f12959b16e5194</td>\n",
|
117 |
+
" <td>5657370332642200804</td>\n",
|
118 |
" <td>7000000000000000003</td>\n",
|
119 |
+
" <td>1724630400</td>\n",
|
120 |
+
" <td>[3560526624520056083, 13762009154082647147]</td>\n",
|
121 |
+
" <td>Will the World War II-era bomb in Northern Ire...</td>\n",
|
122 |
+
" <td>1724320709</td>\n",
|
123 |
" <td>True</td>\n",
|
124 |
+
" <td>6</td>\n",
|
125 |
" <td>...</td>\n",
|
|
|
|
|
126 |
" <td>No</td>\n",
|
127 |
+
" <td>2024-08-22 11:58:29</td>\n",
|
128 |
+
" <td>79.45</td>\n",
|
129 |
+
" <td>20.55</td>\n",
|
130 |
+
" <td>1.150000</td>\n",
|
131 |
+
" <td>6.900</td>\n",
|
132 |
+
" <td>100.00</td>\n",
|
133 |
+
" <td>0.00</td>\n",
|
134 |
+
" <td>100.00</td>\n",
|
135 |
+
" <td>0.00</td>\n",
|
136 |
" </tr>\n",
|
137 |
" <tr>\n",
|
138 |
" <th>3</th>\n",
|
139 |
+
" <td>1724287075</td>\n",
|
140 |
+
" <td>0x3c4a1acefa3049f6de2b212fa3141f46b0b5823f</td>\n",
|
141 |
+
" <td>6755535026140294583</td>\n",
|
142 |
" <td>7000000000000000001</td>\n",
|
143 |
+
" <td>1724716800</td>\n",
|
144 |
+
" <td>[5353172588127988920, 9153450443325863452]</td>\n",
|
145 |
+
" <td>Will the human remains found on the Michigan m...</td>\n",
|
146 |
+
" <td>1724320709</td>\n",
|
147 |
" <td>True</td>\n",
|
148 |
+
" <td>4</td>\n",
|
149 |
" <td>...</td>\n",
|
|
|
|
|
150 |
" <td>No</td>\n",
|
151 |
+
" <td>2024-08-22 11:58:29</td>\n",
|
152 |
+
" <td>63.10</td>\n",
|
153 |
+
" <td>36.90</td>\n",
|
154 |
+
" <td>0.628500</td>\n",
|
155 |
+
" <td>2.514</td>\n",
|
156 |
+
" <td>93.64</td>\n",
|
157 |
+
" <td>6.36</td>\n",
|
158 |
+
" <td>92.98</td>\n",
|
159 |
+
" <td>7.02</td>\n",
|
160 |
" </tr>\n",
|
161 |
" <tr>\n",
|
162 |
" <th>4</th>\n",
|
163 |
+
" <td>1724285320</td>\n",
|
164 |
+
" <td>0x3fc60512d8fff2a565155ee05aef0d2a79fcec23</td>\n",
|
165 |
+
" <td>5975716542231801351</td>\n",
|
166 |
+
" <td>7000000000000000002</td>\n",
|
167 |
+
" <td>1724716800</td>\n",
|
168 |
+
" <td>[12470403414325965877, 3929303517455492411]</td>\n",
|
169 |
+
" <td>Will Ethan Holliday be drafted in the 2025 MLB...</td>\n",
|
170 |
+
" <td>1724320709</td>\n",
|
171 |
" <td>True</td>\n",
|
172 |
+
" <td>4</td>\n",
|
173 |
" <td>...</td>\n",
|
|
|
|
|
174 |
" <td>No</td>\n",
|
175 |
+
" <td>2024-08-22 11:58:29</td>\n",
|
176 |
+
" <td>23.96</td>\n",
|
177 |
+
" <td>76.04</td>\n",
|
178 |
+
" <td>1.395750</td>\n",
|
179 |
+
" <td>5.583</td>\n",
|
180 |
+
" <td>0.00</td>\n",
|
181 |
+
" <td>100.00</td>\n",
|
182 |
+
" <td>0.00</td>\n",
|
183 |
+
" <td>100.00</td>\n",
|
184 |
" </tr>\n",
|
185 |
" </tbody>\n",
|
186 |
"</table>\n",
|
|
|
190 |
"text/plain": [
|
191 |
" creationTimestamp id \\\n",
|
192 |
"0 1724201135 0x241d212b45ae3ecb2809421df1f3cff2bb2988f0 \n",
|
193 |
+
"1 1724286555 0x2ed5a1a207b1e9b1c17a1c2baf64647c3db9d1f6 \n",
|
194 |
+
"2 1724199465 0x320f9768e0fe0d328a9a2c8464f12959b16e5194 \n",
|
195 |
+
"3 1724287075 0x3c4a1acefa3049f6de2b212fa3141f46b0b5823f \n",
|
196 |
+
"4 1724285320 0x3fc60512d8fff2a565155ee05aef0d2a79fcec23 \n",
|
197 |
"\n",
|
198 |
" liquidityMeasure liquidityParameter openingTimestamp \\\n",
|
199 |
+
"0 6861664707883062434 7000000000000000008 1724630400 \n",
|
200 |
+
"1 6764194343046296637 7000000000000000001 1724716800 \n",
|
201 |
+
"2 5657370332642200804 7000000000000000003 1724630400 \n",
|
202 |
+
"3 6755535026140294583 7000000000000000001 1724716800 \n",
|
203 |
+
"4 5975716542231801351 7000000000000000002 1724716800 \n",
|
204 |
"\n",
|
205 |
" outcomeTokenAmounts \\\n",
|
206 |
+
"0 [5728447658624505774, 8553800771178854358] \n",
|
207 |
+
"1 [9108406198169923801, 5379645893465440960] \n",
|
208 |
+
"2 [3560526624520056083, 13762009154082647147] \n",
|
209 |
+
"3 [5353172588127988920, 9153450443325863452] \n",
|
210 |
+
"4 [12470403414325965877, 3929303517455492411] \n",
|
211 |
"\n",
|
212 |
" title sample_timestamp open \\\n",
|
213 |
+
"0 Will SpaceX successfully send four people on a... 1724320709 True \n",
|
214 |
+
"1 Will there be a significant increase in the pu... 1724320709 True \n",
|
215 |
+
"2 Will the World War II-era bomb in Northern Ire... 1724320709 True \n",
|
216 |
+
"3 Will the human remains found on the Michigan m... 1724320709 True \n",
|
217 |
+
"4 Will Ethan Holliday be drafted in the 2025 MLB... 1724320709 True \n",
|
218 |
"\n",
|
219 |
+
" total_trades ... second_outcome sample_datetime first_token_perc \\\n",
|
220 |
+
"0 25 ... No 2024-08-22 11:58:29 59.89 \n",
|
221 |
+
"1 6 ... No 2024-08-22 11:58:29 37.13 \n",
|
222 |
+
"2 6 ... No 2024-08-22 11:58:29 79.45 \n",
|
223 |
+
"3 4 ... No 2024-08-22 11:58:29 63.10 \n",
|
224 |
+
"4 4 ... No 2024-08-22 11:58:29 23.96 \n",
|
225 |
"\n",
|
226 |
+
" second_token_perc mean_trade_size total_bet_amount \\\n",
|
227 |
+
"0 40.11 0.398600 9.965 \n",
|
228 |
+
"1 62.87 0.411333 2.468 \n",
|
229 |
+
"2 20.55 1.150000 6.900 \n",
|
230 |
+
"3 36.90 0.628500 2.514 \n",
|
231 |
+
"4 76.04 1.395750 5.583 \n",
|
232 |
"\n",
|
233 |
+
" price_weighted_first_outcome_perc price_weighted_second_outcome_perc \\\n",
|
234 |
+
"0 62.67 37.33 \n",
|
235 |
+
"1 6.48 93.52 \n",
|
236 |
+
"2 100.00 0.00 \n",
|
237 |
+
"3 93.64 6.36 \n",
|
238 |
+
"4 0.00 100.00 \n",
|
239 |
"\n",
|
240 |
+
" bought_tokens_first_perc bought_tokens_second_perc \n",
|
241 |
+
"0 57.34 42.66 \n",
|
242 |
+
"1 7.13 92.87 \n",
|
243 |
+
"2 100.00 0.00 \n",
|
244 |
+
"3 92.98 7.02 \n",
|
245 |
+
"4 0.00 100.00 \n",
|
246 |
"\n",
|
247 |
"[5 rows x 22 columns]"
|
248 |
]
|
249 |
},
|
250 |
+
"execution_count": 32,
|
251 |
"metadata": {},
|
252 |
"output_type": "execute_result"
|
253 |
}
|
|
|
259 |
},
|
260 |
{
|
261 |
"cell_type": "code",
|
262 |
+
"execution_count": 33,
|
263 |
"metadata": {},
|
264 |
"outputs": [
|
265 |
{
|
|
|
276 |
"open 0\n",
|
277 |
"total_trades 0\n",
|
278 |
"dist_gap_perc 0\n",
|
|
|
|
|
279 |
"first_outcome 0\n",
|
280 |
"second_outcome 0\n",
|
281 |
"sample_datetime 0\n",
|
|
|
285 |
"total_bet_amount 0\n",
|
286 |
"price_weighted_first_outcome_perc 0\n",
|
287 |
"price_weighted_second_outcome_perc 0\n",
|
288 |
+
"bought_tokens_first_perc 0\n",
|
289 |
+
"bought_tokens_second_perc 0\n",
|
290 |
"dtype: int64"
|
291 |
]
|
292 |
},
|
293 |
+
"execution_count": 33,
|
294 |
"metadata": {},
|
295 |
"output_type": "execute_result"
|
296 |
}
|
|
|
301 |
},
|
302 |
{
|
303 |
"cell_type": "code",
|
304 |
+
"execution_count": null,
|
305 |
+
"metadata": {},
|
306 |
+
"outputs": [],
|
307 |
+
"source": []
|
308 |
+
},
|
309 |
+
{
|
310 |
+
"cell_type": "code",
|
311 |
+
"execution_count": 34,
|
312 |
"metadata": {},
|
313 |
"outputs": [
|
314 |
{
|
|
|
316 |
"output_type": "stream",
|
317 |
"text": [
|
318 |
"<class 'pandas.core.frame.DataFrame'>\n",
|
319 |
+
"RangeIndex: 41 entries, 0 to 40\n",
|
320 |
"Data columns (total 22 columns):\n",
|
321 |
" # Column Non-Null Count Dtype \n",
|
322 |
"--- ------ -------------- ----- \n",
|
323 |
+
" 0 creationTimestamp 41 non-null object \n",
|
324 |
+
" 1 id 41 non-null object \n",
|
325 |
+
" 2 liquidityMeasure 41 non-null int64 \n",
|
326 |
+
" 3 liquidityParameter 41 non-null object \n",
|
327 |
+
" 4 openingTimestamp 41 non-null object \n",
|
328 |
+
" 5 outcomeTokenAmounts 41 non-null object \n",
|
329 |
+
" 6 title 41 non-null object \n",
|
330 |
+
" 7 sample_timestamp 41 non-null int64 \n",
|
331 |
+
" 8 open 41 non-null bool \n",
|
332 |
+
" 9 total_trades 41 non-null int64 \n",
|
333 |
+
" 10 dist_gap_perc 41 non-null float64 \n",
|
334 |
+
" 11 first_outcome 41 non-null object \n",
|
335 |
+
" 12 second_outcome 41 non-null object \n",
|
336 |
+
" 13 sample_datetime 41 non-null datetime64[ns]\n",
|
337 |
+
" 14 first_token_perc 41 non-null float64 \n",
|
338 |
+
" 15 second_token_perc 41 non-null float64 \n",
|
339 |
+
" 16 mean_trade_size 41 non-null float64 \n",
|
340 |
+
" 17 total_bet_amount 41 non-null float64 \n",
|
341 |
+
" 18 price_weighted_first_outcome_perc 41 non-null float64 \n",
|
342 |
+
" 19 price_weighted_second_outcome_perc 41 non-null float64 \n",
|
343 |
+
" 20 bought_tokens_first_perc 41 non-null float64 \n",
|
344 |
+
" 21 bought_tokens_second_perc 41 non-null float64 \n",
|
345 |
"dtypes: bool(1), datetime64[ns](1), float64(9), int64(3), object(8)\n",
|
346 |
+
"memory usage: 6.9+ KB\n"
|
347 |
]
|
348 |
}
|
349 |
],
|
|
|
353 |
},
|
354 |
{
|
355 |
"cell_type": "code",
|
356 |
+
"execution_count": 35,
|
357 |
"metadata": {},
|
358 |
"outputs": [
|
359 |
{
|
360 |
"data": {
|
361 |
"text/plain": [
|
362 |
"sample_timestamp\n",
|
363 |
+
"1724320709 41\n",
|
|
|
364 |
"Name: count, dtype: int64"
|
365 |
]
|
366 |
},
|
367 |
+
"execution_count": 35,
|
368 |
"metadata": {},
|
369 |
"output_type": "execute_result"
|
370 |
}
|
tabs/dist_gap.py
CHANGED
@@ -34,6 +34,33 @@ def get_dist_gap_time_evolution(market_id: str, all_markets: pd.DataFrame):
|
|
34 |
)
|
35 |
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
def get_top_best_behaviour_markets(markets_data: pd.DataFrame):
|
38 |
"""Function to paint the top markets with the lowest metric of distribution gap"""
|
39 |
sorted_data = markets_data.sort_values(by="dist_gap_perc", ascending=False)
|
|
|
34 |
)
|
35 |
|
36 |
|
37 |
+
def get_avg_gap_time_evolution(all_markets: pd.DataFrame):
|
38 |
+
avg_dist_gap_perc = (
|
39 |
+
all_markets.groupby("sample_datetime")["dist_gap_perc"].mean().reset_index()
|
40 |
+
)
|
41 |
+
avg_dist_gap_perc["sample_datetime"] = avg_dist_gap_perc["sample_datetime"].astype(
|
42 |
+
str
|
43 |
+
)
|
44 |
+
avg_dist_gap_perc.rename(
|
45 |
+
columns={"dist_gap_perc": "mean_dist_gap_perc"}, inplace=True
|
46 |
+
)
|
47 |
+
avg_dist_gap_perc.columns = avg_dist_gap_perc.columns.astype(str)
|
48 |
+
return gr.LinePlot(
|
49 |
+
value=avg_dist_gap_perc,
|
50 |
+
x="sample_datetime",
|
51 |
+
y="mean_dist_gap_perc",
|
52 |
+
y_title="Mean dist gap percentage (%)",
|
53 |
+
interactive=True,
|
54 |
+
show_actions_button=True,
|
55 |
+
tooltip=[
|
56 |
+
"sample_datetime",
|
57 |
+
"mean_dist_gap_perc",
|
58 |
+
],
|
59 |
+
height=HEIGHT,
|
60 |
+
width=WIDTH,
|
61 |
+
)
|
62 |
+
|
63 |
+
|
64 |
def get_top_best_behaviour_markets(markets_data: pd.DataFrame):
|
65 |
"""Function to paint the top markets with the lowest metric of distribution gap"""
|
66 |
sorted_data = markets_data.sort_values(by="dist_gap_perc", ascending=False)
|
tabs/{tokens_pwc_dist.py → tokens_dist.py}
RENAMED
File without changes
|