cyberosa
commited on
Commit
·
d125423
1
Parent(s):
ddd4c40
gap decimals and filter of trades
Browse files- app.py +9 -3
- notebooks/analysis_of_markets_data.ipynb +0 -0
- notebooks/research_on_specific_markets.ipynb +51 -51
- tabs/tokens_votes_dist.py +7 -13
app.py
CHANGED
@@ -60,7 +60,8 @@ def prepare_data():
|
|
60 |
demo = gr.Blocks()
|
61 |
markets_data = prepare_data()
|
62 |
live_markets_data = markets_data.loc[markets_data["open"] == True]
|
63 |
-
|
|
|
64 |
with demo:
|
65 |
gr.HTML("<h1>Olas Predict Live Markets </h1>")
|
66 |
gr.Markdown("This app shows the distributions of predictions on the live markets.")
|
@@ -72,7 +73,9 @@ with demo:
|
|
72 |
with gr.Row():
|
73 |
gr.Markdown("Best case: a market with a low gap between distributions")
|
74 |
with gr.Row():
|
75 |
-
gr.Markdown(
|
|
|
|
|
76 |
with gr.Row():
|
77 |
with gr.Column(min_width=350):
|
78 |
gr.Markdown("# Evolution of outcomes probability based on tokens")
|
@@ -88,7 +91,9 @@ with demo:
|
|
88 |
with gr.Row():
|
89 |
gr.Markdown("Worst case: a market with a high distribution gap metric")
|
90 |
with gr.Row():
|
91 |
-
gr.Markdown(
|
|
|
|
|
92 |
|
93 |
with gr.Row():
|
94 |
with gr.Column(min_width=350):
|
@@ -102,6 +107,7 @@ with demo:
|
|
102 |
)
|
103 |
|
104 |
with gr.TabItem("📏 Distribution gap metric"):
|
|
|
105 |
with gr.Row():
|
106 |
gr.Markdown(
|
107 |
"This metric measures the difference between the probability distribution based on the tokens distribution and the one based on the votes distribution"
|
|
|
60 |
demo = gr.Blocks()
|
61 |
markets_data = prepare_data()
|
62 |
live_markets_data = markets_data.loc[markets_data["open"] == True]
|
63 |
+
# filter only those with trades
|
64 |
+
markets_data = markets_data.loc[markets_data["total_trades"] > 0]
|
65 |
with demo:
|
66 |
gr.HTML("<h1>Olas Predict Live Markets </h1>")
|
67 |
gr.Markdown("This app shows the distributions of predictions on the live markets.")
|
|
|
73 |
with gr.Row():
|
74 |
gr.Markdown("Best case: a market with a low gap between distributions")
|
75 |
with gr.Row():
|
76 |
+
gr.Markdown(
|
77 |
+
f"Market id = {best_market_id} Dist gap = {round(best_gap,2)}"
|
78 |
+
)
|
79 |
with gr.Row():
|
80 |
with gr.Column(min_width=350):
|
81 |
gr.Markdown("# Evolution of outcomes probability based on tokens")
|
|
|
91 |
with gr.Row():
|
92 |
gr.Markdown("Worst case: a market with a high distribution gap metric")
|
93 |
with gr.Row():
|
94 |
+
gr.Markdown(
|
95 |
+
f"Market id = {worst_market_id} Dist gap = {round(worst_gap,2)}"
|
96 |
+
)
|
97 |
|
98 |
with gr.Row():
|
99 |
with gr.Column(min_width=350):
|
|
|
107 |
)
|
108 |
|
109 |
with gr.TabItem("📏 Distribution gap metric"):
|
110 |
+
# remove samples with no trades
|
111 |
with gr.Row():
|
112 |
gr.Markdown(
|
113 |
"This metric measures the difference between the probability distribution based on the tokens distribution and the one based on the votes distribution"
|
notebooks/analysis_of_markets_data.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/research_on_specific_markets.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 |
{
|
@@ -225,7 +225,7 @@
|
|
225 |
"4 50.32 NaN 2024-07-31 18:06:59 "
|
226 |
]
|
227 |
},
|
228 |
-
"execution_count":
|
229 |
"metadata": {},
|
230 |
"output_type": "execute_result"
|
231 |
}
|
@@ -279,16 +279,16 @@
|
|
279 |
},
|
280 |
{
|
281 |
"cell_type": "code",
|
282 |
-
"execution_count":
|
283 |
"metadata": {},
|
284 |
"outputs": [],
|
285 |
"source": [
|
286 |
-
"id = \"
|
287 |
]
|
288 |
},
|
289 |
{
|
290 |
"cell_type": "code",
|
291 |
-
"execution_count":
|
292 |
"metadata": {},
|
293 |
"outputs": [],
|
294 |
"source": [
|
@@ -297,7 +297,7 @@
|
|
297 |
},
|
298 |
{
|
299 |
"cell_type": "code",
|
300 |
-
"execution_count":
|
301 |
"metadata": {},
|
302 |
"outputs": [
|
303 |
{
|
@@ -344,48 +344,48 @@
|
|
344 |
" </thead>\n",
|
345 |
" <tbody>\n",
|
346 |
" <tr>\n",
|
347 |
-
" <th>
|
348 |
-
" <td>
|
349 |
-
" <td>
|
350 |
-
" <td>
|
351 |
-
" <td>
|
352 |
" <td>1722988800</td>\n",
|
353 |
-
" <td>[
|
354 |
-
" <td>Will
|
355 |
" <td>1722593849</td>\n",
|
356 |
" <td>True</td>\n",
|
357 |
-
" <td>
|
358 |
-
" <td>0.
|
359 |
" <td>50.00</td>\n",
|
360 |
" <td>50.00</td>\n",
|
361 |
" <td>Yes</td>\n",
|
362 |
" <td>No</td>\n",
|
363 |
-
" <td>
|
364 |
-
" <td>50.
|
365 |
-
" <td>0.
|
366 |
" <td>2024-08-02 12:17:29</td>\n",
|
367 |
" </tr>\n",
|
368 |
" <tr>\n",
|
369 |
-
" <th>
|
370 |
-
" <td>
|
371 |
-
" <td>
|
372 |
-
" <td>
|
373 |
-
" <td>
|
374 |
" <td>1722988800</td>\n",
|
375 |
-
" <td>[
|
376 |
-
" <td>Will
|
377 |
-
" <td>
|
378 |
" <td>True</td>\n",
|
379 |
-
" <td>
|
380 |
-
" <td>
|
381 |
-
" <td>
|
382 |
-
" <td>
|
383 |
" <td>Yes</td>\n",
|
384 |
" <td>No</td>\n",
|
385 |
-
" <td>
|
386 |
-
" <td>
|
387 |
-
" <td>0.
|
388 |
-
" <td>
|
389 |
" </tr>\n",
|
390 |
" </tbody>\n",
|
391 |
"</table>\n",
|
@@ -393,35 +393,35 @@
|
|
393 |
],
|
394 |
"text/plain": [
|
395 |
" creationTimestamp id \\\n",
|
396 |
-
"
|
397 |
-
"
|
398 |
"\n",
|
399 |
" liquidityMeasure liquidityParameter openingTimestamp \\\n",
|
400 |
-
"
|
401 |
-
"
|
402 |
"\n",
|
403 |
-
"
|
404 |
-
"
|
405 |
-
"
|
406 |
"\n",
|
407 |
" title sample_timestamp \\\n",
|
408 |
-
"
|
409 |
-
"
|
410 |
"\n",
|
411 |
" open total_trades dist_gap_perc votes_first_outcome_perc \\\n",
|
412 |
-
"
|
413 |
-
"
|
414 |
"\n",
|
415 |
" votes_second_outcome_perc first_outcome second_outcome first_token_perc \\\n",
|
416 |
-
"
|
417 |
-
"
|
418 |
"\n",
|
419 |
" second_token_perc mean_trade_size sample_datetime \n",
|
420 |
-
"
|
421 |
-
"
|
422 |
]
|
423 |
},
|
424 |
-
"execution_count":
|
425 |
"metadata": {},
|
426 |
"output_type": "execute_result"
|
427 |
}
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 12,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
14 |
},
|
15 |
{
|
16 |
"cell_type": "code",
|
17 |
+
"execution_count": 13,
|
18 |
"metadata": {},
|
19 |
"outputs": [
|
20 |
{
|
|
|
225 |
"4 50.32 NaN 2024-07-31 18:06:59 "
|
226 |
]
|
227 |
},
|
228 |
+
"execution_count": 13,
|
229 |
"metadata": {},
|
230 |
"output_type": "execute_result"
|
231 |
}
|
|
|
279 |
},
|
280 |
{
|
281 |
"cell_type": "code",
|
282 |
+
"execution_count": 14,
|
283 |
"metadata": {},
|
284 |
"outputs": [],
|
285 |
"source": [
|
286 |
+
"id = \"0xfc417a9bc90f15eb65f30368f5794e7b39f93e76\""
|
287 |
]
|
288 |
},
|
289 |
{
|
290 |
"cell_type": "code",
|
291 |
+
"execution_count": 15,
|
292 |
"metadata": {},
|
293 |
"outputs": [],
|
294 |
"source": [
|
|
|
297 |
},
|
298 |
{
|
299 |
"cell_type": "code",
|
300 |
+
"execution_count": 16,
|
301 |
"metadata": {},
|
302 |
"outputs": [
|
303 |
{
|
|
|
344 |
" </thead>\n",
|
345 |
" <tbody>\n",
|
346 |
" <tr>\n",
|
347 |
+
" <th>124</th>\n",
|
348 |
+
" <td>1722563105</td>\n",
|
349 |
+
" <td>0xfc417a9bc90f15eb65f30368f5794e7b39f93e76</td>\n",
|
350 |
+
" <td>6999779315564848653</td>\n",
|
351 |
+
" <td>7000000000000000001</td>\n",
|
352 |
" <td>1722988800</td>\n",
|
353 |
+
" <td>[7055806015023361612, 6944635367762128326]</td>\n",
|
354 |
+
" <td>Will the Canadian women's football officials b...</td>\n",
|
355 |
" <td>1722593849</td>\n",
|
356 |
" <td>True</td>\n",
|
357 |
+
" <td>2</td>\n",
|
358 |
+
" <td>0.40</td>\n",
|
359 |
" <td>50.00</td>\n",
|
360 |
" <td>50.00</td>\n",
|
361 |
" <td>Yes</td>\n",
|
362 |
" <td>No</td>\n",
|
363 |
+
" <td>49.60</td>\n",
|
364 |
+
" <td>50.40</td>\n",
|
365 |
+
" <td>0.13000</td>\n",
|
366 |
" <td>2024-08-02 12:17:29</td>\n",
|
367 |
" </tr>\n",
|
368 |
" <tr>\n",
|
369 |
+
" <th>167</th>\n",
|
370 |
+
" <td>1722563105</td>\n",
|
371 |
+
" <td>0xfc417a9bc90f15eb65f30368f5794e7b39f93e76</td>\n",
|
372 |
+
" <td>6511633178027486360</td>\n",
|
373 |
+
" <td>7000000000000000006</td>\n",
|
374 |
" <td>1722988800</td>\n",
|
375 |
+
" <td>[10286430731240040164, 4763557086053793703]</td>\n",
|
376 |
+
" <td>Will the Canadian women's football officials b...</td>\n",
|
377 |
+
" <td>1722852594</td>\n",
|
378 |
" <td>True</td>\n",
|
379 |
+
" <td>21</td>\n",
|
380 |
+
" <td>1.68</td>\n",
|
381 |
+
" <td>33.33</td>\n",
|
382 |
+
" <td>66.67</td>\n",
|
383 |
" <td>Yes</td>\n",
|
384 |
" <td>No</td>\n",
|
385 |
+
" <td>31.65</td>\n",
|
386 |
+
" <td>68.35</td>\n",
|
387 |
+
" <td>0.35881</td>\n",
|
388 |
+
" <td>2024-08-05 12:09:54</td>\n",
|
389 |
" </tr>\n",
|
390 |
" </tbody>\n",
|
391 |
"</table>\n",
|
|
|
393 |
],
|
394 |
"text/plain": [
|
395 |
" creationTimestamp id \\\n",
|
396 |
+
"124 1722563105 0xfc417a9bc90f15eb65f30368f5794e7b39f93e76 \n",
|
397 |
+
"167 1722563105 0xfc417a9bc90f15eb65f30368f5794e7b39f93e76 \n",
|
398 |
"\n",
|
399 |
" liquidityMeasure liquidityParameter openingTimestamp \\\n",
|
400 |
+
"124 6999779315564848653 7000000000000000001 1722988800 \n",
|
401 |
+
"167 6511633178027486360 7000000000000000006 1722988800 \n",
|
402 |
"\n",
|
403 |
+
" outcomeTokenAmounts \\\n",
|
404 |
+
"124 [7055806015023361612, 6944635367762128326] \n",
|
405 |
+
"167 [10286430731240040164, 4763557086053793703] \n",
|
406 |
"\n",
|
407 |
" title sample_timestamp \\\n",
|
408 |
+
"124 Will the Canadian women's football officials b... 1722593849 \n",
|
409 |
+
"167 Will the Canadian women's football officials b... 1722852594 \n",
|
410 |
"\n",
|
411 |
" open total_trades dist_gap_perc votes_first_outcome_perc \\\n",
|
412 |
+
"124 True 2 0.40 50.00 \n",
|
413 |
+
"167 True 21 1.68 33.33 \n",
|
414 |
"\n",
|
415 |
" votes_second_outcome_perc first_outcome second_outcome first_token_perc \\\n",
|
416 |
+
"124 50.00 Yes No 49.60 \n",
|
417 |
+
"167 66.67 Yes No 31.65 \n",
|
418 |
"\n",
|
419 |
" second_token_perc mean_trade_size sample_datetime \n",
|
420 |
+
"124 50.40 0.13000 2024-08-02 12:17:29 \n",
|
421 |
+
"167 68.35 0.35881 2024-08-05 12:09:54 "
|
422 |
]
|
423 |
},
|
424 |
+
"execution_count": 16,
|
425 |
"metadata": {},
|
426 |
"output_type": "execute_result"
|
427 |
}
|
tabs/tokens_votes_dist.py
CHANGED
@@ -12,12 +12,8 @@ def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
12 |
"""Function to paint the evolution of the probability of the outcomes based on the tokens distributions over time"""
|
13 |
sns.set_style("darkgrid")
|
14 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
15 |
-
ax = selected_market.
|
16 |
-
x="sample_datetime",
|
17 |
-
y=["first_token_perc", "second_token_perc"],
|
18 |
-
kind="bar",
|
19 |
-
rot=0,
|
20 |
-
stacked=True,
|
21 |
)
|
22 |
# add overall title
|
23 |
# plt.title(
|
@@ -25,8 +21,8 @@ def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
25 |
# )
|
26 |
|
27 |
# add axis titles
|
28 |
-
plt.xlabel("
|
29 |
-
plt.ylabel("
|
30 |
first_outcome = selected_market.iloc[0].first_outcome
|
31 |
second_outcome = selected_market.iloc[0].second_outcome
|
32 |
ax.legend(
|
@@ -40,19 +36,17 @@ def get_based_votes_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
40 |
"""Function to paint the evolution of the probability of the outcomes based on the votes distributions over time"""
|
41 |
sns.set_style("darkgrid")
|
42 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
43 |
-
ax = selected_market.plot(
|
44 |
x="sample_datetime",
|
45 |
y=["votes_first_outcome_perc", "votes_second_outcome_perc"],
|
46 |
-
kind="bar",
|
47 |
-
rot=0,
|
48 |
stacked=True,
|
49 |
)
|
50 |
# add overall title
|
51 |
# plt.title("Outcomes probability over time based on votes distributions", fontsize=8)
|
52 |
|
53 |
# add axis titles
|
54 |
-
plt.xlabel("
|
55 |
-
plt.ylabel("
|
56 |
first_outcome = selected_market.iloc[0].first_outcome
|
57 |
second_outcome = selected_market.iloc[0].second_outcome
|
58 |
ax.legend(
|
|
|
12 |
"""Function to paint the evolution of the probability of the outcomes based on the tokens distributions over time"""
|
13 |
sns.set_style("darkgrid")
|
14 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
15 |
+
ax = selected_market.plotbarh(
|
16 |
+
x="sample_datetime", y=["first_token_perc", "second_token_perc"], stacked=True
|
|
|
|
|
|
|
|
|
17 |
)
|
18 |
# add overall title
|
19 |
# plt.title(
|
|
|
21 |
# )
|
22 |
|
23 |
# add axis titles
|
24 |
+
plt.xlabel("Probability percentage(%)")
|
25 |
+
plt.ylabel("Sample date")
|
26 |
first_outcome = selected_market.iloc[0].first_outcome
|
27 |
second_outcome = selected_market.iloc[0].second_outcome
|
28 |
ax.legend(
|
|
|
36 |
"""Function to paint the evolution of the probability of the outcomes based on the votes distributions over time"""
|
37 |
sns.set_style("darkgrid")
|
38 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
39 |
+
ax = selected_market.plot.barh(
|
40 |
x="sample_datetime",
|
41 |
y=["votes_first_outcome_perc", "votes_second_outcome_perc"],
|
|
|
|
|
42 |
stacked=True,
|
43 |
)
|
44 |
# add overall title
|
45 |
# plt.title("Outcomes probability over time based on votes distributions", fontsize=8)
|
46 |
|
47 |
# add axis titles
|
48 |
+
plt.xlabel("Probability percentage(%)")
|
49 |
+
plt.ylabel("Sample date")
|
50 |
first_outcome = selected_market.iloc[0].first_outcome
|
51 |
second_outcome = selected_market.iloc[0].second_outcome
|
52 |
ax.legend(
|