Skip to content

Commit

Permalink
Move liquidation curve to pages folder
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKhalili committed Oct 14, 2024
1 parent 8ce555c commit 72ec657
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from page.asset_liability import asset_liab_matrix_page
from page.backend import backend_page
from page.health import health_page
from page.liquidation_curves import liquidation_curves_page
from page.orderbook import orderbook_page
from page.price_shock import price_shock_page
from sections.liquidation_curves import plot_liquidation_curve
from sections.welcome import welcome_page
import streamlit as st

Expand Down Expand Up @@ -53,7 +53,7 @@
icon="📊",
),
st.Page(
needs_backend(plot_liquidation_curve),
needs_backend(liquidation_curves_page),
url_path="liquidation-curves",
title="Liquidation Curves",
icon="🌊",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
import streamlit as st


options = [0, 1, 2]
labels = ["SOL-PERP", "BTC-PERP", "ETH-PERP"]


def plot_liquidation_curves(liquidation_data):
liquidations_long = liquidation_data["liquidations_long"]
liquidations_short = liquidation_data["liquidations_short"]
Expand Down Expand Up @@ -106,17 +102,25 @@ def prepare_data_for_plot(aggregated_data, reverse=False):
return long_fig, short_fig


def plot_liquidation_curve(): # (vat: Vat):
def liquidation_curves_page():

options = [0, 1]
labels = ["SOL-PERP", "BTC-PERP"]
st.write("Liquidation Curves")

# Get query parameters
params = st.query_params
market_index = int(params.get("market_index", 0))

market_index = st.selectbox(
"Market",
options,
format_func=lambda x: labels[x],
index=options.index(market_index),
)

if market_index is None:
market_index = 0
# Update query parameters
st.query_params.update({"market_index": market_index})

liquidation_data = api(
"liquidation", "liquidation-curve", str(market_index), as_json=True
Expand Down

0 comments on commit 72ec657

Please sign in to comment.