(feat) update XE Token analyzer with new components

This commit is contained in:
cardosofede
2023-04-17 21:47:19 -03:00
parent c444d6d6b0
commit eb8a0d14d2

View File

@@ -1,5 +1,3 @@
import time
import pandas as pd
import streamlit as st
import plotly.express as px
@@ -7,37 +5,42 @@ import CONFIG
from utils.coingecko_utils import CoinGeckoUtils
from utils.miner_utils import MinerUtils
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
cg_utils = CoinGeckoUtils()
miner_utils = MinerUtils()
@st.cache_data
def get_all_coins_df():
return CoinGeckoUtils().get_all_coins_df()
return cg_utils.get_all_coins_df()
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
@st.cache_data
def get_all_exchanges_df():
return CoinGeckoUtils().get_all_exchanges_df()
return cg_utils.get_all_exchanges_df()
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
@st.cache_data
def get_miner_stats_df():
return MinerUtils().get_miner_stats_df()
return miner_utils.get_miner_stats_df()
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
@st.cache_data
def get_coin_tickers_by_id_list(coins_id: list):
return CoinGeckoUtils().get_coin_tickers_by_id_list(coins_id)
return cg_utils.get_coin_tickers_by_id_list(coins_id)
st.set_page_config(layout='wide')
st.title("🧙Cross Exchange Token Analyzer")
st.write("---")
with st.spinner(text='In progress'):
exchanges_df = get_all_exchanges_df()
coins_df = get_all_coins_df()
miner_stats_df = get_miner_stats_df()
miner_coins = coins_df.loc[coins_df["symbol"].isin(miner_stats_df["base"].str.lower().unique()), "name"]
miner_coins = coins_df.loc[coins_df["symbol"].isin(miner_stats_df["base"].str.lower().unique()), "name"]
st.write("### Coins filter 🦅")
tokens = st.multiselect(
"Select the tokens to analyze:",
options=coins_df["name"],
default=CONFIG.DEFAULT_MINER_COINS)
default=CONFIG.DEFAULT_MINER_COINS
)
coins_id = coins_df.loc[coins_df["name"].isin(tokens), "id"].tolist()
@@ -48,9 +51,11 @@ st.sidebar.write("### Exchanges filter 🦅")
exchanges = st.sidebar.multiselect(
"Select the exchanges to analyze:",
options=exchanges_df["name"],
default=[exchange for exchange in CONFIG.MINER_EXCHANGES if exchange in exchanges_df["name"].unique()])
default=[exchange for exchange in CONFIG.MINER_EXCHANGES if exchange in exchanges_df["name"].unique()]
)
height = len(coin_tickers_df["coin_name"].unique()) * 500
fig = px.scatter(
data_frame=coin_tickers_df[coin_tickers_df["exchange"].isin(exchanges)],
x="volume",
@@ -67,9 +72,9 @@ fig = px.scatter(
labels={
"volume": 'Volume (USD)',
'bid_ask_spread_percentage': 'Bid Ask Spread (%)'
})
}
)
st.sidebar.write("# Data filters 🏷")
st.sidebar.code("🧳 New filters coming. \nReach us on discord \nif you want to propose one!")
st.plotly_chart(fig, use_container_width=True)