Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- README.md +2 -8
- app.py +74 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
colorFrom: indigo
|
| 5 |
-
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.31.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: hyper_dashboard
|
| 3 |
+
app_file: app.py
|
|
|
|
|
|
|
| 4 |
sdk: gradio
|
| 5 |
sdk_version: 5.31.0
|
|
|
|
|
|
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
from pymongo import MongoClient
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import requests
|
| 5 |
+
import json
|
| 6 |
+
import urllib.parse
|
| 7 |
+
import gradio as gr
|
| 8 |
+
import datetime
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
client = MongoClient(os.getenv('MONGO_DB_URI'))
|
| 12 |
+
db = client["HYPER_balances"]
|
| 13 |
+
collection = db["balance_data"]
|
| 14 |
+
|
| 15 |
+
def load_from_mongo():
|
| 16 |
+
latest = collection.find_one(sort=[("timestamp", -1)])
|
| 17 |
+
if latest:
|
| 18 |
+
df0 = pd.DataFrame(latest["df0"]).T
|
| 19 |
+
df1 = pd.DataFrame(latest["df1"]).T
|
| 20 |
+
df2 = pd.DataFrame(latest["df2"]).T
|
| 21 |
+
df3 = pd.DataFrame(latest["df3"]).T
|
| 22 |
+
df4 = pd.DataFrame(latest["df4"]).T
|
| 23 |
+
|
| 24 |
+
return (
|
| 25 |
+
df0, latest["total0"],
|
| 26 |
+
df1, latest["total1"],
|
| 27 |
+
df2, latest["total2"],
|
| 28 |
+
df3, latest["total3"],
|
| 29 |
+
df4, latest["total4"],
|
| 30 |
+
f"PNL : {latest['pnl']:,.2f}",
|
| 31 |
+
f"LP Rewards : {latest['rewards']:,.2f}"
|
| 32 |
+
)
|
| 33 |
+
else:
|
| 34 |
+
empty_df = pd.DataFrame()
|
| 35 |
+
return empty_df, 0, empty_df, 0, empty_df, 0, empty_df, 0, empty_df, 0,"PNL : 0.00","LP Rewards : 0.00"
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
with gr.Blocks() as demo:
|
| 39 |
+
gr.Markdown("## BILLY Balances and PnL")
|
| 40 |
+
|
| 41 |
+
df0_out = gr.Dataframe(label="Starting Balances")
|
| 42 |
+
txt0_out = gr.Textbox(label="Starting Value Total")
|
| 43 |
+
|
| 44 |
+
df2_out = gr.Dataframe(label="Wallet Balances")
|
| 45 |
+
txt2_out = gr.Textbox(label="Wallet Value Total")
|
| 46 |
+
|
| 47 |
+
df3_out = gr.Dataframe(label="JUP Limit Balances")
|
| 48 |
+
txt3_out = gr.Textbox(label="JUP Limit Value Total")
|
| 49 |
+
|
| 50 |
+
df4_out = gr.Dataframe(label="LP Balances")
|
| 51 |
+
txt4_out = gr.Textbox(label="LP Balances Value Total")
|
| 52 |
+
|
| 53 |
+
reward_out = gr.Textbox(label="LP Rewards")
|
| 54 |
+
|
| 55 |
+
df1_out = gr.Dataframe(label="Total Balances")
|
| 56 |
+
txt1_out = gr.Textbox(label="Current Value Total")
|
| 57 |
+
|
| 58 |
+
pnl_out = gr.Textbox(label="PNL (AUM Model)")
|
| 59 |
+
|
| 60 |
+
# Load from MongoDB on app load (sync function)
|
| 61 |
+
demo.load(
|
| 62 |
+
fn=load_from_mongo,
|
| 63 |
+
inputs=[],
|
| 64 |
+
outputs=[
|
| 65 |
+
df0_out, txt0_out,
|
| 66 |
+
df1_out, txt1_out,
|
| 67 |
+
df2_out, txt2_out,
|
| 68 |
+
df3_out, txt3_out,
|
| 69 |
+
df4_out, txt4_out,
|
| 70 |
+
pnl_out,reward_out
|
| 71 |
+
]
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
demo.launch(debug=True, share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
requests
|
| 3 |
+
gradio
|
| 4 |
+
pymongo[srv]
|