Skip to content

Commit

Permalink
add key
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaKhalili committed Nov 11, 2024
1 parent be1ffcb commit 08ee067
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def api2(url: str, params: Optional[dict] = None) -> dict:
Example with params: /api/price-shock/usermap?asset_group=ignore+stables&oracle_distortion=0.05
-> GET_api_price-shock_usermap__asset_group-ignore+stables_oracle_distortion-0.05.json
"""
print("SERVING FROM R2")
print("===> SERVING FROM R2")

try:
cache_key = f"GET/api/{url}".replace("/", "_")
Expand Down
12 changes: 11 additions & 1 deletion src/page/asset_liability_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ def asset_liab_matrix_cached_page():
index=[x.market_index for x in mainnet_perp_market_configs].index(
perp_market_index
),
format_func=lambda x: f"{x} ({mainnet_perp_market_configs[int(x)].symbol})",
)
st.query_params.update({"perp_market_index": perp_market_index})

# show_leverage_filter = st.toggle("Filter by Effective Leverage", value=False)
# min_leverage = 0.0
# if show_leverage_filter:
# min_leverage = st.slider("Minimum Effective Leverage", 0.0, 100.0, 0.0, 1.0)

try:
result = api2(
"asset-liability/matrix",
Expand Down Expand Up @@ -65,6 +71,9 @@ def asset_liab_matrix_cached_page():
res = pd.DataFrame(result["res"])
df = pd.DataFrame(result["df"])

# if show_leverage_filter:
# res = res[res["effective_leverage"] >= min_leverage]

st.write(f"{df.shape[0]} users for scenario")
st.write(res)

Expand All @@ -73,7 +82,8 @@ def asset_liab_matrix_cached_page():

for idx, tab in enumerate(tabs[1:]):
important_cols = [x for x in df.columns if "spot_" + str(idx) in x]
toshow = df[["spot_asset", "net_usd_value"] + important_cols]
# Sort columns in logical order: all, deposit, borrow
toshow = df[["user_key", "spot_asset", "net_usd_value"] + important_cols]
toshow = toshow[toshow[important_cols].abs().sum(axis=1) != 0].sort_values(
by="spot_" + str(idx) + "_all", ascending=False
)
Expand Down

0 comments on commit 08ee067

Please sign in to comment.