Skip to content

Commit

Permalink
Merge pull request #28 from Synthetixio/feat/all-metrics-new-acc
Browse files Browse the repository at this point in the history
Add New & Returning Accounts Charts
  • Loading branch information
Tburm authored Nov 1, 2024
2 parents 703219c + 008b727 commit c277f6e
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions dashboards/all_metrics/modules/v3/chain_perp_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd

from dashboards.utils.data import export_data
from dashboards.utils.charts import chart_bars, chart_lines
from dashboards.utils.charts import chart_bars, chart_lines, chart_area


@st.cache_data(ttl="30m")
Expand Down Expand Up @@ -55,10 +55,26 @@ def fetch_data(chain, start_date, end_date, resolution):
else pd.DataFrame()
)

df_account_activity = api._run_query(
f"""
SELECT
ts,
new_accounts_daily,
dau - new_accounts_daily as returning_accounts_daily,
new_accounts_monthly,
mau - new_accounts_monthly as returning_accounts_monthly,
dau,
mau
FROM {api.environment}_{chain}.fct_perp_account_activity_{chain}
WHERE DATE(ts) >= '{start_date}' and DATE(ts) <= '{end_date}'
"""
)

return {
"stats": df_stats,
"oi": df_oi,
"buyback": df_buyback,
"account_activity": df_account_activity,
}


Expand Down Expand Up @@ -142,6 +158,24 @@ def make_charts(data):
if st.session_state.chain.startswith("base")
else None
),
"account_activity_daily": chart_bars(
data["account_activity"],
x_col="ts",
y_cols=["new_accounts_daily", "returning_accounts_daily"],
title="Daily New/Returning Accounts",
y_format="#",
help_text="Number of daily new/returning accounts that have at least one order settled",
custom_agg=dict(field="dau", name="Total", agg="sum"),
),
"account_activity_monthly": chart_area(
data["account_activity"],
x_col="ts",
y_cols=["new_accounts_monthly", "returning_accounts_monthly"],
title="Monthly New/Returning Accounts",
y_format="#",
help_text="Number of new/returning accounts that have at least one order settled in the last 28 days",
custom_agg=dict(field="mau", name="Total", agg="sum"),
),
}


Expand Down Expand Up @@ -205,13 +239,13 @@ def main():
st.plotly_chart(charts["oi"], use_container_width=True)
st.plotly_chart(charts["account_liquidations"], use_container_width=True)
st.plotly_chart(charts["cumulative_volume"], use_container_width=True)

st.plotly_chart(charts["account_activity_daily"], use_container_width=True)
with col2:
st.plotly_chart(charts["fees"], use_container_width=True)
st.plotly_chart(charts["trades"], use_container_width=True)
st.plotly_chart(charts["liquidation_rewards"], use_container_width=True)
st.plotly_chart(charts["cumulative_fees"], use_container_width=True)

st.plotly_chart(charts["account_activity_monthly"], use_container_width=True)
if st.session_state.chain.startswith("base"):
bb_col1, bb_col2 = st.columns(2)
with bb_col1:
Expand Down

0 comments on commit c277f6e

Please sign in to comment.