Single-process monitor for US + CN markets

- `trader.py monitor` now handles all markets in one process
  (US 9:45/16:35 ET, CN 9:45/15:35 CST) with unified UTC event loop
- Events from different markets/timezones are merged; sleeps until
  the globally next event across all markets
- Overlapping events (e.g. US evening + CN morning) fire together
- `trader.py compare` defaults to US, use --market cn for A-shares
- One tmux session handles everything: just `uv run python trader.py monitor`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-07 00:16:46 +08:00
parent 4aa17c7e98
commit 14ec64c1da
2 changed files with 154 additions and 112 deletions

View File

@@ -23,7 +23,8 @@ 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 monitor # Monitor ALL markets & strategies (for tmux)
uv run python trader.py monitor --market us # Monitor US only
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
@@ -73,12 +74,16 @@ No test suite or linter is configured.
### Option 1: tmux monitor (recommended)
Two-phase daily schedule — morning (open prices → generate signals) and evening (close prices → execute trades):
Single process monitors both US and CN markets. Two phases per market daily — morning (open → signals) and evening (close → execute). All 9 strategies run for each market.
```bash
tmux new -s quant
uv run python trader.py monitor --market us --strategy recovery_mom_top10
uv run python trader.py monitor # Both US + CN, all strategies
# Ctrl-B D to detach; tmux attach -t quant to reconnect
# After a month, compare:
uv run python trader.py compare # US strategies
uv run python trader.py compare --market cn # CN strategies
```
If monitor starts mid-day (after open, before close), it automatically falls back to `auto` mode for the evening phase.