Skip to content
All library documents

Updating a Portfolio Rotation Strategy After a StrategyContext API Change

Article BigQuant

Summary

This post shows a daily stock strategy that combines a market risk filter, a trailing stop, and ranked portfolio rotation. It exits all holdings when a market risk indicator is positive, otherwise checks each position against a stop set below the highest high since purchase. After an initial holding period, it estimates the cash needed for sales and rotates out existing holdings to make room for new selections. The example also describes staged capital allocation across the holding period.

The reported error is that the upgraded StrategyContext no longer has a perf_tracker attribute. The shown code still uses that attribute to read positions and calculate their values, but the post provides no confirmed replacement API or corrected code. It offers a useful migration clue: inspect portfolio position data and adapt the old tracker references to the current interface. The snippet is duplicated and visibly malformed in places, so its exact execution behavior and compatibility cannot be established from this document.

Key ideas

  • The example combines a market risk filter, trailing stop, and ranked stock rotation.
  • A positive market risk reading triggers liquidation of current holdings.
  • The trailing stop is set below the highest high observed since a position was opened.
  • The reported upgrade error concerns access to the removed or unavailable perf_tracker attribute.
  • The post does not document a verified API replacement, and the copied code contains formatting issues.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.