I think the primary confusion here is that the symbols method that's pre-populated into the Research namespace and the symbols function that you imported from zipline.api are actually two entirely different functions, which unfortunately happen to have the same name.
The symbols function that's in the namespace by default is a function specially-written for research, which allows for ad-hoc querying of symbol information. It's designed to always work, and internally it's querying a Quantopian symbol resolution database.
zipline.api is a much older module that's part of our standalone Zipline package. It provides a bunch of functions that are only intended to be executed during calls to TradingAlgorithm.run(). Most of these functions are things like "order", or "schedule_function", which only really make sense in the context of a running TradingAlgorithm. zipline.api.symbols is a bit of an exception here, since you could plausibly imagine querying for symbol resolution outside the context of a running algorithm. The specific semantics of that method, however, mean that zipline.api.symbols actually does depend on a currently-running TradingAlgorithm in a few subtle ways:
- It uses the algorithm's current date to resolve symbols (though I actually consider this a bug, documented here: https://github.com/quantopian/zipline/issues/632 ).
- Zipline provides APIs for users to specify their own symbol-mapping data. zipline.api.symbols uses this data if it's available.
I know that there is no need to import it as it already exists in the research environment, but blocking it might be a good idea to avoid confusion.
This isn't quite true. These are two different functions with two different purposes: you should use the built-in symbols when you're doing ad-hoc querying outside the backtester. You should use zipline.api.symbols if you want to refer to a specific asset by symbol during execution of a TradingAlgorithm. Using the built-in symbols during a TradingAlgorithm run would cause you to make a web request to our database on every tick of your simulation, which will be quite slow.
I think the confusion here is exacerbated by the fact that we pre-populate a bunch of names into the Research Environment namespace. If users were required to do something like
from quantopian.api import symbols, get_pricing, get_backtest, I think it would alleviate the issue.
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.