Fixing a Position Dictionary Attribute Error in a Trading Strategy
Summary
This brief troubleshooting note addresses a Python AttributeError raised when a strategy tries to access a last-sale-date attribute on a Zipline equity object. The suggested correction is to build the holdings mapping from each position’s equity symbol and position object, filtering for positions with a positive amount. This avoids relying on the unavailable attribute and provides a way to identify currently held securities.
The note repeats the reported error and proposed change, but does not include the surrounding strategy code, explain how the problematic attribute was originally used, or show a test confirming the fix. Its guidance is therefore narrow: it may help when the error arises during construction of a holdings mapping, but does not establish a general solution for other uses of the missing field or other Zipline versions. Readers should check that the revised mapping matches the data their strategy expects.
Key ideas
- The reported exception concerns a missing last-sale-date attribute on a Zipline equity object.
- The proposed fix maps held positions by equity symbol and position object.
- Only positions with a positive amount are included in the suggested mapping.
- The note provides no test results or broader explanation of the surrounding strategy.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.