Hello,
I was trying to skip the tradeBars that has fillforwarded data and noticed it behaves different when I use
if data[self.symbol].IsFillForward:
pass
instead of
if data.Bars[self.symbol].IsFillForward:
pass
first one returns True even if there is real data. I can see volume is positive when I log the values. Why this is happening?
Second one works as expected, only returns True if the data is artificial.
Also, I was wondering if there is a way to change the fillforward logic? Because it copies OHLC from previous bar as is. Instead, It should be copying the close price of previous bar for all its values of OHLC
thanks!
Mia Alissi
Hello Gorkem,
The difference in behavior you're observing between
data[self.symbol].IsFillForward
anddata.Bars[self.symbol].IsFillForward
is likely due to the way the data is accessed in theSlice
object.In the first case,
data[self.symbol]
is accessing theTradeBar
object directly, which contains theIsFillForward
property. This property indicates whether the data point is a fill-forward data point, meaning it was created to fill a gap in data.In the second case,
data.Bars[self.symbol]
is accessing theTradeBars
collection in theSlice
object, which contains all theTradeBar
objects for the current time slice. TheIsFillForward
property in this case is indicating whether theTradeBar
for the specific symbol is a fill-forward data point.Regarding your question about changing the fill-forward logic, the current implementation in LEAN, the engine powering QuantConnect, uses the previous data point when there is no data point for the current slice. This is the default behavior and it's not currently possible to change this logic. The fill-forward feature is designed to ensure that there is always data at each time step in your algorithm, which is important for many trading models.
Here is how you can disable fill-forward for a security in Python:
This will prevent LEAN from filling forward missing data points. However, please note that if you disable fill forward, you may get stale fills or you may see trade volume as zero.
For more information, you can refer to the QuantConnect documentation.
I hope this helps! Let me know if you have any other questions.
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.
Gorkem
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!