Upload folder using huggingface_hub
Browse files- README.md +1 -1
- __pycache__/app.cpython-312.pyc +0 -0
- app.py +53 -35
README.md
CHANGED
|
@@ -25,5 +25,5 @@ narrates it, and β within strict evidence gates β recalibrates it.
|
|
| 25 |
re-checked by a code validator (full walk-forward acceptance criteria, 90-day rate limit, hard rails).
|
| 26 |
- **MarketGuruLLM** (fine-tuned Qwen2.5-14B) narrates every rebalance and decision in plain English.
|
| 27 |
|
| 28 |
-
The page is **read-only**: live positions,
|
| 29 |
with its reasoning, and a dry-run rebalance preview. Backtested results, paper trading β not investment advice.
|
|
|
|
| 25 |
re-checked by a code validator (full walk-forward acceptance criteria, 90-day rate limit, hard rails).
|
| 26 |
- **MarketGuruLLM** (fine-tuned Qwen2.5-14B) narrates every rebalance and decision in plain English.
|
| 27 |
|
| 28 |
+
The page is **read-only**: live positions, the fund vs the S&P 500 since inception, agent health, the latest decision
|
| 29 |
with its reasoning, and a dry-run rebalance preview. Backtested results, paper trading β not investment advice.
|
__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
|
@@ -154,7 +154,7 @@ def load_health():
|
|
| 154 |
r = json.load(open(hf_hub_download("s-ttp/marketfm-panel", "deepquant_health.json", repo_type="dataset",
|
| 155 |
token=tok, force_download=True)))
|
| 156 |
icon = {"OK": "π’", "WATCH": "π‘", "ALERT": "π΄"}
|
| 157 |
-
lines = [f"### π©Ί
|
| 158 |
for c in r.get("checks", []):
|
| 159 |
lines.append(f"- {icon.get(c['status'], 'βͺ')} **{c['name']}** β {c['detail']}")
|
| 160 |
try:
|
|
@@ -163,13 +163,30 @@ 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 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
except Exception:
|
| 174 |
pass
|
| 175 |
lines.append("<sub>Deterministic daily checks: live tracking gap located in the 20-year backtest distribution, "
|
|
@@ -268,41 +285,17 @@ with gr.Blocks(title="DeepQuant β live paper monitor", theme=gr.themes.Soft())
|
|
| 268 |
"S&P 500's ~11%**, higher Sharpe, β35% max drawdown vs the index's β49%.\n"
|
| 269 |
"<sub>Fully autonomous, paper trading, this page is read-only. Backtested results β past performance β future. "
|
| 270 |
"Not investment advice.</sub>")
|
| 271 |
-
with gr.Accordion("𧬠Why hybrid? Who decides what β and why", open=False):
|
| 272 |
-
gr.Markdown(
|
| 273 |
-
"The lesson from building this system: **neither pure determinism nor pure agency is enough.** Rules can't "
|
| 274 |
-
"weigh ambiguous evidence; models can't be allowed to improvise with money. So each job goes to the framework "
|
| 275 |
-
"that has *earned* it:\n\n"
|
| 276 |
-
"| Responsibility | Framework | Why |\n|---|---|---|\n"
|
| 277 |
-
"| Stock ranking & target weights | **Deterministic** (MarketFM factors + fixed rules) | Validated on a 20-year "
|
| 278 |
-
"walk-forward, survivorship-free, net of costs β and reproducible to the penny |\n"
|
| 279 |
-
"| Order execution & risk rails | **Deterministic** | Execution is arithmetic β the last place you want a model "
|
| 280 |
-
"hallucinating. The rails (long-only, caps, no leverage) are code no one can override |\n"
|
| 281 |
-
"| Daily monitoring | **Deterministic** | Statistical checks against the strategy's own history β e.g. \"is this "
|
| 282 |
-
"drawdown inside the envelope of 280 historical 8-week windows?\" |\n"
|
| 283 |
-
"| Weekly assessment & judgment | **Agentic** β a role-separated crew (Analyst β adversarial Critic β PM) on "
|
| 284 |
-
"Claude Opus 5 | Weighing noisy, conflicting evidence is judgment; separating the roles makes each argument "
|
| 285 |
-
"survive an adversarial challenge before any decision |\n"
|
| 286 |
-
"| Strategy changes | **Hybrid** | The crew may adopt *only* variants that beat the incumbent across a bounded "
|
| 287 |
-
"menu (selection signal Γ regime rule Γ defense sleeve Γ cadence) on the full 20-year walk-forward, net of cost β "
|
| 288 |
-
"re-checked by a code validator; max one change per 90 days. Trigger on recent data, validate on all data |\n"
|
| 289 |
-
"| Emergency brake | **Hybrid** | The crew can pause execution up to 2 weeks on operational anomalies; holding "
|
| 290 |
-
"the validated book is always the safe default β and any AI failure automatically resolves to HOLD |\n"
|
| 291 |
-
"| Explanations | **Agentic** (MarketGuruLLM) | Language is what language models are for |\n\n"
|
| 292 |
-
"Every weekly decision is logged in full β the Analyst's assessment, the Critic's objections, the PM's ruling "
|
| 293 |
-
"and the evidence they cite β and the current strategy configuration is versioned, so the fund's entire "
|
| 294 |
-
"decision history is auditable. **AI proposes and judges; validated evidence admits; code enforces.**")
|
| 295 |
with gr.Tabs():
|
| 296 |
with gr.Tab("π Live account"):
|
| 297 |
stats = gr.Markdown()
|
| 298 |
health = gr.Markdown()
|
| 299 |
rebal = gr.Markdown()
|
| 300 |
-
gr.Markdown("###
|
| 301 |
-
tbl = gr.Dataframe(wrap=True, interactive=False)
|
| 302 |
-
gr.Markdown("### Equity vs S&P 500")
|
| 303 |
plot = gr.LinePlot(x="date", y="value", color="series", height=320,
|
| 304 |
y_title="Account value ($)", x_title="")
|
| 305 |
note = gr.Markdown(visible=False)
|
|
|
|
|
|
|
| 306 |
with gr.Row():
|
| 307 |
updated = gr.Markdown("_loadingβ¦_")
|
| 308 |
btn = gr.Button("β» Refresh now", scale=0)
|
|
@@ -319,6 +312,31 @@ with gr.Blocks(title="DeepQuant β live paper monitor", theme=gr.themes.Soft())
|
|
| 319 |
with gr.Column():
|
| 320 |
gr.Markdown("**Proposed orders** β sells first, then buys")
|
| 321 |
ord_tbl = gr.Dataframe(interactive=False, wrap=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
timer = gr.Timer(1800)
|
| 323 |
|
| 324 |
acct_outs = [stats, tbl, plot, note, updated]
|
|
|
|
| 154 |
r = json.load(open(hf_hub_download("s-ttp/marketfm-panel", "deepquant_health.json", repo_type="dataset",
|
| 155 |
token=tok, force_download=True)))
|
| 156 |
icon = {"OK": "π’", "WATCH": "π‘", "ALERT": "π΄"}
|
| 157 |
+
lines = [f"### π©Ί System health β {icon.get(r.get('overall'), 'βͺ')} {r.get('overall')} <sub>(checked {r.get('date')})</sub>"]
|
| 158 |
for c in r.get("checks", []):
|
| 159 |
lines.append(f"- {icon.get(c['status'], 'βͺ')} **{c['name']}** β {c['detail']}")
|
| 160 |
try:
|
|
|
|
| 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, "
|
|
|
|
| 285 |
"S&P 500's ~11%**, higher Sharpe, β35% max drawdown vs the index's β49%.\n"
|
| 286 |
"<sub>Fully autonomous, paper trading, this page is read-only. Backtested results β past performance β future. "
|
| 287 |
"Not investment advice.</sub>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
with gr.Tabs():
|
| 289 |
with gr.Tab("π Live account"):
|
| 290 |
stats = gr.Markdown()
|
| 291 |
health = gr.Markdown()
|
| 292 |
rebal = gr.Markdown()
|
| 293 |
+
gr.Markdown("### π DeepQuant fund vs S&P 500")
|
|
|
|
|
|
|
| 294 |
plot = gr.LinePlot(x="date", y="value", color="series", height=320,
|
| 295 |
y_title="Account value ($)", x_title="")
|
| 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)
|
|
|
|
| 312 |
with gr.Column():
|
| 313 |
gr.Markdown("**Proposed orders** β sells first, then buys")
|
| 314 |
ord_tbl = gr.Dataframe(interactive=False, wrap=True)
|
| 315 |
+
with gr.Accordion("𧬠Why hybrid? Who decides what β and why", open=False):
|
| 316 |
+
gr.Markdown(
|
| 317 |
+
"The lesson from building this system: **neither pure determinism nor pure agency is enough.** Rules can't "
|
| 318 |
+
"weigh ambiguous evidence; models can't be allowed to improvise with money. So each job goes to the framework "
|
| 319 |
+
"that has *earned* it:\n\n"
|
| 320 |
+
"| Responsibility | Framework | Why |\n|---|---|---|\n"
|
| 321 |
+
"| Stock ranking & target weights | **Deterministic** (MarketFM factors + fixed rules) | Validated on a 20-year "
|
| 322 |
+
"walk-forward, survivorship-free, net of costs β and reproducible to the penny |\n"
|
| 323 |
+
"| Order execution & risk rails | **Deterministic** | Execution is arithmetic β the last place you want a model "
|
| 324 |
+
"hallucinating. The rails (long-only, caps, no leverage) are code no one can override |\n"
|
| 325 |
+
"| Daily monitoring | **Deterministic** | Statistical checks against the strategy's own history β e.g. \"is this "
|
| 326 |
+
"drawdown inside the envelope of 280 historical 8-week windows?\" |\n"
|
| 327 |
+
"| Weekly assessment & judgment | **Agentic** β a role-separated crew (Analyst β adversarial Critic β PM) on "
|
| 328 |
+
"Claude Opus 5 | Weighing noisy, conflicting evidence is judgment; separating the roles makes each argument "
|
| 329 |
+
"survive an adversarial challenge before any decision |\n"
|
| 330 |
+
"| Strategy changes | **Hybrid** | The crew may adopt *only* variants that beat the incumbent across a bounded "
|
| 331 |
+
"menu (selection signal Γ regime rule Γ defense sleeve Γ cadence) on the full 20-year walk-forward, net of cost β "
|
| 332 |
+
"re-checked by a code validator; max one change per 90 days. Trigger on recent data, validate on all data |\n"
|
| 333 |
+
"| Emergency brake | **Hybrid** | The crew can pause execution up to 2 weeks on operational anomalies; holding "
|
| 334 |
+
"the validated book is always the safe default β and any AI failure automatically resolves to HOLD |\n"
|
| 335 |
+
"| Explanations | **Agentic** (MarketGuruLLM) | Language is what language models are for |\n\n"
|
| 336 |
+
"Every weekly decision is logged in full β the Analyst's assessment, the Critic's objections, the PM's ruling "
|
| 337 |
+
"and the evidence they cite β and the current strategy configuration is versioned, so the fund's entire "
|
| 338 |
+
"decision history is auditable. **AI proposes and judges; validated evidence admits; code enforces.**")
|
| 339 |
+
|
| 340 |
timer = gr.Timer(1800)
|
| 341 |
|
| 342 |
acct_outs = [stats, tbl, plot, note, updated]
|