|
| 1 | +# Next-window cleanup split plan |
| 2 | + |
| 3 | +_Verified snapshot: 2026-04-07_ |
| 4 | + |
| 5 | +This document pre-splits the **next compatibility-window cleanup** into small PR-sized batches. |
| 6 | + |
| 7 | +It is a planning document only. |
| 8 | +Do **not** merge these removals early. |
| 9 | +The current window still intentionally keeps rollback hooks. |
| 10 | + |
| 11 | +## Scope |
| 12 | + |
| 13 | +Remove only migration-window compatibility layers that were kept during PR1-PR6. |
| 14 | + |
| 15 | +Do **not** use this cleanup window to: |
| 16 | + |
| 17 | +- change any strategy formulas |
| 18 | +- change thresholds or risk semantics |
| 19 | +- refactor broker integrations beyond the boundary-removal work |
| 20 | +- mix feature work into cleanup PRs |
| 21 | + |
| 22 | +## Common release gates |
| 23 | + |
| 24 | +Every removal PR below should wait until all of these are true: |
| 25 | + |
| 26 | +1. the unified-entrypoint mainline has shipped for at least one stable release window |
| 27 | +2. rollback to the previous release tag is still possible during the cutover |
| 28 | +3. regression tests for the affected repo are green on the unified path |
| 29 | +4. `rg` shows the legacy symbol is only referenced in the files being deleted or updated in that PR |
| 30 | +5. any research or test-only imports have been moved off the compatibility shim first |
| 31 | + |
| 32 | +## Recommended PR order |
| 33 | + |
| 34 | +1. `NW1` QuantPlatformKit deprecated helper removal - done |
| 35 | +2. `NW2` LongBridgePlatform allocation-loader removal - done |
| 36 | +3. `NW3` CharlesSchwabPlatform allocation-loader removal - done |
| 37 | +4. `NW4` UsEquityStrategies metadata lift for IB cleanup - done |
| 38 | +5. `NW5` InteractiveBrokersPlatform legacy-module bridge removal - done |
| 39 | +6. `NW6` BinancePlatform direct component-loader and main-wrapper removal - done |
| 40 | + |
| 41 | +This order keeps the easy and low-coupling deletions first, and leaves the IB / Binance boundary cleanup for after their remaining test and adapter dependencies are gone. |
| 42 | + |
| 43 | +## Execution status |
| 44 | + |
| 45 | +- Completed on the current branch: `NW1`, `NW2`, `NW3`, `NW4`, `NW5`, `NW6` |
| 46 | +- Remaining planned batch after that: none |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## NW1 - QuantPlatformKit: remove deprecated global compatibility helpers |
| 51 | + |
| 52 | +**Status:** completed on the current branch. |
| 53 | + |
| 54 | +### Goal |
| 55 | + |
| 56 | +Delete the migration-window helpers that were superseded by `StrategyCatalog` + `PlatformStrategyPolicy`. |
| 57 | + |
| 58 | +### Repositories |
| 59 | + |
| 60 | +- `QuantPlatformKit` |
| 61 | + |
| 62 | +### Delete |
| 63 | + |
| 64 | +- `src/quant_platform_kit/common/strategies.py` |
| 65 | + - `get_supported_profiles_for_platform(...)` |
| 66 | + - `resolve_strategy_definition(...)` |
| 67 | + - the deprecation warning strings and legacy call path that support them |
| 68 | +- `src/quant_platform_kit/__init__.py` |
| 69 | + - legacy exports for the two deprecated helpers |
| 70 | +- tests and docs that still assert the deprecated flow |
| 71 | + |
| 72 | +### Keep |
| 73 | + |
| 74 | +- `resolve_platform_strategy_definition(...)` |
| 75 | +- `get_enabled_profiles_for_platform(...)` |
| 76 | +- `build_platform_profile_matrix(...)` |
| 77 | +- platform-local `strategy_registry.py` wrappers that already sit on top of the new policy/catalog API |
| 78 | + |
| 79 | +### Current references to clean up |
| 80 | + |
| 81 | +- `src/quant_platform_kit/common/strategies.py` |
| 82 | +- `src/quant_platform_kit/__init__.py` |
| 83 | +- `tests/test_strategies.py` |
| 84 | +- `tests/test_strategy_contracts.py` |
| 85 | +- `docs/strategy_contract_migration.md` |
| 86 | + |
| 87 | +### Done when |
| 88 | + |
| 89 | +- `rg -n "resolve_strategy_definition\(|get_supported_profiles_for_platform\(" .` in `QuantPlatformKit` only finds historical notes that were intentionally rewritten, or finds no runtime code at all |
| 90 | +- tests cover only the catalog/policy path |
| 91 | + |
| 92 | +### Suggested validation |
| 93 | + |
| 94 | +```bash |
| 95 | +cd /Users/lisiyi/Projects/QuantPlatformKit |
| 96 | +python3 -m ruff check src tests |
| 97 | +PYTHONPATH=src python3 -m unittest tests.test_strategy_contracts tests.test_strategies tests.test_models -v |
| 98 | +``` |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## NW2 - LongBridgePlatform: remove allocation compatibility loader |
| 103 | + |
| 104 | +**Status:** completed on the current branch. |
| 105 | + |
| 106 | +### Goal |
| 107 | + |
| 108 | +Delete the last platform-local allocation shim API now that `main.py` already runs through `strategy_runtime` + unified entrypoint. |
| 109 | + |
| 110 | +### Repositories |
| 111 | + |
| 112 | +- `LongBridgePlatform` |
| 113 | + |
| 114 | +### Delete |
| 115 | + |
| 116 | +- `strategy_loader.py` |
| 117 | + - `load_allocation_module(...)` |
| 118 | +- tests that still verify allocation-module loading |
| 119 | + |
| 120 | +### Current references to clean up |
| 121 | + |
| 122 | +- `strategy_loader.py` |
| 123 | +- `tests/test_strategy_loader.py` |
| 124 | + |
| 125 | +### Preconditions |
| 126 | + |
| 127 | +None beyond the common release gates. |
| 128 | +The mainline path is already on `load_strategy_entrypoint_for_profile(...)`. |
| 129 | + |
| 130 | +### Done when |
| 131 | + |
| 132 | +- `rg -n "load_allocation_module\(" .` in `LongBridgePlatform` returns no matches |
| 133 | +- loader tests only assert unified entrypoint loading |
| 134 | + |
| 135 | +### Suggested validation |
| 136 | + |
| 137 | +```bash |
| 138 | +cd /Users/lisiyi/Projects/LongBridgePlatform |
| 139 | +python3 -m ruff check strategy_loader.py tests/test_strategy_loader.py tests/test_strategy_runtime.py |
| 140 | +PYTHONPATH=.:/Users/lisiyi/Projects/QuantPlatformKit/src:/Users/lisiyi/Projects/UsEquityStrategies/src python -m unittest \ |
| 141 | + tests.test_strategy_loader tests.test_strategy_runtime tests.test_rebalance_service tests.test_request_handling -v |
| 142 | +``` |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## NW3 - CharlesSchwabPlatform: remove allocation compatibility loader |
| 147 | + |
| 148 | +**Status:** completed on the current branch. |
| 149 | + |
| 150 | +### Goal |
| 151 | + |
| 152 | +Do the same cleanup as LongBridge, but in the Schwab runtime. |
| 153 | + |
| 154 | +### Repositories |
| 155 | + |
| 156 | +- `CharlesSchwabPlatform` |
| 157 | + |
| 158 | +### Delete |
| 159 | + |
| 160 | +- `strategy_loader.py` |
| 161 | + - `load_allocation_module(...)` |
| 162 | +- tests that still verify allocation-module loading |
| 163 | + |
| 164 | +### Current references to clean up |
| 165 | + |
| 166 | +- `strategy_loader.py` |
| 167 | +- `tests/test_strategy_loader.py` |
| 168 | + |
| 169 | +### Preconditions |
| 170 | + |
| 171 | +None beyond the common release gates. |
| 172 | +The mainline path is already on `load_strategy_entrypoint_for_profile(...)`. |
| 173 | + |
| 174 | +### Done when |
| 175 | + |
| 176 | +- `rg -n "load_allocation_module\(" .` in `CharlesSchwabPlatform` returns no matches |
| 177 | +- loader tests only assert unified entrypoint loading |
| 178 | + |
| 179 | +### Suggested validation |
| 180 | + |
| 181 | +```bash |
| 182 | +cd /Users/lisiyi/Projects/CharlesSchwabPlatform |
| 183 | +python3 -m ruff check strategy_loader.py tests/test_strategy_loader.py tests/test_strategy_runtime.py |
| 184 | +PYTHONPATH=.:/Users/lisiyi/Projects/QuantPlatformKit/src:/Users/lisiyi/Projects/UsEquityStrategies/src python -m unittest \ |
| 185 | + tests.test_strategy_loader tests.test_strategy_runtime tests.test_rebalance_service tests.test_request_handling -v |
| 186 | +``` |
| 187 | + |
| 188 | +--- |
| 189 | + |
| 190 | +## NW4 - UsEquityStrategies: lift the remaining IB-facing legacy metadata |
| 191 | + |
| 192 | +**Status:** completed on the current branch. A typed runtime adapter now exists in `UsEquityStrategies`, and `InteractiveBrokersPlatform` now consumes it without the legacy signal-module fallback. |
| 193 | + |
| 194 | +### Goal |
| 195 | + |
| 196 | +Move the last **strategy-side** metadata that IB still reads through the legacy signal module into the unified side, so the platform can delete the legacy bridge in the next PR. |
| 197 | + |
| 198 | +### Repositories |
| 199 | + |
| 200 | +- `UsEquityStrategies` |
| 201 | +- possibly `QuantPlatformKit` only if the existing manifest/default-config shape proves insufficient |
| 202 | + |
| 203 | +### Strategy-side data still consumed through the IB legacy module today |
| 204 | + |
| 205 | +`InteractiveBrokersPlatform/strategy_runtime.py` still reads these through `legacy_module`: |
| 206 | + |
| 207 | +- `STATUS_ICON` |
| 208 | +- `load_runtime_parameters(...)` |
| 209 | +- `REQUIRED_FEATURE_COLUMNS` |
| 210 | +- `SNAPSHOT_DATE_COLUMNS` |
| 211 | +- `MAX_SNAPSHOT_MONTH_LAG` |
| 212 | +- `REQUIRE_SNAPSHOT_MANIFEST` |
| 213 | +- `SNAPSHOT_CONTRACT_VERSION` |
| 214 | +- `extract_managed_symbols(...)` |
| 215 | + |
| 216 | +### Recommended direction |
| 217 | + |
| 218 | +Prefer one of these, in this order: |
| 219 | + |
| 220 | +1. move the data into `manifest.default_config` when it is declarative |
| 221 | +2. expose a strategy-side adapter object next to the unified entrypoint for IB-only snapshot/runtime metadata |
| 222 | +3. only extend QuantPlatformKit contract types if the first two options are clearly not enough |
| 223 | + |
| 224 | +Do **not** reintroduce platform-shaped return payloads into `StrategyDecision`. |
| 225 | + |
| 226 | +### Done when |
| 227 | + |
| 228 | +- IB runtime can build snapshot guards and managed-symbol metadata without importing the legacy signal module |
| 229 | +- the strategy-side contract remains formula-neutral |
| 230 | +- there is a regression test in `UsEquityStrategies` for the new metadata path |
| 231 | + |
| 232 | +### Suggested validation |
| 233 | + |
| 234 | +```bash |
| 235 | +cd /Users/lisiyi/Projects/UsEquityStrategies |
| 236 | +python3 -m ruff check src tests |
| 237 | +PYTHONPATH=src:/Users/lisiyi/Projects/QuantPlatformKit/src python -m unittest tests.test_entrypoints tests.test_catalog -v |
| 238 | +``` |
| 239 | + |
| 240 | +--- |
| 241 | + |
| 242 | +## NW5 - InteractiveBrokersPlatform: remove the legacy signal-module bridge |
| 243 | + |
| 244 | +### Goal |
| 245 | + |
| 246 | +Delete the remaining platform-side bridge to legacy signal modules after NW4 has moved the required metadata to the unified side. |
| 247 | + |
| 248 | +### Repositories |
| 249 | + |
| 250 | +- `InteractiveBrokersPlatform` |
| 251 | +- depends on `UsEquityStrategies` work from `NW4` |
| 252 | + |
| 253 | +### Delete |
| 254 | + |
| 255 | +- `strategy_loader.py` |
| 256 | + - `load_signal_logic_module(...)` |
| 257 | +- `strategy_runtime.py` |
| 258 | + - `legacy_module` field on `LoadedStrategyRuntime` |
| 259 | + - all `getattr(..., legacy_module, ...)` snapshot/runtime fallbacks |
| 260 | + - direct `load_runtime_parameters(...)` call through the legacy module |
| 261 | +- `main.py` |
| 262 | + - `STRATEGY_LOGIC` |
| 263 | + - `strategy_check_sma` |
| 264 | + - `strategy_compute_13612w_momentum` |
| 265 | + - `strategy_compute_signals` (currently dead) |
| 266 | + - any wrapper logic that only exists to proxy legacy module helpers |
| 267 | +- tests that still exercise `load_signal_logic_module(...)` |
| 268 | + |
| 269 | +### Current references to clean up |
| 270 | + |
| 271 | +- `strategy_loader.py` |
| 272 | +- `strategy_runtime.py` |
| 273 | +- `main.py` |
| 274 | +- `tests/test_strategy_loader.py` |
| 275 | + |
| 276 | +### Additional notes |
| 277 | + |
| 278 | +`compute_signals(...)` stays. |
| 279 | +It is the platform mainline entry into `STRATEGY_RUNTIME.evaluate(...)` and `decision_mapper.map_strategy_decision(...)`. |
| 280 | +Only the legacy module bridge should go away. |
| 281 | + |
| 282 | +### Done when |
| 283 | + |
| 284 | +- `rg -n "load_signal_logic_module\(|\bSTRATEGY_LOGIC\b" .` in `InteractiveBrokersPlatform` returns no runtime matches |
| 285 | +- snapshot guard configuration comes from the unified side only |
| 286 | +- IB smoke/regression tests still pass with no behavior drift |
| 287 | + |
| 288 | +### Suggested validation |
| 289 | + |
| 290 | +```bash |
| 291 | +cd /Users/lisiyi/Projects/InteractiveBrokersPlatform |
| 292 | +python3 -m ruff check main.py strategy_loader.py strategy_runtime.py tests/test_strategy_loader.py tests/test_strategy_runtime.py |
| 293 | +PYTHONPATH=.:/Users/lisiyi/Projects/QuantPlatformKit/src:/Users/lisiyi/Projects/UsEquityStrategies/src ./.venv/bin/python -m pytest \ |
| 294 | + tests/test_strategy_loader.py \ |
| 295 | + tests/test_strategy_runtime.py \ |
| 296 | + tests/test_decision_mapper.py \ |
| 297 | + tests/test_rebalance_service.py \ |
| 298 | + tests/test_request_handling.py \ |
| 299 | + tests/test_runtime_config_support.py -q |
| 300 | +``` |
| 301 | + |
| 302 | +--- |
| 303 | + |
| 304 | +## NW6 - BinancePlatform: remove direct core/rotation component loading and main-level compatibility wrappers |
| 305 | + |
| 306 | +**Status:** completed on the current branch. |
| 307 | + |
| 308 | +### Goal |
| 309 | + |
| 310 | +Finish the platform-side cleanup so Binance only loads the unified entrypoint and decision mappers, while research/tests use either unified runtime outputs or explicit upstream strategy imports. |
| 311 | + |
| 312 | +### Repositories |
| 313 | + |
| 314 | +- `BinancePlatform` |
| 315 | +- optional follow-up in `CryptoStrategies` only if an extra typed helper is still missing |
| 316 | + |
| 317 | +### Delete from platform runtime code |
| 318 | + |
| 319 | +- `strategy_loader.py` |
| 320 | + - `load_strategy_component(...)` |
| 321 | +- `strategy_runtime.py` |
| 322 | + - `core_module` |
| 323 | + - `rotation_module` |
| 324 | + - temporary helper methods: |
| 325 | + - `compute_allocation_budgets(...)` |
| 326 | + - `get_dynamic_btc_base_order(...)` |
| 327 | + - `allocate_trend_buy_budget(...)` |
| 328 | + - `refresh_rotation_pool(...)` |
| 329 | +- `main.py` |
| 330 | + - `get_dynamic_btc_target_ratio(...)` |
| 331 | + - `get_dynamic_btc_base_order(...)` |
| 332 | + - `rank_normalize(...)` |
| 333 | + - `build_stable_quality_pool(...)` |
| 334 | + - `refresh_rotation_pool(...)` |
| 335 | + - `select_rotation_weights(...)` |
| 336 | + - `allocate_trend_buy_budget(...)` |
| 337 | + |
| 338 | +### Current references that must move first |
| 339 | + |
| 340 | +- `tests/test_strategy_loader.py` |
| 341 | + - currently still asserts `load_strategy_component(...)` |
| 342 | +- `tests/test_trend_pool_loading.py` |
| 343 | + - currently patches `main.build_stable_quality_pool(...)` and calls `main.refresh_rotation_pool(...)` |
| 344 | +- `research/backtest.py` |
| 345 | + - still calls `get_dynamic_btc_base_order(...)` |
| 346 | +- any remaining tests that import main-level compatibility wrappers instead of using unified runtime output or explicit `crypto_strategies` imports |
| 347 | + |
| 348 | +### Preferred migration targets |
| 349 | + |
| 350 | +- use `StrategyDecision.diagnostics` for runtime-facing BTC / trend-rotation facts |
| 351 | +- import explicit upstream modules from `CryptoStrategies` in research-only code when a helper is intentionally research-only |
| 352 | +- keep platform runtime code on `load_strategy_entrypoint_for_profile(...)` only |
| 353 | + |
| 354 | +### Done when |
| 355 | + |
| 356 | +- `rg -n "load_strategy_component\(|get_dynamic_btc_target_ratio\(|get_dynamic_btc_base_order\(|build_stable_quality_pool\(|refresh_rotation_pool\(|select_rotation_weights\(|allocate_trend_buy_budget\(" .` in `BinancePlatform` only finds intended research-side upstream imports or returns no matches for platform runtime code |
| 357 | +- `strategy_runtime.py` loads the unified entrypoint only |
| 358 | +- loader tests no longer assert direct `core` / `rotation` module resolution |
| 359 | + |
| 360 | +### Suggested validation |
| 361 | + |
| 362 | +```bash |
| 363 | +cd /Users/lisiyi/Projects/BinancePlatform |
| 364 | +python3 -m ruff check main.py strategy_loader.py strategy_runtime.py research/backtest.py tests |
| 365 | +PYTHONPATH=.:/Users/lisiyi/Projects/QuantPlatformKit/src:/Users/lisiyi/Projects/CryptoStrategies/src python -m unittest discover -s tests -p 'test_*.py' -v |
| 366 | +``` |
| 367 | + |
| 368 | +--- |
| 369 | + |
| 370 | +## Cross-repo grep checklist before opening removal PRs |
| 371 | + |
| 372 | +Use these quick checks before starting each deletion batch: |
| 373 | + |
| 374 | +```bash |
| 375 | +for repo in QuantPlatformKit InteractiveBrokersPlatform LongBridgePlatform CharlesSchwabPlatform BinancePlatform; do |
| 376 | + echo "===== $repo =====" |
| 377 | + cd /Users/lisiyi/Projects/$repo || exit 1 |
| 378 | + rg -n "resolve_strategy_definition\(|get_supported_profiles_for_platform\(|load_signal_logic_module\(|STRATEGY_LOGIC\b|load_allocation_module\(|load_strategy_component\(|get_dynamic_btc_target_ratio\(|get_dynamic_btc_base_order\(|build_stable_quality_pool\(|refresh_rotation_pool\(|select_rotation_weights\(|allocate_trend_buy_budget\(" . --glob '!**/__pycache__/**' |
| 379 | + echo |
| 380 | + done |
| 381 | +``` |
| 382 | + |
| 383 | +If that output still shows runtime or test references outside the PR scope, split again before deleting. |
0 commit comments