Back

Long/Short Strategy correct SetHoldings Parameter

In the Fundamental Factor Long Short Strategy tutorial here is the part of rebalance function

# Assign each stock equally. Always hold 10% cash to avoid margin call
for i in self.long:
self.SetHoldings(i,0.9/self.num_fine)

for i in self.short:
self.SetHoldings(i,-0.9/self.num_fine)

shouldn't it be:

# Assign each stock equally. Always hold 10% cash to avoid margin call
for i in self.long:
self.SetHoldings(i,0.45/self.num_fine)

for i in self.short:
self.SetHoldings(i,-0.45/self.num_fine)

if .9 does work, will .45 work too?

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


what if i want .7 of my portfolio to long and .3 of portfolio to short?

0

I think you are right, self.num_fine = 10 in that example and the universe filters out 10 Longs and 10 Shorts.SetHoldings should have 0.45 in the numerator if the intention is to allocate 50% Long and 50% Short for a total of 90% unlevered portfolio buying power.Alternatively, maybe the universe was intended to be defined like:self.long = [x.Symbol for x in sorted_symbol[:int(self.num_fine/2)]]

so that the Longs / Shorts add up to self.num_fine.

 

Anyways, for your follow up question:

def FineSelectionFunction(self, fine):

self.long = [x.Symbol for x in sorted_symbol[:int(self.num_fine/2)]]
self.short = [x.Symbol for x in sorted_symbol[-int(self.num_fine/2):]]
return self.long+self.short

def rebalance(self):

# Number of Longs/Shorts symbols in filtered tradable universe
numLongs = len(self.long)
numShorts = len(self.short)

# Portfolio allocation between Long/Short
longAllocation = 0.7
shortAllocation = 0.3
marginBuffer = 0.1

# Long allocations
for symbol in self.long:
self.SetHoldings(symbol,
(longAllocation - marginBuffer/2) / self.numLongs
)
# Short allocations
for symbol in self.short:
self.SetHoldings(symbol,
- (shortAllocation - marginBuffer/2) / numShorts
)

 

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed