s-ttp commited on
Commit
de18417
·
verified ·
1 Parent(s): 51ab4a7

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-312.pyc +0 -0
  2. app.py +25 -0
__pycache__/app.cpython-312.pyc CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
 
app.py CHANGED
@@ -12,6 +12,7 @@ import urllib.request
12
 
13
  import gradio as gr
14
  import pandas as pd
 
15
 
16
  import alpaca_client as ac
17
  import rebalance_engine as eng
@@ -107,6 +108,26 @@ def refresh():
107
  f"_Last updated {now} · auto-refreshes every 30 min_")
108
 
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  def rebalance_preview():
111
  tok = os.environ.get("HF_TOKEN")
112
  if not tok:
@@ -161,6 +182,7 @@ with gr.Blocks(title="DeepQuant — live paper monitor", theme=gr.themes.Soft())
161
  with gr.Tabs():
162
  with gr.Tab("📊 Live account"):
163
  stats = gr.Markdown()
 
164
  gr.Markdown("### Holdings")
165
  tbl = gr.Dataframe(wrap=True, interactive=False)
166
  gr.Markdown("### Equity vs S&P 500")
@@ -188,6 +210,9 @@ with gr.Blocks(title="DeepQuant — live paper monitor", theme=gr.themes.Soft())
188
  demo.load(refresh, None, acct_outs)
189
  btn.click(refresh, None, acct_outs)
190
  timer.tick(refresh, None, acct_outs)
 
 
 
191
 
192
  pv_outs = [pv_banner, tgt_tbl, ord_tbl]
193
  demo.load(rebalance_preview, None, pv_outs)
 
12
 
13
  import gradio as gr
14
  import pandas as pd
15
+ from huggingface_hub import hf_hub_download
16
 
17
  import alpaca_client as ac
18
  import rebalance_engine as eng
 
108
  f"_Last updated {now} · auto-refreshes every 30 min_")
109
 
110
 
111
+ def load_rebalance():
112
+ tok = os.environ.get("HF_TOKEN")
113
+ if not tok:
114
+ return ""
115
+ try:
116
+ log = json.load(open(hf_hub_download("s-ttp/marketfm-panel", "deepquant_log.json", repo_type="dataset", token=tok)))
117
+ if not log:
118
+ return ""
119
+ e = log[-1]
120
+ mode = "🟢 OFFENSE" if e.get("mode") == "OFFENSE" else "🛡️ DEFENSE"
121
+ head = (f"### 🗓️ Latest rebalance — {e.get('date','')} · {mode}\n"
122
+ f"{e.get('buys',0)} buys · {e.get('sells',0)} sells · {e.get('turnover_pct',0)}% turnover · "
123
+ f"{e.get('n_positions','—')} holdings\n\n")
124
+ if e.get("narration"):
125
+ return head + f"> 💬 *{e['narration']}*\n\n<sub>— {e.get('narrated_by','MarketGuruLLM')}</sub>"
126
+ return head + f"<sub>{e.get('summary','')}</sub>"
127
+ except Exception:
128
+ return ""
129
+
130
+
131
  def rebalance_preview():
132
  tok = os.environ.get("HF_TOKEN")
133
  if not tok:
 
182
  with gr.Tabs():
183
  with gr.Tab("📊 Live account"):
184
  stats = gr.Markdown()
185
+ rebal = gr.Markdown()
186
  gr.Markdown("### Holdings")
187
  tbl = gr.Dataframe(wrap=True, interactive=False)
188
  gr.Markdown("### Equity vs S&P 500")
 
210
  demo.load(refresh, None, acct_outs)
211
  btn.click(refresh, None, acct_outs)
212
  timer.tick(refresh, None, acct_outs)
213
+ demo.load(load_rebalance, None, rebal)
214
+ btn.click(load_rebalance, None, rebal)
215
+ timer.tick(load_rebalance, None, rebal)
216
 
217
  pv_outs = [pv_banner, tgt_tbl, ord_tbl]
218
  demo.load(rebalance_preview, None, pv_outs)