ExecuteDonorStrategy missing some PosSizer settings?
Author: jaredm
Creation Date: 3/27/2016 8:48 PM
profile picture

jaredm

#1
I noticed the results of a strategy I ran using runDonor (now ExecuteDonorStrategy) didn't match the results when running the strategy normally. NetProfit was wrong, APR was wrong, etc. Looking further, I noticed that runDonor was picking a different number of shares than the normal method. I was using a simple Percent of Equity: 100 Position Size, but runDonor was using 10% sizing. Looking at PortfolioEquityEx.cs, I notice some code to set PosSize on the TradingSystemExecutor, like this:

CODE:
Please log in to see this code.


In my case PctEquity never gets set. I assume it defaults to 10%. I have not spent a bunch of time with this code, but I don't understand why ExecuteDonorStrategy is cherry-picking properties from ps and stuffing them into exec.PosSize. Instead I wonder why those dozen or so lines can't be replaced with this:
CODE:
Please log in to see this code.


This solved my issue, though I didn't run any other tests besides the Percent of Equity: 100 PosSizer, so not confident I didn't break something else, but hard to imagine why only some properties were being set.

-Jared
profile picture

Eugene

#2
QUOTE:
In my case PctEquity never gets set.

Line 114 sets it:
CODE:
Please log in to see this code.


QUOTE:
didn't match the results when running the strategy normally. (...) I was using a simple Percent of Equity: 100 Position Size

This is the key. A mismatch is expected if your strategy doesn't set Position.Priority properly and/or uses a 100% sizing. Please review the Wiki FAQ for insight:

I'm using 100% Equity position sizing and strategy doesn't seem to use all capital and/or there are trades not included due to insufficient capital.

QUOTE:
Instead I wonder why those dozen or so lines can't be replaced with this:

On the surface this sounds like a reasonable idea. Thank you for your suggestion. I'll review the code later.
profile picture

jaredm

#3
Thanks for the quick response.

Before I went to the code I did review that FAQ as part of my troubleshooting and also tried setting meaningful priorities on my trades. Didn't work. I also looked for NSF trades to explain it and that wasn't it either. I should have said this in my first post but it slipped my mind -- I was trying so many things to fix it -- until you mentioned it.

I said PctEquity never gets set. My mistake. I meant PctSize.

Here's some code that demonstrates the problem I was seeing. It spits out some PositionSize info from a normal (non-donor? patient?) strategy and also from a donor strategy. I would expect them to be the same, but they aren't.
CODE:
Please log in to see this code.


Here's the output I get with ExecuteDonorStrategy() as is:
CODE:
Please log in to see this code.


And with my suggested change:
CODE:
Please log in to see this code.


profile picture

Eugene

#4
Jared, thank you for the detailed bug report and the fix. That's the power of community and open source. I confirm the bug and the fact that your code does fix it. The fix will be included in the upcoming release of the library (2016.04).
profile picture

jaredm

#5
I have been using the tools for a while so happy to finally contribute a piece, however small, back. Thanks.
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).