Trireme commited on
Commit
65e0ff8
·
verified ·
1 Parent(s): 67cfee3

Upload folder using huggingface_hub

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