Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How do you buy a long position and a short position of the same security at the same time?

When trying to go long and short on the same security using this syntax my position is zero. Is it because am buy then selling as pose to buy 50% long and shorting 50%

        order_target_percent(context.spy, .50)  
         order_target_percent(context.spy, -.50)  
3 responses

i don't think you can, and doing so doesn't make sense anyways. the definition of selling short is to sell without actually owning the security

You can do that using LIMIT orders. Put a limit order to buy at lower threshold and a limit order to sell at higher threshold. This is typically used by institutions to trade "brackets" of volatile stocks during opening or closing hours when there is a liquidity premium to be captured if they believe that prices will mean revert. Anyway more on brackets later.

interesting, i wonder if institutions have the long side sell the short side the shares to cover to avoid any sort of arbitrage issues. i doubt the back tester supports selling yourself your own shares