mirror of
https://github.com/d0zingcat/deploy.git
synced 2026-05-23 07:26:53 +00:00
(feat) update data
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import streamlit as st
|
||||
from datetime import datetime, time
|
||||
|
||||
import pandas as pd
|
||||
import plotly.graph_objects as go
|
||||
import streamlit as st
|
||||
|
||||
from frontend.st_utils import initialize_st_page, get_backend_api_client
|
||||
from frontend.st_utils import get_backend_api_client, initialize_st_page
|
||||
|
||||
# Initialize Streamlit page
|
||||
initialize_st_page(title="Download Candles", icon="💾")
|
||||
@@ -11,7 +12,9 @@ backend_api_client = get_backend_api_client()
|
||||
|
||||
c1, c2, c3, c4 = st.columns([2, 2, 2, 0.5])
|
||||
with c1:
|
||||
connector = st.selectbox("Exchange", ["binance_perpetual", "binance", "gate_io", "gate_io_perpetual", "kucoin", "ascend_ex"], index=0)
|
||||
connector = st.selectbox("Exchange",
|
||||
["binance_perpetual", "binance", "gate_io", "gate_io_perpetual", "kucoin", "ascend_ex"],
|
||||
index=0)
|
||||
trading_pair = st.text_input("Trading Pair", value="BTC-USDT")
|
||||
with c2:
|
||||
interval = st.selectbox("Interval", options=["1m", "3m", "5m", "15m", "1h", "4h", "1d", "1s"])
|
||||
@@ -29,8 +32,8 @@ if get_data_button:
|
||||
connector=connector,
|
||||
trading_pair=trading_pair,
|
||||
interval=interval,
|
||||
start_time=int(start_datetime.timestamp()) * 1000,
|
||||
end_time=int(end_datetime.timestamp()) * 1000
|
||||
start_time=int(start_datetime.timestamp()),
|
||||
end_time=int(end_datetime.timestamp())
|
||||
)
|
||||
|
||||
candles_df = pd.DataFrame(candles)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import streamlit as st
|
||||
import plotly.express as px
|
||||
import streamlit as st
|
||||
|
||||
import CONFIG
|
||||
from backend.services.coingecko_client import CoinGeckoClient
|
||||
from backend.services.miner_client import MinerClient
|
||||
@@ -11,22 +12,27 @@ initialize_st_page(title="Token Spreads", icon="🧙")
|
||||
cg_utils = CoinGeckoClient()
|
||||
miner_utils = MinerClient()
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_all_coins_df():
|
||||
return cg_utils.get_all_coins_df()
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_all_exchanges_df():
|
||||
return cg_utils.get_all_exchanges_df()
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_miner_stats_df():
|
||||
return miner_utils.get_miner_stats_df()
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_coin_tickers_by_id_list(coins_id: list):
|
||||
return cg_utils.get_coin_tickers_by_id_list(coins_id)
|
||||
|
||||
|
||||
with st.spinner(text='In progress'):
|
||||
exchanges_df = get_all_exchanges_df()
|
||||
coins_df = get_all_coins_df()
|
||||
@@ -43,7 +49,8 @@ tokens = st.multiselect(
|
||||
coins_id = coins_df.loc[coins_df["name"].isin(tokens), "id"].tolist()
|
||||
|
||||
coin_tickers_df = get_coin_tickers_by_id_list(coins_id)
|
||||
coin_tickers_df["coin_name"] = coin_tickers_df.apply(lambda x: coins_df.loc[coins_df["id"] == x.token_id, "name"].item(), axis=1)
|
||||
coin_tickers_df["coin_name"] = coin_tickers_df.apply(
|
||||
lambda x: coins_df.loc[coins_df["id"] == x.token_id, "name"].item(), axis=1)
|
||||
|
||||
exchanges = st.multiselect(
|
||||
"Select the exchanges to analyze:",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
import streamlit as st
|
||||
import pandas as pd
|
||||
import plotly.express as px
|
||||
import streamlit as st
|
||||
from defillama import DefiLlama
|
||||
|
||||
from frontend.st_utils import initialize_st_page
|
||||
@@ -12,16 +12,21 @@ initialize_st_page(title="TVL vs Market Cap", icon="🦉")
|
||||
MIN_TVL = 1000000.
|
||||
MIN_MCAP = 1000000.
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_tvl_mcap_data():
|
||||
llama = DefiLlama()
|
||||
df = pd.DataFrame(llama.get_all_protocols())
|
||||
tvl_mcap_df = df.loc[(df["tvl"]>0) & (df["mcap"]>0), ["name", "tvl", "mcap", "chain", "category", "slug"]].sort_values(by=["mcap"], ascending=False)
|
||||
return tvl_mcap_df[(tvl_mcap_df["tvl"] > MIN_TVL) & (tvl_mcap_df["mcap"]> MIN_MCAP)]
|
||||
tvl_mcap_df = df.loc[
|
||||
(df["tvl"] > 0) & (df["mcap"] > 0), ["name", "tvl", "mcap", "chain", "category", "slug"]].sort_values(
|
||||
by=["mcap"], ascending=False)
|
||||
return tvl_mcap_df[(tvl_mcap_df["tvl"] > MIN_TVL) & (tvl_mcap_df["mcap"] > MIN_MCAP)]
|
||||
|
||||
|
||||
def get_protocols_by_chain_category(protocols: pd.DataFrame, group_by: list, nth: list):
|
||||
return protocols.sort_values('tvl', ascending=False).groupby(group_by).nth(nth).reset_index()
|
||||
|
||||
|
||||
with st.spinner(text='In progress'):
|
||||
tvl_mcap_df = get_tvl_mcap_data()
|
||||
|
||||
@@ -57,7 +62,8 @@ st.write("### SunBurst 🌞")
|
||||
groupby = st.selectbox('Group by:', [['chain', 'category'], ['category', 'chain']])
|
||||
nth = st.slider('Top protocols by Category', min_value=1, max_value=5)
|
||||
|
||||
proto_agg = get_protocols_by_chain_category(tvl_mcap_df[tvl_mcap_df["chain"].isin(chains)], groupby, np.arange(0, nth, 1).tolist())
|
||||
proto_agg = get_protocols_by_chain_category(tvl_mcap_df[tvl_mcap_df["chain"].isin(chains)],
|
||||
groupby, np.arange(0, nth, 1).tolist())
|
||||
groupby.append("slug")
|
||||
sunburst = px.sunburst(
|
||||
proto_agg,
|
||||
@@ -65,6 +71,6 @@ sunburst = px.sunburst(
|
||||
values='tvl',
|
||||
height=800,
|
||||
title="SunBurst",
|
||||
template="plotly_dark",)
|
||||
template="plotly_dark", )
|
||||
|
||||
st.plotly_chart(sunburst, use_container_width=True)
|
||||
st.plotly_chart(sunburst, use_container_width=True)
|
||||
|
||||
Reference in New Issue
Block a user