From 04729123140efebc613b7581ea0315a94160b230 Mon Sep 17 00:00:00 2001 From: Jcstack Date: Fri, 26 Jun 2026 11:35:56 +0800 Subject: [PATCH] feat(demo): one-command offline quickstart via `make demo` (#57) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #57 (P3.1). Lowers onboarding friction with a zero-setup demo that runs the v2 backtest on a bundled sample dataset — no Docker, API keys, or network: - `make demo` → `scripts/backtest_v2 --csv scripts/sample/demo_ohlcv.csv --no-regime`, printing a full performance report in one command. - scripts/sample/demo_ohlcv.csv: small committed synthetic OHLCV (160 bars). - README: a "30-second / no-setup" Quick Start step above the Docker path. Verified `make demo` runs end-to-end offline. The full Docker stack (`make up`) is unchanged. Simulation-only; not investment advice. Co-Authored-By: Claude Opus 4.8 (1M context) --- Makefile | 19 +++- README.md | 10 +++ scripts/sample/demo_ohlcv.csv | 161 ++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 scripts/sample/demo_ohlcv.csv diff --git a/Makefile b/Makefile index 185bf56..8d6da1a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: up down restart rebuild logs status clean purge test-integration-real health qlib-update qlib-status bridge-start bridge-stop bridge-status help +.PHONY: up down restart rebuild logs status clean purge test-integration-real health qlib-update qlib-status bridge-start bridge-stop bridge-status demo help + +PYTHON ?= $(shell [ -x .venv/bin/python ] && echo .venv/bin/python || echo python3) # ============================================================ # Docker Compose 管理脚本 @@ -198,12 +200,27 @@ bridge-status: @curl -s http://localhost:19821/health 2>/dev/null | python3 -m json.tool \ || echo "Bridge not running" +# ============================================================ +# 离线演示 / Offline demo (no Docker, no API keys, no network) +# ============================================================ + +demo: + @echo "▶ v2 回测离线演示(无需 Docker / API Key / 网络)" + @echo " v2 backtest on bundled sample data — no Docker, API keys, or network." + @echo "" + @$(PYTHON) -m scripts.backtest_v2 --csv scripts/sample/demo_ohlcv.csv --no-regime + @echo "" + @echo "下一步 / Next: 用真实数据跑 universe 回测:" + @echo " $(PYTHON) -m scripts.backtest_v2_universe --start 20190101 --end 20241231" + @echo "完整启动 / Full stack: make up · 文档/docs: docs/how-it-works.md" + # 帮助信息 help: @echo "" @echo "Docker Compose 管理命令" @echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" @echo "" + @echo " make demo 一键离线演示 (无需 Docker/API Key/网络)" @echo " make up 构建并启动所有服务 (默认)" @echo " make down 停止所有服务 (优雅等待 30s)" @echo " make restart 重启 (保留镜像)" diff --git a/README.md b/README.md index 7837c04..d7676ea 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,16 @@ src/web/ FastAPI · frontend/ React SPA · src/discord_bot/ · openclaw/ C ## 快速开始 · Quick Start +### 0. 30 秒离线演示 / Try it in 30s (no Docker, no API keys, no network) + +```bash +pip install -r requirements.txt +make demo # 用样例数据跑 v2 回测 / runs the v2 backtest on bundled sample data +``` + +See [`docs/how-it-works.md`](docs/how-it-works.md) for what it does. For the full +stack (web UI, agent loop, automation), continue below. + ### 前置条件 / Prerequisites - Docker & Docker Compose diff --git a/scripts/sample/demo_ohlcv.csv b/scripts/sample/demo_ohlcv.csv new file mode 100644 index 0000000..17b1b67 --- /dev/null +++ b/scripts/sample/demo_ohlcv.csv @@ -0,0 +1,161 @@ +date,open,high,low,close,volume +2023-01-03,50.33,50.58,50.31,50.43,6364474 +2023-01-04,51.39,51.4,51.17,51.35,3901750 +2023-01-05,50.45,50.4,50.1,50.25,2615727 +2023-01-06,50.11,50.16,49.97,50.16,2442437 +2023-01-09,50.2,50.53,49.95,49.99,4884991 +2023-01-10,50.63,50.86,50.62,50.68,5657774 +2023-01-11,51.22,51.55,51.28,51.36,6706724 +2023-01-12,52.18,52.33,52.01,52.14,4355960 +2023-01-13,52.12,52.58,51.98,52.14,5602142 +2023-01-16,52.09,52.2,52.01,52.05,3092538 +2023-01-17,52.65,52.92,52.42,52.51,6868878 +2023-01-18,52.54,53.2,52.46,52.52,3086507 +2023-01-19,52.17,52.61,52.14,52.29,7759765 +2023-01-20,52.73,53.25,52.57,52.76,2133090 +2023-01-23,52.42,53.1,52.28,52.52,6209130 +2023-01-24,51.64,51.72,51.34,51.69,6972128 +2023-01-25,51.02,51.25,50.61,50.9,6396246 +2023-01-26,51.57,51.49,51.31,51.4,4579295 +2023-01-27,51.51,51.63,51.55,51.58,4570295 +2023-01-30,51.88,51.77,51.62,51.75,2444155 +2023-01-31,52.15,52.48,52.27,52.28,6608963 +2023-02-01,53.99,54.2,53.88,53.97,7968268 +2023-02-02,54.38,54.25,54.14,54.24,6965740 +2023-02-03,55.71,55.8,55.64,55.69,4463394 +2023-02-06,56.7,56.87,56.47,56.71,4161764 +2023-02-07,57.68,57.72,57.55,57.62,7921813 +2023-02-08,57.74,58.04,57.65,57.76,5814234 +2023-02-09,58.69,59.3,58.7,58.8,3787293 +2023-02-10,59.04,59.31,58.79,58.95,7394932 +2023-02-13,58.54,58.8,58.48,58.53,2735783 +2023-02-14,58.8,58.87,58.71,58.77,5790852 +2023-02-15,58.86,59.48,58.19,58.96,6747920 +2023-02-16,59.14,59.16,58.46,58.98,6706397 +2023-02-17,59.89,60.23,59.71,59.96,4560740 +2023-02-20,58.1,58.62,58.11,58.32,5189629 +2023-02-21,57.85,57.73,57.47,57.71,2057640 +2023-02-22,57.17,57.31,57.13,57.3,3485405 +2023-02-23,56.8,56.85,56.26,56.81,7319261 +2023-02-24,56.91,57.59,57.04,57.2,4781456 +2023-02-27,57.7,57.77,57.66,57.72,4329892 +2023-02-28,57.54,57.94,57.45,57.63,3773566 +2023-03-01,58.28,58.29,58.07,58.2,4033571 +2023-03-02,58.52,59.08,58.32,58.52,5289537 +2023-03-03,58.78,59.02,58.49,58.76,3956530 +2023-03-06,59.7,60.1,59.19,59.87,5291088 +2023-03-07,59.56,59.97,59.15,59.51,2844248 +2023-03-08,59.77,59.74,58.91,59.67,6818412 +2023-03-09,59.76,59.77,59.44,59.67,3827059 +2023-03-10,59.87,59.88,59.7,59.78,5375127 +2023-03-13,61.76,62.24,61.62,61.75,3061211 +2023-03-14,61.54,61.66,61.41,61.44,2982748 +2023-03-15,61.22,61.41,60.69,61.12,5493788 +2023-03-16,60.71,60.73,60.5,60.72,5777688 +2023-03-17,60.56,60.57,60.26,60.49,5337498 +2023-03-20,61.88,61.97,61.31,61.9,3374576 +2023-03-21,62.7,63.15,62.58,62.74,4860315 +2023-03-22,62.83,62.79,62.51,62.68,7319556 +2023-03-23,62.76,62.75,62.52,62.65,3856141 +2023-03-24,62.96,63.25,62.56,62.95,7999707 +2023-03-27,63.03,63.12,63.05,63.05,2681721 +2023-03-28,63.25,63.45,63.0,63.26,5118394 +2023-03-29,62.71,63.62,62.88,62.96,6562685 +2023-03-30,63.54,63.82,63.2,63.48,3544728 +2023-03-31,62.98,62.92,62.78,62.85,3301091 +2023-04-03,63.62,63.46,63.37,63.38,2004247 +2023-04-04,64.24,64.73,64.25,64.27,2764896 +2023-04-05,63.69,63.87,63.35,63.84,6621470 +2023-04-06,64.12,64.36,63.93,63.97,2868443 +2023-04-07,65.29,65.3,65.07,65.23,3725145 +2023-04-10,65.5,65.47,65.08,65.29,6259961 +2023-04-11,65.36,65.49,65.21,65.4,6198939 +2023-04-12,65.3,65.5,65.11,65.31,7842312 +2023-04-13,66.71,67.34,66.86,66.98,5518414 +2023-04-14,67.01,67.64,66.55,67.12,5846836 +2023-04-17,66.99,67.45,66.77,67.09,4329121 +2023-04-18,67.59,67.68,67.37,67.61,3858110 +2023-04-19,70.35,70.98,69.97,70.15,4788960 +2023-04-20,68.88,68.75,68.27,68.64,4850275 +2023-04-21,68.93,68.77,68.47,68.68,5256448 +2023-04-24,69.22,70.22,68.78,69.17,6244874 +2023-04-25,68.95,68.8,68.37,68.67,2093448 +2023-04-26,67.97,68.14,67.68,68.0,7753459 +2023-04-27,68.55,68.75,68.18,68.54,6442411 +2023-04-28,68.11,68.56,68.29,68.37,7103913 +2023-05-01,70.06,70.61,69.96,70.21,2986611 +2023-05-02,71.85,72.4,71.52,72.07,4386715 +2023-05-03,70.79,71.18,70.35,70.75,3358201 +2023-05-04,69.38,69.69,68.99,69.14,5360037 +2023-05-05,69.24,69.23,68.99,69.16,7803736 +2023-05-08,69.29,69.27,68.9,68.98,3284415 +2023-05-09,68.09,68.45,67.57,67.99,6736695 +2023-05-10,68.44,68.44,67.78,68.22,6933063 +2023-05-11,67.72,68.25,67.58,67.73,7010173 +2023-05-12,65.95,66.14,65.98,66.07,2967648 +2023-05-15,65.56,66.17,65.68,65.84,6640622 +2023-05-16,66.36,66.45,65.61,66.31,5682006 +2023-05-17,65.85,66.04,65.65,65.7,7139025 +2023-05-18,65.96,66.03,65.73,65.8,3571007 +2023-05-19,65.67,65.74,65.15,65.51,6740045 +2023-05-22,65.52,65.82,64.64,65.34,3179639 +2023-05-23,66.46,66.84,66.02,66.69,4338476 +2023-05-24,67.9,68.11,67.75,67.95,7750700 +2023-05-25,67.72,68.31,67.58,67.79,6324730 +2023-05-26,67.51,67.26,66.95,67.24,4045445 +2023-05-29,67.46,67.65,67.0,67.46,5876231 +2023-05-30,66.25,66.94,66.23,66.42,3812579 +2023-05-31,66.09,66.15,65.91,66.01,2841483 +2023-06-01,65.49,65.71,64.72,65.42,3276498 +2023-06-02,64.9,65.06,64.98,65.02,2110810 +2023-06-05,64.33,64.92,64.18,64.5,6749145 +2023-06-06,63.45,63.77,63.15,63.59,4304563 +2023-06-07,63.91,63.8,63.7,63.77,7059106 +2023-06-08,62.79,62.91,62.33,62.75,5434840 +2023-06-09,62.28,62.44,62.24,62.34,2746734 +2023-06-12,62.55,62.67,62.14,62.45,4594675 +2023-06-13,63.18,63.06,62.69,62.89,3209593 +2023-06-14,64.08,64.25,63.82,63.87,3229659 +2023-06-15,63.86,63.89,63.33,63.84,3035532 +2023-06-16,63.61,64.28,63.66,63.91,5769776 +2023-06-19,62.44,63.31,62.16,62.47,7670808 +2023-06-20,62.53,62.92,62.47,62.57,6051288 +2023-06-21,63.11,63.14,62.69,63.13,6067478 +2023-06-22,63.28,63.25,62.6,63.17,7001428 +2023-06-23,62.77,63.37,62.71,62.83,7647468 +2023-06-26,63.38,63.4,63.27,63.34,3969026 +2023-06-27,63.22,63.57,63.14,63.26,6339313 +2023-06-28,63.6,63.63,63.54,63.6,2023544 +2023-06-29,63.74,63.7,63.62,63.68,3387473 +2023-06-30,62.4,62.78,62.1,62.45,4741897 +2023-07-03,62.77,62.97,62.12,62.74,6869180 +2023-07-04,63.88,64.62,63.72,63.97,6848191 +2023-07-05,64.14,64.63,63.64,64.14,7845607 +2023-07-06,64.14,64.08,63.69,63.93,6816375 +2023-07-07,63.49,63.79,63.59,63.61,7592753 +2023-07-10,62.87,63.07,62.52,62.82,4022721 +2023-07-11,63.96,64.17,63.47,63.83,6728261 +2023-07-12,63.16,63.29,62.72,63.14,2370007 +2023-07-13,62.83,63.68,62.63,62.82,4247896 +2023-07-14,61.11,61.13,60.96,61.07,7147718 +2023-07-17,60.76,60.93,60.71,60.72,6994277 +2023-07-18,61.14,61.21,60.93,61.1,2605961 +2023-07-19,60.38,61.02,60.25,60.54,5062650 +2023-07-20,59.48,59.44,59.07,59.42,7026407 +2023-07-21,58.88,59.21,58.71,58.93,4009455 +2023-07-24,58.54,58.85,58.63,58.76,4193089 +2023-07-25,58.74,58.97,58.81,58.85,7230005 +2023-07-26,58.51,58.86,58.13,58.34,6313973 +2023-07-27,58.3,58.33,57.88,58.13,6108572 +2023-07-28,57.88,57.93,57.59,57.91,3447564 +2023-07-31,57.32,57.29,57.22,57.28,2952148 +2023-08-01,56.56,56.6,56.37,56.5,7229628 +2023-08-02,55.71,55.68,55.29,55.65,2129108 +2023-08-03,56.33,56.19,55.89,56.04,3492307 +2023-08-04,55.73,56.1,55.97,55.97,3532576 +2023-08-07,55.66,55.71,55.3,55.64,2129046 +2023-08-08,55.24,55.25,55.11,55.25,6465221 +2023-08-09,54.7,55.16,54.38,54.84,7397167 +2023-08-10,54.78,55.1,54.65,54.95,6446231 +2023-08-11,56.19,56.15,55.99,56.05,2550144 +2023-08-14,54.28,54.43,53.9,54.33,6318972