backtest_lib.target_weights#
- backtest_lib.target_weights(weights: Mapping[str, float], fill_cash: bool = False) TargetWeightsDecision#
Create a decision targeting portfolio weights.
This is part of the strategy output language. Use it when your strategy expresses desired positions as weights that should sum with cash. The weight keys must be a subset of the strategy universe; missing securities are treated as zero.
- Parameters:
weights – Desired weights per security.
fill_cash – Whether to allocate remaining cash automatically.
- Returns:
TargetWeightsDecision for the target weights.