Two-phase monitor, integer shares, and daily log

- Monitor now runs morning (9:45 → signals) and evening (4:35 → execute)
  instead of single daily run; falls back to auto if morning missed
- Add --integer-shares flag for whole-share-only trading (no fractional)
- Add daily_log to state: each day records holdings, cash, and operations
- Add 'log' subcommand to view daily snapshots with date range filter
- record_daily_snapshot() called from both simulate and auto commands

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 23:57:03 +08:00
parent 4709271504
commit 942164a38f
2 changed files with 323 additions and 69 deletions

View File

@@ -23,8 +23,11 @@ uv run python main.py --execution open-close # Signal on open, execute at close
uv run python trader.py auto --market us --strategy recovery_mom_top10 # Single daily run (for cron)
uv run python trader.py morning --market us --strategy recovery_mom_top10 # Morning: generate orders
uv run python trader.py evening --market us --strategy recovery_mom_top10 # Evening: record execution
uv run python trader.py monitor --market us --strategy recovery_mom_top10 # Long-running daemon (for tmux)
uv run python trader.py status --market us --strategy recovery_mom_top10 # Portfolio status
uv run python trader.py simulate --market us --strategy recovery_mom_top10 --start 2026-01-01 --end 2026-04-01 # Historical replay
uv run python trader.py log --market us --strategy sim_recovery_mom_top10 --start 2026-03-01 # View daily log
uv run python trader.py simulate --integer-shares --fixed-fee 2.0 ... # Integer shares mode
# Setup
uv sync # Install/sync dependencies
@@ -66,7 +69,21 @@ No test suite or linter is configured.
- Python 3.12+, managed with `uv`.
- Do not show matplotlib figures when running backtests; use `--no-plot`.
## Server Deployment (Cron)
## Server Deployment
### Option 1: tmux monitor (recommended)
Two-phase daily schedule — morning (open prices → generate signals) and evening (close prices → execute trades):
```bash
tmux new -s quant
uv run python trader.py monitor --market us --strategy recovery_mom_top10
# Ctrl-B D to detach; tmux attach -t quant to reconnect
```
If monitor starts mid-day (after open, before close), it automatically falls back to `auto` mode for the evening phase.
### Option 2: Cron
Run daily after market close. The `auto` command is idempotent — safe to re-run: