cyberosa commited on
Commit
4cb55cc
·
1 Parent(s): 5a04992

updated live data and average time evolution graph

Browse files
live_data/markets_live_data.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ef505e34ed9cf0b28b18b2ba22952bc89c7c70a40dae9ce5ce4e2141898d4010
3
- size 140888
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69a3fffac1b1e11e818cdf3c709fd3006d6f93107df947693548a05bc66f337d
3
+ size 145777
live_data/markets_live_data_sample.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6a6f9834eccc4663ea7f95de171ad40c199376474b6c3f311c7e7407ebcafc9e
3
- size 129910
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef505e34ed9cf0b28b18b2ba22952bc89c7c70a40dae9ce5ce4e2141898d4010
3
+ size 140888
tabs/dist_gap.py CHANGED
@@ -2,7 +2,7 @@ import pandas as pd
2
  import gradio as gr
3
  import matplotlib.pyplot as plt
4
  import seaborn as sns
5
- from seaborn import FacetGrid
6
  import plotly.express as px
7
 
8
  HEIGHT = 300
@@ -49,20 +49,36 @@ def get_dist_gap_timeline_plotly(market_id: str, all_markets: pd.DataFrame) -> g
49
 
50
 
51
  def get_avg_gap_time_evolution(all_markets: pd.DataFrame) -> gr.Plot:
 
 
 
 
 
 
 
 
 
 
 
52
  avg_dist_gap_perc = (
53
- all_markets.groupby("sample_date")["dist_gap_perc"].mean().reset_index()
 
 
54
  )
55
- avg_dist_gap_perc["sample_date"] = avg_dist_gap_perc["sample_date"].astype(str)
56
  avg_dist_gap_perc.rename(
57
  columns={"dist_gap_perc": "mean_dist_gap_perc"}, inplace=True
58
  )
59
- fig = px.line(avg_dist_gap_perc, x="sample_date", y="mean_dist_gap_perc")
 
 
 
 
 
60
  fig.update_layout(
61
- xaxis_title="Day of the sample",
62
  yaxis_title="Mean dist gap percentage (%)",
63
  )
64
- # fig.update_layout(width=WIDTH, height=HEIGHT)
65
- # fig.update_xaxes(tickangle=45)
66
  fig.update_xaxes(tickformat="%b-%d-%Y")
67
  return gr.Plot(value=fig)
68
 
 
2
  import gradio as gr
3
  import matplotlib.pyplot as plt
4
  import seaborn as sns
5
+ from datetime import datetime, UTC
6
  import plotly.express as px
7
 
8
  HEIGHT = 300
 
49
 
50
 
51
  def get_avg_gap_time_evolution(all_markets: pd.DataFrame) -> gr.Plot:
52
+ # filter by the opening datetime
53
+ current = pd.Timestamp("today")
54
+
55
+ recent_markets = all_markets.loc[all_markets["opening_datetime"] > current]
56
+ recent_markets["creation_datetime"] = recent_markets["creationTimestamp"].apply(
57
+ lambda x: datetime.fromtimestamp(int(x))
58
+ )
59
+
60
+ recent_markets["creation_date"] = pd.to_datetime(
61
+ recent_markets["creation_datetime"]
62
+ ).dt.date
63
  avg_dist_gap_perc = (
64
+ recent_markets.groupby(["sample_date", "creation_date"])["dist_gap_perc"]
65
+ .mean()
66
+ .reset_index()
67
  )
68
+ avg_dist_gap_perc["creation_date"] = avg_dist_gap_perc["creation_date"].astype(str)
69
  avg_dist_gap_perc.rename(
70
  columns={"dist_gap_perc": "mean_dist_gap_perc"}, inplace=True
71
  )
72
+ fig = px.line(
73
+ avg_dist_gap_perc,
74
+ x="sample_date",
75
+ y="mean_dist_gap_perc",
76
+ color="creation_date",
77
+ )
78
  fig.update_layout(
79
+ xaxis_title="Day the samples were collected",
80
  yaxis_title="Mean dist gap percentage (%)",
81
  )
 
 
82
  fig.update_xaxes(tickformat="%b-%d-%Y")
83
  return gr.Plot(value=fig)
84