Adjusting position size
Author: fritz
Creation Date: 2/27/2010 4:46 PM
profile picture

fritz

#1
I'm writing a script that tests a portfolio-trading approach. Because of what I'm doing, I can't just turn it loose on a DataSet and let it choose position sizes &etc. I need to calculate and specify position sizes. I know I can do that with SetShareSize.

But I want to *adjust* position sizes as I go along. E.g. if one position in the basket gets too large or too small, I want to sell or buy a few shares to adjust it to the right size.

As far as I can tell this is impossible, yes? I can split a position if I want to do two separate exits, but I can't adjust a running position size arbitrarily. I can approximate this by selling the position, then buying a new one with the new size, but obviously that's not ideal. Is there a better answer?
profile picture

Cone

#2
CODE:
Please log in to see this code.
Nothing's impossible. The things you have to work with are Positions. You have [at least] 2 options each for adding and removing shares:

Adding
1. As you said, sell the existing Position and then enter a new Position with the number of shares you want.
2. Add another Position. If you do it this way, however, you need to deal with both Positions. There is no way to "combine" multiple Positions.

Removing
1. Same as 1. above.
2. Split the Position (SplitPosition) and exit one of them.
profile picture

fritz

#3
Yup, that's what I figured. Managing multiple positions for this would be unwieldy at best, unless I wanted to manage an N-share position as a set of N 1-share positions. OK, I'll go with the sell & re-buy approach. It won't handle slippage and commissions properly, but ohwell.
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).