Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
New to this, selling without owning?

I threw in a basic algorithm idea and my initial results show me selling stock that I don't yet own. (also my returns are 1,330%) What am I doing wrong.

I have some logic followed by:
if highFlag == 1: ##some concern about order got it above
order(s, -20) #reverse this odd does better, if up to sat sell?
log.info("sell" + str(s))
if highFlag != 1:
order(s,20)

Why am I getting such insane values?

5 responses

The 'handle_data' code gets called every day for daily backtesting and every minute for minute back testing.

Assuming you have it on daily that means you are buying 20 or selling 20 every day. That means they can add up quickly.

Have a look at the api but try replacing with this:

if highFlag == 1: ##some concern about order got it above
order_target_percent(s,0.0) #reverse this odd does better, if up to sat sell?
log.info("sell" + str(s))
if highFlag != 1:
order_target_percent(s,1.0)

This will make you portfolio 100% stock s or 0% stock s based on the flag.

"Selling without owning" is known as "selling short", or "shorting". See https://en.m.wikipedia.org/wiki/Short_(finance) and https://en.m.wikipedia.org/wiki/Naked_short_selling.

I"m still a bit confused by the huge swings though, like how do I end up ~1300% ? Does it let me go severely negative of what I start with?

It lets you buy or sell an unlimited quantity. This is why it makes sense to use order_target_percent or order_target or order_target_value so that you dont go over board so easily.

^That's what I was wondering. Thanks James.