Commit Graph

122 Commits

Author SHA1 Message Date
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
ee90b8dcfa feat: sidebar navigation with V5.1/V5.2 separate entries
- Sidebar: 信号/模拟盘 section headers
- Three paper trade entries: 全部持仓, V5.1模拟盘, V5.2模拟盘 (NEW badge)
- Paper page reads strategy from URL query params
- Suspense boundary for useSearchParams
2026-03-01 12:25:40 +00:00
root
778cf8cce1 feat: V5.2 frontend differentiation - strategy tabs, side-by-side scores, visual badges
- Paper page: prominent strategy tabs (全部/V5.1/V5.2) at top
- Paper trades: strategy column with color-coded badges (blue=V5.1, green=V5.2)
- Paper positions: FR/Liq scores displayed prominently for V5.2
- Signals page: side-by-side V5.1 vs V5.2 score comparison cards
- Signals page title updated to 'V5.1 vs V5.2'
- New API endpoint for strategy comparison data
- Layout: local font fallback for build stability
2026-03-01 12:21:19 +00:00
root
7ba53a5005 Update paper UI for strategy filters and FR/liquidation details 2026-03-01 11:55:03 +00:00
root
f6156a2cfe Add strategy-aware paper trade schema and API endpoints 2026-03-01 11:55:00 +00:00
root
732b01691b Implement V5.2 FR/liquidation scoring and strategy AB loop 2026-03-01 11:54:58 +00:00
root
a7600e8db1 Add V5.2 strategy configuration files 2026-03-01 11:54:54 +00:00
root
4b841bc5f4 fix: floating PnL now accounts for half-position after TP1
Before: unrealR = full position × price move (wrong after TP1)
After: unrealR = 0.5×TP1_locked + 0.5×current_float (correct)

This fixes the display showing >1R floating profit that never
materializes in final PnL because only half position remains.
2026-03-01 09:48:46 +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
d351949a7c fix: historical pnl_r correction script 2026-03-01 09:31:13 +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
d8ad87958a docs: add comprehensive project documentation (PROJECT.md)
- Full architecture overview
- All 36 files documented with purpose and line counts
- 5-layer scoring system explained
- Database schema, PM2 processes, signal sources
- Deployment info, version roadmap
- Known issues and improvements
2026-03-01 08:34:56 +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
8b73500d22 feat: migrate auth system from SQLite to PostgreSQL
- auth.py: rewrite to use PG via db.py (was sqlite3)
- admin_cli.py: rewrite to use PG
- migrate_auth_sqlite_to_pg.py: one-time migration script
- SQLite arb.db no longer needed after migration
2026-03-01 07:29:14 +00:00
root
4f54e36d1a feat: dual-write agg_trades to local PG + Cloud SQL
- db.py: add Cloud SQL connection pool (CLOUD_PG_ENABLED env toggle)
- agg_trades_collector: flush_buffer writes to both local and cloud
- Cloud SQL write failure is non-fatal (log warning, don't block local)
2026-03-01 07:16:03 +00:00
root
77d38c7269 fix: add total_pnl to stats API top-level response 2026-03-01 01:42:39 +00:00
root
bda42e669a feat: stats panel with per-symbol tabs (ALL/BTC/ETH/XRP/SOL) - full stats for each coin 2026-03-01 01:37:02 +00:00
root
abfdc63705 feat: liquidation_collector.py - Binance WS forceOrder realtime + 5min aggregation to market_indicators 2026-02-28 15:38:14 +00:00
root
6659c4524c feat: market_data_collector add funding_rate collection for all 4 symbols 2026-02-28 15:34:24 +00:00
root
83dc456119 feat: signal page add detailed 5-layer explanation section 2026-02-28 14:33:33 +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
404cc683e0 fix: latest signals pass symbol without USDT suffix to signal-history API 2026-02-28 13:31:14 +00:00
root
71192d4209 fix: latest signals use signal-history API (last triggered signal, not realtime eval) 2026-02-28 13:20:24 +00:00
root
374615dea7 feat: paper page show latest signal per coin 2026-02-28 12:45:47 +00:00
root
95fec35d97 fix: paper balance font-size auto-fit (text-base instead of text-lg) 2026-02-28 12:38:52 +00:00
root
1d2304261b feat: paper frontend use aggTrade WS for real-time price (every tick instead of 1s) 2026-02-28 12:30:11 +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
d0e626a437 feat: paper summary add balance + pnl_usdt 2026-02-28 12:00:19 +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
d177d28498 fix: paper positions use Binance realtime price instead of signal_indicators 2026-02-28 11:49:49 +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
f90df6f3b5 feat: paper positions show real-time price + unrealized PnL (R + USDT) 2026-02-28 11:40:11 +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
59910fe9cd fix: paper page use useAuth() instead of manual localStorage check 2026-02-28 11:24:29 +00:00
root
961cbc6bd8 chore: gitignore __pycache__ 2026-02-28 11:21:00 +00:00
root
b232270948 fix: add Request import 2026-02-28 11:20:05 +00:00
root
cd17c76000 fix: remove duplicate return causing IndentationError in main.py 2026-02-28 11:19:01 +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
271658c725 ui: sidebar label → 信号引擎 V5.1 2026-02-28 10:46:29 +00:00
root
9382d35496 ui: compact signal engine layout - smaller panels, tighter spacing, V5.1 title 2026-02-28 10:42:51 +00:00
root
fb37dfb288 fix: show 4 decimal places for prices under 00 (XRP/SOL) 2026-02-28 10:22:52 +00:00
root
2c28d660ce fix: add XRP/SOL to trades and kline pages 2026-02-28 10:19:33 +00:00
root
5cf2003ca7 fix: limit trade flow to 20 rows 2026-02-28 10:16:38 +00:00
root
0ac2225979 feat: add XRP and SOL symbols (4 coins total) 2026-02-28 10:11:05 +00:00
root
3155e8848b perf: backtest optimization - 15s eval interval + 50k batch + OHLC TP/SL check 2026-02-28 07:34:48 +00:00
root
ec6a8fc64d fix: rename signal-history API to avoid route conflict + restart backfill 2026-02-28 06:22:32 +00:00
root
424cb993f8 feat: signal history list + always compute scoring even without signal 2026-02-28 06:09:32 +00:00
root
ca25938adc fix: remove autocommit for named cursor in backtest 2026-02-28 05:54:32 +00:00