Hi everybody, I am very curious to know how to sell short and to cover the short position as there currently seems to be no reference on how to do so. I also would like to know how Quantopian's backtester uses leverage and how to customize leverage settings. On a different note, I would like to know how to prevent the algorithm to place endless sell orders for 0 shares for stocks that aren't even in your portfolio. Here is an example:
if current_price <= buy_long_band and cash > number_of_shares and notional < context.max_notional:
order(stock, +number_of_shares)
log.debug("Buying long" + str(stock))
elif current_price >= average_band:
order_target(stock, 0)
log.debug("Selling long" + str(stock))
Whenever I run this, the backtester places endless sell orders on stocks I didn't previously buy. Help is greatly appreciated. Thanks!
Owen