s-ttp commited on
Commit
0a0177f
Β·
verified Β·
1 Parent(s): 95ec185

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +14 -8
  2. __pycache__/app.cpython-312.pyc +0 -0
  3. app.py +50 -15
README.md CHANGED
@@ -7,17 +7,23 @@ sdk: gradio
7
  sdk_version: 5.50.0
8
  app_file: app.py
9
  pinned: false
10
- short_description: Read-only monitor of a MarketFM paper-trading agent
11
  ---
12
 
13
  # DeepQuant
14
 
15
- A transparent, **read-only** monitor of an agent that trades the **MarketFM Tactical** strategy on an
16
- Alpaca **paper** account. Phase 0 shows the live account β€” equity, cash, today's P&L, open positions, and
17
- an equity curve vs the S&P 500 β€” auto-refreshing every 30 minutes.
18
 
19
- This page only *observes*: it contains no order-placing code and cannot trade. Execution is handled in a
20
- later phase by a separate, guardrailed scheduled agent (paper-only, long-only, position-capped).
 
 
 
 
 
 
21
 
22
- **Roadmap:** P0 read-only monitor β†’ P1 dry-run rebalance preview β†’ P2 paper execution β†’ P3 MarketGuru
23
- narration + scheduled weekly agent β†’ P4 reconciliation & drift alerts.
 
7
  sdk_version: 5.50.0
8
  app_file: app.py
9
  pinned: false
10
+ short_description: Hybrid autonomous fund β€” deterministic engine + agentic AI
11
  ---
12
 
13
  # DeepQuant
14
 
15
+ A **hybrid autonomous fund** running end-to-end on an Alpaca **paper** account: a deterministic quant engine
16
+ executes a 20-year-validated, regime-aware multi-asset strategy, while an **agentic AI layer** supervises it,
17
+ narrates it, and β€” within strict evidence gates β€” recalibrates it. No human in the loop.
18
 
19
+ **Division of labour, by design:**
20
+ - **Deterministic:** stock ranking (MarketFM, ~11,800-name survivorship-free universe), order execution over the
21
+ Alpaca API, risk rails (long-only, 10% cap, no leverage), daily statistical health checks vs the strategy's own
22
+ backtest distribution.
23
+ - **Agentic (Claude Opus 5):** a weekly role-separated crew β€” Analyst β†’ adversarial Critic β†’ PM β€” that assesses
24
+ the evidence and decides to hold, adopt a better-validated strategy variant, or pause trading; every action is
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, equity vs 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
@@ -245,19 +245,53 @@ def rebalance_preview():
245
  with gr.Blocks(title="DeepQuant β€” live paper monitor", theme=gr.themes.Soft()) as demo:
246
  gr.Markdown(
247
  "# πŸ€– DeepQuant\n"
248
- "### An agent that autonomously **executes** a strategy backtested to beat the S&P 500 over 20+ years\n"
249
- "DeepQuant runs a regime-aware, **multi-asset** strategy end-to-end β€” using the **Alpaca API to both execute "
250
- "*and* monitor** every trade on a live paper account.\n\n"
251
- "**Under the hood:**\n"
252
- "- 🧠 **[MarketFM](https://huggingface.co/spaces/s-ttp/marketfm-ranker)** β€” a survivorship-free quant model β€” ranks the universe and sets the target portfolio\n"
253
- "- πŸ’¬ **[MarketGuruLLM](https://huggingface.co/s-ttp/qwen25-14b-fin-lora)** β€” a fine-tuned analyst LLM β€” reasons over and narrates every rebalance\n"
254
- "- ⚑ **Alpaca API** β€” the brokerage rails the **quant execution engine** drives to place orders and stream live fills, positions and P&L\n"
255
- "- πŸ” **Autonomous recalibration** β€” tracks live vs backtest over rolling 8-week windows; on statistically unusual deviation it re-runs the full walk-forward due diligence and adopts a better-validated variant on its own\n\n"
256
- "**The strategy:** large-cap **momentum + quality** while the trend is up; when it turns down it de-risks into a "
257
- "blend of **stocks + bonds + gold** (60 / 20 / 20). Backtested 2002–2026: **~14% / yr vs the S&P 500's ~11%**, "
258
- "higher Sharpe, smaller drawdown.\n"
259
- "<sub>Phase 0 β€” live paper-account monitor below; autonomous weekly execution rolls out next. "
260
- "Backtested results, paper trading β€” not investment advice.</sub>")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  with gr.Tabs():
262
  with gr.Tab("πŸ“Š Live account"):
263
  stats = gr.Markdown()
@@ -273,8 +307,9 @@ with gr.Blocks(title="DeepQuant β€” live paper monitor", theme=gr.themes.Soft())
273
  updated = gr.Markdown("_loading…_")
274
  btn = gr.Button("↻ Refresh now", scale=0)
275
  with gr.Tab("πŸ”„ Rebalance preview"):
276
- gr.Markdown("What the agent **would** trade at the next rebalance β€” computed live from the MarketFM target "
277
- "and your current account. **Nothing is placed** (Phase 1, dry-run).")
 
278
  pv_banner = gr.Markdown()
279
  pbtn = gr.Button("⟳ Recompute preview", scale=0)
280
  with gr.Row():
 
245
  with gr.Blocks(title="DeepQuant β€” live paper monitor", theme=gr.themes.Soft()) as demo:
246
  gr.Markdown(
247
  "# πŸ€– DeepQuant\n"
248
+ "### A hybrid autonomous fund β€” deterministic quant engine, agentic AI judgment\n"
249
+ "DeepQuant runs a 20-year-validated, regime-aware multi-asset strategy **end-to-end on a live paper account** β€” "
250
+ "it selects, executes, monitors, explains, recalibrates and even pauses itself, with no human in the loop. "
251
+ "Every responsibility is assigned by one principle: **deterministic code wherever correctness must be provable, "
252
+ "agentic AI wherever judgment adds value** β€” never the other way around.\n\n"
253
+ "**The stack:**\n"
254
+ "- 🧠 **[MarketFM](https://huggingface.co/spaces/s-ttp/marketfm-ranker)** β€” a survivorship-free quant model "
255
+ "(~11,800 US stocks, 21 point-in-time factors) ranks the cross-section and sets the target portfolio\n"
256
+ "- βš™οΈ **Deterministic execution engine** β€” turns targets into orders over the **Alpaca API**: weekly rebalances, "
257
+ "market-open checks, notional market orders, idempotent reconciliation β€” inside uncrossable rails "
258
+ "(long-only, 10% position cap, no leverage, cash buffer)\n"
259
+ "- 🩺 **Deterministic supervision** β€” daily health checks locate live performance *inside the strategy's own "
260
+ "20-year backtest distribution* and watch guardrails, drift and pipeline freshness\n"
261
+ "- 🀝 **Agentic decision crew** (Claude Opus 5) β€” every week an **Analyst** assesses the evidence, an adversarial "
262
+ "**Critic** stress-tests it, and a **PM** decides: hold, adopt a better-validated strategy variant, or pause "
263
+ "trading β€” each action gated by a **code validator** (walk-forward acceptance criteria, 90-day rate limit, hard rails)\n"
264
+ "- πŸ’¬ **[MarketGuruLLM](https://huggingface.co/s-ttp/qwen25-14b-fin-lora)** β€” a fine-tuned analyst model narrates "
265
+ "every rebalance and every decision in plain English\n\n"
266
+ "**The strategy:** large-cap **momentum + quality** while the market trend is up; when it turns down, de-risk into "
267
+ "a blend of **stocks + bonds + gold** (60 / 20 / 20). Backtested 2002–2026, net of costs: **~14% / yr vs the "
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()
 
307
  updated = gr.Markdown("_loading…_")
308
  btn = gr.Button("↻ Refresh now", scale=0)
309
  with gr.Tab("πŸ”„ Rebalance preview"):
310
+ gr.Markdown("What the deterministic engine **would** trade right now β€” the live target portfolio from the "
311
+ "current (versioned) strategy config, diffed against the account. Display only: orders are placed "
312
+ "solely by the scheduled Monday agent, inside its guardrails.")
313
  pv_banner = gr.Markdown()
314
  pbtn = gr.Button("⟳ Recompute preview", scale=0)
315
  with gr.Row():