Designing a Strategy Scheduling Architecture Driven by Macro Data and Policy Events
This article describes an event-driven architecture that schedules strategy research signals from index adjustments, macroeconomic indicators, exchange rule changes, and industrial policy text. It covers trading-calendar-aware event modeling, macro feature engineering, configuration-driven rule management, NLP policy extraction with human review, reliable message pipelines, and common failure modes. All code is illustrative and must be validated in simulation or backtesting before use.
Risk disclaimer: This article discusses only technical architecture and code examples. It does not constitute investment advice. The code and rule configurations in this article must be verified in a simulation or backtesting environment before use. Markets carry risk, and readers bear responsibility for their own decisions.
1. Problem Background and Design Goals
Short-term moves in financial markets are often triggered by external information. Examples include changes to international index constituents, macroeconomic data releases, temporary exchange rule changes, and new industrial policies. This information comes from different sources, in different formats, and at irregular times. Manual market monitoring makes it hard to ensure both timeliness and consistency.
From an engineering standpoint, a workable scheduling system must do four things: ingest heterogeneous data reliably, convert raw information into structured events, generate signals according to rules, and pass those signals to downstream modules for backtesting or simulation. This article covers each of these steps. It focuses on the data structures, boundary conditions, and failure handling for each stage.
2. Modeling Index Adjustment Events and Time Boundaries
Index adjustments are usually announced in advance and take effect on a specific date. The system can model each adjustment as a timestamped event object. Date calculations must rely on a trading calendar, not calendar days. For example, the fifth calendar day before an effective date is not necessarily the fifth trading day, because holidays and trading suspensions both change the result.
The code below provides a runnable skeleton. All times use the exchange’s local time zone, and the calendar is passed in as an external input.
from dataclasses import dataclassfrom datetime import date@dataclass(frozen=True)class IndexAdjustmentEvent:event_id: str # Globally unique, used for idempotent deduplicationstock_code: straction: str # "include" or "exclude"announce_date: dateeffective_date: datedef __post_init__(self):if self.action not in {"include", "exclude"}:raise ValueError(f"Unknown action: {self.action}")if self.effective_date <= self.announce_date:raise ValueError("Effective date must be later than announcement date")def calculate_window(self, calendar: list[date], lead_days: int = 5) -> tuple[date, date]:"""Returns (observation start date, effective date). calendar is an ascending list of trading days and must include the effective date."""idx = calendar.index(self.effective_date) # Raises ValueError if the effective date is not in the calendarif idx < lead_days:raise ValueError("Trading calendar is too short to compute the observation window")return calendar[idx - lead_days], self.effective_datedef generate_signal(self, today: date, calendar: list[date]) -> str:start, eff = self.calculate_window(calendar)if today < start:return "WAIT"if start <= today < eff:return "PRE_EVENT_CANDIDATE" # Candidate signal, research input onlyif today == eff:return "REVIEW_EXPOSURE" # Triggers exposure review, not a sell orderreturn "CLOSED"
Several points about this code need explanation. First, the signal names use “candidate” and “review.” These names indicate that the system outputs research signals that still need validation. It does not produce trading orders directly. Second, calculate_window depends on the trading calendar, so the calendar data source must be version-controlled and must cover changes to holiday schedules. Third, invalid inputs raise errors immediately. This prevents the system from silently producing an incorrect window.
In a real deployment, the following boundaries also need attention:
- Time zones: Announcements may be published in foreign time zones. Timestamps must be converted to the exchange’s local date before they are stored.
- Retries: When an external data pull fails, use exponential backoff retries and log the failure count. Raise an alert when the count exceeds a threshold.
- Slippage and liquidity: In research, include slippage assumptions in backtests and check that trading volume can support simulated fills.
- Price limits and suspensions: If a security cannot be traded on a signal day, the backtest should record the signal as unfilled. It must not assume execution at the closing price.
3. Feature Engineering for Macro Indicators
CPI (Consumer Price Index) and PPI (Producer Price Index) reflect price trends and are often used as inputs for industry research. The key step is to convert macro data into comparable features rather than use raw values directly.
Take the non-ferrous metals sector as an example. You can construct a “price spread factor” that measures the gap between the year-over-year growth of product selling prices and the year-over-year growth of raw material costs:
Price spread factor = Year-over-year growth in product selling price − Year-over-year growth in raw material cost
When this factor is positive, selling price growth is outpacing cost growth. In theory, this widens the gross margin for companies in the sector. If the factor stays positive and keeps rising across several consecutive observation periods, the system can tag the corresponding industry as a “candidate leading theme.” The industry then goes to the liquidity, volatility, and backtesting modules for further confirmation. The system should not adjust positions based on this factor alone.
The consumer sector is handled in the opposite way. If CPI data shows weak growth in consumer demand, the model can set a lower weight cap during feature weighting. This reduces the sector’s contribution to the composite score. The “lower weight” is an internal model parameter. It affects only score ranking and does not represent a view on any specific security.
Macro data also has a common problem: the release date and the reference period differ. For example, a month’s data may be published in the middle of the following month, and revised values come out later. The feature table should store both the reference period and the release timestamp. Backtests may only use data that was available at the time. Otherwise, look-ahead bias enters the results and inflates backtest performance.
4. A Rule Engine for Trading Rule Changes
Exchanges adjust rules such as margin requirements, price limits, and position limits based on market conditions. If these changes are hardcoded into strategy code, every change requires a new program release. This process is slow and prone to missed updates. A safer approach is to store the rules in a separate rule engine driven by configuration files.
The following example uses a silver futures rule adjustment as an illustration. The data is for demonstration only.
{"schema_version": "1.2.0","rule_id": "AG-FUT-MARGIN-20260210-001","instrument": "silver_futures","effective_from": "2026-02-10T00:00:00+08:00","changes": {"margin_multiplier": 1.1,"short_position_limit": "decreased"},"derived_flag": "SHORT_CONSTRAINT_EASED","rollout": {"mode": "canary","percent": 5},"rollback": {"previous_rule_id": "AG-FUT-MARGIN-20251201-003"},"audit": {"source_notice_id": "<exchange notice ID>","reviewed_by": "<reviewer>","reviewed_at": "2026-02-09T18:00:00+08:00"}}
This configuration includes several types of fields, each with a specific purpose. schema_version checks whether the parsing logic is compatible. The system rejects the file when the version does not match. effective_from must include a time zone to prevent parsing errors across time zones. rollout supports canary releases. A canary release applies the change to a small share of strategies first, and the change is rolled out fully only after no anomalies appear. rollback records the previous version so the system can revert quickly if a problem occurs. audit stores the notice ID and review details for traceability.
When loading a configuration, the rule engine should perform these steps: validate the JSON structure, check that the effective time is earlier than the current time, confirm that rule_id is unique, and write the change to the audit log. If any step fails, the engine should block the load and raise an alert.
For products affected by substitution effects, such as metals whose prices move sharply after overseas production cuts, the system can record substitution relationships in a knowledge graph. When a product’s price rise exceeds a preset threshold, the system can lower that product’s concentration limit in the portfolio and suggest candidate substitutes. Substitution thresholds, substitute lists, and graph versions should all be managed as configuration. Every change should be recorded with a new version.
5. NLP Parsing of Industrial Policy and Human Review
Industrial policies are usually published as unstructured text. A natural language processing (NLP) module needs to extract entities, such as “cross-provincial power transmission,” “clean energy,” and “UHV equipment.” It then maps these entities to relevant industry chain nodes using an industry knowledge graph.
Each extracted entity must carry a confidence score. One workable handling scheme is as follows:
- Confidence of 0.85 or higher: Write automatically to the graph and record the source.
- Confidence between 0.60 and 0.85: Send to a human review queue. An analyst confirms the entity before it is written to the graph.
- Confidence below 0.60: Discard the entity and keep the original text for future model training.
These thresholds must be calibrated against historical labeled data. Do not copy them directly. Graph updates also need version records. Each time a node is added or removed, generate a new version number and keep a snapshot of the previous version. This way, backtests can use the industry chain relationships that matched the period being tested.
A policy can push different sectors in opposite directions. For example, exporting clean energy may lower electricity prices in some regions, which then affects costs for energy-intensive industries. Indirect transmission paths like this should be modeled separately and labeled as “inferred relationships.” They should be kept apart from direct relationships so that inferences are not treated as facts.
6. Timing Filters and Research Conditions
Many strategies look for entry points after prices pull back. A common approach combines moving averages (MA), the relative strength index (RSI), and volatility indicators to set trigger conditions. For example, if price falls from a recent high and approaches a moving average, while volume shrinks and shows signs of stabilizing, the system can generate a “pullback candidate” flag.
These conditions should serve only as research inputs. When you use them, keep the following in mind:
- Do not repeatedly optimize parameters over the full sample, because this leads to overfitting. Split the data into in-s
