Getting the symbols (without the unique ID) in Python


How can I get the list of symbols from this code :

def CoarseSelectionFunction(self, coarse):

# First narrow the original coarse universe down to a managable level.
init_select = [stock for stock in coarse if (stock.HasFundamentalData)]

# second convert the initial selection to a pandas dataframe.
stock_symbols = [stock.Symbol for stock in init_select]

stock_data = [(stock.DollarVolume,) for stock in init_select]

column_names = ['dollar_volume']


basically, down the road, i want to be able to extract the previous X numbers of days of clsing price as follows:


hist = self.History([all_the_symbols_in_my_universe], 10, Resolution.Daily)

Thanks so much in advance !

Update Backtest

In CoarseSelectionFunction(self, coarse), "coarse" is a list of coarse fundamental objects. This object has property "Symbol". You can get a list of symbol objects with 

symbol_list = [i.Symbol for i in coarse]

However, you should be wary of large history requests. Once you get over about 120K data points you'll run into timeout issues. For reference, coarse data set has approximate 7500 symbols, so 10 days history at the daily resolution on all symbols is 75k data points. 

More reasonable would be trimming the result set down using coarse selection and then issuing a single history request for the filtered results of coarse.


Thanks Jing ! (Sorry for the delay)

Im new to QC and I need to convert a quantopian code to QC so all of this is a bit of a challenge to me especially with my relatively intermediate Python knowledge. Anyway, I'll dig deeper what you just mentioned and I thank you again !



Update Backtest


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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed