strategy: implement Strategy ABC and signal framework#9
Merged
marwinsteiner merged 2 commits intomainfrom Feb 21, 2026
Merged
Conversation
Adds the main user extension point for trading strategies: - StrategyContext: provides bus/clock access and convenience methods for emitting signals and requesting orders - Strategy ABC: abstract on_market_data, optional lifecycle hooks (on_start, on_stop, on_fill, on_position), convenience wrappers - 18 tests covering context, init, lifecycle, abstract enforcement, convenience methods, and concrete strategy behavior
Adds the signal framework for expressing and combining trading intentions: - Signal: frozen Pydantic model with direction, strength (clamped to [-1,1]), instrument, strategy_id, timestamp, and metadata - SignalBook: mutable container tracking latest signal per instrument with optional max_age_seconds for stale signal filtering - Combinators: combine_signals_average, combine_signals_majority, combine_signals_weighted for multi-signal aggregation - Conversion: signal_from_event/signal_to_event for bus integration - 32 tests covering model creation, clamping, immutability, book CRUD, staleness, all combinators, and event round-trips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 3 Round 1: Strategy ABC and Signal Framework implementation.
src/sysls/strategy/base.py-- Strategy ABC (main user extension point) and StrategyContextStrategyContext: provides bus/clock access plusemit_signal()andrequest_order()convenience methodsStrategyABC: abstracton_market_data(), optional lifecycle hooks (on_start,on_stop,on_fill,on_position), convenience wrappers for signal emission and order requestssrc/sysls/strategy/signal.py-- Signal model, SignalBook, and combinatorsSignal: frozen Pydantic model with direction, strength (clamped to [-1.0, 1.0] via model_validator), instrument, strategy_id, timestamp_ns, metadataSignalBook: mutable container tracking latest signal per instrument with optional max_age_seconds for stale signal filteringcombine_signals_average,combine_signals_majority,combine_signals_weightedsignal_from_event/signal_to_eventfor bus event integration50 tests total (18 base + 32 signal), all passing
Full ruff lint + format compliance
Zero regressions across the full 472-test suite
Test plan