Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Sell without buy

Hello !
I am a beginner on Quantopian
I am following this course :
https://www.youtube.com/watch?v=4I57xNAW4qA&list=PLRFLF1OxMm_WUX97SE1HwQQIpkcWLVCvB&index=4
I don't udnerstand at 2:05
We never buy SPY Action so how can we sell for -0.5 Of the portfolio ?
And we never sell Apple Action so, how does it works please ?
Thank you
Have a Nice Day !

4 responses

Specifying a negative number in any of the order methods will sell shares. If one currently has a long position it will reduce that long position. However, if one doesn't have a position (as in the example above with SPY) then this implies one wants to sell shares that one doesn't own. This is what is meant by 'shorting' a stock. Maybe take a look at this definition https://www.investopedia.com/university/shortselling/shortselling1.asp .

So yes, one can sell something even if you don't own it (sort of).

Hello !
Thank you for your answer !
I think I understood the idea of shorting a stock now But There is a Thing that I don't Understand.
To short we have to Borrow some action of the society. But for example, in the code of the video, at which moment are theses actions Borrowed ?
At which price are they Borrowed ? Ok They are selled if we can Trade then but when are they Borrowed ? Just one instant before selling ?

Sorry for my English ( I am French )
Thank you !

Hi Ryan,

'Borrowing' we don't really need to worry too much about. Zipline (the backtester & simulator) doesn't actually account for 'borrowing costs' or 'hard to borrow' stocks, and just assumes that we can borrow (for free) any stock we want to sell short. This might be somewhat realistic (trading the QTU) if one is trading via a Prime Broker (as the Q Fund does), but less realistic for retail clients.

When we sell short (aka a short-sell), we're hoping to 'sell high' and then buy it back at a lower price (buy low). And yes, effectively the stock is 'borrowed' instantly when we short sell it, and 'returned' instantly when we buy it back (again, without any sort of borrowing costs associated).

How to short a stock? There is the complicated answer and the simple answer. I'll give you the simple answer because in practice one never sees the complexities going on in the background.

First, one must have a 'margin account' with a broker. They may also require some other things, but generally, just opening a margin account allows one to short stocks.

Second, place an order for the stock you wish to short. Generally this is done exactly like placing a long order but maybe checking a box that says 'short' or 'sell' or perhaps placing a negative sign for the shares to trade. That's it. It's completely transparent what is happening in the background. It's as easy as that.

When you want to close a short position simply 'buy' shares exactly as one would if opening a long position. You don't need to explicitly say you are closing a short position. The broker will take care of all the details in the background.

Now, for all their effort in the background, your broker will charge interest and/or fees. Since you are basically borrowing shares they will charge you 'interest' on that amount borrowed. It simply shows up on your account statement each month.

As a trader shorting stock is very simple. For the 'complicated' answer of what's going on in the background maybe do a google search. There are a lot of sites that go into the details. Just remember, those details are taken care of by your broker. Generally one doesn't need to do anything more than buy and sell similar to going long. Just watch your monthly statement to make sure you understand the associated charges.

Hope that helps.