Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need some help in setting up portfolio: LONG=SHORT and no cash.

Need a little help:

Starting with USD 10,000, I wish to establish a portfolio with 1 position LONG in secA @ 100% of the NAV; at the same time I wish to SHORT secB where secA is the only collateral.

I issued the following orders simultaneously: (1) order_target_percent(secA, 1), and (2) order_target_percent(secB, -1).
Following completion, I received about $10K invested Long in secA, and sold short in secB, but remained with $10K in cash.

How can I setup my portfolio to become fully invested, where the LONG
amount (in secA) is identical to the SHORT amount (from secB) and
there is no remaining cash?

10,000 THX

3 responses

The mechanics are like this:

Cash balance at start before trading: $10,000
Purchase $10,000 worth of stock leaves a cash balance of: $10,000 less $10,000 = $0
Short sell $10,000 worth of stock would result in $10,000 being deposited in your account: $0 + $10,000 = $10,000

So the algo is working correctly. If you wanted to use that $10,000 to purchase more stock you could, to get the total cash to zero.
The effect you noticed is one of the reasons that the long/short portfolio is preferred. It is self-financing.
The only initial capital you would need to put into an account used for a long/short portfolio would be to fulfill any margin requirements the broker has in place.

Most brokers will have restrictions around what you can do with the cash from the short sale, margin requirements, but the back tester lets you do it without any implicit restriction, up to unlimited multiples. That is why Quantopian talks so much about leverage and the contest puts a max of 3X on the portfolio leverage. In a real account, you would find much tighter restrictions on short selling and what can be done with the proceeds from a short sale.

Hope that helps.
Best

Thank you for your help.
Rgds!

Thank you for your help.
Rgds!