Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
New Asset Restrictions API, Deprecation of set_do_not_order_list

Sometimes, it is useful to be able to restrict the trading of certain assets in an algorithm. The set_do_not_order_list method previously provided this ability, and allowed users to restrict a static list of assets or security_lists.leveraged_etf_list.

Because of its confusing name and unclear parameters (security_lists.leveraged_etf_list was not actually a static list), set_do_not_order_list has been deprecated in favor of a new, more clearly defined, assets restrictions API. This new API also provides the ability to set custom dynamic restrictions on what assets are tradable.

The new method, set_asset_restrictions, takes an object representing the point-in-time restrictions for some assets. Instead of calling set_do_not_order_list(security_lists.leveraged_etf_list) to restrict the trading of leveraged ETFs, one should call set_asset_restrictions(security_lists.restrict_leveraged_etfs).

The ability to iterate through, or check for the inclusion of an asset in, security_lists.leveraged_etf_list has also been deprecated. Instead, security_lists.leveraged_etf_list.current_securities(dt) will return an iterable of currently restricted securities on the given datetime (dt).

The best way to avoid attempts to trade restricted assets, however, is to now call data.can_trade(asset), which will return False if the asset is restricted.

set_asset_restrictions can also take custom restrictions objects. These custom restrictions can be created from StaticRestrictions and HistoricalRestrictions. For more information on how to make these custom restrictions, please refer to the documentation. The following example demonstrates how an algorithm can restrict the trading of two stocks during certain time periods using HistoricalRestrictions.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

3 responses

Hi,
I have generated a list with pipeline and tries to take out securities from the "leveraged_etf_list" from the list but the old method is deprecated. With the new method, where I try:

context.output = pipeline_output('my_pipeline').drop(security_lists.leveraged_etf_list.current_securities(dt))

does work, since "security_lists.leveraged_etf_list.current_securities(dt)" is really just an array of integers, where the index of my pipline is in "Equity(### [ticker name])", and I can't find a way to drop the leveraged etf securities. I wonder if there is a solution to my problem.

Is it not possible to set asset restrictions based on a fetch_csv based list?

data.fetcher_assets cannot be called in initialize() and set_asset_restrictions() cannot be called or updated outside of initialize()

Is there another way to get the fetch_csv data into initialize?

There's this for bringing symbols into a list within initialize.