This commit is contained in:
薇薇安 2026-07-08 13:55:14 +08:00
parent bc962d93f9
commit f09676bae1
5 changed files with 164 additions and 27 deletions

View File

@ -143,27 +143,6 @@
"category": "strategy", "category": "strategy",
"description": "瞬时波动观察周期" "description": "瞬时波动观察周期"
}, },
{
"key": "VP_VOL_LOOKBACK_BARS",
"value": 5,
"type": "number",
"category": "strategy",
"description": "15m波动计算根数"
},
{
"key": "VP_LONG_MIN_DROP_PCT",
"value": 0.008,
"type": "number",
"category": "strategy",
"description": "做多15m合计跌幅≥0.8%"
},
{
"key": "VP_SHORT_MIN_RISE_PCT",
"value": 0.008,
"type": "number",
"category": "strategy",
"description": "做空15m合计涨幅≥0.8%"
},
{ {
"key": "VP_SIGNAL_STRENGTH", "key": "VP_SIGNAL_STRENGTH",
"value": 8, "value": 8,

View File

@ -0,0 +1,122 @@
[
{
"key": "VP_ALLOW_4H_NEUTRAL",
"value": true,
"type": "boolean",
"category": "strategy",
"description": "增机会4H中性时按1H方向+波动触发"
},
{
"key": "VP_1H_FLUSH_MIN_PCT",
"value": 0.003,
"type": "number",
"category": "strategy",
"description": "1H进行中波动门槛 0.5%→0.3%"
},
{
"key": "VP_NEAR_PRIOR_LOW_PCT",
"value": 0.012,
"type": "number",
"category": "strategy",
"description": "入场区放宽前低上方1.2%内"
},
{
"key": "VP_MAX_BELOW_PRIOR_LOW_PCT",
"value": 0.006,
"type": "number",
"category": "strategy",
"description": "允许刺破前低0.6%"
},
{
"key": "VP_NEAR_PRIOR_HIGH_PCT",
"value": 0.012,
"type": "number",
"category": "strategy"
},
{
"key": "VP_MAX_ABOVE_PRIOR_HIGH_PCT",
"value": 0.006,
"type": "number",
"category": "strategy"
},
{
"key": "VP_LONG_MIN_DROP_PCT",
"value": 0.004,
"type": "number",
"category": "strategy",
"description": "15m辅助触发 0.6%→0.4%"
},
{
"key": "VP_SHORT_MIN_RISE_PCT",
"value": 0.004,
"type": "number",
"category": "strategy"
},
{
"key": "VP_VOL_LOOKBACK_BARS",
"value": 3,
"type": "number",
"category": "strategy"
},
{
"key": "VP_PRIOR_STRUCTURE_BARS",
"value": 18,
"type": "number",
"category": "strategy",
"description": "结构位回看略放宽"
},
{
"key": "VP_SCAN_INTERVAL_SEC",
"value": 120,
"type": "number",
"category": "scan",
"description": "扫描 3min→2min"
},
{
"key": "SCAN_INTERVAL",
"value": 120,
"type": "number",
"category": "scan"
},
{
"key": "BETA_FILTER_THRESHOLD",
"value": -0.012,
"type": "number",
"category": "strategy",
"description": "大盘禁多略放宽15m/1h跌1.2%才拦"
},
{
"key": "ENTRY_SYMBOL_COOLDOWN_SEC",
"value": 600,
"type": "number",
"category": "strategy",
"description": "同币冷却 20min→10min"
},
{
"key": "MAX_OPEN_POSITIONS",
"value": 3,
"type": "number",
"category": "risk"
},
{
"key": "TOP_N_SYMBOLS",
"value": 12,
"type": "number",
"category": "scan",
"description": "每轮多扫几个候选"
},
{
"key": "MIN_CHANGE_PERCENT",
"value": 0.8,
"type": "number",
"category": "scan",
"description": "前置涨跌幅 1%→0.8%"
},
{
"key": "MANUAL_REDUCED_SYMBOL_SIGNAL_BOOST",
"value": 0,
"type": "number",
"category": "strategy",
"description": "山寨不再额外+1信号门槛"
}
]

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# VP 增机会档:放宽波动/结构/扫描门槛(在已启用 VP 基础上叠加)
# 用法: ./scripts/apply_vp_more_opportunities.sh [--dry-run]
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
PYTHON_BIN=""
for _py in "${ROOT}/.venv/bin/python" "${ROOT}/trading_system/.venv/bin/python" "${ROOT}/backend/.venv/bin/python"; do
[ -x "$_py" ] && PYTHON_BIN="$_py" && break
done
PYTHON_BIN="${PYTHON_BIN:-$(command -v python3)}"
DRY_RUN=()
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=(--dry-run)
exec "$PYTHON_BIN" "$ROOT/scripts/apply_config_patch_only.py" \
--from "$ROOT/config/my_batch_vp_more_opportunities.json" \
--updated-by "vp_more_opportunities" \
"${DRY_RUN[@]}"

View File

@ -424,6 +424,7 @@ DEFAULT_TRADING_CONFIG = {
'VP_NEAR_PRIOR_HIGH_PCT': 0.008, 'VP_NEAR_PRIOR_HIGH_PCT': 0.008,
'VP_MAX_ABOVE_PRIOR_HIGH_PCT': 0.004, 'VP_MAX_ABOVE_PRIOR_HIGH_PCT': 0.004,
'VP_SCAN_INTERVAL_SEC': 180, 'VP_SCAN_INTERVAL_SEC': 180,
'VP_ALLOW_4H_NEUTRAL': False,
# ===== 智能入场方案C===== # ===== 智能入场方案C=====
# 根治方案:默认关闭。关闭后回归“纯限价单模式”(不追价/不市价兜底/未成交撤单跳过) # 根治方案:默认关闭。关闭后回归“纯限价单模式”(不追价/不市价兜底/未成交撤单跳过)

View File

@ -212,9 +212,22 @@ async def _evaluate_instant_flush(
) -> Dict[str, Any]: ) -> Dict[str, Any]:
"""1H 进行中 K 线快速波动 + 前结构低/高点入场(更贴近手动抄底/摸顶)。""" """1H 进行中 K 线快速波动 + 前结构低/高点入场(更贴近手动抄底/摸顶)。"""
t4 = (trend_4h or "neutral").strip().lower() t4 = (trend_4h or "neutral").strip().lower()
if t4 not in ("up", "down"): trend_1h = judge_trend_1h(
return _fail(f"4H 趋势未明确(4H={t4}),即时模式需 up/down", trend_4h) price_f, symbol_info.get("ema20"), symbol_info.get("ema50")
direction = "BUY" if t4 == "up" else "SELL" )
t1 = trend_1h
allow_neutral_4h = bool(_cfg("VP_ALLOW_4H_NEUTRAL", False))
if t4 in ("up", "down"):
direction = "BUY" if t4 == "up" else "SELL"
elif allow_neutral_4h and t1 in ("up", "down"):
direction = "BUY" if t1 == "up" else "SELL"
else:
return _fail(
f"4H 趋势未明确(4H={t4})"
+ (f"1H={t1}" if allow_neutral_4h else ",即时模式需 up/down"),
trend_4h,
)
lookback = max(8, int(_cfg("VP_RANGE_LOOKBACK_BARS", 24) or 24)) lookback = max(8, int(_cfg("VP_RANGE_LOOKBACK_BARS", 24) or 24))
prior_bars = max(3, int(_cfg("VP_PRIOR_STRUCTURE_BARS", 12) or 12)) prior_bars = max(3, int(_cfg("VP_PRIOR_STRUCTURE_BARS", 12) or 12))
@ -243,7 +256,6 @@ async def _evaluate_instant_flush(
short_min_rise = float(_cfg("VP_SHORT_MIN_RISE_PCT", 0.006) or 0.006) short_min_rise = float(_cfg("VP_SHORT_MIN_RISE_PCT", 0.006) or 0.006)
vol_change = await _period_change(client, symbol, vol_iv, vol_bars) vol_change = await _period_change(client, symbol, vol_iv, vol_bars)
trend_1h = judge_trend_1h(price_f, symbol_info.get("ema20"), symbol_info.get("ema50"))
reasons: List[str] = [] reasons: List[str] = []
if direction == "BUY": if direction == "BUY":
@ -275,7 +287,10 @@ async def _evaluate_instant_flush(
if vol_ok: if vol_ok:
reasons.append(f"{vol_iv}{(vol_change or 0)*100:.2f}%") reasons.append(f"{vol_iv}{(vol_change or 0)*100:.2f}%")
reasons.append(f"贴近前低{prior_low:.6f}") reasons.append(f"贴近前低{prior_low:.6f}")
reasons.append(f"4H向上") if t4 == "up":
reasons.append("4H向上")
else:
reasons.append(f"4H中性+1H向上")
struct_key, struct_val = "prior_structure_low", prior_low struct_key, struct_val = "prior_structure_low", prior_low
else: else:
flush_ok = flush["flush_up_pct"] >= flush_min flush_ok = flush["flush_up_pct"] >= flush_min
@ -299,7 +314,10 @@ async def _evaluate_instant_flush(
if vol_ok: if vol_ok:
reasons.append(f"{vol_iv}{(vol_change or 0)*100:.2f}%") reasons.append(f"{vol_iv}{(vol_change or 0)*100:.2f}%")
reasons.append(f"贴近前高{prior_high:.6f}") reasons.append(f"贴近前高{prior_high:.6f}")
reasons.append(f"4H向下") if t4 == "down":
reasons.append("4H向下")
else:
reasons.append(f"4H中性+1H向下")
struct_key, struct_val = "prior_structure_high", prior_high struct_key, struct_val = "prior_structure_high", prior_high
strength = int(_cfg("VP_SIGNAL_STRENGTH", 8) or 8) strength = int(_cfg("VP_SIGNAL_STRENGTH", 8) or 8)