I'm running a local lean backtest with Polygon data provider. My polygon subscription only supports TradeBars and that's what my strategy needs. But lean trying to download QuoteBars and the TradeBars which spam my logs with error messages from the download failure of QuoteBars. How do we force the usage of TradeBars only?
These are the errors I'm getting:
2025-01-25T14:51:47.2731362Z ERROR:: <>c__DisplayClass9_0.<Fetch>b__0(): System.Exception: PolygonRestApiClient.DownloadAndParseData: Failed to download data for v3/quotes/BMO after 10 attempts.
at QuantConnect.Lean.DataSource.Polygon.PolygonRestApiClient.DownloadAndParseData[T](RestRequest request)+MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at QuantConnect.Lean.DataSource.Polygon.PolygonDataProvider.a[a,b](HistoryRequest A_0, Func`4 A_1)+MoveNext()
at QuantConnect.Lean.DataSource.Polygon.PolygonDataProvider.e(HistoryRequest A_0)+MoveNext()
at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
at QuantConnect.Lean.Engine.DataFeeds.DownloaderDataProvider.GetDownloadedData(IEnumerable`1 downloaderDataParameters, Symbol symbol, DateTimeZone exchangeTimeZone, DateTimeZone dataTimeZone, Type dataType)+MoveNext() in Engine/DataFeeds/DownloaderDataProvider.cs:line 237
at QuantConnect.Lean.Engine.DataFeeds.DownloaderDataProvider.<>c__DisplayClass9_0.<Fetch>b__0(String s) in Engine/DataFeeds/DownloaderDataProvider.cs:line 178
Mia Alissi
To ensure that your algorithm only uses TradeBars and avoids downloading QuoteBars, you can explicitly specify the data type when adding securities. Here's how you can modify your algorithm:
Specify TradeBars in
add_equity
: When you add an equity, ensure you specify the data normalization mode and resolution that suits your needs. This will help in ensuring that only TradeBars are used.Review and Adjust Data Subscription: Make sure your algorithm is not implicitly requesting QuoteBars. This can be done by checking your universe selection and any history requests.
Here's an example of how you can add an equity with TradeBars:
Key Points:
DataNormalizationMode.RAW
if you want raw price data without adjustments.By following these steps, you should be able to run your backtest using only TradeBars and avoid the errors related to QuoteBars.
Sources: US Equity - QuantConnect.com, Requesting Data - QuantConnect.com, US Equities - QuantConnect.com, Crypto - QuantConnect.com, Correct Consolidated Bar Type For Tick Types 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.
Ahmed Sobhy Khattab
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!