Legacy → Domain Import Inventory
Sprint ticket: S5 — Legacy import inventory for AlphaSwarm first-class module (ADRs 033-020 approved) Scope: READ-ONLY audit; no production code was modified. Root scanned:
c:\Users\Julian Wiley\Documents\GitHub\Alpha-Swarm-ai\Worktrees excluded:alphaswarm_worktrees/**Generated: 2026-08-10 byalphaswarm-index-curator(sprint S5)
1. Summary counts
| Package | Total files | Production files | Test files |
|---|---|---|---|
alphaswarm (monolith) | 174 | 131 | 43 |
alphaswarm_agents | 7 | 6 | 1 |
alphaswarm_bots | 1 | 1 | 0 |
alphaswarm_models | 6 | 6 | 0 |
alphaswarm_rl | 5 | 5 | 0 |
alphaswarm_cli | 0 | 0 | 0 |
alphaswarm_controller | 0 | 0 | 0 |
alphaswarm_core | 0 | 0 | 0 |
| TOTAL | 193 | 149 | 44 |
Key finding: alphaswarm_cli and alphaswarm_controller are already clean — zero direct legacy imports, confirming the boundary isolation for those repos.
2. Migration map — legacy symbol to canonical domain target
The following table is derived from the shim docstring in VERIFIED file
alphaswarm/alphaswarm/core/types.py:1-80.
Legacy symbol (alphaswarm.core.types) | Canonical domain target | Module | Notes |
|---|---|---|---|
Symbol | InstrumentId | alphaswarm.core.domain.identifiers | Bridge: Symbol.to_instrument_id() / Symbol.from_instrument_id() |
Exchange | Venue | alphaswarm.core.domain.identifiers | Venue is a string value-object, not an enum |
AssetClass | AssetClass | alphaswarm.core.domain.enums | Domain is a superset (adds RATES/CREDIT/ALTERNATIVE/EVENT/MIXED/CASH) |
SecurityType | InstrumentClass | alphaswarm.core.domain.enums | Domain adds REIT/MUTUAL_FUND/OTC_DERIVATIVE/ADR/GDR |
OrderType | OrderType | alphaswarm.core.domain.enums | Domain superset adds STOP_MARKET/MIT/LIT/MTL/TSM/TSL/FOK/FAK/RFQ |
OrderSide | OrderSide | alphaswarm.core.domain.enums | Domain adds NONE |
OrderStatus | OrderStatus | alphaswarm.core.domain.enums | Domain has richer state machine; CANCELLED → CANCELED rename |
Direction | PositionSide | alphaswarm.core.domain.enums | Conflict: legacy NET ≠ domain FLAT; requires value mapping |
OrderRequest | DomainOrder / MarketOrder / LimitOrder / StopMarketOrder | alphaswarm.core.domain.orders | Bridge: OrderRequest.to_domain_order() → legacy_adapter.domain_order_from_order_request() |
OrderData | DomainOrder (view) | alphaswarm.core.domain.orders | Bridge: OrderData.to_domain_order() / OrderData.from_domain_order() |
TradeData | ExecutionReport | alphaswarm.trading.execution | Bridge: TradeData.from_execution_report() |
PositionData | EquityPosition / DomainPosition | alphaswarm.core.domain.positions | Bridge: PositionData.from_account_position_row() |
AccountData | AccountRow + balances | alphaswarm.persistence.models_accounts | Bridge: AccountData.from_account_row() |
Types that remain authoritative in alphaswarm.core.types (no domain equivalent):
| Symbol | Category | Rationale |
|---|---|---|
BarData, TradeBar, QuoteBar, TickData, Tick | Market data records | Domain layer covers identity/orders/accounts, not the data plane |
Interval, Resolution, TickType, DataNormalizationMode, SubscriptionDataConfig | Data-plane routing keys | No domain replacement planned |
Signal, PortfolioTarget | Alpha/portfolio value objects | Alpha-framework primitives with no domain equivalent |
Event, MarketEvent, SignalEvent, OrderEvent_Msg, FillEvent_Msg, EventType | Backtest event loop messages | Core to the event-driven engine bus |
OrderEvent, OrderTicket | Legacy framework patterns | Keep for existing PaperTradingSession |
Cash, CashBook | Multi-currency accounting | No domain equivalent |
SecurityHolding | Lean-style position record | No domain equivalent |
ACTIVE_STATUSES, iter_subscriptions, money | Helpers | Utility, no migration needed |
3. Full file inventory — production files only
3.1 Critical hotspots (block strangler migration)
These files use multiple legacy types including OrderRequest, OrderData, TradeData, or PositionData — the types with explicit domain bridges — and are on the critical path for removing the shim.
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm/alphaswarm/backtest/engine.py:46 | BarData, EventType, FillEvent_Msg, Interval, MarketEvent, OrderEvent, OrderEvent_Msg, OrderRequest, OrderTicket, SignalEvent, Symbol, TradeData | H | Phase 3 — engine refactor |
alphaswarm/alphaswarm/backtest/broker_sim.py:19 | AccountData, Direction, OrderData, OrderRequest, OrderSide, OrderStatus, PositionData, TradeData | H | Phase 3 — engine refactor |
alphaswarm/alphaswarm/core/interfaces.py:15 | AccountData, BarData, OrderData, OrderEvent, OrderRequest, OrderTicket, PortfolioTarget, PositionData, Signal, SubscriptionDataConfig, Symbol | H | Phase 2 — interfaces lift |
alphaswarm/alphaswarm/trading/session.py:32 | BarData, OrderData, OrderRequest, TradeData | H | Phase 3 — session refactor |
alphaswarm/alphaswarm/trading/execution/legacy_adapter.py:50,281,357,394 | AccountData, OrderData, OrderRequest, OrderSide, OrderStatus, OrderType, PositionData, Symbol, Exchange, Direction | H | Phase 2 — already the bridge, promote to permanent |
alphaswarm/alphaswarm/trading/brokerages/base.py:13 | AccountData, OrderData, OrderRequest, PositionData | H | Phase 3 — brokerage interface |
alphaswarm/alphaswarm/trading/brokerages/alpaca.py:52 | AccountData, Direction, OrderData, OrderRequest, OrderSide, OrderStatus, OrderType, PositionData, Symbol | H | Phase 3 — brokerage adapter |
alphaswarm/alphaswarm/trading/brokerages/ibkr.py:31 | AccountData, Direction, OrderData, OrderRequest, OrderSide, OrderStatus, OrderType, PositionData, Symbol | H | Phase 3 — brokerage adapter |
alphaswarm/alphaswarm/trading/brokerages/tradier.py:14 | AccountData, Direction, OrderData, OrderRequest, OrderSide, OrderStatus, OrderType, PositionData, Symbol | H | Phase 3 — brokerage adapter |
alphaswarm/alphaswarm/trading/brokerages/rest.py:25 | AccountData, OrderData, OrderRequest, OrderSide, OrderStatus, OrderType, PositionData, Symbol | H | Phase 3 — brokerage adapter |
alphaswarm/alphaswarm/persistence/ledger.py:19 | OrderData, Signal, TradeData | H | Phase 2 — ledger writer must consume domain types |
alphaswarm/alphaswarm/backtest/result_handler.py:16 | OrderEvent, OrderTicket, PositionData | H | Phase 3 — result handler |
alphaswarm/alphaswarm/strategies/framework.py:36 | BarData, OrderData, OrderRequest, Signal | H | Phase 3 — strategy framework ABC |
alphaswarm/alphaswarm/strategies/execution.py:9 | Direction, OrderRequest, OrderSide, OrderType, PortfolioTarget, PositionData | H | Phase 3 — execution models |
alphaswarm/alphaswarm/strategies/vwap_execution.py:16 | OrderRequest, OrderSide, OrderType, PortfolioTarget | H | Phase 3 — execution models |
alphaswarm/alphaswarm/strategies/twap_execution.py:9 | OrderRequest, OrderSide, OrderType, PortfolioTarget | H | Phase 3 — execution models |
alphaswarm/alphaswarm/backtest/replay.py:27 | EventType, OrderEvent, OrderTicket, TradeData | H | Phase 3 — replay engine |
alphaswarm/alphaswarm/api/routes/orders.py:40 | OrderRequest, OrderSide, OrderType, Symbol | H | Phase 2 — order API surface |
alphaswarm/alphaswarm/api/routes/brokers.py:35 | AccountData, OrderRequest, OrderSide, OrderType, PositionData, Symbol | H | Phase 2 — broker API surface |
3.2 Symbol-only consumers (lower risk, high volume)
These files import only Symbol (and sometimes Exchange, AssetClass, SecurityType). Migration path: swap Symbol → InstrumentId, call Symbol.parse(vt) → InstrumentId.parse(vt) with the domain form.
alphaswarm strategies (Symbol + Direction + Signal — all three are high-frequency)
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm/alphaswarm/strategies/portfolio_construction.py:22 | PortfolioTarget, Signal, Symbol | M | Phase 4 |
alphaswarm/alphaswarm/strategies/black_litterman.py:17 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/hrp.py:23 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/risk_parity.py:11 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/risk_models.py:29 | Direction, PortfolioTarget | M | Phase 4 |
alphaswarm/alphaswarm/strategies/mean_variance.py:12 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio_opt/_base.py:21 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio_opt/min_variance.py:19 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio_opt/cla.py:17 | PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio_opt/efficient_cvar.py:18 | PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio_opt/efficient_cdar.py:11 | PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio_opt/efficient_semivariance.py:11 | PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/portfolio.py:8 | Direction, PortfolioTarget, Signal | M | Phase 4 |
alphaswarm/alphaswarm/strategies/drawdown_per_security.py:8 | PortfolioTarget | L | Phase 4 |
alphaswarm/alphaswarm/strategies/sector_exposure.py:8 | PortfolioTarget | L | Phase 4 |
alphaswarm/alphaswarm/strategies/trailing_stop.py:8 | PortfolioTarget | L | Phase 4 |
alphaswarm/alphaswarm/strategies/ema_cross_alpha.py:10 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/macd_alpha.py:10 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/momentum.py:10 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/mean_reversion.py:10 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/rsi_alpha.py:10 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/dual_thrust_alpha.py:18 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/bollinger_w_alpha.py:18 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/heikin_ashi_alpha.py:18 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/oil_money_alpha.py:22 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/london_breakout_alpha.py:19 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/awesome_oscillator_alpha.py:19 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/shooting_star_alpha.py:17 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/parabolic_sar_alpha.py:18 | BarData, Direction, Signal, Symbol | M | Phase 5 |
alphaswarm/alphaswarm/strategies/rsi_pattern_alpha.py:21 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/ml_alphas.py:26 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/ml_selection.py:31 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/rl_policy.py:13 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/pairs_alpha.py:18 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/base_algo_example.py:18 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/etf_baskets.py:9 | Exchange, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/universes.py:17 | Exchange, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/fundamental_universe.py:11 | Exchange, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/adaptive_rotation/gics_buckets.py:19 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/adaptive_rotation/rotation_alpha.py:13 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/agentic/agentic_alpha.py:44 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/agentic/agent_aware_alpha.py:24 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/agentic/ml_selector_alpha.py:33 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/stat_arb/multi_cluster.py:51 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/stat_arb/cross_sectional_residual.py:26 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/options/vrp_straddle.py:36 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/options/variance_swap.py:27 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/options/iron_condor.py:29 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/momentum/dual_momentum.py:24 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/momentum/sector_rotation.py:17 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/momentum/residual_momentum.py:17 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/momentum/smoothed_crossover.py:21 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/ml/svm_fx_trend.py:27 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/ml/nb_sentiment.py:22 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/ml/ann_crypto_decile.py:23 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/qtradex/alphas.py:27 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/vbtpro/agentic_alpha.py:36 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/vbtpro/ml_alpha.py:34 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/vbtpro/agent_order_model.py:27 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/sae/alphas.py:15 | BarData, Direction, OrderData, OrderRequest, Signal, Symbol | H | Phase 3 |
alphaswarm/alphaswarm/strategies/akquant/alphas.py:103,143,247,269 | BarData, Direction, OrderData, OrderRequest, Signal, Symbol | H | Phase 3 |
alphaswarm/alphaswarm/strategies/analyzingalpha/alphas.py:159,204 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/notebooks/alphas.py:143,204,236,299,511 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/examples/sma_cross.py:13 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/examples/sma4_cross.py:17 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/strategies/examples/trailing_atr.py:17 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm core/backtest/data/trading/api layers
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm/alphaswarm/core/__init__.py:215 | All legacy types (mass re-export) | H | Phase 2 — remove or scope re-exports |
alphaswarm/alphaswarm/core/slice.py:19 | BarData, QuoteBar, Symbol, TickData | M | Phase 3 |
alphaswarm/alphaswarm/core/indicators.py:23 | BarData | L | Phase 5 |
alphaswarm/alphaswarm/core/indicators_extra.py:40 | BarData | L | Phase 5 |
alphaswarm/alphaswarm/backtest/aat_engine.py:29 | Direction, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/bt_engine.py:39 | Direction, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/vectorbt_engine.py:41 | Direction, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/zvt_engine.py:30 | Direction, Signal, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/components.py:12 | Direction, Signal, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/history.py:11 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/market_impact.py:25 | OrderSide | M | Phase 3 |
alphaswarm/alphaswarm/backtest/runner.py:28 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/vbtpro/data_utils.py:16 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/vbtpro/order_builder.py:27 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/backtest/vbtpro/signal_builder.py:27 | Direction, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/data/catalog.py:14,383 | Symbol, SecurityType | M | Phase 3 |
alphaswarm/alphaswarm/data/duckdb_engine.py:30 | DataNormalizationMode, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/data/feature_sets.py:35 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/data/indicators_zoo.py:258 | BarData, Symbol | L | Phase 5 |
alphaswarm/alphaswarm/data/ingestion.py:30 | Exchange, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/data/subscription.py:23 | DataNormalizationMode, Resolution, SubscriptionDataConfig, Symbol, TickType | L | Phase 4 |
alphaswarm/alphaswarm/data/sources/alpha_vantage/bulk_loader.py:32 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/data/sources/alpha_vantage/coordination.py:13 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/data/sources/alpha_vantage/history.py:12 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/data/sources/alpha_vantage/intraday_plan.py:16 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/data/sources/alpha_vantage/universe.py:13 | AssetClass, Exchange, SecurityType | M | Phase 4 |
alphaswarm/alphaswarm/trading/feeds/base.py:13 | BarData, Exchange, Interval, Symbol | M | Phase 3 |
alphaswarm/alphaswarm/trading/feeds/alpaca_feed.py:22 | BarData, Exchange, Interval, Symbol | M | Phase 3 |
alphaswarm/alphaswarm/trading/feeds/ibkr_feed.py:21 | BarData, Exchange, Interval, Symbol | M | Phase 3 |
alphaswarm/alphaswarm/trading/feeds/kafka_feed.py:40 | BarData, Direction, Exchange, Interval, QuoteBar, Signal, Symbol, TickData, TickType | M | Phase 3 |
alphaswarm/alphaswarm/trading/feeds/rest_poll.py:20 | BarData, Exchange, Interval, Symbol | M | Phase 3 |
alphaswarm/alphaswarm/trading/runner.py:23 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/backtest.py:239 | DataNormalizationMode, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/data.py:33,1085,1244 | DataNormalizationMode, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/factors.py:164 | DataNormalizationMode, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/feature_catalog.py:179 | DataNormalizationMode, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/feature_sets.py:32 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/market_data_live.py:25,451 | DataNormalizationMode, Symbol | L | Phase 4 |
alphaswarm/alphaswarm/api/routes/quant_agents.py:803 | Symbol | L | Phase 4 |
alphaswarm/alphaswarm/facade/foundation.py:36 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/services/portfolio_service.py:18 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/tasks/ingestion_tasks.py:127 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/tasks/feature_set_tasks.py:43 | Symbol | L | Phase 5 |
alphaswarm/alphaswarm/tasks/factor_tasks.py:40 | Symbol | L | Phase 5 |
3.3 Sibling-package consumers (external to alphaswarm monolith)
alphaswarm_agents
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm_agents/src/alphaswarm_agents/quant/factor_strategy_shim.py:25 | OrderRequest, OrderSide, OrderType, Symbol | H | Phase 3 |
alphaswarm_agents/src/alphaswarm_agents/graph/builder.py:252 | Direction, Signal, SignalEvent, Symbol | M | Phase 4 |
alphaswarm_agents/src/alphaswarm_agents/screening/llm_screener.py:27 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm_agents/src/alphaswarm_agents/tools/analytics_tools.py:52,99,146,190,273,339 | Symbol (inline, 6 occurrences) | L | Phase 5 |
alphaswarm_agents/src/alphaswarm_agents/tools/technical_tool.py:120,158 | BarData, Interval, Symbol | L | Phase 5 |
alphaswarm_agents/src/alphaswarm_agents/tools/volatility_tool.py:73 | Symbol | L | Phase 5 |
alphaswarm_agents/src/alphaswarm_agents/tools/simulation_tool.py:132 | Symbol | L | Phase 5 |
alphaswarm_bots
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm_bots/adapters/bridges/execution_bridges.py:149 | OrderData (inline, lazy import) | H | Phase 3 — bridge translates NewOrder → OrderData; needs domain path |
alphaswarm_models
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm_models/src/alphaswarm_models/api/routes/ml.py:30 | Symbol | L | Phase 5 |
alphaswarm_models/src/alphaswarm_models/applications/forecaster/alpha.py:12 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm_models/src/alphaswarm_models/loader.py:158 | Symbol (inline lazy import) | L | Phase 5 |
alphaswarm_models/src/alphaswarm_models/recorder.py:206 | Symbol (inline lazy import) | L | Phase 5 |
alphaswarm_models/src/alphaswarm_models/tasks/ml_tasks.py:397 | Symbol (inline lazy import) | L | Phase 5 |
alphaswarm_models/src/alphaswarm_models/tasks/ml_test_tasks.py:37,475,552 | Symbol (inline, 3 occurrences) | L | Phase 5 |
alphaswarm_rl
| File | Imported legacy symbols | Risk | Phase |
|---|---|---|---|
alphaswarm_rl/src/alphaswarm_rl/envs/rl_backtest_env.py:57 | Direction, OrderRequest, OrderSide, OrderType, Symbol | H | Phase 3 — wraps SimulatedBrokerage directly |
alphaswarm_rl/src/alphaswarm_rl/envs/base.py:18 | Symbol | L | Phase 5 |
alphaswarm_rl/src/alphaswarm_rl/applications/ensemble_strategy.py:22 | Direction, Signal, Symbol | L | Phase 5 |
alphaswarm_rl/src/alphaswarm_rl/applications/fundamental_portfolio_drl.py:107 | Symbol (inline lazy import) | L | Phase 5 |
alphaswarm_rl/src/alphaswarm_rl/data_pipelines/iceberg.py:58 | Symbol (inline lazy import) | L | Phase 5 |
4. Hotspots that block strangler migration
The following files are on the critical path. Migrating away from the legacy stack requires all of these to be updated first because they form the shared interface contracts consumed by everything above.
| File | Why it blocks | Strangler action |
|---|---|---|
alphaswarm/alphaswarm/core/interfaces.py | Declares IBrokerage, IHistoryProvider, IStrategy, IExecutionModel, IResultHandler ABCs with legacy type signatures | PRIORITY 1: Dual-signature the ABCs to accept both OrderRequest and DomainOrder; gate by ADR 037 |
alphaswarm/alphaswarm/backtest/engine.py | The canonical event-driven engine; all other engines and the paper session depend on its event types | PRIORITY 1: Move to domain orders with event-bus adapters |
alphaswarm/alphaswarm/backtest/broker_sim.py | Used by both engine.py and rl_backtest_env.py; drives all order matching | PRIORITY 1: Dual-write path while domain orders roll out |
alphaswarm/alphaswarm/trading/session.py | The live/paper runtime; shares IBrokerage with the backtest path | PRIORITY 1: Migrate when interfaces.py dual-signature is ready |
alphaswarm/alphaswarm/trading/execution/legacy_adapter.py | The translation bridge itself; must stay alive during migration window | PRIORITY 2: Promote to permanent adapter pattern; wire into gateway |
alphaswarm/alphaswarm/trading/brokerages/base.py | Base class for all live brokerages; extends IBrokerage with legacy types | PRIORITY 2: Migrate after interfaces.py |
alphaswarm/alphaswarm/persistence/ledger.py | Every signal/order/fill flows through LedgerWriter; uses OrderData, Signal, TradeData | PRIORITY 2: Accept domain types in parallel |
alphaswarm/alphaswarm/core/__init__.py | Mass re-export of all legacy types; makes from alphaswarm.core import Symbol silently work everywhere | PRIORITY 3: Scope or remove legacy re-exports at end of migration window |
5. Consumer counts by symbol
This table counts unique production files (no tests, no worktrees) importing each legacy symbol.
| Legacy symbol | Production-file consumers | Domain target |
|---|---|---|
Symbol | 93 | InstrumentId (alphaswarm.core.domain.identifiers) |
Direction | 60 | PositionSide (alphaswarm.core.domain.enums) |
Signal | 59 | No domain equivalent — keep in alphaswarm.core.types |
PortfolioTarget | 18 | No domain equivalent — keep in alphaswarm.core.types |
BarData | 15 | No domain equivalent — keep in alphaswarm.core.types |
OrderRequest | 15 | DomainOrder subtypes (alphaswarm.core.domain.orders) |
OrderSide | 11 | OrderSide (alphaswarm.core.domain.enums) |
OrderType | 11 | OrderType (alphaswarm.core.domain.enums) |
OrderData | 9 | DomainOrder (view) (alphaswarm.core.domain.orders) |
Exchange | 9 | Venue (alphaswarm.core.domain.identifiers) |
PositionData | 8 | DomainPosition / EquityPosition (alphaswarm.core.domain.positions) |
TradeData | 5 | ExecutionReport (alphaswarm.trading.execution) |
AccountData | 5 | AccountRow + balances (alphaswarm.persistence.models_accounts) |
DataNormalizationMode | 8 | No domain equivalent — keep in alphaswarm.core.types |
SubscriptionDataConfig | 2 | No domain equivalent — keep in alphaswarm.core.types |
SecurityType | 2 | InstrumentClass (alphaswarm.core.domain.enums) |
AssetClass | 2 | AssetClass (alphaswarm.core.domain.enums) |
OrderStatus | 6 | OrderStatus (alphaswarm.core.domain.enums) |
EventType | 2 | No domain equivalent — keep in alphaswarm.core.types |
OrderEvent | 3 | No domain equivalent — keep in alphaswarm.core.types |
OrderTicket | 2 | No domain equivalent — keep in alphaswarm.core.types |
Interval | 3 | No domain equivalent — keep in alphaswarm.core.types |
Resolution | 1 | No domain equivalent — keep in alphaswarm.core.types |
TickType | 2 | No domain equivalent — keep in alphaswarm.core.types |
QuoteBar | 2 | No domain equivalent — keep in alphaswarm.core.types |
TickData | 1 | No domain equivalent — keep in alphaswarm.core.types |
TradeBar | 0 (alias for BarData) | No domain equivalent |
Tick | 0 (alias for TickData) | No domain equivalent |
6. Suggested migration phases
| Phase | Description | Files affected | Est. change scope |
|---|---|---|---|
| Phase 2 | Interfaces + order API routes — dual-signature ABCs so both OrderRequest and DomainOrder are accepted; migrate /api/routes/orders.py and /api/routes/brokers.py to emit/consume DomainOrder | interfaces.py, orders.py, brokers.py, legacy_adapter.py (promote) | ~5 files, high-complexity |
| Phase 3 | Engine + brokerage core — migrate engine.py, broker_sim.py, session.py, all 4 live brokerages, feeds, trading/execution/, persistence/ledger.py | 19 high-risk production files | ~20 files, highest complexity |
| Phase 4 | Secondary backtest engines + data layer — migrate aat_engine.py, bt_engine.py, vectorbt_engine.py, zvt_engine.py, replay.py, result_handler.py, data/catalog.py, feeds helper layers | ~25 M-risk files | ~25 files, medium complexity |
| Phase 5 | Strategy catalogue + sibling packages — all strategies that import Direction, Signal, Symbol only; sibling repos (alphaswarm_agents, alphaswarm_models, alphaswarm_rl) | ~70 L-risk files | ~70 files, mostly 1-line swaps |
| Phase 6 | Shim removal — remove alphaswarm.core.types deprecated symbols (keep BarData, Signal, PortfolioTarget, data-plane types as permanent) | alphaswarm/alphaswarm/core/types.py cleanup | 1 file, low complexity |
7. Notes on Direction special case
Direction (LONG/SHORT/NET) maps to domain PositionSide (LONG/SHORT/FLAT). The value NET has no direct equivalent in the domain enum. Consumers using Direction.NET are:
alphaswarm/alphaswarm/backtest/broker_sim.py(position direction tracking)alphaswarm/alphaswarm/strategies/execution.py(position-to-order delta)
These files require a value-remapping step (treat NET as absolute-size accounting, not a direction) before the swap can be done safely.
VERIFIED: alphaswarm/alphaswarm/core/types.py:174 — Direction.NET = "net" is the legacy-only variant.
VERIFIED: alphaswarm/alphaswarm/core/domain/enums.py — PositionSide has LONG/SHORT/FLAT, no NET.
8. Verified evidence samples
| Claim | VERIFIED evidence |
|---|---|
| Legacy shim doc with full migration map | alphaswarm/alphaswarm/core/types.py:1-80 |
engine.py imports 12 legacy types | alphaswarm/alphaswarm/backtest/engine.py:46-59 |
interfaces.py imports 11 legacy types | alphaswarm/alphaswarm/core/interfaces.py:15-27 |
broker_sim.py imports 8 legacy types including AccountData, PositionData | alphaswarm/alphaswarm/backtest/broker_sim.py:19-28 |
legacy_adapter.py imports domain+legacy both | alphaswarm/alphaswarm/trading/execution/legacy_adapter.py:30-62 |
rl_backtest_env.py imports OrderRequest/OrderSide/OrderType | alphaswarm_rl/src/alphaswarm_rl/envs/rl_backtest_env.py:57-64 |
alphaswarm_cli and alphaswarm_controller have zero legacy imports | grep result: 0 matches in both packages |
domain/__init__.py exports all domain types | alphaswarm/alphaswarm/core/domain/__init__.py (full file) |
Direction.NET exists only in legacy | alphaswarm/alphaswarm/core/types.py:183 |
Symbol.to_instrument_id() bridge exists | alphaswarm/alphaswarm/core/types.py:372-383 |
Debt note: run the alphaswarm-index-curator after Phase 2 lands to update alphaswarm_index/ signatures and code-index references for interfaces.py and orders.py.