Runbook for iterating the Vegas strategy in this repo. Use when running Vegas 4H backtests, querying back_test_log metrics, updating strategy_config/risk_config (typically id=11), and consulting iteration history.
DB_HOST='mysql://root:example@localhost:33306/test?ssl-mode=DISABLED'TIGHTEN_VEGAS_RISK=0STRATEGY_WARMUP_LIMIT=500STRATEGY_WARMUP_LIMIT_MAX=10000max(STRATEGY_WARMUP_LIMIT, strategy.value.min_k_line_num),并受 MAX 限制OKX_REQUEST_EXPIRATION_MS=300000从仓库根目录执行:
TIGHTEN_VEGAS_RISK=0 \
DB_HOST='mysql://root:example@localhost:33306/test?ssl-mode=DISABLED' \
cargo run
podman exec -i mysql mysql -uroot -pexample test -e "select id,win_rate,profit,final_fund,sharpe_ratio,annual_return,max_drawdown,volatility,created_at from back_test_log order by id desc limit 1\\G"
podman exec -i mysql mysql -uroot -pexample test -e "select id,strategy_type,inst_type,time,win_rate,profit,final_fund,sharpe_ratio,annual_return,max_drawdown,volatility,created_at from back_test_log where id=<ID>\\G"
# 查看当前配置
podman exec -i mysql mysql -uroot -pexample test -e "select value,risk_config from strategy_config where id=11\\G"
# 更新配置(建议使用 JSON_OBJECT 避免转义地狱)
podman exec -i mysql mysql -uroot -pexample test -e 'UPDATE strategy_config SET value=JSON_OBJECT(...), risk_config=JSON_OBJECT(...) WHERE id=11;'
win_rate >= 0.55 且 profit > 0Sharpe ↓ → MaxDD ↑ → Profit ↓(收益偏好时可用 Profit ↓ → win_rate ↓)ETH 单样本出发的新规则/止损/形态修正,必须先确认 ETH 单币种回测净正向,再去做 BTC / SOL / BCH 复核。ETH 正向且其他币种未被明显拖坏后,才允许更新正式基线、默认 DB 配置和迭代日志中的“推荐基线/已确认基线”。BTC / ETH / 其他币种 三层处理,因为 BTC 波动性 < ETH 波动性 < 其他币种。若同一结构因子在不同层需要不同阈值、权重、止损参数,允许做分层参数验证,不再强求单一参数组跨币种最优。单参数通用:同一套参数跨 BTC / ETH / 其他币种 都成立;分层参数通用:同一结构逻辑成立,但需按波动性分层微调参数;仅 ETH 有效:只在 ETH 正向,其他层即使做合理分层调整后仍不成立。ETH 有效,不能因为 BTC / 其他币种 波动更大或更小就直接判为“具备普适性”;只有在完成分层参数复核后,才能写入“分层参数通用”类结论。基线 vs 实验 的缺失交易、新增交易、共同交易 PnL delta;若总路径 delta 为负,不能仅凭 shadow pnl 或局部坏单改善升级。TotalPnL <= -10)才允许进入下一轮实验;低于门槛的候选只进入观察区。其他币种 不作为可执行整体结论,必须按具体标的(如 SOL / BCH)拆分后再判断样本数、TotalPnL 与是否进入实验。histogram 数值正负;仅当 histogram 缺失时才回退到 above_zero 布尔字段,避免历史快照中派生布尔值与数值不一致污染候选。stop_loss_update_history,确认 signal_ts/source/new_price;不能只看开仓行 signal_value,否则会把止损来源误判成错误的 K 线或错误的信号链。back_test_detail 的 close 行 signal_value 可能为空;分析入场形态、信号快照、指标组合时,必须改查同笔交易的 open/long/short 行。close 行只用于查看 close_type、stop_loss_source 和 stop_loss_update_history。目标样本 -> ETH 单币 -> BTC / ETH / 其他币种分层复核;ETH 未净正向,不进入下一层。ETH -> BTC -> SOL -> BCH 单币补跑,而不是四币一次性全跑。这样更省 token、更省库表空间,也更容易定位阻塞。filtered_signal_log 的命中数和 shadow pnl;若命中为 0 或明显与预期相反,直接拒绝,不做扩大验证。ETH 新旧基线 deltaETH 胜率/Sharpe 上升但 profit 微降,先做一轮最小阈值收敛,不直接接受,也不立刻全回滚。back_test_detail / filtered_signal_log / back_test_log,但不得删除当前正式基线与保留候选。假设:这一轮只验证什么目标样本:具体时间点或坏簇定义预计命中层:BTC / ETH / 其他币种命中结果:是否命中,命中多少笔ETH delta:win_rate / profit / sharpe / max_drawdown分层结果:BTC / ETH / 其他币种分类结论:单参数通用 / 分层参数通用 / 仅 ETH 有效 / 已验证但无效strategy_detail 里出现某模块且 is_open=true,就不要删除该模块/字段/指标链路;下线只能通过配置关闭(例如 is_open=false 或权重设为 0.0),并保留最小实现兼容旧配置。kline_hammer_signal:必须存在(缺失会解析失败)。SignalType 值要用正确枚举名(例如 SimpleBreakEma2through,不是 SimpleBreakEma2)。LIVE_ATTACH_TP=1:下单时附带止盈(默认不附带)LIVE_CLOSE_OPPOSITE_POSITION=1:反向持仓先平仓再开仓LIVE_SKIP_IF_SAME_SIDE_POSITION=1:已有同向持仓则跳过开新仓SimpleBreakEma2through, VolumeTrend, EmaTrend, Rsi, TrendStrength, EmaDivergence, PriceLevel, Bolling, Engulfing, KlineHammer, LegDetection, MarketStructure, FairValueGap, EqualHighLow, PremiumDiscount, FakeBreakoutmax_loss_percent: f64,
is_used_signal_k_line_stop_loss: Option<bool>,
is_one_k_line_diff_stop_loss: Option<bool>,
is_move_stop_open_price_when_touch_price: Option<bool>,
atr_take_profit_ratio: Option<f64>,
fixed_signal_kline_take_profit_ratio: Option<f64>,
is_counter_trend_pullback_take_profit: Option<bool>,
-- 1) 查最新回测
SELECT id, win_rate, profit, final_fund, sharpe_ratio, max_drawdown, created_at
FROM back_test_log
WHERE strategy_type='Vegas'
ORDER BY id DESC
LIMIT 1;
-- 2) 查最佳(Sharpe ↓ → MaxDD ↑ → Profit ↓)
SELECT id, win_rate, profit, final_fund, sharpe_ratio, max_drawdown, created_at
FROM back_test_log
WHERE strategy_type='Vegas' AND inst_type='ETH-USDT-SWAP' AND time='4H' AND profit > 0
ORDER BY sharpe_ratio DESC, max_drawdown ASC, profit DESC
LIMIT 5;
-- 3) 查最近 N 条
SELECT id, win_rate, profit, final_fund, sharpe_ratio, max_drawdown, created_at
FROM back_test_log
WHERE strategy_type='Vegas' AND inst_type='ETH-USDT-SWAP' AND time='4H'
ORDER BY id DESC
LIMIT 20;
-- 4) 查某回测的明细统计
SELECT option_type, COUNT(*) AS cnt, SUM(CAST(profit_loss AS DECIMAL(16,4))) AS total_profit
FROM back_test_detail
WHERE back_test_id = 5552
GROUP BY option_type;
references/VEGAS_ITERATION_LOG.md(超长 SQL/INSERT 行已省略)。docs/VEGAS_ITERATION_LOG.md。Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer