Hello,
I'm not sure if I messed up the add equity line in my code here. I'm trying to get this algorithm to trade SBET. It should be trading that stock on 5/27 but it never bought the stock. Is my add equity line messed up? Do I need to add another symbol to the f.symbol.id.market line to get SBET automatically pulled in? Thanks!
Mia Alissi
Here is a detailed review of your code for the issues around SBET not trading on 5/27, focusing on your core questions:
Is your add_equity("SBET") line messed up?
add_equity("SBET")
line is correct. It subscribes to SBET's data feed. However, this alone does not guarantee the algorithm will trade SBET because your universe selection logic (viaadd_universe(self.coarse_selection_function)
) controls what securities are actually considered for trading at each timestep.Do you need to add another symbol to the
f.symbol.id.market
line for SBET?f.symbol.id.market
matches one of these (case-sensitive). If SBET has a different or differently-cased market code, it will not be selected, even ifadd_equity
was called..upper()
in the check (e.g.,f.symbol.id.market.upper()
), depending on the casing used in your data.Other critical logic issues preventing SBET from trading:
Universe selection pitfalls
Trade condition thresholds
open >= 2.50
ANDopen >= previous close * 1.10
(at least a 10% gap up)current_close > breakout_level
)Historical data requirements
history.empty or history.shape[0] < 2
prevents trading.What you should do
"Coarse selection:"
and"Universe selected:"
to confirm SBET is showing up each day..upper()
themarket
matching, if necessary.add_equity
, then simplify your logic so it's always evaluated.In Short
add_equity("SBET")
is correct, but does NOT guarantee SBET is considered for trading if your universe selection excludes it.Concrete Fix Example:
Or just remove the universe selection entirely and rely on
add_equity("SBET")
.If you want example code for guaranteeing SBET is always included, let me know!
Sources: Futures Fast Trend Following, with Trend Strength, Adjusted Trend on Futures, Opening Range Breakout for Stocks in Play, Momentum Short Term Reversal Strategy, Head & Shoulders TA Pattern Detection
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.
Digitall
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!