Skip to content

feat(backtest): default hk research wrappers to orchestrator - #83

Merged
Pigbibi merged 4 commits into
mainfrom
feat/hk-equity-combo-orchestrator
Jul 10, 2026
Merged

feat(backtest): default hk research wrappers to orchestrator#83
Pigbibi merged 4 commits into
mainfrom
feat/hk-equity-combo-orchestrator

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary\n- Default HK research wrappers to orchestrator/profile\n- Preserve legacy AkShare path behind --analysis\n\n## Test Plan\n- python3 -m py_compile on modified scripts\n- --help smoke test on modified wrappers

Pigbibi and others added 2 commits July 10, 2026 03:23
Wire hk_equity_combo through HkEquityComboBacktestRunner, combo_simulator,
walk-forward CLI, and research --orchestrator entrypoint.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Codex <noreply@openai.com>
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Co-Authored-By: Codex <noreply@openai.com>
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Co-Authored-By: Codex <noreply@openai.com>
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

close = build_close_matrix(market_history, universe_symbols=universe_symbols)

P1 Badge Preserve the full ETF universe in combo backtests

When run_combo_backtest is reached from HkEquityComboBacktestRunner or the default research wrapper, universe_symbols is left as None, so this call falls back to etf_rotation_core.build_close_matrix's six-symbol default instead of the HK global ETF universe that includes 02834 and 03175. The signal function still ranks the eight-symbol global universe, and build_rotation_target_weights only keeps weights for close.columns, so any allocation to NASDAQ100 or crude is silently dropped and the combo metrics are wrong whenever those assets are selected. Pass the global ETF universe, or otherwise keep the signal and close-matrix universes identical.


SUPPORTED_PROFILES = frozenset({HK_GLOBAL_ETF_TACTICAL_ROTATION_PROFILE, HK_EQUITY_COMBO_PROFILE})

P2 Badge Keep the ETF runner from accepting combo profiles

Adding HK_EQUITY_COMBO_PROFILE to the shared SUPPORTED_PROFILES set makes HkEtfRotationBacktestRunner.run() accept hk_equity_combo, because that method validates against this set and then always calls run_etf_rotation_backtest. Any caller that directly registers or invokes HkEtfRotationBacktestRunner with the newly listed combo profile will get ETF-rotation metrics mislabeled as combo metrics instead of being forced through HkEquityComboBacktestRunner.


_signal_fn,
combo_config=HkComboBacktestConfig(
combo_mode=cast(ComboMode, combo_mode),
min_history_days=min_history_days,
),

P2 Badge Forward combo backtest params into the simulation

When orchestrator callers pass combo parameters such as etf_weight, dividend_weight, cost_bps, or rebalance_frequency, this construction drops them and only forwards combo_mode/min_history_days, even though the returned BacktestResult.params still records the original params. That makes experiments report one configuration while the simulator always runs the default 60/40, 10 bps, monthly setup, so parameter sweeps and profile overrides can produce misleading results.


payload = run_etf_rotation_profile_backtest(
"hk_global_etf_tactical_rotation",
market_history=market_history,
params={"min_history_days": DEFAULT_MIN_HISTORY_DAYS},

P2 Badge Preserve the analysis window in orchestrator wrappers

In the new default path, this call omits start_date=config.analysis_start/end_date=config.data_end; the legacy path immediately below still slices from config.analysis_start, while config.start is only the warmup download start for the long ETF lookbacks. Running the wrapper without --legacy now reports metrics over the warmup window, including initial cash/zero-return days, rather than the intended research window, so default results are not comparable to the legacy analysis.


etf_gross = float(base_etf_weights.sum())
if etf_gross > 0.0:
scaled_etf = base_etf_weights.multiply(etf_target_weight / etf_gross)

P2 Badge Preserve ETF leg cash from volatility targeting

When the ETF signal returns gross exposure below 1.0 because its volatility target or cash allocation fired, this branch renormalizes it back to the full combo ETF sleeve. The production combo profile multiplies ETF weights by the sleeve weight without rescaling, so orchestrator combo backtests overstate ETF exposure in those periods instead of leaving the ETF leg's cash uninvested.


params = {"min_history_days": 200}
if args.profile == "hk_equity_combo":
params["combo_mode"] = "dynamic"

P2 Badge Use a valid history default for combo single runs

For --mode single --profile hk_equity_combo, this keeps min_history_days at 200 while the ETF leg still uses the 252-day momentum window and rejects min_history_days <= 252. The new combo single path therefore raises before returning metrics unless the user overrides the script behavior; use the profile defaults as in run_walk_forward or a value above the ETF lookbacks.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Pigbibi
Pigbibi merged commit 54011c3 into main Jul 10, 2026
2 checks passed
@Pigbibi
Pigbibi deleted the feat/hk-equity-combo-orchestrator branch July 10, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant