PosSizer - Any example extensions for how to create a new one?
Author: sl44096
Creation Date: 1/6/2010 9:19 PM
profile picture

sl44096

#1
I know PosSizers have been introduced in 5.6 to adjust position sizing. In looking over the latest extensions available, I didn't see an example of how to create a new, custom position sizer. Am I overlooking such a beast?

Here's some specifics of what I'd like to do - in the ideal world the newly exposed capabilities around position sizing would allow this to happen without doing something that's too overly convoluted:

1) Let's say I have a system that generates, on average, 10 alerts (for 10 different stocks) each day. However, on some days I have 15 alerts (15 different stocks), while on other days I only have 5 alerts.

2) To keep things simple, let's say that the alerts are all for market orders for the next day (end of day system). In reality, this isn't quite the case, since they're limit orders that may not execute, but... let's keep things fairly simple.

3) Based on the number of alerts for any given day, I want to specify the percent of equity that is applied to each trade. So, for example, if I have 10 alerts, I'll apply 10% of equity to each, while if I have 5 alerts I'll bump up the percent of equity for each to 20%.

4) To support some risk mgmt, the new custom posSizer would support a constraint whereby no position could ever exceed x% of equity (e.g., 20%). For example, if I only have 1 alert on a given day, the % of equity would be the max allowed, in this example 20%.


Something like this would seem to make good sense for any system that generates a variable number of alerts for a given day, where the desire is to spread equity out over more of the alerts (positions) when possible. By supporting this, equity can be more effectively utilized, at the potential cost of introducing some additional risk due to larger positions.

Thoughts? Again if an example remotely similar to this exists that I could base some code off of, I'd gladly implement this and share it back to the community.

My current work-around would be to run the simulation in raw profit mode, track all the trades in a file for each day, then re-run the simulation, read the file (put the results in global), then do a set share size kind of a deal to match a percent of equity. Doable? Yeah... A bit of a hack? yeah... I'd like to do this a bit more cleanly if possible.

Thx! Lee K.
(and you thought I never played with WLP anymore! :-)

PS. Great job with the documentation and other support info, as always!
profile picture

Eugene

#2
Lee,

An example (Random) PosSizer with open source code will be published shortly in the Wealth-Lab Wiki.

This idea is possible to implement as a PosSizer. I'll probably take the job, but first need to hear from you re: #4 (risk mgmt). Setting such a trade cap is valid, but let's imagine that a system generated a really big number of alerts after running on, say, S&P 500 - hundreds or thousands. Will we be still taking those tiny-sized positions? Is it unacceptable?
profile picture

dan_rozenberg

#3
Eugene, I am really looking forward for your PosSizer code too. Do you have any sort of ETA for it?

Thanks!
profile picture

Eugene

#4
Dan,

Please read the forum, I have announced it today in two threads e.g.

MS123.PosSizers - a collection of money management methods
profile picture

dan_rozenberg

#5
I can easily say this is the best day of my life now!
profile picture

sl44096

#6
Eugene,

Thanks for the follow-up. The question you raise is a good one, and I think the best answer is to make it configurable (albeit perhaps a bit more work). That is, allow a person to specify a minimum % of current equity for a given position, as well as a maximum %. I realize that in the case of minimums, there's could be a degree of randomness involved introduced, similar to how WLP works today. For example, if someone dictates that the minimum position size allowed is 5% of equity, but they have more than 20 alerts, then clearly some of the alerts won't be acted upon in a backtest. No different than what happens today when doing portfolio back-tests.

That said, when backtesting a person could specify a very small minimum percentage required per position, and could then play with that minimum to see what it does to the associated equity curve, draw-down, commissions paid, etc.

If you wanted to get really sophisticated, you'd be thinking about how to combine this idea with the notion of underlying volatility position sizing. For example, if you have 10 alerts that you want to act on, but one of the stocks is twice as volatile as one of the other stocks, we'd increase the percentage allocated to the less-volatile stock as a way to further manage risk. Again - something to have in the back of your head, but not something to necessarily tackle right out of the gate.

As you can probably tell, position and money/risk managment is something that I think can really enhance how people trade. I'm not sure how popular this is amongst the current WLP community, but for anyone who's lived through some nasty surprises in their trading career, some solid money mgmt rules can potentially help avoid some of the pain.

Thx... Lee
profile picture

sl44096

#7
Eugene,

I had a chance to check out your source code example for the random pos sizer. Thanks for such a quick response on this one - very nice. There's always some details to paw through, but... it looks very logical.

I think I could pull together a customer pos sizer that does what is laid out in this thread. Laying out the UI and a few other "details" would undoubtedly take me more time than the actual logic behind the sizing logic (sigh).

Please let me know if you're going to tackle the pos sizer described in this thread, or if you're fully consumed (in which case I'll take a shot at it).

Now if I could just get my strategies to do what they're supposed to do! :-)

- Lee
profile picture

Eugene

#8
Lee,

I would like to include this item in MS123.PosSizers. In fact, a "CandidateCount"-like position sizing option was already on my plans for a future release of the library. I can't give any ETA of this feature, as I will have to switch back to my recurring deadlines and other projects. So if time permits, you can wait for my implementation or otherwise start building it on your own.
profile picture

sl44096

#9
Eugene,

Thanks for the follow-up. I will probably wait for your implementation of this, since I've got quite a few projects already backed up as well. If I can get ahead of the curve and get to this, I'll let you know. Otherwise, I'll await your implementation.

- Lee
profile picture

wl64bit

#10
Eugene,

Could you please consider splitting "CandidateCount" into "LongCandidateCount" and "ShortCandidateCount". It would be very helpful.

Thank you
profile picture

Eugene

#11
Hi,

Sure. I'd appreciate if you could post more ideas re: CandidateCount here or in the original thread, so the resulting PosSizer would be feature packed and could suit your requirements.

At this time, I'll be looking at translating the WL4's QuickRef example for CandidateCount + your suggestion.
profile picture

Eugene

#12
Lee,

Re: allow a person to specify a minimum % of current equity for a given position, as well as a maximum %.

- This will be implemented:



Re: combine this idea with the notion of underlying volatility position sizing.

- Nope, I'm not planning to get that sophisticated. :)

You may create a support ticket to get the PosSizer pack with this item, when available (the development is not over yet.)
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).