In the Quantopian Open, leveraged ETFs are not allowed in the algorithm's universe. To help you avoid them, we created a trading guard that will prevent your algorithm from ordering these securities.
In the initialize() function, you can add in the new trading guard: set_do_not_order_list(security_lists.leveraged_etf_list). The list is maintained by Quantopian, and will be modified as securities come and go on the exchanges. It's point-in-time and becomes active in the backtester on January 23, 2015. You can read more in the documentation.
You can also pass a custom list as a parameter to set_do_not_order_list. This will prevent your algorithm from ordering any security in the tailored list.
Below is an example of an algo that checks if the trading guard is violated before placing orders.
|Returns||1 Month||3 Month||6 Month||12 Month|
|Alpha||1 Month||3 Month||6 Month||12 Month|
|Beta||1 Month||3 Month||6 Month||12 Month|
|Sharpe||1 Month||3 Month||6 Month||12 Month|
|Sortino||1 Month||3 Month||6 Month||12 Month|
|Volatility||1 Month||3 Month||6 Month||12 Month|
|Max Drawdown||1 Month||3 Month||6 Month||12 Month|
def initialize(context): # select a random basket of stocks based on traded dollar-volume set_universe(universe.DollarVolumeUniverse(floor_percentile=95, ceiling_percentile=100)) # set trading guard to avoid ordering over-leveraged ETFs set_do_not_order_list(security_lists.leveraged_etf_list) # Will be called on every trade event for the securities you specify. def handle_data(context, data): for sec in data: # check if the security is eligible in the Quantopian Open and # then order a target position of 100 shares if sec in security_lists.leveraged_etf_list: log.info("%s is an over-leveraged ETF, not purchasing" % (sec.symbol)) else: order_target(sec, 100)