Hello,
I thought this debug code would help me understand why no purchases were made. When I look at the logs, I only see a few lines that don't help me understand why no purchases were made. Am I not looking in the right place? Is there another way to understand why no purchases of SBET were made? Thanks!
Mia Alissi
Here are bugs and issues in your code that could prevent purchases of SBET or cause your debug output to not be meaningful. All are related to logic, method binding, or QuantConnect event pipeline—not to naming, imports, or allocation:
Class Method Indentation and Binding (Major bug):
coarse_selection_function
,on_data
, andon_end_of_day
methods are defined outside theGapUpBreakout
class due to their indentation.on_data
in particular will never be called, and neither willcoarse_selection_function
if you use universe selection.GapUpBreakout
class.Universe Selection and Coarse Handler Declaration:
initialize
. For example:coarse_selection_function
will never be called.Incorrect Use of
self.active_securities.keys
:for symbol in self.active_securities.keys
instead offor symbol in self.active_securities.keys()
(missing parentheses).self.securities.keys()
orself.securities
.keys (if you want all tracked securities). Preferself.securities.keys()
for QuantConnect.on_end_of_day Handler Behavior:
on_end_of_day(self, symbol)
is not called automatically unless registered with a scheduler or universe.on_end_of_day()
event (without parameter) and iterate there if necessary.Logic for SymbolData Initialization and Symbol Tracking:
_symbol_data
is never created, which means no breakout trades are possible that day.Minimum Order Size/Qty:
self.calculate_order_quantity(symbol, 0.01)
might return0
if that percent of equity fails to meet broker lot constraints, minimum trade size, or fractional restriction. Your logging does note this, but as a practical bug, it is very common for single-symbol, single-share strategies to accidentally zero out execution.Potential Missed Symbol in Bar Loop:
self.active_securities
or doesn't have abar
indata.bars
at the right moment, you might miss your one valid breakout window.Summary of Most Critical Fixes:
GapUpBreakout
class.initialize
.self.active_securities.keys
withself.securities.keys()
in theon_data
routine.self.securities.keys()
and relevant active sets to make sure SBET is truly in your active set every second.If you fix these, you should get the debug logs and entry attempts as expected!
Sources: Opening Range Breakout for Stocks in Play, Debugging - QuantConnect.com, Adjusted Trend on Futures, Stock Selection Strategy Based On Fundamental Factors, Momentum Effect In Commodities Futures
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!