- core/price_db.py: add wf_state table CRUD (ensure/upsert/load/delete)
to persist shadow_cons_wins across restarts
- core/trader.py: save WF blocked state on shadow enter/close,
restore shadow_cons_wins on startup from DB
- core/monitor.py: lower ATR_MAX_STOP 4.0% → 2.0% based on sweep results
- atr_sweep.py: new ATR_MAX_STOP sweep tool using real ATR calc from DB
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each buy generates a UUID trade_id stored in positions table.
Each sell links via same trade_id in trade_results, enabling
round-trip grouping of buy→sell pairs.
Additional fields saved per trade:
- fee_krw: commission amount (0.05% each side)
- krw_profit: net KRW profit/loss after fees
- buy_price / sell_price: exact prices
- invested_krw: capital deployed
- sell_reason: trailing stop / time stop / etc.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- price_db: add sell_prices table (ensure/upsert/load/delete)
- trader: restore _last_sell_prices from DB on startup so re-entry
block survives restarts; persist each sell price immediately
- market: retry chunk requests up to 3 times with backoff on 429
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add trade_results table to Oracle DB for persistent trade history
- Record win/loss after each sell with pnl_pct
- Load last N trades per ticker from DB on startup (survives restarts)
- Block buy() when recent win rate (last 5 trades) < 40% threshold
- Configurable via WF_WINDOW and WF_MIN_WIN_RATE env vars
- Backtest showed improvement from -7.5% to +37.4% cumulative return
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- price_history table on Oracle ADB stores prices every 10 minutes
- check_trend(): current price vs N hours ago (default 1h, +3% threshold)
- check_momentum(): unchanged (MA20 + 2x volume still applies)
- Ticker list cached 5 minutes to avoid 429 rate limits
- Collector starts 30s after boot to avoid simultaneous API calls
- Configurable: TREND_HOURS, TREND_MIN_GAIN_PCT in .env
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>