matching the number and timing of short positions to long ones
Author: johnls101
Creation Date: 9/14/2014 1:53 AM
profile picture

johnls101

#1
I have a two short term banding strategies for stocks: one long, one short. They act independently of each other and the number of long or short trades ranges from 0 to 5 on any given day. Trades range from 1 to 4 days.

I am concerned for “black swan” events such as 9/11. Even though not as lucrative, I don’t mind when my short system fires off trades that go overnight. However, I do feel nervous with my longs even though they are more lucrative on average.

I would like to look at the possibility of linking in “most probable shorts” when I have a number of long trades in a “pseudo pairs” approach. I appreciate that I could look at volatility matching longs with shorts and having a pos sizer to adjust the size of the short positions, but I would like to start with the more simple scenario of setting the (minimum) number of short trades to match the total number of long trades with an equal equity contribution.

Could anyone point me to any code that does this kind of thing? If not, could you suggest some tips on what to do?
profile picture

Eugene

#2
profile picture

johnls101

#3
What is graded equity percentage? How and why might you vary it?

To start with, lets say 20% equity to each long and 20% to every matching short.

I am interested in varying the equity down the track to match the volatility, but would like to deal with this once I know what to do with the basic organisation of the code.
profile picture

Eugene

#4
The graded equity percentage PosSizer is documented by the link above. The idea is to break the capital into two equity pools for long and short positions. It's up to you to decide if it suits your vision or not. I'm just suggesting options.
profile picture

johnls101

#5
Thanks Eugene.

I will look at the Pos Sizer just now to see if it helps me.

Interactive Brokers has a dataset of stocks that I can short that includes about half the number of stocks of the dataset that I have been using to go long. I am thinking that it might be necessary to somehow store the active position count for the long trades at each bar, and to somehow be able to access this when going short, but I don't know where to begin with this.

profile picture

johnls101

#6
I have just looked at the Pos Sizer (and will look at it in more detail soon), and it would be a very good suggestion if I just stuck with the Short Sellable Dataset for both longs and shorts.

However, doing this really limits the yield from the bigger dataset for going long. As I really need to use two different datasets, it might have to be more sophisticated. Thoughts as to how to approach this?
profile picture

Eugene

#7
How about this:

1. Merge together your long- and short-only DataSets into one.
2. In the Strategy, discern between the stocks to go long and the ones to short.
profile picture

johnls101

#8
Thanks Eugene.

I have been looking for ways to discern the two groups within the merged DataSet.

I could use Bars.Symbol and then list each symbol in the DataSet for shorting. However, it is clearly not efficient as the members of the DataSets may change slightly over time and I would need to adjust piecemeal for every change.

Is there a way to access DataSet Symbol lists of an external DataSet? What I am hoping to do achieve is a way of looking at the "Shorting DataSet" members list while working on the Merged DataSet. Please excuse my inexperience, but I would like to achieve something along the lines of the following….

CODE:
Please log in to see this code.


I am thinking along the right lines? Is there a way to distinguish the members of other DataSets like this?
profile picture

Eugene

#9
QUOTE:
However, it is clearly not efficient as the members of the DataSets may change slightly over time and I would need to adjust piecemeal for every change.

Agreed, even though the subgroups could be stored externally in a format you prefer (database, plain text file, web service... whatever). It's easier when you dynamically access DataSet symbols like shown below.

QUOTE:
Is there a way to access DataSet Symbol lists of an external DataSet?

Yes, if making some undocumented API calls:
CODE:
Please log in to see this code.
profile picture

johnls101

#10
Thanks so much Eugene! You are amazing. I will need time dwelling on this, but I can immediately see application for looking up members of sector groups and filtering with the sector indices - whole new topic of course!

Once I have applied the above, I will get back to you about adjusting allocated capital for shorts to that of the longs. For instance, sometimes there might be only one long trade available (or no trades for that matter) and it would be totally inappropriate to allocate all of my capital for longs to one trade. Anyway, I'll get back to you. Thanks again.
profile picture

Eugene

#11
QUOTE:
For instance, sometimes there might be only one long trade available (or no trades for that matter) and it would be totally inappropriate to allocate all of my capital for longs to one trade.

The Graded equity percentage PosSizer's algorithm doesn't consider such scenario. Might make sense to introduce an adjustable upper limit for position size, right?
profile picture

johnls101

#12
It would make sense having an adjustable upper limit e.g. if there were a 60/40 split of longs to shorts, and one wanted a maximum of 4 long trades, then one could allocate 15% maximum to each long. If there was only one trade, then the long allocation would still be 15% and the other 45% for longs would be unallocated. What I would really like is the option to match the capital allocated to shorts to that of the longs, in this case 15%.

However, coding Pos Sizers is something I have yet to learn :)