Accessing Position data in Strategy while using PosSizer
Author: tcastle
Creation Date: 11/19/2016 1:21 PM
profile picture

tcastle

#1
Interrogating Positions from within the Execute routine of a .net strategy that also employs a PosSizer produces correct values for entrydates, exitdates, prices, etc. but not shares. I presume share data is missing because share data is not determined until after the Execute routine concludes and WL completes processing for a backtest. How can I obtain share values programmatically after WL processing has been completed?
profile picture

Eugene

#2
If you haven't found the answer by yourself, I suggest to review the QuickRef > Position object > and then browse for individual properties. Where applicable you will find this remark, duplicated here for your convenience:
CODE:
Please log in to see this code.

So your understanding is correct: "share data is not determined until after the Execute routine concludes".

QUOTE:
How can I obtain share values programmatically after WL processing has been completed?

I'd say with the current design there might be no official way because it's too late: the Strategy has finished processing. But first let's find out why do you need it?
profile picture

tcastle

#3
I suppose I don't really need to access share data from within the .net strategy. I can work around. I was just trying a couple backtest ideas and noticed the issue. Thanks for your confirmation.
profile picture

Eugene

#4
Here's a couple of workarounds:

1. While it doesn't exemplify the usage of Position properties, those could be derived from the SystemResults object using this advanced technique: Interacting Dynamically with Portfolio Level Equity

2. Using SetShareSize and a Strategy rewrite: ... / Portfolio Equity Tracker
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).