DSH HUB
首页插件商店插件包社区排行榜资源发布指南
插件源码
返回插件目录

ethan2737 /

ethan2737/dsh-quant

仅 Topic 仓库

Quantitative trading workbench inside DeepSeek Harness: A-share data center, factor library, screening, strategy rotation, backtests, and 21 model-callable tools.

★ 0 Stars0 Forks0 IssuesN/A 社区评分0 已确认安装
查看 GitHub
README来源: master@a7c51582

quant-plugin

English · 简体中文

A quantitative trading workbench that runs inside DeepSeek Harness (DSH) Web. One package, two halves: the client half rebuilds the harness shell into an eleven-page trading console, the host half registers twenty-one model-callable tools, serves the page data routes, and manages its own PostgreSQL instance.

The system does the analysis; you place the orders. Every data-facing job — screening, signals, news, strategy and factor management — belongs to the workbench and the agent. The single manual step left is sending the order to a broker.

What it does

Area Capability
Data center Local PostgreSQL warehouse, A-shares + ETFs from 2015-01-01, daily bars and incremental sync; delisted stocks included so backtests get a point-in-time universe instead of today's survivors
Market regime Three-state classification (range / uptrend / downtrend) per stock, index and industry; position sizing and dual-momentum asset allocation on top
Screening Configurable engine: a method (registry entry) plus plans (method + parameter set + enabled flag), emitting star-rated candidates with fundamental cards
Factor library Registry-driven factors with daily value snapshots, four-step preprocessing (MAD → z-score → industry neutral → size neutral) and quarterly effectiveness review (rank IC / ICIR / monotonicity / crowding)
Strategy library Strategy templates and instances with lifecycle labels, walk-forward evaluation and adaptive rotation per stock
Trading records Moving-average cost basis that auto-adjusts on dividends and splits, position reconciliation against broker app snapshots, lightweight backtests
Intel center News / F10 / sentiment / macro / policy feeds, a 15-class event engine, and a four-zone board; high-severity events feed the strategy watch channel
Agent tools Twenty-one tools over these domains — the model queries the same data the pages show

Architecture

DSH Web (browser)
  client half ......... sidebar entry · 11 workbench pages · 6 conversation cards
        ⇅  HTTP /api/quant/*  ·  tool calls
DSH host (Node)
  host half ............ 21 tools · context protocol · audit hooks · PostgreSQL lifecycle
        ⇅  spawn python scripts/*.py
Python data layer ....... akshare fetchers · factor engine · screening · backtest · validation
        ⇅  psycopg
PostgreSQL 16.16 ........ 109 tables · 228 partitions · ~153M rows

The host half never talks to the database directly. Everything goes through scripts/*.py, so the CLI and the agent share one implementation.

Layout

Path Contents
packages/quant-plugin/src/index.ts Host half: tool registration, /api/quant/* routes, context protocol, audit hooks, schedules
packages/quant-plugin/src/client/ Client half: workbench pages, six chat cards
packages/quant-plugin/src/db-lifecycle.ts Portable PostgreSQL: download, SHA256 check, initdb, schema, start/stop, instance ownership
packages/quant-plugin/pg-version.json Pinned PostgreSQL build URL, size and digest
scripts/ Python data layer (51 modules): fetch, factors, screening, strategy, backtest, validation
scripts/sql/ Schema; executed in filename order
docs/ Design documents (Chinese) and ADRs
tests/ pytest suite

Quick start

Requirements: Windows, Node with pnpm, Python 3.13, DSH >= 0.2.2-rc.3.

pnpm install
pnpm bundle                     # lib/index.js (host) + lib/client.js (client)

# link the package into a DSH profile
New-Item -ItemType Junction -Path "$env:USERPROFILE\.dsh\profiles\web\node_modules\quant-plugin" `
  -Target (Resolve-Path packages/quant-plugin)

# run a development instance
dsh --profile web --patch packages/quant-plugin/cordis.yml --port 13081

Open http://127.0.0.1:13081 — the sidebar shows a 量化交易 entry, and the panel opens on the dashboard. The first launch prepares the database on its own: download PostgreSQL 16.16 (378 MB, SHA256-verified), extract, initdb, create the database, run the twelve schema files, start the server. Progress is logged as percentages while it downloads.

Historical data is not fetched automatically — that is hours of network work:

python scripts\init_data.py --source sina --workers 4 --skip-financial --skip-rate

Configuration

.env in the repository root (git-ignored):

Variable Default Purpose
PG_HOST / PG_PORT localhost / 15432 Database endpoint
PG_USER / PG_PASSWORD / PG_DATABASE quant / — / quant Credentials and database name
QUANT_PG_HOME <repo>/.pg/pgsql PostgreSQL binaries
QUANT_PG_DATA <repo>/.pg/data Data directory
QUANT_PLUGIN_SCHEDULES off on enables the scheduled sync / validation / review jobs
QUANT_PLUGIN_CHANGE_APPROVAL auto auto | ask | deny for mutating tools (config, trade entry)

Two DSH instances can share one database. The first one to start writes pgowner.lock and owns the instance lifetime; a second instance detects the listening port and only reuses it, so closing one window never kills the database someone else is using. See ADR-0002.

Agent tools

Domain Tools
Data query_kline, query_stock_info, query_trade_calendar, query_financial
Market market_overview, query_regime
Screening screen_stocks
Strategy list_strategies, get_strategy_detail, get_eval_snapshot, recommend_strategy, apply_config, revert_config
Signals & portfolio trade_signals, portfolio, record_trade
Factors list_factors, evaluate_factor
Intel query_intel
Profile build_stock_context
Backtest run_backtest

Tool contracts are specified in docs/agent-tools.md. Mutating tools pass an approval gate and every call is audited into tool_call_log.

Workbench pages

Dashboard · Factor library · Market overview · Screening · Trading records · Backtest · Strategy library · Intel center · Stock detail · Data center · Agent analysis.

Pages read /api/quant/*, which resolves to the same Python scripts the tools call, so what you see and what the model sees cannot drift apart.

Documentation

Document Subject
docs/database.md Data center design: principles, deployment, table schemas, validation
docs/agent-tools.md Tool contracts and the context protocol
docs/screen-engine.md Configurable screening engine
docs/factor-library.md Factor registry, preprocessing, effectiveness review
docs/strategy-library.md Strategy templates, instances, rotation
docs/regime-model.md Regime classification and strategy matching
docs/intel-center.md News sources, event engine, sentiment board
docs/trading-records.md Trade records and lightweight backtests
docs/adr/ Architecture decisions
CONTEXT.md Domain glossary (Chinese)

The design documents are written in Chinese; the code, schema and tool names are English.

Status

Under active development. The data layer moved from a Docker container to a portable PostgreSQL instance on 2026-11-24 — 109 tables verified row-for-row (153,459,084 rows) before cutover, see ADR-0002. Scheduled jobs ship disabled so a development instance does not hit the network or the database in the background.

Conventions

  • AGENTS.md — instructions for coding agents working in this repository
  • CONTEXT.md — the domain glossary; implementation details belong in ADRs and design docs
  • docs/agents/domain.md — single-context layout, ADR rules

Private repository; no license granted for redistribution.

—/ 5

暂无评分

需要先验证清单

Commit a7c515820ba2

社区评论

还没有评论,来写第一条。

DSH HUB

社区维护的 DSH 插件索引。不是 GitHub 或 DeepSeek AI 的官方产品。

社区资源API关于