Applying Strategy at Symbol Level on Unequally Weighted (% or $) Data Set ?
Author: jpmorgan
Creation Date: 11/21/2011 12:46 PM
profile picture

jpmorgan

#1
Eugene, per your suggestion I have restarted the conversation thread here, as I thought this topic heading was much more representative of what I am really looking to do versus creating an index or basket of securities (again unless those would be unequally weighted).

Overview:
- 1 multi-factor strategy
- Single open position per security at any given time
- 25 securities
- un-equal weight of each security: each security will be held at a different targeted weight ideally in %s, or $ if necessary (different exposure for commodity etf, reit, foreign bond, domestic equity, etc.)
- trade and apply strategy at symbol level, NOT as a synthetic single security or custom index

Description of Objective:
I have a half dozen model portfolios I have contructed. I have a rather simple strategy that I use, however, the models consist of 12-25 different exchanged traded securities and each of these holdings have a different weight. This is a long only strategy, with only one open position per security at a time, so I am simply in our out of the holding based on the execution of the underlying strategy. I want to be sure that it is clear that I am not really looking for a custom index, because I am not looking to be long or out of the whole strategy (and all of the undlying holdings) at a given time, but rather be long the portfolio constituents as dictated by the strategy at a given time. Otherwise said, I am interested in applying the strategy symbol level of an unequally weighted portfolio, rather than creating a custom index of equally share components and trading it as a single security.


As a final note, I am curious as to whether my request and desire is so unique and why the function would not exist, particularly when I can create such weighted portfolios with either dollars or percentages in many other free tools, albeit without the more comprehensive backtesting features. Would you anticipate this to be more easily addressed in future releases, as I would greatly appreciate fulfillment of the request and the assistance in putting it into the consideration pool for development.

Thanks again in advance,
J. P.
profile picture

Eugene

#2
In short, is the objective to assign a different % equity or number of shares to each asset? Then the "Use .Tag" button (% Equity) from MS123 PosSizers library > Position Options might do the trick.
profile picture

jpmorgan

#3
I believe your understanding and assessment is correct. I am looking to establish a dataset with varied % of equity based upon the individual asset, all being evaluated under the same strategy. Might there be an easily referenced example of how this is applied to the coding found in the Editor?

Thanks yet again! - j. p.
profile picture

Eugene

#4
OK. Just to be clear, the idea is to pass the equity percentage for the Position just created, to the PosSizer.

Here's an example of passing a variable equity percentage for the "Use .Tag" option:

CODE:
Please log in to see this code.
profile picture

jpmorgan

#5
Eugene, thanks again for the response. It certainly gives me confidence that this can be done. In an effort to share, I wanted to provide the code directly from the strategy I am using and see if you may be able to at least indicate how or where I would work it in to the existing code, given that it was originally created with the visual rules/tools. As you will see the strategy is quite simply, I am just novice at incorporating manually written code with that of the auto generated rule based code produced by strategy builder.

Thanks yet again!

CODE:
Please log in to see this code.
profile picture

Eugene

#6
Concentrate on this fragment -- it's the only piece that matters for your task:
CODE:
Please log in to see this code.

Look up the method names in the QuickRef. Compare it with the code you have. You'll need two things:

1. Replace your trading function with my construct:
CODE:
Please log in to see this code.

2. Adjust the provided string that assigns variable equity percentages with your own.

Good luck!
profile picture

jpmorgan

#7
Eugene, thanks again for your assistance up to this point. I was playing around with your suggestions, but I don't believe I have been successful in my endeavors and I was wondering if you may be able to offer any furhter guidance. Per your suggestions the new code is below.

CODE:
Please log in to see this code.


I simply stuck with the AAPL and MSFT for trial purposes. I was also unclear on what you meant by the method names (BuyAtClose?). I also was not clear if you were still suggesting you PosSizers or if the code alone you suggested should essentially address the issues. Basically, I will just need to enter the 20+ symbols and their relevant percentages following the same format, but the problem at the moment is that I do not appear to be getting a correct result. The code does compile and run, but the results using the percentage outlined would be limited to a total of 4 symbols (2 @ 20% beyond the 60% combined total for AAPL and MSFT.

Might you be able to advise or offer any suggestion on what I may be missing? Thanks again from a novice.

Best, J. P.
profile picture

Eugene

#8
Have you already employed the "Use .Tag" option? (See my first reply from 11/21/2011 1:01 PM). This is the prerequisite -- otherwise the LastPosition.Tag assignment is pretty useless.
profile picture

jpmorgan

#9
Eugene, thanks for the response. Apparently I did not, but what am I missing? I did look for the "Use.Tag" call in your response from 11/21/11 at 2:08 pm, but I did not see it after reviewing the code multiple times. I did look at the link and I understand the usage of PosSizer via the Use.Tag, but I still fail to see where or how to embed it in the code in Editor. Thanks again for your patience.
profile picture

Eugene

#10
My example code from 11/21/2011 3:39 PM that you quoted is what will be "driving" the Use Tag option. Look up the Position.Tag property in the QuickRef.
profile picture

jpmorgan

#11
Eugene, thanks again and sorry for any misunderstanding. Fundamentally, the issue appears to be with the Use.Tag button. I am running WLP 6.2.46.0. The PosSizer Settings box that I get, regardless of which of the 5 options I choose ("Avg Down with Pct Equity Limit "to "Pct Winners Position Sizing") does not offer the image found at http://www2.wealth-lab.com/WL5WIKI/psPositionOptions.ashx representing the PosSizer Settings. Thereby, I have no access to the Use.Tag button, nor do I have access to the Position limits and filters (found on the right). I essentially only have the 3 basic options of Fixed Dollar, Pct of Equity and Max Risk Pct. Can you advise on what code I need to activated the "advanced" or more comprehensive PosSizer Settings as found at the link you provided?

For clarification - Use.Tag is a button in the PosSizer Settings, not code found in the Editor? (Although I do not seem to have access to for some reason)

profile picture

Eugene

#12
Install MS123 PosSizer Library and restart WLP.
profile picture

jpmorgan

#13
Eugene, thanks for the further clarification. I have successfully installed the PosSizer and I think I am all but set here. I did have two final points of clarification.
1) should the following code
CODE:
Please log in to see this code.
have the values following the "?" be represented in Green?
2) Do you have a suggested method for independently confirming that the code and Use.Tag button are, in fact, performing the functions as desired? That is do you have an approach for suggesting that in the sample about AAPL is 50% of the total portfolio and MSFT is 40% with all others being 5%?

Thanks! - J. P.
profile picture

Eugene

#14
1) In green, comments are highlighted in the Editor. The code is OK so no need to confirm everything with me over and over again.

2) Sure I have. Assign 10 to the LastPosition.Tag for the unconditional 10% position sizing, run a simulation using the "Position Options" with the Use Tag option enabled. Next switch to the built in "Percent Equity" option in WLP using same 10%. Values will match.

Good luck.
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).