# Implementation Log ## 2026-05-27 - Reviewed the stock scalping bot structure and moved it toward an AI-training-ready paper-trading platform. - Added database tables for AI training: - `entry_snapshots` - `post_entry_snapshots` - Added entry-time data capture after successful buys. - Added post-entry sampling at 60s, 180s, 300s, and 600s. - Fixed partial-exit accounting so partial TP1 exits no longer close the whole trade row. - Relaxed strict entry-limit enforcement during paper-trading data collection while preserving warning logs. - Added daily/export training scripts: - `scripts/export_training_dataset.py` - `scripts/collect_daily_features.py` - `scripts/collect_minute_data.py` - `scripts/build_external_training_dataset.py` - Added ML training and runtime support: - `app/ml/features.py` - `app/ml/predictor.py` - `scripts/train_ai_model.py` - Added observation-only AI scoring: - Runtime scores are recorded only when a trained model exists. - AI scores do not block entries, change sizing, or override exits. - Added daily training pipeline: - `scripts/run_training_pipeline.ps1` - Registered and verified Windows Scheduler tasks: - `StockBot_Morning` - `StockBot_Watchdog` - `StockBot_Midday` - `StockBot_Evening` - `StockBot_Training` - Rewrote scheduler setup to avoid hardcoded broken Korean paths: - `scripts/setup_scheduler.ps1` - Rewrote watchdog wrapper with trading-day and time-window checks: - `scripts/run_watchdog.ps1` - Added dependency portability: - Root `requirements.txt` - `scripts/install_dependencies.ps1` - `scripts/download_dependencies.ps1` - `vendor/wheels` wheelhouse for Windows/Python 3.11 - Updated operational docs: - `README.md` - `CLAUDE.md` - `reports/daily/2026-05-27.md` Validation performed: - Python compile check passed. - DB migration checked. - AI score snapshot insert checked with a temporary DB. - Training script checked with empty dataset. - Scheduler registration checked. - PowerShell script parse check passed. Open risks: - KIS minute endpoint still needs live response verification. - Early model quality is expected to be weak until enough labeled rows exist. - External minute data is useful for pretraining, not final bot-trade truth. - Real-cash trading still needs stronger fill, partial-fill, unfilled-order, cancel/replace, and recovery handling. - Raspberry Pi dependency packaging needs a Linux/ARM-specific setup. - Approved and applied `ENTRY_START = "09:15"` after the 2026-05-27 evening review. - Reason: 09:05-09:06 generated four immediate SL trades and most of the daily loss. - Time-based sizing and time-based SL changes remain deferred. ### 2026-05-27 Strategy Approval Log - User approved Claude Evening Proposal 1. - Changed `app/config.py`: - Before: `ENTRY_START = "09:05"` - After: `ENTRY_START = "09:15"` - Rationale: - Four immediate SL trades occurred from 09:05:03 to 09:05:49. - Those four trades lost about `-183,969 KRW`. - This represented about 74.5% of the daily loss. - Deferred: - Time-based position-size reduction. - Time-based stop-loss adjustment. - Verification: - Python compile check passed. - Runtime import confirmed `ENTRY_START == "09:15"`.