Combining Multiple Factors in Quantitative Strategies: From Signal Synthesis to Position Sizing
This article explains how to combine multiple factors in quantitative trading strategies through three distinct layers: signal synthesis, portfolio construction, and capital allocation. It covers factor standardization techniques such as winsorization and z-score normalization, composite score calculation with equal or weighted schemes, exit rule design, position sizing with capital constraints, and critical execution details including data alignment and cost modeling. The article also discusses common validation pitfalls like overfitting, factor correlation, and look-ahead bias. Practical Python code examples accompany each major step, making this a useful technical reference for quantitative researchers and developers.
Three Problems Multi-Factor Combination Must Solve
Implementing a multi-factor strategy typically involves three layers. First is signal synthesis, which aggregates outputs from multiple individual factors into a single comparable score or a set of boolean signals. Second is portfolio construction, which determines which stocks to select and how many shares of each to buy. Third is capital and risk control, which decides how funds are allocated across strategies or positions and when to exit.
Although these three layers share some mathematical tools, they are distinct engineering stages. Examining each separately makes the problems in each layer much clearer.
Individual Factors: Transforming Raw Data into Judgable Signals
A factor is essentially a transformation of raw data into a numeric value that can be compared and evaluated. Consider a set of common technical and fundamental factors:
- Moving Average Golden Cross: A short-term moving average (e.g., 5-day) crosses above a long-term moving average (e.g., 10-day). The period parameters are adjustable.
- Volume Surge: Today’s trading volume exceeds yesterday’s volume by a specified multiple. Note that “double” in casual language is ambiguous—it may mean “two times” or “one time more.” In practice, always define this explicitly as a parameter to avoid confusion.
- Earnings Growth: Quarterly net profit increased compared to the previous quarter. Fundamental data must be aligned to trading days based on the announcement date—never use report-period-end data prematurely, as doing so introduces look-ahead bias into backtests.
Most of these factors are boolean signals (1 when satisfied, 0 otherwise). An alternative approach outputs continuous scores, such as return-based, turnover-based, or valuation-percentile values. Boolean signals are easy to interpret and audit, while continuous scores preserve more information. Both can be mixed in the same system.
The code below demonstrates the computation of three boolean factors and the synthesis of a buy condition:
import pandas as pddef build_buy_signal(df: pd.DataFrame, fin: pd.DataFrame,short_win: int = 5, long_win: int = 10,volume_ratio: float = 2.0) -> pd.Series:"""df: daily bar data, indexed by trading day, with columns close and volumefin: fundamental data aligned to trading days by announcement date,containing column profit_growth"""ma_short = df["close"].rolling(short_win).mean()ma_long = df["close"].rolling(long_win).mean()# Golden cross: short MA above long MA today, at or below it yesterdaygolden_cross = (ma_short > ma_long) & (ma_short.shift(1) <= ma_long.shift(1))# Volume surge: today's volume exceeds yesterday's by volume_ratio timesheavy_volume = df["volume"] > df["volume"].shift(1) * volume_ratio# Earnings growth: positive quarter-over-quarter net profit growthprofit_up = fin["profit_growth"] > 0# All three conditions must hold simultaneously to trigger a buyreturn golden_cross & heavy_volume & profit_up
Using the logical AND to combine three conditions produces a very strict signal. More conditions mean fewer signals. While each individual trade may have higher certainty, the sample size shrinks, raising the risk of parameter overfitting. This trade-off must be considered during strategy design.
Factor Standardization: Necessary Preprocessing Before Combining
Different factors have vastly different scales and distributions. Turnover rates may cluster between 0 and 0.1, while market capitalization is long-tailed. Summing such values directly would let larger-magnitude factors dominate the result. Three preprocessing steps are therefore typically required before synthesis:
- Winsorization: Clip outliers beyond a percentile range, commonly the 1st and 99th percentiles.
- Standardization: Transform into z-scores with mean 0 and standard deviation 1.
- Neutralization (optional): Regress out exposures such as industry and market cap, so the factor reflects only stock-selection information.
After standardization, factor values become directly comparable. The composite score combines standardized factors as follows:
Scorei = w_1 × F{i,1} + w2 × F{i,2} + … + wK × F{i,K}
Here, F_{i,k} is the standardized score of stock i on factor k, w_k is that factor’s weight, and K is the total number of factors.
An equal-weight scheme sets w_k = 1/K. It is simple to implement and does not depend on historical fitting, making it a robust starting point. A weighted scheme adjusts weights based on historical performance, such as by assigning weights proportional to each factor’s mean information coefficient (IC) or ICIR (mean IC divided by IC standard deviation). Weighting introduces dependence on historical data and requires out-of-sample validation.
import pandas as pddef zscore_winsorized(s: pd.Series) -> pd.Series:# Winsorize: clip to the 1st and 99th percentiless = s.clip(s.quantile(0.01), s.quantile(0.99))# Standardizereturn (s - s.mean()) / s.std()def composite_score(factors: pd.DataFrame, weights: pd.Series = None) -> pd.Series:"""factors: DataFrame with stock codes as rows and factor names as columnsweights: factor weights; defaults to equal weighting"""z = factors.apply(zscore_winsorized)if weights is None:weights = pd.Series(1 / factors.shape[1], index=factors.columns)return z.mul(weights, axis=1).sum(axis=1)
Note the dropna behavior in composite_score. Missing values will result in an empty composite score for affected stocks. The handling method must be decided explicitly before ranking—either drop those stocks or fill with the industry median.
Exit Rules: Take-Profit, Stop-Loss, and Priority
Exit conditions often matter more than entry conditions, because they directly cap the maximum loss per trade. Using “take profit at 10% and stop loss at 5%” as an example, the two conditions form an OR relationship—exiting if either is satisfied:
Sell signal = take-profit signal OR stop-loss signal
def should_exit(entry_price: float, last_price: float,take_profit: float = 0.10, stop_loss: float = 0.05) -> bool:ret = last_price / entry_price - 1return ret >= take_profit or ret <= -stop_loss
Several practical issues require attention during execution:
- Cost-basis adjustment: Dividends, stock splits, and rights issues alter the holding cost. Use adjusted prices or a revised cost basis before calculating returns.
- Fill feasibility: When a stock is suspended or locked at the daily price limit, a triggered stop-loss may still result in no fill. The strategy must record unfilled orders and retry at the next opportunity.
- Position consistency: Exit logic depends on “current holdings.” If the order system’s position records diverge from the strategy’s internal state, duplicate orders or missed sells can occur.
From Signals to Positions: Portfolio Construction
Signals answer “what to buy and what to sell,” while positions answer “how much to buy.” Portfolio construction typically involves the following steps:
- Stock selection: Rank stocks by composite score and select the top N.
- Weight allocation: Equal weighting is a common starting point. Alternatively, weights may be proportional to scores, but a per-stock cap should be set to avoid over-concentration.
- Share conversion: Markets such as A-shares trade in board lots of 100 shares. Round down to the nearest lot; leftover cash remains as a reserve.
- Capital constraints: Deduct estimated costs such as commissions and slippage, and maintain a cash buffer.
import pandas as pddef target_volumes(scores: pd.Series, prices: pd.Series, capital: float,top_n: int = 5, max_weight: float = 0.2,lot: int = 100) -> dict:picks = scores.dropna().nlargest(top_n).indexweight = min(1 / top_n, max_weight) # equal weight, capped by per-stock limitresult = {}for code in picks:budget = capital * weightshares = int(budget // prices[code] // lot) * lotresult[code] = sharesreturn result
In this code, if the per-stock cap is lower than 1/top_n, total position will be below full investment and the remainder stays in cash. This is an intentional design choice, not an omission.
Engineering Details at the Execution Layer
No matter how well signals and positions are computed, execution errors will still erode returns. Key areas to address include:
- Time alignment: Signals are typically computed from closing prices. Corresponding trades should be placed in the next trading session. Using the same day’s closing price for both signal computation and trade execution makes backtest results overly optimistic.
- Data alignment: Prices, volumes, and fundamental data have different frequencies and disclosure timings. Align all data to a unified trading-day index before merging.
- Trading rules: T+1 settlement, daily price limits, trading halts, and minimum lot sizes all affect actual fills.
- Cost model: Commissions, stamp duty, and slippage must be included in backtests; otherwise, high-turnover strategies will show significantly inflated returns.
The following example illustrates state-based decision logic. Order submission itself is handled by the trading platform’s API; only the decision logic is shown here.
def decide_action(code: str, buy_flag: bool, holding: int,entry_price: float, last_price: float) -> tuple:if holding == 0 and buy_flag:return ("buy", code)if holding > 0 and should_exit(entry_price, last_price):return ("sell", code)return ("hold", code)
The decision function should be a pure function: it takes current state as input and outputs an action. This design supports unit testing and allows the same logic to be reused across backtesting and live trading.
Validation and Common Pitfalls
Validation of a multi-factor strategy should focus not on how high a single backtest return is, but on whether results are stable.
- Out-of-sample testing: After fixing parameters on one historical period, test on a subsequent period that was not used during parameter tuning.
- Parameter sensitivity: If results change dramatically when moving-average periods shift from (5, 10) to (4, 9) or (6, 11), the strategy is likely overfitted to specific parameters.
- Factor correlation: If two factors are highly correlated, equal-weight combination double-counts the same information, meaning the actual risk exposure is larger than the surface weights suggest.
- Risk metrics: Beyond returns, examine maximum drawdown, volatility, turnover rate, and win rate to judge whether returns justify the risks taken.
The more parameters are tuned, the higher the overfitting risk. For every adjustable parameter added, ask whether there is a clear economic or statistical rationale for it.
Summary
- Multi-factor combination operates across three layers—signal synthesis, portfolio construction, and capital/risk control—each solving distinct problems.
- Logical AND/OR between boolean conditions determines signal strictness and consequently sample size.
- Winsorization and standardization are prerequisites before factor synthesis. Equal weighting is a robust starting point; weighting schemes require out-of-sample validation.
- Exit rules directly cap per-trade losses. Execution must handle cost-basis adjustments, fill feasibility, and position consistency.
- Data time alignment, trading rules, and cost models are the primary sources of divergence between backtest and live-trading results.
This article is a technical methodology discussion only and does not constitute investment advice. Historical performance of any strategy does not guarantee future results. Thorough testing and risk control are essential before actual deployment.
