v1.2.0: 新增量化策略模块(6主流策略全市场回测+单股净值曲线/交易明细),策略: 双均线/MACD/RSI/布林带/动量/N日突破

This commit is contained in:
2026-08-19 21:09:16 +08:00
parent 4a9ea9ddd7
commit c05b1d54b3
9 changed files with 713 additions and 3 deletions
+12 -1
View File
@@ -111,6 +111,17 @@ CREATE TABLE IF NOT EXISTS analysis_history (
);
CREATE INDEX IF NOT EXISTS idx_history_code ON analysis_history(code);
CREATE TABLE IF NOT EXISTS strategy_backtests (
strategy TEXT NOT NULL,
code TEXT NOT NULL,
stock_name TEXT DEFAULT '',
metrics TEXT DEFAULT '{}', -- JSON:收益/回撤/夏普/胜率等
equity TEXT DEFAULT '[]', -- JSON[{date,value,bh}, ...] 净值曲线
trades TEXT DEFAULT '[]', -- JSON:交易明细
run_at TEXT DEFAULT (datetime('now','localtime')),
PRIMARY KEY (strategy, code)
);
CREATE TABLE IF NOT EXISTS market_index (
date TEXT PRIMARY KEY,
sh REAL DEFAULT 0, -- 上证指数(点)
@@ -177,7 +188,7 @@ def wipe_all():
"""清空业务表(保留结构)+ 重置自增序列,用于重灌数据"""
for t in ("stock_daily", "inst_ratings", "fund_holdings", "news",
"institutions", "stocks", "watchlist", "analysis_cache", "analysis_history",
"market_index"):
"market_index", "strategy_backtests"):
with db() as conn:
conn.execute(f'DELETE FROM "{t}"')
with db() as conn: