Runtime Error: Exception of type 'System.OutOfMemoryException' was thrown. in TimeSliceFactory.cs:line 370
def CoarseSelectionFunction(self, coarse: List[CoarseFundamental]) -> List[Symbol]:
self.logger.log("CoarseSelectionFunction Started.")
selected: List[Symbol] = []
for stock in coarse:
if stock.Price > parameters.PRICE_THRESHOLD and stock.DollarVolume > parameters.DOLLAR_VOLUME_THRESHOLD:
selected.append(stock.Symbol)
# Initialize the historical data if not already done
# if stock.Symbol not in self.history:
# self.InitializeIndicators(stock.Symbol)
self.logger.log(f"CoarseSelectionFunction Selected {len(selected)} stocks.")
return selected
Mia Alissi
To address the
System.OutOfMemoryException
and improve theCoarseSelectionFunction
, you need to make the following changes:Correct Attribute Names: The attributes
Price
,DollarVolume
, andSymbol
should be lowercase. Usestock.price
,stock.dollar_volume
, andstock.symbol
.Define Parameters: Ensure that
parameters.PRICE_THRESHOLD
andparameters.DOLLAR_VOLUME_THRESHOLD
are defined and accessible within the function. You might need to define these parameters in your class or pass them as arguments.Here's the corrected version of your function:
Additional Recommendations:
selected
list to reduce memory usage.Sources: Legacy Fundamental Universes - QuantConnect.com, Stock Selection Strategy Based On Fundamental Factors, Fundamental Factor Long Short Strategy, Momentum Short Term Reversal Strategy, Coarse Fine Fundamental Combo Algorithm
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.
Dharmesh Khalasi
Louis Szeto
Hi Dharmesh
It is recommended to upgrade your backtest node if you have a large universe to work with.
Best
Louis
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.
Dharmesh Khalasi
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!