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
e405a9c21e
fix: parse factors JSON string in /api/signals/latest
...
psycopg2 writes factors as JSON string, asyncpg reads it back as string
instead of dict. Parse it before returning to frontend.
2026-03-02 00:44:36 +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
5849bf6522
refactor: completely separate V5.1 and V5.2 pages
...
- /signals: V5.1 ONLY, 5-layer scoring, no FR/Liq
- /signals-v52: V5.2 ONLY, 7-layer scoring with FR/Liq
- /paper: V5.1 ONLY, no strategy tabs/badges
- /paper-v52: V5.2 ONLY, with FR/Liq display
- Sidebar: V5.1 and V5.2 separate sections
- V5.2 weights: 40+18+5+12+15+5+5=100 (no more >100)
- Zero cross-contamination between V5.1 and V5.2
2026-03-02 00:25:07 +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
58c72b4d90
fix: V5.2 TP/SL parameters - wider stops for better risk/reward
...
V5.2: SL=3.0×ATR, TP1=2.0×ATR, TP2=4.5×ATR
V5.1: SL=2.0×ATR, TP1=1.5×ATR, TP2=3.0×ATR (unchanged)
Expected improvement: win/loss ratio 0.72→0.84, breakeven winrate 58%→54%
2026-03-01 23:06:29 +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
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
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
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
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
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
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
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
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
root
5ba4c7fe98
feat: V5.1 backtest framework - tick-by-tick replay with TP/SL/position management
2026-02-28 05:53:42 +00:00
root
2e969f68b4
fix: parse JSONB string from asyncpg + frontend parseVal fallback
2026-02-28 05:49:42 +00:00
root
7ca843ca70
fix: revert signals/latest API to explicit column query (to_jsonb broke field names)
2026-02-28 05:45:21 +00:00
root
340d8eb3a1
feat: V5.1 frontend - 5-layer scoring display + market indicators panel
2026-02-28 05:33:40 +00:00
root
5c38a2f9bf
feat: upgrade signal engine to V5.1 layered scoring
2026-02-28 05:24:16 +00:00
root
a9bdec208f
feat(backend): add market indicators collector for V5.1 (4 data sources: L/S ratio, top trader position, OI hist, Coinbase Premium)
2026-02-28 05:17:31 +00:00
root
748f6f57a5
perf: server/status接口优化(cpu非阻塞+pm2直接调用+COUNT估算+5秒缓存)
2026-02-27 18:46:56 +00:00
root
fbf84f2be5
tune: signal-engine循环15秒(从5秒,降CPU60%)
2026-02-27 18:38:03 +00:00
root
a8e1e123ca
tune: backfill改500ms/批(CPU100%→平衡模式)
2026-02-27 17:59:20 +00:00
root
930c8d3a9c
feat: 服务器监控面板(/server) - CPU/内存/硬盘/PM2进程/PG数据库/回补状态
2026-02-27 17:30:41 +00:00
root
55422b0ae0
perf: backfill全速200ms/批(PG无锁冲突)
2026-02-27 17:04:36 +00:00
root
61287657df
perf: trades/summary聚合下推PG(SQL GROUP BY替代Python循环) + trades/latest加2秒缓存
2026-02-27 16:52:35 +00:00
root
e56766ed98
feat: SQLite→PG data migration script
2026-02-27 16:16:06 +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
23c7597a40
fix: backfill sleep 2s per batch to avoid SQLite WAL lock contention
2026-02-27 15:44:43 +00:00
root
547f093352
feat: V5 signal-engine + API endpoints for indicators/latest/trades
2026-02-27 15:31:12 +00:00
root
3e630166b4
fix: backfill meta update - handle existing rows with NOT NULL last_agg_id
2026-02-27 15:03:24 +00:00
root
009f114e4d
feat: backfill_agg_trades.py - historical aggTrades REST backfill with rate limiting, continuity check
2026-02-27 15:01:55 +00:00
root
bb187167bb
feat: add LiveTradesCard - real-time agg trades display + /api/trades/latest endpoint
2026-02-27 11:35:55 +00:00
root
7e38b24fa8
feat: V3.0 aggTrades collector - WS+REST补洞+巡检+按月分表+查询API
2026-02-27 11:29:16 +00:00
root
1ab228286c
feat: V2.0 auth system - JWT access/refresh, invite codes, route protection, admin CLI, auth gate blur overlay
2026-02-27 11:08:57 +00:00
root
11667d4faa
feat: add YTD annualized rate to RateCard
2026-02-27 10:08:22 +00:00
root
362c1f1e16
fix: add /api/signals/history endpoint
2026-02-27 08:54:13 +00:00
root
32e9dd3531
feat: rate kline unit x10000 (bps), default interval 1h
2026-02-27 07:56:07 +00:00
root
80c4ea67e7
fix: add background snapshot loop - collect every 2s regardless of frontend
2026-02-27 07:04:41 +00:00
root
072592145f
feat: kline page with lightweight-charts + /api/kline OHLC aggregation endpoint
2026-02-27 06:36:19 +00:00
root
8efa6ede32
feat: rate_snapshots 2s persistent storage + /live realtime chart page
2026-02-27 05:47:26 +00:00
root
cf531d8c44
feat: add auth and subscriptions backend modules
2026-02-27 02:28:21 +00:00
root
b1d959cf20
feat: use discord bot api for signal push, add binance fallback
2026-02-26 16:54:45 +00:00
root
03218dce04
fix: split rate/stats refresh intervals, rates 2s stats 2min
2026-02-26 13:57:39 +00:00
root
42e329cc55
fix: add cache to prevent Binance rate limit (rates 3s, history/stats 60s)
2026-02-26 13:54:59 +00:00
root
44e07eabb2
feat: arbitrage engine Phase 0 scaffold - FastAPI + Next.js
2026-02-26 12:06:10 +00:00