position.Shares is always 1.0
Author: Ben_Zurich
Creation Date: 3/1/2013 10:55 AM
profile picture

Ben_Zurich

#1
I'd like to fetch the number of shares WL6 has assigned to a position but always end up with

CODE:
Please log in to see this code.


having the value of 1.0 and not the number of shares listed in the 'Trades' visualizer.
My position size method is: Percent of equity.

How can I get the correct number of shares?
profile picture

Eugene

#2
If in doubt, please open up the QuickRef for Position object, Shares property, and see the remark:

QUOTE:
"In portfolio simulation mode, all trades are pre-executed using 1 share per Position, and then position sizing is applied after the fact. So the Shares property will always return 1 while the Strategy is executing."


You will have access to the actual number of shares in Position Sizers and Visualizers.

P.S. The "interacting with equity curve" solution allows to extract the number of shares too (see SystemResults.Positions collection) to some extent but essentially is a workaround that you play with on your own.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).