File size: 2,513 Bytes
4f94489
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553e7cb
4f94489
3407d9e
4f94489
 
 
 
 
 
 
 
 
3407d9e
4f94489
 
 
 
 
 
f9a8db6
4f94489
 
 
 
 
 
 
3407d9e
 
 
 
 
 
4f94489
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import gradio as gr
import pandas as pd
from tabs.market_plots import (
    plot_top_10_ranking_by_nr_trades,
    plot_trades_and_traders_ranking,
    plot_wordcloud_topics,
)
import logging
from huggingface_hub import hf_hub_download


def get_logger():
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    # stream handler and formatter
    stream_handler = logging.StreamHandler()
    stream_handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
        "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    )
    stream_handler.setFormatter(formatter)
    logger.addHandler(stream_handler)
    return logger


def load_data():
    # closed_markets metrics
    closed_markets_df = hf_hub_download(
        repo_id="valory/Olas-predict-dataset",
        filename="closed_market_metrics.parquet",
        repo_type="dataset",
    )
    df = pd.read_parquet(closed_markets_df)

    return df


logger = get_logger()
logger.info("Loading data from Olas predict dataset")
market_metrics = load_data()
demo = gr.Blocks(theme=gr.themes.Origin())
with demo:
    gr.HTML("<h1>Prediction markets popularity dashboard (WIP)</h1>")
    gr.Markdown(
        """This app shows the popularity ranking of prediction markets in Olas Predict. Popularity based on two main metrics: 
                * number of generated trades on the market
                * number of traders active on the market.
                
                These are computed only for closed markets."""
    )

    with gr.Tabs():
        with gr.TabItem("🔥 Market Popularity metrics"):
            with gr.Row():
                gr.Markdown("# 🔝 Top 10 markets based on number of trades")
            with gr.Row():
                top_10_plot = plot_top_10_ranking_by_nr_trades(
                    market_metrics=market_metrics
                )
            with gr.Row(equal_height=True):
                gr.Markdown(
                    "# 🏁 Classification based on nr of trades and nr of traders"
                )
            with gr.Row():
                scatterplot = plot_trades_and_traders_ranking(
                    market_metrics=market_metrics
                )
            with gr.Row():
                gr.Markdown(
                    "# ☁️ Wordcloud composed with words from most popular markets"
                )
            with gr.Row():
                wordcloud = plot_wordcloud_topics(market_metrics=market_metrics)

demo.queue(default_concurrency_limit=40).launch()