Commit Graph
18 Commits
Author SHA1 Message Date
Haozhe Wu d5ea0ec519 docs(readme): add 2026-07-26 news and ignore workbuddy 2026-07-26 19:13:36 +08:00
shadowinlife 6f9e304987 test(memory): add retrieval quality benchmark suite
Add P@5/MRR/NDCG@5 evaluation framework for memory retrieval A/B testing.
Benchmark compares Baseline (pure token overlap) vs Treatment (BM25 + importance
decay) on a 200-entry corpus with 50 annotated queries.

The benchmark suite is NOT intended for CI — it requires corpus files
(tmp/benchmark_corpus/) that are not version-controlled. The suite
automatically skips when corpus files are absent.

Corpus is derived from anonymized production agent sessions.

Usage:
    python -m pytest agent/tests/memory/benchmarks/ -v

Refs: #732
Signed-off-by: shadowinlife <shadowinlife@gmail.com>
2026-07-21 16:18:21 +08:00
shadowinlife 4cbb9c3243 chore: remove bench_report.json and revert .gitignore changes
These files are not part of the community contribution scope.
Benchmark results are kept locally for validation only.

Refs: #732
Signed-off-by: shadowinlife <shadowinlife@gmail.com>
2026-07-21 14:15:50 +08:00
shadowinlife 6ffa63be8d feat(memory): add content dedup, hotness decay and P@5 benchmark
- Implement SHA-256 content-hash deduplication with 30s sliding window
- Add compute_hotness() with sigmoid frequency × exponential recency decay
- Register VT_MEMORY_HOTNESS_DECAY feature flag (default off)
- Add P@5/MRR/NDCG@5 evaluation framework with A/B comparison
- Benchmark shows +12.9% P@5 improvement with lifecycle-aware retrieval
- 35 new tests (17 dedup + 8 hotness + 10 benchmark)

Refs: #732
Signed-off-by: shadowinlife <shadowinlife@gmail.com>
2026-07-21 14:12:30 +08:00
sambazhu d17faacefc test: add frontend test suite + backend security/coverage tests
Cherry-picked the test-infra commit from #175 (sambazhu): vitest setup + 19 frontend test files (197 tests), backend auth/path-traversal/CORS tests, yfinance crypto fallback (BTC-USDT->BTC-USD), and CI coverage + frontend-test steps. Dropped the PR's separate i18n commit to stay consistent with #163.

Fix: align @vitest/coverage-v8 to ^3.2.6 (was ^4.1.8, incompatible with vitest ^3.2.6 - blocked npm install and the new npm ci CI step).
2026-06-05 20:41:14 +08:00
Haozhe Wu 25b6ee5d72 feat(wiki): add agent-vs-human traffic counter to vibetrading.wiki
First-party, anonymous analytics for the public wiki — no client-side telemetry in the pip package. Pages Function middleware classifies each page request (AI agent / bot / human) by User-Agent server-side and counts it into D1; /api/stats serves the footer's aggregate counts alongside public PyPI install and GitHub star numbers.
2026-06-05 14:03:17 +08:00
Haozhe Wuandykykj 74614f0e7c feat(cli): refresh interactive terminal UI
Refresh the interactive terminal transcript, activity rail, and prompt visuals. Document the 2026-05-23 CLI update in README and keep generated CLI screenshots out of git.

Co-authored-by: ykykj <140159248+ykykj@users.noreply.github.com>
2026-05-24 00:17:45 +08:00
Haozhe Wu 137689c5c1 feat(wiki): Alpha Library auto-render + "Alpha 191 in 2026" blog
wiki/scripts/build_alpha_library.py (475L)
- Reads manifest.json produced by `vibe-trading alpha export-manifest`
- Emits per-alpha pages (content/<zoo>/<id>.html) and per-zoo
  overview tables (content/<zoo>/index.html) — 452 + 4 = 456 pages
- Jinja2 with select_autoescape(["html","xml"]) mandatory; no |safe
  on user-derived content; strict CSP on every generated page
  (default-src 'self'; style-src 'self' 'unsafe-inline';
   script-src 'none'; img-src 'self' data:)
- Emits content/index.json for the landing page to hydrate per-zoo
  counts via fetch()
- Friendly exit when manifest.json missing
- End-of-main self-test compares manifest formula content against
  rendered HTML to verify the escape pipeline; prints
  "html escape ok" or "html escape FAIL"

wiki/alpha-library/index.html (rewritten from 78-line shell to 192L)
- Hero + 4 zoo cards (Kakushadze 101 Formulaic Alphas, qlib158,
  gtja191, academic) + stats grid + 3-line CLI quickstart + GitHub
  footer
- Per-zoo counts hydrated at runtime from content/index.json
- Loose CSP (script-src 'self' 'unsafe-inline') only on this landing
  page to keep the site theme-init inline script and the inline
  fetch() — generated /content/** pages stay on script-src 'none'

wiki/research-lab/index.html
- Post grid replacing the empty hero stub; links to the new blog
- One-line lede explaining the section

wiki/research-lab/posts/alpha-191-in-2026.html (~675L, ~2400 words)
- 6-section deep-dive: TL;DR / Background / Method / Findings /
  Caveats / Reproduce
- Numbers from a real bench run on CSI 300 / 2018-2025: 10 alive,
  15 reversed, 165 dead (of 190 tested, 1 skipped). Top 5 by IR:
  gtja191_171 / _111 / _163 / _002 / _054. Theme survival rates:
  microstructure 22%, reversal 11%, volatility 8%, volume 5%,
  momentum 2%, liquidity 0%
- Survivorship-bias caveat for cross-zoo readers (the current
  constituent list of any index is a forward-biased proxy for the
  point-in-time constituents during the window)
- Strict CSP (script-src 'none'); no MathJax/KaTeX — formula_latex
  rendered as <code class="formula">; aggregate stats only (no
  per-stock per-date values, Tushare ToS)

wiki/research-lab/posts/alpha-191-in-2026.tweet.md
- HKUDS-style draft tweet (Chao Huang voice): emoji-decorated
  project name, real numbers (10 / 15 / 165), 8-year OOS qualifier,
  GitHub + pip links, ≤2 hashtags. READY to post once the release
  goes live.

.gitignore adds wiki/alpha-library/manifest.json and
wiki/alpha-library/content/ as generated, never-checked-in artifacts.
2026-05-17 20:04:24 +08:00
shadowinlifeandshadowinlife e346fa1adf feat(agent): add MCP client integration (stdio, v1) (#83)
Adds a stdio MCP client so the built-in agent can load external MCP tools alongside local tools.

- Pydantic `AgentConfig` + loader (JSON/YAML, ~/.vibe-trading discovery) with safe fallback
- `MCPServerAdapter` wraps FastMCP stdio client: per-tool timeout, single transient retry, schema normalization, sync-from-async bridge
- Per-server failure isolation in `build_registry` — one broken server never blocks local tools or other MCP servers
- Sanitization gate: `mcpServers` in session-level overrides is stripped by default (RCE prevention); opt-in via `ALLOW_SESSION_MCP_SERVERS=1`
- Server-name collision resolver with operator-facing warnings propagated through CLI + SessionService SSE
- v1 scope: stdio only, serial execution, tools only, no Swarm propagation
- 58 new tests (16 adapter + 17 config + 11 registry + 6 stdio subprocess + 6 regression + 2 sanitize/merge invariant)

Co-authored-by: shadowinlife <shadowinlife@users.noreply.github.com>
2026-05-16 01:17:47 +08:00
Haozhe Wu 7b27f6e3e2 Add static Vibe-Trading wiki
Add a static Cloudflare Pages wiki under wiki/, including the landing page, docs app, redirects/headers, maintainer README, and wiki validation workflow.
2026-05-14 19:31:31 +08:00
Haozhe Wu f917b71960 chore: add local dev workflow 2026-05-06 19:04:43 +08:00
warren618 05fc5cac22 test(api): add /upload streaming + size-limit regression tests
Pin PR #53 behavior with 4 cases:
- under-limit upload writes to UPLOADS_DIR
- exactly-at-limit upload succeeds
- over-limit returns 413 and removes the partial file
- blocked extension returns 400 with no file written

Tests shrink MAX_UPLOAD_SIZE to 4 KB via monkeypatch so the streaming
chunk loop and cleanup path run without allocating 50 MB.

Also gitignore AGENTS.md (local mirror of CLAUDE.md for non-Claude
agent tools, identical content, no need to track twice).
2026-04-27 21:53:50 +08:00
Hamza Mobeen f9022a3ac4 docs: add usage examples to README (#45) 2026-04-20 18:46:00 +08:00
warren618 25380bac96 feat(ux): surface shadow account + trade journal in CLI, web, README
CLI (agent/cli.py):
- Welcome footer + help table natural-language hints for journal/shadow
- Tool preview highlights report_url for render_shadow_report;
  shadow_id for extract_shadow_strategy / run_shadow_backtest

Frontend:
- WelcomeScreen: Trade Journal (2) + Shadow Account (3) sample categories;
  capability chips refreshed (56→70 skills, 25→29 presets, 19→32 tools)
  + 4 new chips (Trade Journal / Shadow Account / Persistent Memory /
  Session Search)
- Home: 4th feature card "Strategy Replay" (grid: 4 cols at lg)
- RunCompleteCard: detects msg.shadowId, opens /shadow-reports/<id>
  in new tab; runId now optional so shadow-only runs render the card
- Agent.tsx: parses render_shadow_report preview for shadow_id; emits
  run_complete even when no backtest metrics if shadowId present
- AgentMessage: + shadowId optional field
- i18n: feat4/feat4d ("Strategy Replay")
- vite.config.ts: /shadow-reports proxy to :8899 (without this, the
  button 404s in dev because Vite doesn't forward unknown routes)

README news (en/zh/ja/ko/ar):
- 2026-04-18 Shadow Account entry
- 2026-04-15 Z.ai + MiniMax collapsed into <details> Earlier news

Repo hygiene:
- .gitignore: assets/*.mp4 (demo videos kept local);
  agent/tests/e2e_*.py + test_e2e_*.py (manual smoke tests requiring
  live API keys — would break CI if collected by pytest)
2026-04-18 23:15:59 +08:00
warren618 2b0a775db0 feat: trade journal analyzer — profile + behavior diagnostics
Users upload broker exports (CSV/Excel) and get a trading portrait
plus 4 bias diagnostics. Parses 同花顺/东方财富/富途/generic formats
with encoding fallback (utf-8/gbk/gb2312/big5).

Profile: holding days, win rate, PnL ratio, max drawdown, top
symbols, market/hourly distribution via FIFO lot matching.

Behavior: disposition effect, overtrading, chasing momentum,
anchoring — each with severity + numeric evidence derived from
the journal itself, no external market data pulls.

Also: gitignore agent/uploads/ so runtime user uploads never leak
into the repo; inline a tiny csv in test_doc_reader instead of
depending on a fixture file.
2026-04-17 21:46:13 +08:00
warren618 483de22b7d test: add 236 unit tests + CI pytest integration
- 13 test files covering: market detection, loader registry/fallback,
  engine market rules (ChinaA T+1/涨跌停, Crypto funding/liquidation,
  US/HK commission), signal alignment, metrics, optimizer, provider mapping
- CI: fix branch master→main, add pytest step (e2e excluded)
- pyproject.toml: add pytest config + dev dependencies
- .gitignore: expose unit tests, keep e2e local-only
2026-04-10 14:36:11 +08:00
warren618 8e6963f462 feat: multi-market backtest engines with per-market rules
Replace single vectorised daily_portfolio engine with bar-by-bar engines
that enforce real market rules:
- ChinaAEngine: T+1, no shorting, price limits, 100-lot, stamp tax
- CryptoEngine: 24/7, funding fees, liquidation, maker/taker, leverage
- GlobalEquityEngine: US zero-commission + fractional / HK stamp tax + lots

New shared foundation: models.py (Position/TradeRecord/EquitySnapshot),
metrics.py (extracted from daily_portfolio), base.py (BaseEngine ABC).
Runner routes by source to the correct engine automatically.
2026-04-09 01:17:28 +08:00
warren618 34eae37ba4 Initial commit 2026-04-01 18:14:49 +08:00