s-ttp commited on
Commit
bd0c191
Β·
verified Β·
1 Parent(s): bf1e860

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-312.pyc +0 -0
  2. app.py +47 -21
__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
@@ -163,30 +163,12 @@ def load_health():
163
  tr = rr.get("tracking", {})
164
  inc = rr.get("incumbent", {})
165
  flag = "πŸ”" if rr.get("changed") else ("🟑" if rr.get("triggered") else "🟒")
166
- SIGMAP = {"n_mom_12_1": "momentum (12-1)", "n_roe": "ROE", "n_fcf_yield": "FCF yield",
167
- "n_roa": "ROA", "n_vol_13w": "low volatility"}
168
- DEFMAP = {"mom60_agg20_gld20": "60% stocks + 20% bonds + 20% gold",
169
- "mom40_agg30_gld30": "40% stocks + 30% bonds + 30% gold",
170
- "agg50_gld50": "50% bonds + 50% gold", "lowvol": "low-volatility stocks"}
171
  dec = rr.get("decision", "")
172
  if dec.startswith("[agentic] "):
173
  dec = dec[10:]
174
- act, _, why = dec.partition(":")
175
- why = (why.strip()
176
- .replace("adopt_rate_limit_ok=false", "a strategy change is currently rate-limited")
177
- .replace("ADOPT is infeasible", "no change is possible this cycle")
178
- .replace("validator-approved candidates", "validated better variants"))
179
- cut = why.find(". ")
180
- why = (why[:cut + 1] if 0 < cut <= 230 else (why[:230].rsplit(" ", 1)[0] + "…" if len(why) > 230 else why))
181
- lines.append(f"- {flag} **Autonomous recalibration agent** (weekly, Analyst β†’ Critic β†’ PM) β€” latest decision "
182
- f"**{act.strip()}**: {why}")
183
- sig = " + ".join(SIGMAP.get(x, x) for x in (inc.get("signal") or []))
184
- lines.append(f"<sub>Tracking: 8-week gap vs S&P {tr.get('gap_8w_pp', 'β€”')}pp β€” the {tr.get('pctile_8w', 'β€”')}th "
185
- f"percentile of the strategy's 20-year history Β· implementation drift {tr.get('impl_drift_pp', 'β€”')}pp. "
186
- f"Live strategy v{inc.get('version', '?')}: {sig} selection Β· {inc.get('regime', '?')} trend rule Β· "
187
- f"defense = {DEFMAP.get(inc.get('defense'), inc.get('defense'))} Β· rebalanced every "
188
- f"{inc.get('cadence_weeks', 1)} week(s). A change is adopted only if it beats the incumbent on the "
189
- f"full 20-year walk-forward, net of costs β€” never a re-fit to recent weeks; at most one change per 90 days.</sub>")
190
  except Exception:
191
  pass
192
  lines.append("<sub>Deterministic daily checks: live tracking gap located in the 20-year backtest distribution, "
@@ -196,6 +178,46 @@ def load_health():
196
  return ""
197
 
198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  def load_rebalance():
200
  tok = os.environ.get("HF_TOKEN")
201
  if not tok:
@@ -296,6 +318,7 @@ with gr.Blocks(title="DeepQuant β€” live paper monitor", theme=gr.themes.Soft())
296
  note = gr.Markdown(visible=False)
297
  gr.Markdown("### πŸ“‹ Current holdings")
298
  tbl = gr.Dataframe(wrap=True, interactive=False)
 
299
  with gr.Row():
300
  updated = gr.Markdown("_loading…_")
301
  btn = gr.Button("↻ Refresh now", scale=0)
@@ -349,6 +372,9 @@ with gr.Blocks(title="DeepQuant β€” live paper monitor", theme=gr.themes.Soft())
349
  demo.load(load_health, None, health)
350
  btn.click(load_health, None, health)
351
  timer.tick(load_health, None, health)
 
 
 
352
 
353
  pv_outs = [pv_banner, tgt_tbl, ord_tbl]
354
  demo.load(rebalance_preview, None, pv_outs)
 
163
  tr = rr.get("tracking", {})
164
  inc = rr.get("incumbent", {})
165
  flag = "πŸ”" if rr.get("changed") else ("🟑" if rr.get("triggered") else "🟒")
 
 
 
 
 
166
  dec = rr.get("decision", "")
167
  if dec.startswith("[agentic] "):
168
  dec = dec[10:]
169
+ act = dec.partition(":")[0].strip()
170
+ lines.append(f"- {flag} **Autonomous recalibration agent** (weekly) β€” latest decision **{act}** "
171
+ f"<sub>(reasoning & live strategy config under Strategy governance below)</sub>")
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  except Exception:
173
  pass
174
  lines.append("<sub>Deterministic daily checks: live tracking gap located in the 20-year backtest distribution, "
 
178
  return ""
179
 
180
 
181
+ def load_governance():
182
+ tok = os.environ.get("HF_TOKEN")
183
+ if not tok:
184
+ return ""
185
+ try:
186
+ rr = json.load(open(hf_hub_download("s-ttp/marketfm-panel", "recalibration_report.json", repo_type="dataset",
187
+ token=tok, force_download=True)))
188
+ except Exception:
189
+ return ""
190
+ SIGMAP = {"n_mom_12_1": "momentum (12-1)", "n_roe": "ROE", "n_fcf_yield": "FCF yield",
191
+ "n_roa": "ROA", "n_vol_13w": "low volatility"}
192
+ DEFMAP = {"mom60_agg20_gld20": "60% stocks + 20% bonds + 20% gold",
193
+ "mom40_agg30_gld30": "40% stocks + 30% bonds + 30% gold",
194
+ "agg50_gld50": "50% bonds + 50% gold", "lowvol": "low-volatility stocks"}
195
+ tr = rr.get("tracking", {})
196
+ inc = rr.get("incumbent", {})
197
+ dec = rr.get("decision", "")
198
+ if dec.startswith("[agentic] "):
199
+ dec = dec[10:]
200
+ act, _, why = dec.partition(":")
201
+ why = (why.strip()
202
+ .replace("adopt_rate_limit_ok=false", "a strategy change is currently rate-limited")
203
+ .replace("ADOPT is infeasible", "no change is possible this cycle")
204
+ .replace("validator-approved candidates", "validated better variants"))
205
+ if len(why) > 420:
206
+ why = why[:420].rsplit(" ", 1)[0] + "…"
207
+ sig = " + ".join(SIGMAP.get(x, x) for x in (inc.get("signal") or []))
208
+ return (f"### 🀝 Strategy governance β€” the crew's latest decision\n"
209
+ f"**{act.strip()}** β€” {why}\n"
210
+ f"- **Tracking:** 8-week gap vs S&P {tr.get('gap_8w_pp', 'β€”')}pp β€” the {tr.get('pctile_8w', 'β€”')}th percentile "
211
+ f"of the strategy's 20-year history Β· implementation drift {tr.get('impl_drift_pp', 'β€”')}pp vs its own simulation\n"
212
+ f"- **Live strategy (v{inc.get('version', '?')}):** {sig} selection Β· {inc.get('regime', '?')} trend rule Β· "
213
+ f"defense = {DEFMAP.get(inc.get('defense'), inc.get('defense'))} Β· rebalanced every {inc.get('cadence_weeks', 1)} week(s)\n"
214
+ f"- **Change policy:** decided weekly by an agentic crew β€” Analyst β†’ adversarial Critic β†’ PM (Claude Opus 5) β€” "
215
+ f"gated by a code validator. A variant is adopted only if it beats the incumbent on the full 20-year "
216
+ f"walk-forward, net of costs β€” never a re-fit to recent weeks; at most one change per 90 days. Any AI failure "
217
+ f"defaults to HOLD.\n"
218
+ f"<sub>Decided {rr.get('date', '')} Β· the full Analyst / Critic / PM reasoning is logged with every decision.</sub>")
219
+
220
+
221
  def load_rebalance():
222
  tok = os.environ.get("HF_TOKEN")
223
  if not tok:
 
318
  note = gr.Markdown(visible=False)
319
  gr.Markdown("### πŸ“‹ Current holdings")
320
  tbl = gr.Dataframe(wrap=True, interactive=False)
321
+ gov = gr.Markdown()
322
  with gr.Row():
323
  updated = gr.Markdown("_loading…_")
324
  btn = gr.Button("↻ Refresh now", scale=0)
 
372
  demo.load(load_health, None, health)
373
  btn.click(load_health, None, health)
374
  timer.tick(load_health, None, health)
375
+ demo.load(load_governance, None, gov)
376
+ btn.click(load_governance, None, gov)
377
+ timer.tick(load_governance, None, gov)
378
 
379
  pv_outs = [pv_banner, tgt_tbl, ord_tbl]
380
  demo.load(rebalance_preview, None, pv_outs)