Adds five trend_rider ETF strategies (best 10-year Sharpe of each version,
plus v7_vt36): 31 strategies in all. Fees per order are $2 and ¥10, and CN
accounts start with ¥100,000. No trade has been executed yet (US accounts
hold only this morning's orders; CN starts 2026-09-28).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A live book is a cohort of strategies, each with its own account, started
on one date with one capital and a flat fee per order (trader.LIVE_BOOKS).
The original book keeps its state in data/; a named book in
data/books/<book>/. The monitor runs every book; auto/status/log/compare/
replay take --book. A fresh account opens on the book's first session.
selected_2026_09: US $10,000 and $1 per order from 2026-09-25, CN ¥50,000
and ¥5 per order from 2026-09-28 (the first CN session after the choice).
Strategies beat their benchmark in the Apr-Sep 2026 point-in-time replay
and passed a 10-year PIT backtest (US Sharpe >= 0.6, MaxDD > -50%; CN
Sharpe >= 0.2, CAGR > 0), no daily variants, at most two frequencies per
factor signal, plus the three 2026-09 research strategies.
bridge.py live --book and bridge.py books feed a book selector on the
live page (/api/strategies/live?book=, /api/strategies/live/books).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Replaying live books over past sessions used today's constituent list for
every day, so US books bought names (BE, MRVL, ILMN, FLEX, P) before they
joined the S&P 500. session_universes/session_signals now compute each past
session on that day's members (S&P change log, CSI 300 snapshots); the
latest session keeps the live list. Used by auto/monitor catch-up, replay
and simulate. _run_session takes precomputed targets only.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Strategies
- BarStrategy protocol (close/open/high/low/volume bars; row d uses bars
through d-1) and RobustMomentumStrategy: overnight_recovery_top10 (US),
lowrisk_momentum_top15 and lowbeta_sharpe_mom_top20 (CN), top-N with
rank hysteresis, 10-day rebalance, weights drift between rebalances.
- trader: strategy_fields/strategy_bars/bar_session_weights; one signal
path (_signals_for_sessions) replaces generate_target_weights.
Live fixes
- CSI 300 constituents come from China Securities Index's file; the
Wikipedia table was 122 names off the real index.
- S&P 500 change log moved to "Historical components of the S&P 500".
- data_manager: tickers missing from a partial Yahoo batch are retried
alone before being marked unavailable (CEG, GEV, SNDK ... were dropped).
update() takes fields=[...] and stores high/low/volume panels.
- Whole-lot orders go to the nearest lot within cash (CN books held ~62%
cash); held names are resized only beyond RESIZE_BAND (10%), so books no
longer pay a ticket fee to trade daily drift.
Web backtests
- backtest_runner.py replaces the duplicated bridge/precompute code: PIT
membership in both markets (data/csi300_history.json), stock universe
limited to index members (ETFs and benchmarks in the shared panel were
pickable), and the book kept like the live trader (simulate_live_book:
signal timing, drift, order floor, resize band, fees on orders placed).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
trend_rider_v6 backtests failed ('SPY' not in data) because only the stock
universe was passed. Strategy markets in 'list' now follow the trader's
eligibility rule, so v6 is no longer offered for CN.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Every strategy used to re-download its whole universe each phase (~75
downloads of 500+ tickers for the US book), which tripped Yahoo's rate
limit. The monitor now refreshes each panel once for the union of tickers
and runs strategies offline, like replay.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Rounding to cents made trade logs irreproducible for low-priced lines
(HK ETFs in USD, A-shares): replaying a log drifted up to $200 from the
recorded cash.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Replay refreshes each price panel once for the union of tickers and then
replays offline; target weights for all sessions come from one causal
signal pass instead of re-running the strategy per day (verified identical
daily equity for v7_vt36, recovery_mom_top10 and fc monthly).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tickers count as alive for 10 rows after their last bar, so a newest row
printed by a few early tickers is dropped until the rest arrive. The
benchmark-print session rule now applies only to the mixed US/HK ETF panel:
Yahoo's 510300.SS lags CN stocks by days and would stall the CN book.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Process every completed session since the last recorded one, so monitor
downtime and late data are caught up; today's bar only counts after the
exchange closes. The monitor's evening phase always goes through auto and
catches up at startup.
- Tickers without a real closing print are valued at the last price but not
traded; held tickers missing from the panel keep their last recorded price
instead of being valued at zero.
- Use registry parameters (live momentum strategies ran top_n=len//10=49
instead of the backtested 20).
- A-share orders use 100-share board lots; per-market default capital
(US $10k, CN ¥70k); HK tickers are converted to USD (HKD=X, peg fallback)
and exempt from the US per-share fee.
- ETF strategies only run in the US book; buy_and_hold is excluded from live
because its ~$20 slices never reach the minimum order size.
- CN benchmark switches to 510300.SS (Yahoo's 000300.SS is truncated).
- New 'replay' command rebuilds live state files from each start date.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Register trend_rider_v7_vt36 (target_vol=0.36, min_lev=0.75) in
strategy registry, ETF universe map, and bridge metadata.
10y backtest: Ann 60.5%, Sharpe 1.87, MaxDD -29.2%.
- Add hot-reload to monitor: each phase re-imports trader module to
pick up newly registered strategies without restart. New strategies
are logged on detection.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- DEFAULT_MONITOR_STRATEGIES now includes ALL strategies (stock + ETF)
instead of excluding ETF strategies. The cmd_morning/evening/auto
already route ETF strategies to the correct data pipeline via
strategy_universe() and strategy_data_market().
- Register trend_rider_v7, v7_vt24, v7_vt32 in bridge.py STRATEGY_META
so they appear in the stock-agent frontend via /api/strategies.
- Monitor now runs as a background daemon with logs written to
logs/monitor.log (PYTHONUNBUFFERED=1, no tmux dependency).
PID saved to logs/monitor.pid.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three-layer strategy for leveraged ETF portfolios:
Layer 1: V3 regime engine (MA150) — SPY technicals for risk-on/off
Layer 2: Vol-target overlay (28%, clip 0.6-1.0) — scale by realized vol
Layer 3: Profit-take with hysteresis (+30% → clear to SHY, restore <20%)
The profit-take exploits a structural property of 3x leveraged ETFs:
after large gains, volatility drag on the inflated base erodes compound
returns. Clearing the position locks in geometric gains before the drag
takes effect — this is rebalancing alpha, not prediction alpha.
10y backtest (2016-2026, 10bps one-way cost):
Ann 54.7%, Sharpe(rf=5%) 1.72, MaxDD -25.7%, Sortino 2.23
Also registers trend_rider_v7, trend_rider_v7_vt24, trend_rider_v7_vt32
in the trader strategy registry and ETF_STRATEGY_UNIVERSES.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add MARKET_FEES {us: 2, cn: 5} so the monitor and cron (auto) paths
automatically apply the correct local-currency fixed commission without
needing a per-strategy override. CLI --fixed-fee still wins when set
explicitly for auto; monitor now always resolves from the table so its
banner and each strategy sub-call agree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cmd_evening (used by the monitor path) only updated the simple daily_equity
dict, so daily_log had gaps on every monitor-driven day. Mirror cmd_auto's
pattern and call record_daily_snapshot so each strategy's NAV is recorded
every trading day, even when no trades execute.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New FactorComboStrategy class (strategies/factor_combo.py) implements
8 champion factor signals (4 US, 4 CN) discovered through iterative
factor research, each at 4 rebalancing frequencies (daily/weekly/
biweekly/monthly). Registered in trader.py as fc_{signal}_{freq}.
Existing strategies and state files are untouched — safe to git pull
and restart monitor on server.
Also includes factor research scripts (factor_loop.py, factor_research.py,
etc.) used to discover and validate these factors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- `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>
- `trader.py monitor` — runs ALL 9 strategies by default, $10k capital,
$2 fee, integer shares. Just start and forget.
- `trader.py compare` — auto-discovers all state files in data/, no
--strategy needed. Ranks by return with equity curves.
- Monitor defaults: --capital 10000, --fixed-fee 2.0, --integer-shares
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 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>
Backtesting engine supporting 11 strategies across US (S&P 500) and CN (CSI 300)
markets with open-to-close execution, proportional + fixed per-trade fees.
Daily trader (trader.py) with auto/morning/evening/simulate/status commands
and cron-friendly `auto` mode for unattended daily runs on a server.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>