Commit Graph

48 Commits

Author SHA1 Message Date
root
ccb53cb3a8 feat: record cvd_fast_5m in signal_indicators for v53_fast strategy 2026-03-04 02:41:02 +00:00
root
c8416b4916 feat: add v53_fast strategy - 5m/30m CVD + OBI positive scoring + accel independent trigger 2026-03-04 01:44:09 +00:00
root
3352489ce9 fix: add SL sanity check on open_position; add entry_ts display in paper-v53 positions 2026-03-04 01:15:09 +00:00
root
42cb230337 feat: merge v53_alt+v53_btc into unified v53 strategy (all 4 symbols, per-symbol gates) 2026-03-03 15:59:27 +00:00
root
2a9e4db756 fix: pass ALT layer scores into BTC factors for frontend display 2026-03-03 15:32:04 +00:00
root
1e982c48f9 feat: extend RT-WS to ETH/XRP/SOL + add per-symbol 4-gate control to v53_alt 2026-03-03 15:22:54 +00:00
root
57f749c094 fix: set gate_passed=True for ALT track in save_feature_event (NOT NULL constraint) 2026-03-03 14:37:38 +00:00
root
a7cd78e06f feat: implement save_feature_event() for v53 training data collection (Phase 3) 2026-03-03 14:35:26 +00:00
root
85db47e41f feat: Phase 2 - realtime WebSocket OBI + spot/perp divergence for BTC gate-control, tiered whale CVD in-process 2026-03-03 13:59:34 +00:00
root
17a387b6f4 feat: Phase 2 - collect obi_depth_10, spot_perp_divergence, tiered_cvd_whale for BTC gate-control 2026-03-03 13:42:21 +00:00
root
fcac8c2334 feat: Phase 1 - V5.3 dual-track signal engine (ALT 55/25/15/5, BTC gate-control) 2026-03-03 13:35:23 +00:00
root
4c43309c16 fix: remove leftover conn.commit() after deleting paper_check_positions 2026-03-03 13:27:40 +00:00
root
0a5222a1de feat: Phase 0 - add signal_feature_events/label_events tables, atr_value snapshot, label_backfill script 2026-03-03 13:22:53 +00:00
root
8280aaf6ea refactor: A1 hot-reload strategy configs, A4 remove dead paper_check_positions, A6 signals/history query signal_indicators 2026-03-03 13:00:54 +00:00
dev-worker
262594f16e fix: entry_price改用最新成交价(last_trade_price)而非VWAP
VWAP是30分钟加权均价,快速行情下与实际价偏差可达1-2%
历史587笔entry_price+596笔pnl_r已用agg_trades真实价修正
平均偏差31.9bps, 最大189.4bps(1.9%)
V5.1: 42.18R→15.32R | V5.2: 29.83R→0.76R
2026-03-03 02:53:56 +00:00
dev-worker
31e6e19ea6 fix: V3全面审阅修复 — 12项问题
P0-1: 风控Fail-Closed(状态文件缺失/过期/异常→拒绝开仓)
P0-2: 1R基准跨模块统一(position_sync+risk_guard从live_config动态读)
P0-3: close_all紧急全平校验返回值+二次验仓
P0-4: Coinbase Premium单位修复(premium_pct/100→比例值)
P1-3: 正向funding计入净PnL(不再只扣负值)
P1-4: 数据新鲜度检查落地(查signal_indicators最新ts)
P1-6: live表DDL补全到SCHEMA_SQL(live_config/live_events/live_trades)
P2-1: _get_risk_usd()加60秒缓存
P2-3: 模拟盘前端*200→从config动态算paper1R
P2-4: XRP/SOL跳过Coinbase Premium采集(无数据源)
P3-2: SQL参数化(fetch_pending_signals用ANY替代f-string)
额外: pnl_r公式修正(gross-fee+funding,funding正负都正确计入)
2026-03-02 17:28:23 +00:00
root
855df24eba feat: signal-engine配置热加载,改paper_config不需要重启
- 每60轮(~15分钟)自动重读paper_config.json
- 检测enabled_strategies变更时输出日志
- 避免频繁重启导致:
  - 4h历史数据重新回灌
  - CVD/VWAP窗口状态丢失
  - 45秒warmup+10分钟冷却期
  - 信号准确度下降
2026-03-02 13:12:04 +00:00
root
21970038df feat: live_executor.py + signal_engine NOTIFY + live_trades table
- live_executor.py: PG LISTEN/NOTIFY接收信号, 币安API开仓+挂保护单
- signal_engine: 有信号时发NOTIFY new_signal
- live_trades表: 含binance_order_id, slippage_bps, protection_gap_ms等实盘字段
- 支持GCP Secret Manager + env fallback读API Key
- 支持testnet/production环境切换
2026-03-02 08:55:36 +00:00
root
72ea0ffd0e fix: remove 0.7 ATR multiplier, store risk_distance in DB
- Removed 0.7*ATR multiplier from signal_engine and paper_monitor
- risk_distance now stored per-trade in paper_trades table
- paper_monitor/signal_engine read risk_distance from DB (no hardcoded values)
- V5.1 TP/SL: 2.0/1.5/3.0 -> 1.4/1.05/2.1 (same actual distance)
- V5.2 TP/SL: 3.0/2.0/4.5 -> 2.1/1.4/3.15 (same actual distance)
- Fixed V5.2 pnl_r: all historical values corrected by *2/3
- API unrealized_pnl_r also reads from DB risk_distance
2026-03-02 07:00:05 +00:00
root
7ebdb98643 feat: store and serve indicators per strategy
- signal_indicators table: added strategy column
- Each strategy gets its own row per cycle
- API /api/signals/latest?strategy=v51_baseline|v52_8signals
- API /api/signals/signal-history?strategy=...
- V5.1 page reads v51_baseline data, V5.2 reads v52_8signals
- Now V5.1 and V5.2 show truly independent scores
2026-03-02 02:52:17 +00:00
root
7dee6bffbd fix: FR score 0~5 only, no negative scores
Direction is already decided. FR layer measures how favorable
the funding rate is for that direction. Unfavorable = 0, not negative.
2026-03-02 02:30:56 +00:00
root
318bcb99a3 fix: clamp direction score to max weight (accel_bonus included) 2026-03-02 01:36:20 +00:00
root
d4f0bbbcb1 fix: read fundingRate field (not lastFundingRate) from market_indicators
DB stores Binance API response with 'fundingRate' key, but code was
looking for 'lastFundingRate' - always got 0.
2026-03-02 01:07:05 +00:00
root
1fa6f178b6 feat: linear FR scoring based on historical max
- FR score = (|current_FR| / max_historical_FR) × 5, clamped to [-5, +5]
- Contrarian direction: positive score (going against crowded side)
- Same direction: negative score (going with crowded side)
- Historical max FR cached per symbol, refreshed every hour
- Score is float with 2 decimal places
- Total score supports 1 decimal place
2026-03-02 00:56:22 +00:00
root
05673c0850 fix: V5.2 scoring uses strategy weights, total capped at 100
Backend:
- Each layer score scaled by strategy config weights
- direction: 0~40, crowding: 0~18, FR: 0~5, environment: 0~12
- confirmation: 0~15, liquidation: 0~5, auxiliary: 0~5
- total_score clamped to 0~100
- factors include max field for frontend

Frontend:
- V5.2 signals page reads max from factors
2026-03-02 00:34:22 +00:00
root
01b1992643 feat: save factors to signal_indicators + show FR/Liq on signals page
- DB: added factors JSONB column to signal_indicators
- Backend: save_indicator now includes factors JSON
- API: /api/signals/latest returns factors field
- Frontend: signals page shows FR and 清算 score bars
2026-03-01 23:57:55 +00:00
root
a571a221e5 feat: gradient liquidation scoring - no threshold, ratio-based
Removed USD threshold gates. Now any liquidation data triggers scoring:
- ratio ≥ 2.0 → +5 (extreme imbalance)
- ratio ≥ 1.5 → +3
- ratio ≥ 1.2 → +1
- ratio 0.8~1.2 → 0 (balanced)
- Inverse for SHORT direction
2026-03-01 23:35:45 +00:00
root
8279b16c68 fix: FR thresholds based on actual data
Historical FR range: BTC ±0.005%, SOL/XRP max -0.022%
Old thresholds were unreachable (0.03% extreme / 0.005% moderate)

New thresholds:
- Extreme: ±0.01% (0.0001) — clearly biased market
- Moderate: ±0.003% (0.00003) — slight bias, reward contrarian
2026-03-01 23:23:43 +00:00
root
7d2bb9f392 fix: FR/Liq scoring bugs + compact UI
Backend:
- FR threshold: 0.001→0.0003 (extreme), 0.0003→0.00005 (moderate)
- Liquidation SQL: side='SELL'/'BUY' → 'LONG'/'SHORT' (was never matching!)

Frontend:
- FR/Liq scores now inline in score column (compact)
- Removed bulky green badge buttons from position cards
2026-03-01 23:14:07 +00:00
root
a9c3523a24 feat: independent strategy paper trading controls
- Each strategy has its own position count (max 4 each)
- paper_config.enabled_strategies: per-strategy toggle
- is_strategy_enabled() checks both master switch and strategy list
- API: /api/paper/config now supports enabled_strategies array
- Config auto-loads on API startup

Usage: POST /api/paper/config {enabled_strategies: ['v52_8signals']}
2026-03-01 12:43:46 +00:00
root
732b01691b Implement V5.2 FR/liquidation scoring and strategy AB loop 2026-03-01 11:54:58 +00:00
root
2f9dce483c fix: simulate limit orders for TP/SL (match real trading)
- TP/SL now exit at order price (limit order), not market price
- SL exits at sl_price, TP1 at tp1_price, TP2 at tp2_price
- Only timeout and signal_flip use market price (current price)
- Updated fix_historical_pnl.py to also correct exit_price
- This eliminates fake slippage in paper trading stats
2026-03-01 09:40:00 +00:00
root
45bad25156 fix(P0): pnl_r calculation + cooldown bypass + partition month bug
P0-1: Reverse signal now bypasses cooldown - evaluate_signal always
      outputs direction, main loop checks direction+score>=60 for
      closing positions against trend (not blocked by COOLDOWN_MS)

P0-2: pnl_r unified to (exit-entry)/risk_distance across all exit
      scenarios (tp, sl, sl_be, timeout) in both paper_monitor.py
      and signal_engine.py. Old hardcoded values (1.5R/2.25R) were
      ~2x too high vs actual risk_distance basis.

P1-1: ensure_partitions month calculation fixed from timedelta(30d)
      to proper month arithmetic. Also fixed UTC timezone for
      partition boundaries.

docs: V52-TODO.md with full audit backlog for V5.2
2026-03-01 09:29:32 +00:00
root
9528d69a42 fix: deduplicate recent_large_trades to prevent memory bloat
Each evaluate cycle was re-appending all qualifying trades from
win_fast, causing duplicates. Added seen-set dedup.
2026-03-01 07:58:51 +00:00
root
022ead6d6c feat: paper_trades store score_factors JSONB (direction/crowding/environment/confirmation/auxiliary breakdown) 2026-02-28 13:45:26 +00:00
root
95b45d0f07 fix: skip first 3 cycles after cold start to prevent duplicate paper trades 2026-02-28 12:03:48 +00:00
root
7b901a2390 feat: paper_monitor.py - WebSocket realtime TP/SL + frontend WS price feed (1s update) 2026-02-28 11:55:40 +00:00
root
66810701fb feat: paper trading signal flip - reverse signal closes existing position then opens new 2026-02-28 11:45:48 +00:00
root
47004ece8c feat: paper trading deduct taker fee 0.05% per side (0.1% round trip) 2026-02-28 11:30:17 +00:00
root
282aed138a feat: paper trading switch + config API + max positions limit 2026-02-28 11:13:39 +00:00
root
e054db112d feat: paper trading - backend (table+signal_engine integration+5 APIs) + frontend page 2026-02-28 11:10:28 +00:00
root
317031ab57 fix: signal_engine now reads real market_indicators (JSONB parsing + OI change rate) 2026-02-28 11:03:44 +00:00
root
0ac2225979 feat: add XRP and SOL symbols (4 coins total) 2026-02-28 10:11:05 +00:00
root
424cb993f8 feat: signal history list + always compute scoring even without signal 2026-02-28 06:09:32 +00:00
root
5c38a2f9bf feat: upgrade signal engine to V5.1 layered scoring 2026-02-28 05:24:16 +00:00
root
fbf84f2be5 tune: signal-engine循环15秒(从5秒,降CPU60%) 2026-02-27 18:38:03 +00:00
root
4168c1dd88 refactor: SQLite→PostgreSQL migration - db.py连接层 + main/collector/signal-engine/backfill全部改PG
Phase 1: 核心数据表(agg_trades/rate_snapshots/signal*)迁PG
auth.py暂保留SQLite(低频,不影响性能)
- db.py: psycopg2同步池 + asyncpg异步池 + PG schema + 分区管理
- main.py: 全部改asyncpg查询
- collector: psycopg2 + execute_values批量写入
- signal-engine: psycopg2同步读写
- backfill: psycopg2 + ON CONFLICT DO NOTHING
2026-02-27 16:15:16 +00:00
root
547f093352 feat: V5 signal-engine + API endpoints for indicators/latest/trades 2026-02-27 15:31:12 +00:00